private async Task OneAttackAsync(BattleBase unit, Army enemy) { while (unit.IsAlive() && enemy.IsAlive()) { var one = enemy.FindOne(); if (one != null) { await unit.AttackAsync(one); } } }
public void AttackOnce(BattleBase enemy = null) { if (enemy != null) { ResetEnemyTarget(enemy); } if (HasAttackTarget) { HurtEnemy(_enemy); if (_enemy.IsAlive() == false) { ClearTarget(); } } }
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(); }