int danoAoInimigo = GeradorDeNumeroAleatorio.NumeroEntre(0, 10);
int danoAoJogador = GeradorDeNumeroAleatorio.NumeroEntre(0, 10);
Console.WriteLine(">>PRESSIONE QUALQUER TECLA<<");
Console.ReadKey();
Console.WriteLine("Você causou: " + danoAoInimigo + " de dano ao" _jogador.LocalAtual.InimigoVivendoAqui.Nome + " !! ");
_jogador.LocalAtual.InimigoVivendoAqui.VidaAtual = (_jogador.LocalAtual.InimigoVivendoAqui.VidaAtual) - danoAoInimigo;
Console.WriteLine("O inimigo tem: " + _jogador.LocalAtual.InimigoVivendoAqui.VidaAtual + " de vida.");
if (_jogador.LocalAtual.InimigoVivendoAqui.VidaAtual <= 0)
{
Console.WriteLine("Você matou o inimigo.");
Console.WriteLine(">>PRESSIONE QUALQUER TECLA<<");
Console.ReadKey();
}
Basically What I'm doing here is just a simple "battle system" for my text game. It starts with the declaration of two variables to hold the damage that the palyer will dealt to the monster and the damage that the monster will dealt to the player. And then I made a message to the user for he knows how much damage he dealts. And then I made the monster lose life with some classes that I'm using and after i'm displaying the current life of the monster to the user. And finally if the health of the monster is less or equal to 0 he dies.
The problem is: everytime I run de code and get at this part of the game, the visual studio gives me a message in a little window saying that "System.NullReferenceException was unhandled". But I already have two more parts of the code before this one where I have those same lines and it had never show me this problem and it works perfectly. So could someone help me with this one? I really have no idea what to do.