Beispiel #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);
    }
Beispiel #2
0
    // moves a soldier fromCountry to toCountry - called by fwd and back buttons
    public void MoveSoldier(GameObject fromCountry, GameObject toCountry)
    {
        // create a list of the fromCountry's soldiers
        soldiers = new List <GameObject> ();
        foreach (Transform soldier in fromCountry.transform)
        {
            if (soldier.name == "Soldier(Clone)")
            {
                soldiers.Add(soldier.gameObject);
            }
        }
        // remove the last soldier fromCountry
        soldierToTransfer = soldiers [soldiers.Count - 1];
        GameObject.DestroyImmediate(soldierToTransfer);
        // add a soldier toCountry
        addSoldier = toCountry.GetComponent <AddSoldier> ();
        addSoldier.PlaceSoldier();

        // update game stats
        troopCount.UpdateTroopBankV2(playerTurn.CurrentPlayer(), -1);
        countryManagement.ChangeArmySize(fromCountry, -1);
        countryManagement.ChangeArmySize(toCountry, 1);

        buttonColour.MovementPlusMinusColour(fromCountry, toCountry);
    }
Beispiel #3
0
    // Randomly places a soldier on a players allocated piece of land
    void SetBoard()
    {
        // Loops through each country adding a soldier at the COM
        foreach (Transform continent in this.transform)
        {
            foreach (Transform country in continent.transform)
            {
                //Instantiate at countries COM soldier at the stored placer location
                addSoldier             = country.GetComponent <AddSoldier>();
                clone                  = Instantiate(Resources.Load("Soldier"), addSoldier.findCOM(country), Quaternion.identity) as GameObject;
                clone.transform.parent = country.transform;

                // make the soldiers random colours
                randomPlayerNum = RandomPlayer();
                soldierManagement.SetSoldierColour(clone, randomPlayerNum);
                countryManagement.ChangeArmySize(country.gameObject, 1);
            }
        }
        // selects Alaska as the default selected country - prevent +button at the start error
        GameObject defaultCountry = GameObject.Find("Alaska");

        defaultCountry.gameObject.tag = "SelectedCountry";
        // start opening phase
        phases.startingPhase = false;
        phases.openingPhase  = true;
    }
    //TODO: move all troops to a country then pressing minus move them all back, once back to the original position the + button becomes unactive grey and locked.

    // Add a soldier to the selected country - setup phase only
    public void Add()
    {
        if (phases.setupPhase)
        {
            audioFadeOut.MoreTroopsAudio();
            country = GameObject.FindGameObjectWithTag("SelectedCountry");
            if (teamChecker.UnderControl(country) & deploySoldiers.CanAddSoldier())
            {
                addSoldier = country.GetComponent <AddSoldier> ();
                addSoldier.PlaceSoldier();
                UpdateNumbers(country, 1);
            }
            buttonColour.SetupPlusMinusColour();
        }
    }
Beispiel #5
0
    void Awake()
    {
        territories = GameObject.FindGameObjectWithTag("Territories");
        troopCount  = territories.GetComponent <TroopCount> ();

        GUI = GameObject.FindGameObjectWithTag("GUI");
        gameInstructions = GUI.GetComponent <GameInstructions> ();
        buttonColour     = GUI.GetComponent <ButtonColour> ();
        displayEditor    = GUI.GetComponent <DisplayEditor> ();

        phases            = this.GetComponent <Phases> ();
        countryManagement = this.GetComponent <CountryManagement> ();
        addSoldier        = this.GetComponent <AddSoldier> ();
        linkedTerritories = this.GetComponent <LinkedTerritories> ();
        playerTurn        = this.GetComponent <PlayerTurn> ();
        teamChecker       = this.GetComponent <TeamChecker> ();
    }
 // places a single soldier on mouse click and changes player turn - opening phase only
 public void DropSoldier(GameObject country)
 {
     currentPlayer = playerTurn.CurrentPlayer();
     // can only drop soldier on owned territory
     if (teamChecker.UnderControl(country) & dropCounter == playerTurn.turn)
     {
         // place a soldier on the selected country
         addSoldier = country.GetComponent <AddSoldier> ();
         addSoldier.PlaceSoldier();
         // update game stats
         UpdateStats(country);
         // ends opening phase if all soliders have been deployed
         FinishOpeningPhase();
         // changes player after time delay
         StartCoroutine(ExecuteAfterTime(globalFunctions.timeDelay));
     }
 }