示例#1
0
    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;
        }
    }
示例#2
0
        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);
        }
示例#3
0
 public Task AddAsync(BattleOutcome battleOutcome)
 {
     return(_dbContext.BattleOutcomes.AddAsync(battleOutcome).AsTask());
 }
示例#4
0
文件: Empire.cs 项目: valdisz/C-evo-x
 protected override void OnBeforeForeignAttack(IUnitInfo attacker, Location target, BattleOutcome outcome)
 {
 }
示例#5
0
 public void SetSuccessor(BattleOutcome successor)
 {
     Successor = successor;
 }