private IEnumerator ResolveBattle(List <Card> opUnit, List <Card> plUnit, bool ignoreWizards) { uiUnitScores.UpdateScores(opUnit, plUnit); yield return(new WaitForSeconds(1f)); BattleOutcome outcome = BattleResolver.GetBattleOutcome(opUnit, plUnit, ignoreWizards); switch (outcome) { case BattleOutcome.PlayerWins: ShowMessage("Player wins!", 2.0f); Player.numberOfWins++; numRoundsBattled++; OnBattleResolved?.Invoke(outcome); yield return(new WaitForSeconds(2.0f)); StartCoroutine(RemoveCardsFromField(opUnit, plUnit)); ContinueToNextTurn(); break; case BattleOutcome.OpponentWins: ShowMessage("Opponent wins!", 2.0f); Opponent.numberOfWins++; numRoundsBattled++; OnBattleResolved?.Invoke(outcome); yield return(new WaitForSeconds(2.0f)); StartCoroutine(RemoveCardsFromField(opUnit, plUnit)); ContinueToNextTurn(); break; case BattleOutcome.SwapUnitsOnce: SwapUnits(opUnit, plUnit, 0.5f); yield return(new WaitForSeconds(0.5f)); StartCoroutine(ResolveBattle(plUnit, opUnit, true)); break; case BattleOutcome.SwapUnitsTwice: SwapUnits(opUnit, plUnit, 0.5f); yield return(new WaitForSeconds(0.5f)); SwapUnits(plUnit, opUnit, 0.5f); yield return(new WaitForSeconds(0.5f)); StartCoroutine(ResolveBattle(plUnit, opUnit, true)); break; case BattleOutcome.Draw: ShowMessage("Draw!", 2.0f); numRoundsBattled++; OnBattleResolved?.Invoke(outcome); yield return(new WaitForSeconds(2.0f)); StartCoroutine(RemoveCardsFromField(opUnit, plUnit)); ContinueToNextTurn(); break; } }
public BattleOutcome BattleLoop() { long battleTick = 0; while (battleTick <= maxTicks && _party1.IsAlive() && _party2.IsAlive()) { _party1.UpdateParty(battleTick); _party2.UpdateParty(battleTick); ++battleTick; } BattleOutcome winner = GetWinner(); switch (winner) { case BattleOutcome.Party1Win: _log.Log(_party1.GetWinText()); break; case BattleOutcome.Party2Win: _log.Log(_party2.GetWinText()); break; case BattleOutcome.Draw: _log.Log("Battle ended in a draw."); break; default: throw new ArgumentOutOfRangeException(); } return(winner); }
public Task AddAsync(BattleOutcome battleOutcome) { return(_dbContext.BattleOutcomes.AddAsync(battleOutcome).AsTask()); }
protected override void OnBeforeForeignAttack(IUnitInfo attacker, Location target, BattleOutcome outcome) { }
public void SetSuccessor(BattleOutcome successor) { Successor = successor; }