Ejemplo n.º 1
0
    private IEnumerator IndividualBattle(Property property, BattleInformation battleInformation)
    {
        var cam = Camera.main.GetComponent <CameraMovement>();

        yield return(cam.FollowPosition(property.gameObject.transform.position));

        yield return(cam.Zoom(true));

        int attackerSoldiers = battleInformation.attackingSoldiers;
        int defenderSoldiers = battleInformation.defendingSoldiers;
        int attackerBattlePoints;
        int defenderBattlePoints;
        int remainingAttackerSoldiers;
        int remainingDefenderSoldiers;

        SimulateBattle(attackerSoldiers, defenderSoldiers, out remainingAttackerSoldiers, out remainingDefenderSoldiers, out attackerBattlePoints, out defenderBattlePoints);

        battleWindow.Show(attackerSoldiers, defenderSoldiers, attackerBattlePoints, defenderBattlePoints, battleInformation, remainingAttackerSoldiers, remainingDefenderSoldiers,
                          (battleInformation.attackingKingdom == StartingKingdomController.Instance.PlayerKingdom));

        if (InvaderIsTheWinner(remainingAttackerSoldiers, remainingDefenderSoldiers))
        {
            if (property.dominated)
            {
                numberOfBattlesLostByThePlayerLastTurn++;
            }
            else
            {
                numberOfBattlesWonByThePlayerLastTurn++;
            }

            property.SetDominated(!property.dominated, false);
            property.SetSoldiers(SoldierType.InProperty, remainingAttackerSoldiers);
            if (!property.mainProperty)
            {
                property.WeakenCastle();
            }
            property.ChangeKingdom(battleInformation.attackingKingdom);
        }
        else
        {
            if (!property.dominated)
            {
                numberOfBattlesLostByThePlayerLastTurn++;
            }
            else
            {
                numberOfBattlesWonByThePlayerLastTurn++;
            }

            property.SetSoldiers(SoldierType.InProperty, remainingDefenderSoldiers);
        }
        property.SetSoldiers(SoldierType.Enemy, 0);
        yield return(battleWindow.currentBattle);

        yield return(cam.Zoom(false));

        property.UpdateSoldierInfo();
        property.UpdateSprite(property);
    }
Ejemplo n.º 2
0
        public void RunBattle(Party goodguys, Party badguys)
        {
            BattleWindow battle = new BattleWindow(goodguys.getImg(), badguys.getImg());

            battle.Show();
        }