//--------------------------------- original code ----------------------------- // 50/50 chance to place troop on country already populated or onto a new one (the larger the army the more likely it will place on the country) public void AIDeployTroop() { currentPlayer = playerTurn.CurrentPlayer(); currentPlayerIndex = currentPlayer - 2; if (currentPlayer != 1) { // only runs once and places a country in the list for the below code to work if (playerTurn.turn == 1) { PrePopulateLists(); } // take a random country from within the built list of populated countries if (PickfromList()) { randomListIndex = Mathf.FloorToInt(Random.Range(0f, SelectionList [currentPlayerIndex].Count)); selectedCountry = SelectionList [currentPlayerIndex] [randomListIndex]; } // or choose another front line country else { setupPhase.SelectFrontLineCountry(); selectedCountry = GameObject.FindGameObjectWithTag("SelectedCountry"); // adds the new selection to the list SelectionList [currentPlayerIndex].Add(selectedCountry); } // places a soldier onto country allocateSoldiers.DropSoldier(selectedCountry); } }
//Remove presvious country selected and add tag to new country selection void OnMouseDown() { audioFadeOut.Click(); //TODO: adjust this to take the number human players into account // cannot select countries during AI turn if (playerTurn.CurrentPlayer() != 1) { return; } // removes tag from previously selected country previousCountry = GameObject.FindGameObjectWithTag("SelectedCountry"); if (previousCountry != null) { previousCountry.gameObject.tag = "Untagged"; } // updates the current country selection country = gameObject.transform.parent.gameObject; country.gameObject.tag = "SelectedCountry"; // activates and deactivates button colours buttonColour.SetupPlusMinusColour(); if (phases.battlePhase) { buttonColour.BattleAttackColour(targetCountry.selectingDefender); } // sets the target as "defender" rather than "selectedCountry" when target country to attack if (targetCountry.selectingDefender) { targetCountry.SetDefender(); return; } // movement phase mechanics if (phases.movementPhase) { buttonColour.MovementSelectFromCountry(country); // selects countries to move troops between if (armyMovement.movementSelected) { armyMovement.MovementCountries(country); } } // doesnt display selected territory during movement phase (other display is shown) if (armyMovement.movementSelected) { return; } // place soldiers during the opening phase script if (phases.openingPhase & teamChecker.UnderControl(country)) { allocateSoldiers.DropSoldier(country); audioFadeOut.MoreTroopsAudio(); } // Runs display selected country, doesnt run when selecting attacker or defender displayEditor.SelectedTerritory(country); }