public void Fortify() { Debug.Log("Fortify called"); //Add the armies that the slider was set to fortified.AddArmies((int)slider.value); //Subtract the armies from the territory that you're fortifying from activeTerritoryScript.AddArmies(-(int)slider.value); //Unpause the game Time.timeScale = 1; //If there's only one army in the territory, deactivate it if (activeTerritoryScript.armyValue == 1) { activeTerritoryScript.Activate(false); } //Hide the slider and its components sliderObject.SetActive(false); if (GameManager.instance.mode == GameManager.Mode.fortify) { Debug.Log("next turn"); GameManager.instance.NextMode(); } }
public void Attack(Territory attacker, Territory defender) { //In a standard risk game, the attacker caps their dice at 3 and the defender caps their dice at 2, //so those are the base values for my variables //TODO: Make customizable attackerDie amounts attackerDice = 3; defenderDice = 2; //Make sure that the attacker can't attack territories that they control if (this.controller == activeTerritoryScript.controller) { return; } /*TODO: Check if this is really necessary, i dont think it is now * if (attacker.armyValue <= 1) { * return; * }*/ //If the defender isn't attackable, then stop the script if (!CheckIfAttackable(defender)) { return; } //If the attacking armies are less than 3 (remember, one army has to stay in the territory as a rule of risk), then you //can't attack with 3 dice, because you don't have 3 armies to attack with if (attacker.armyValue - 1 < 3) { //If only one army is attacking, set the attacker dice to 1 if (attacker.armyValue - 1 == 1) { attackerDice = 1; } //If 2 armies are attacking, set the attacker dice to 2 if (attacker.armyValue - 1 == 2) { attackerDice = 2; } } //If the defender is only defending with one army, then only 1 dice can be used if (defender.armyValue == 1) { defenderDice = 1; } //This creates a new list of bools called winsAttack. winsAttack gets its list from the list function called WinsAttack. List <bool> winsAttack = WinsAttack(RollDice(attackerDice), RollDice(defenderDice)); for (int i = 0; i < winsAttack.Count; i++) { if (winsAttack[i]) { defender.AddArmies(-1); } else { attacker.AddArmies(-1); } } if (activeTerritoryScript.armyValue <= 1) { activeTerritoryScript.Activate(false); } if (defender.armyValue <= 0) { TakeTerritory(defender); } }