Beispiel #1
0
        private void SwapAttackerAndDefender()
        {
            LivingBeing _previousAttacker = _currentAttacker;

            _currentAttacker = _currentDefender;
            _currentDefender = _previousAttacker;
        }
Beispiel #2
0
        public Battle(Player player, LivingBeing enemy)
        {
            _player = player;
            _enemy  = enemy;

            _player.IsInBattle = true;

            CalculateAndSetTurnOrder();
        }
Beispiel #3
0
 private void CheckBattleProgress()
 {
     if (_currentDefender.HP < 1)
     {
         _player.IsInBattle = false;
         Winner             = _currentAttacker;
     }
     else
     {
         SwapAttackerAndDefender();
     }
 }
Beispiel #4
0
 private void CalculateAndSetTurnOrder()
 {
     if (_player.Speed == _enemy.Speed || _player.Speed > _enemy.Speed)
     {
         _currentAttacker = _player;
         _currentDefender = _enemy;
     }
     else
     {
         _currentAttacker = _enemy;
         _currentDefender = _player;
     }
 }
Beispiel #5
0
        static void Main(string[] args)
        {
            var player = new Player("Player", 1, 100, 5);
            var enemy  = new LivingBeing("Enemy", 1, 100, 5);

            var battle = new Battle(player, enemy);

            while (player.IsInBattle)
            {
                battle.NextTurn();
            }

            Console.WriteLine($"The winner is {battle.Winner.Name}!");
        }