private void state1() { Debug.Log("Press Space to Roll for: " + this.name); if (Input.GetKeyDown(KeyCode.Space)) { Dice1.throwDice(); Dice2.throwDice(); hasRolled = true; } if (this.hasRolled) { if (Dice1.hasLanded && Dice2.hasLanded) { StartCoroutine(WaitforResult()); return; } } }
public int GetDiceRoll() { int total; Dice1.Roll(); Dice2.Roll(); total = Dice1.FaceValue + Dice2.FaceValue; if (doubleRule == true) { if (Dice1.FaceValue == Dice2.FaceValue) { Dice3.Roll(); total = total + Dice3.FaceValue; } } return(total); }
void ZeroingOut() { totalDamage = 0; HowManyDicesKnown = 0; Dice1.ChangeAttack(0); Dice2.ChangeAttack(0); Dice3.ChangeAttack(0); Dice4.ChangeAttack(0); Dice1.whatadice = false; Dice2.whatadice = false; Dice3.whatadice = false; Dice4.whatadice = false; d1WasAdded = false; d2WasAdded = false; d3WasAdded = false; d4WasAdded = false; }
/// <summary> /// Roll the dices and return their values. /// </summary> /// <param name="dice1">First dice. If true, the dice value will be processed again.</param> /// <param name="dice2">Second dice. If true, the dice value will be processed again.</param> /// <param name="dice3">Third dice. If true, the dice value will be processed again.</param> public void RollDices() { if (!this.Dice1.Checked) { Dice1.Roll(); } if (!this.Dice2.Checked) { Dice2.Roll(); } if (!this.Dice3.Checked) { Dice3.Roll(); } // Sorts the score so it's shown from the bigger number to the lowest. char[] arrayTmp = (Dice1.ToString() + Dice2.ToString() + Dice3.ToString()).ToArray(); Array.Sort(arrayTmp); Array.Reverse(arrayTmp); GamePlayers.CurrentPlayer.DiceRoll = Convert.ToInt32(new string(arrayTmp)); GamePlayers.CurrentPlayer.PlaysLeft--; }
/// <summary> /// Resets the dices. /// </summary> private void ResetDices() { Dice1.Reset(); Dice2.Reset(); Dice3.Reset(); }
//Méthode qui gère les dés et le résultat void Update() { //Si tous les territoires sont désactivés (pour les collisions) if (active) { //Désactivation des "boutons" passer et menu (pour les collisions) passer.SetActive(false); menu.SetActive(false); //Variables pour savoir qui attaque et qui se fait attaquer int tourJoueur = CountryManager.instance.TourJoueur; int nbJoueurAtt = Country.theTribes.IndexOf(CountryManager.instance.countrySelectedAttacked.country.tribe); //Variable pour savoir si le dé part de la gauche ou la droite bool startDroite = false; //Case of pour savoir quels dés instancier en fonction de qui attaque et de qui se fait attaquer switch (tourJoueur) { //Le joueur rouge attaque... case 0: //Instantiation des dés sur le modèle du dé "R"ouge à "D"roite dice1 = Instantiate <GameObject>(diceRD); dice2 = Instantiate <GameObject>(diceRD); dice3 = Instantiate <GameObject>(diceRD); value11 = dice1.GetComponent <Dice>(); value12 = dice2.GetComponent <Dice>(); value13 = dice3.GetComponent <Dice>(); switch (nbJoueurAtt) { //...le joueur bleu case 1: dice4 = Instantiate <GameObject>(diceBG); dice5 = Instantiate <GameObject>(diceBG); dice6 = Instantiate <GameObject>(diceBG); value24 = dice4.GetComponent <Dice2>(); value25 = dice5.GetComponent <Dice2>(); value26 = dice6.GetComponent <Dice2>(); jetDes.SetActive(true); break; //...le joueur vert case 2: dice4 = Instantiate <GameObject>(diceVG); dice5 = Instantiate <GameObject>(diceVG); dice6 = Instantiate <GameObject>(diceVG); value24 = dice4.GetComponent <Dice2>(); value25 = dice5.GetComponent <Dice2>(); value26 = dice6.GetComponent <Dice2>(); jetVVR.SetActive(true); break; //...le joueur jaune case 3: dice4 = Instantiate <GameObject>(diceJG); dice5 = Instantiate <GameObject>(diceJG); dice6 = Instantiate <GameObject>(diceJG); value24 = dice4.GetComponent <Dice2>(); value25 = dice5.GetComponent <Dice2>(); value26 = dice6.GetComponent <Dice2>(); jetJVR.SetActive(true); break; } startDroite = true; break; //Le joueur bleu attaque... case 1: dice1 = Instantiate <GameObject>(diceBG); dice2 = Instantiate <GameObject>(diceBG); dice3 = Instantiate <GameObject>(diceBG); value21 = dice1.GetComponent <Dice2>(); value22 = dice2.GetComponent <Dice2>(); value23 = dice3.GetComponent <Dice2>(); switch (nbJoueurAtt) { //...le joueur rouge case 0: dice4 = Instantiate <GameObject>(diceRD); dice5 = Instantiate <GameObject>(diceRD); dice6 = Instantiate <GameObject>(diceRD); value14 = dice4.GetComponent <Dice>(); value15 = dice5.GetComponent <Dice>(); value16 = dice6.GetComponent <Dice>(); jetDes.SetActive(true); break; //...le joueur vert case 2: dice4 = Instantiate <GameObject>(diceVD); dice5 = Instantiate <GameObject>(diceVD); dice6 = Instantiate <GameObject>(diceVD); value14 = dice4.GetComponent <Dice>(); value15 = dice5.GetComponent <Dice>(); value16 = dice6.GetComponent <Dice>(); jetBVV.SetActive(true); break; //...le joueur jaune case 3: dice4 = Instantiate <GameObject>(diceJD); dice5 = Instantiate <GameObject>(diceJD); dice6 = Instantiate <GameObject>(diceJD); value14 = dice4.GetComponent <Dice>(); value15 = dice5.GetComponent <Dice>(); value16 = dice6.GetComponent <Dice>(); jetBVJ.SetActive(true); break; } break; //Le joueur vert attaque... case 2: switch (nbJoueurAtt) { //...le joueur rouge case 0: dice1 = Instantiate <GameObject>(diceVG); dice2 = Instantiate <GameObject>(diceVG); dice3 = Instantiate <GameObject>(diceVG); value21 = dice1.GetComponent <Dice2>(); value22 = dice2.GetComponent <Dice2>(); value23 = dice3.GetComponent <Dice2>(); dice4 = Instantiate <GameObject>(diceRD); dice5 = Instantiate <GameObject>(diceRD); dice6 = Instantiate <GameObject>(diceRD); value14 = dice4.GetComponent <Dice>(); value15 = dice5.GetComponent <Dice>(); value16 = dice6.GetComponent <Dice>(); jetVVR.SetActive(true); break; //...le joueur bleu case 1: dice1 = Instantiate <GameObject>(diceVD); dice2 = Instantiate <GameObject>(diceVD); dice3 = Instantiate <GameObject>(diceVD); value11 = dice1.GetComponent <Dice>(); value12 = dice2.GetComponent <Dice>(); value13 = dice3.GetComponent <Dice>(); dice4 = Instantiate <GameObject>(diceBG); dice5 = Instantiate <GameObject>(diceBG); dice6 = Instantiate <GameObject>(diceBG); value24 = dice4.GetComponent <Dice2>(); value25 = dice5.GetComponent <Dice2>(); value26 = dice6.GetComponent <Dice2>(); jetBVV.SetActive(true); startDroite = true; break; //...le joueur jaune case 3: dice1 = Instantiate <GameObject>(diceVG); dice2 = Instantiate <GameObject>(diceVG); dice3 = Instantiate <GameObject>(diceVG); value21 = dice1.GetComponent <Dice2>(); value22 = dice2.GetComponent <Dice2>(); value23 = dice3.GetComponent <Dice2>(); dice4 = Instantiate <GameObject>(diceJD); dice5 = Instantiate <GameObject>(diceJD); dice6 = Instantiate <GameObject>(diceJD); value14 = dice4.GetComponent <Dice>(); value15 = dice5.GetComponent <Dice>(); value16 = dice6.GetComponent <Dice>(); jetVVJ.SetActive(true); break; } break; //Le joueur jaune attaque... case 3: switch (nbJoueurAtt) { //...le joueur rouge case 0: dice1 = Instantiate <GameObject>(diceJG); dice2 = Instantiate <GameObject>(diceJG); dice3 = Instantiate <GameObject>(diceJG); value21 = dice1.GetComponent <Dice2>(); value22 = dice2.GetComponent <Dice2>(); value23 = dice3.GetComponent <Dice2>(); dice4 = Instantiate <GameObject>(diceRD); dice5 = Instantiate <GameObject>(diceRD); dice6 = Instantiate <GameObject>(diceRD); value14 = dice4.GetComponent <Dice>(); value15 = dice5.GetComponent <Dice>(); value16 = dice6.GetComponent <Dice>(); jetJVR.SetActive(true); break; //...le joueur bleu case 1: dice1 = Instantiate <GameObject>(diceJD); dice2 = Instantiate <GameObject>(diceJD); dice3 = Instantiate <GameObject>(diceJD); value11 = dice1.GetComponent <Dice>(); value12 = dice2.GetComponent <Dice>(); value13 = dice3.GetComponent <Dice>(); dice4 = Instantiate <GameObject>(diceBG); dice5 = Instantiate <GameObject>(diceBG); dice6 = Instantiate <GameObject>(diceBG); value24 = dice4.GetComponent <Dice2>(); value25 = dice5.GetComponent <Dice2>(); value26 = dice6.GetComponent <Dice2>(); jetBVJ.SetActive(true); startDroite = true; break; //...le joueur vert case 2: dice1 = Instantiate <GameObject>(diceJD); dice2 = Instantiate <GameObject>(diceJD); dice3 = Instantiate <GameObject>(diceJD); value11 = dice1.GetComponent <Dice>(); value12 = dice2.GetComponent <Dice>(); value13 = dice3.GetComponent <Dice>(); dice4 = Instantiate <GameObject>(diceVG); dice5 = Instantiate <GameObject>(diceVG); dice6 = Instantiate <GameObject>(diceVG); value24 = dice4.GetComponent <Dice2>(); value25 = dice5.GetComponent <Dice2>(); value26 = dice6.GetComponent <Dice2>(); jetVVJ.SetActive(true); startDroite = true; break; } break; } //Instancie le nombre de dés en fonction de la valeur du slider et récupère son résultat dice1.SetActive(true); //Si le dé part de droite... if (startDroite == true) { r = value11.value(); } else { r = value21.value(); } resultat.Add((int)r + 1); //Si deux dés if (nbDe == 2) { dice2.SetActive(true); if (startDroite == true) { r2 = value12.value(); } else { r2 = value22.value(); } resultat.Add((int)r2 + 1); } //Si trois dés else if (nbDe == 3) { dice2.SetActive(true); if (startDroite == true) { r2 = value12.value(); } else { r2 = value22.value(); } dice3.SetActive(true); if (startDroite == true) { r3 = value13.value(); } else { r3 = value23.value(); } resultat.Add((int)r2 + 1); resultat.Add((int)r3 + 1); } //Trie du tableau contenant les résultats des dés resultat.Sort(); //Début de la couroutine pour les autres dés coroutine4 = jet2(startDroite); StartCoroutine(coroutine4); //Démarre les 2 couroutines coroutine = wait(); StartCoroutine(coroutine); coroutine2 = wait2(resultat, resultatAttacked); StartCoroutine(coroutine2); coroutine5 = resBattle(resultat, resultatAttacked); StartCoroutine(coroutine5); //Les territoires redevienent actifs active = false; } }