コード例 #1
0
 private async Task OneAttackAsync(BattleBase unit, Army enemy)
 {
     while (unit.IsAlive() && enemy.IsAlive())
     {
         var one = enemy.FindOne();
         if (one != null)
         {
             await unit.AttackAsync(one);
         }
     }
 }
コード例 #2
0
        public void AttackOnce(BattleBase enemy = null)
        {
            if (enemy != null)
            {
                ResetEnemyTarget(enemy);
            }

            if (HasAttackTarget)
            {
                HurtEnemy(_enemy);
                if (_enemy.IsAlive() == false)
                {
                    ClearTarget();
                }
            }
        }
コード例 #3
0
        public async Task AttackAsync(BattleBase enemy)
        {
            ResetEnemyTarget(enemy);

            var token = _source.Token;

            while (IsAlive() && enemy.IsAlive())
            {
                if (token != null)
                {
                    token.ThrowIfCancellationRequested();
                }
                HurtEnemy(enemy);
                await Task.Delay((int)(AttackInterval * 1000));
            }

            ClearTarget();
        }