public override void Interaction(GameObject obj) { base.Interaction(obj); if (obj is GamePerson person && person != this && person.PlayerFriend != PlayerFriend) { Battle newBattle = new Battle(person, this); GamePerson winner = newBattle.Fight(); } }
public Position GetPersonPosition(GamePerson person) { for (int i = 0; i < WorldHeight; i++) { for (int k = 0; k < WorldWidth; k++) { if (Cells[i, k].GameObject == person) { return(new Position(i, k)); } } } return(null); }
public void Hit(GamePerson target) { if (Alive) { Random random = new Random(); target.HealthPoints -= random.Next(Damage - 5, Damage + 6) + (Weapon?.Damage ?? 0); if (random.Next(0, 5) == 4) { Weapon?.SpecialAttack(target); } if (target.HealthPoints == 0) { LevelUp(); } } }
public void Show(GamePerson player1, GamePerson player2, int turn, bool?phase = null) { Console.Clear(); player1.ShowInfo(phase); player2.ShowInfo(phase); Refresh(); Console.WriteLine(); for (int i = 0; i < WorldHeight; i++) { for (int k = 0; k < WorldWidth; k++) { Extensions.ToConsoleWrite("|", ConsoleColor.DarkGreen, Season); if (Cells[i, k].GameObject != null) { if (Cells[i, k].GameObject is Character character) { Extensions.ToConsoleWrite($"☺{(character.Weapon == null ? "_" : "\u2694")}", character.PlayerFriend ? ConsoleColor.Yellow : ConsoleColor.Red, Season); } else if (Cells[i, k].GameObject is Bot enemy) { Extensions.ToConsoleWrite($"☻{(enemy.Weapon == null ? "_" : "\u2694")}", enemy.PlayerFriend ? ConsoleColor.Yellow : ConsoleColor.Red, Season); } else if (Cells[i, k].GameObject is Heart) { Extensions.ToConsoleWrite("♥", ConsoleColor.Green, Season); } else if (Cells[i, k].GameObject is Sword) { Extensions.ToConsoleWrite("_\u2694", ConsoleColor.Cyan, Season); } else if (Cells[i, k].GameObject is Knife) { Extensions.ToConsoleWrite("_\u2694", ConsoleColor.Magenta, Season); } } else { Extensions.ToConsoleWrite("__", ConsoleColor.DarkGreen, Season); } } Extensions.ToConsole("|", ConsoleColor.DarkGreen, Season); } Console.WriteLine(); Console.WriteLine($"Turn: {turn}"); }
public Battle(GamePerson character, GamePerson enemy) { Character = character; Enemy = enemy; }