Пример #1
0
    // claims the land once called - removes defender and places attacker
    // NOTE: do not change order of commands below
    public void ClaimLand(GameObject attackingCountry, GameObject defendingCountry)
    {
        victoryCry.Play();
        controlTaken = true;
        defendingCountry.gameObject.tag = "SelectedCountry";
        addSoldier = defendingCountry.GetComponent <AddSoldier> ();

        // Adds a new soldier to defending country (attacker colour)
        addSoldier.PlaceSoldier();
        // causes a troop to be added to defender and removed from attacker in UpdateTroopCounter;
        countryManagement.ChangeArmySize(defendingCountry, 1);
        // Removes a soldier from attacker (moved to defender land - now claimed)
        armyManagement.RemoveDead("AttackingCountry", 1);
        // default transfers all attackers over to claimed land
        soldierTransfer.DefaultTransfer(attackingCountry, defendingCountry);
        // update the number of territories dictionary
        territoryCount.UpdateTerritoryBank(attackingCountry, defendingCountry);
        // update continent bonus
        continentBonus.UpdateContBonus();

        // set button colours
        buttonColour.BattleBattleColour(attackingCountry, defendingCountry);
        buttonColour.BattleAttackColour(false);
        buttonColour.BattlePlusMinusColour(false);

        // update instructions
        gameInstructions.BattleClaim(defendingCountry);
    }
Пример #2
0
    //Label target as the attacker and sets up SetDefender function - Attack button
    void SetAttacker()
    {
        // Remove previous attckers tag
        previousCountry = GameObject.FindGameObjectWithTag("AttackingCountry");
        if (previousCountry != null)
        {
            previousCountry.gameObject.tag = "Untagged";
        }

        // Selected country becomes attacker
        attackingCountry = GameObject.FindGameObjectWithTag("SelectedCountry");
        // Can only attack with countries owned
        if (attackingCountry != null)
        {
            if (!selectingDefender & !teamChecker.UnderControl(attackingCountry) || countryManagement.GetArmySize(attackingCountry.name) == 1)
            {
                return;
            }
        }

        // prevents error if player changes target during attack
        if (attackingCountry == null & previousCountry != null)
        {
            previousCountry.gameObject.tag = "AttackingCountry";
            attackingCountry = previousCountry;
        }         // this part should run most of the time
        else if (attackingCountry != null)
        {
            attackingCountry.gameObject.tag = "AttackingCountry";
            displayEditor.AttackingTerritory(attackingCountry);
        }

        // Allows SetDefender to be called as the following country selection in countrySelector
        if (!selectingDefender)
        {
            // runs here when 'attack' is selected
            selectingDefender = true;
            // change button colours
            buttonColour.BattleAttackColour(selectingDefender);
            // reomves +/- colour after 'attack' has been selected
            buttonColour.BattlePlusMinusColour(selectingDefender);
        }
        else
        {
            // runs here when 'deselect attacker' is selected - reverts game back to pre attack state
            selectingDefender = false;
            // prevents error if attacker tries to attack itself
            if (attackingCountry != null)
            {
                attackingCountry.gameObject.tag = "SelectedCountry";
                displayEditor.SelectedTerritory(attackingCountry);
                buttonColour.BattleBattleColour(attackingCountry, defendingCountry);
            }
            else
            {
                defendingCountry.gameObject.tag = "SelectedCountry";
                displayEditor.SelectedTerritory(defendingCountry);
                buttonColour.BattleBattleColour(attackingCountry, defendingCountry);
            }
            buttonColour.BattleAttackColour(selectingDefender);
        }
    }