public void AEteArrose() { renderer.material = grass; EnleverArrosoir(); QueteJardin scriptQueteJardin = GameObject.Find("_GameManager").GetComponent <QueteJardin>(); scriptQueteJardin.IncrementNbLegumesArroses(); ChangeState(ParcelleState.arrosage, ParcelleState.maturation); GameManagerJardin.sndASArrose.Play(); }
// renvoit vrai si on peut ajouter un legume, faux sinon bool AjoutLegume(GUITexture gTex) { QueteJardin scriptQueteJardin = GetComponent <QueteJardin>(); // si le legume a ete plante if (scriptQueteJardin.VerifierAjoutLegume(gTex.gameObject)) { NePasAfficherUILegumes(); selectedParcelle.GetComponent <Parcelle>().AEteSeme(gTex); return(true); } else { return(false); } }
void InitGameManagerJardin() { curGameState = GameState.queteJessicaP1; _alertState = AlerteState.attente; chrono = new System.Diagnostics.Stopwatch(); touchJardin = GetComponent <TouchJardin>(); queteJardin = GetComponent <QueteJardin>(); ambiance = AddAudio(musiqueAmbiance, true, true, 0.8f); sonDragOK = AddAudio(dragOK, false, false, 0.6f); sonErreur = AddAudio(erreur, false, false, 0.6f); sndASCreuse = AddAudio(sndCreuse, false, false, 0.6f); sndASArrose = AddAudio(sndArrose, false, false, 0.6f); sndASSelect = AddAudio(sndSelect, false, false, 0.6f); sndASPousse = AddAudio(sndPousse, false, false, 0.6f); ambiance.Play(); initGameManager(); CreerFichierStats(); GameManagerJardin.chrono.Start(); }
// affiche un écran de score qui dépend du nombre d'etoiles passé en parametre public void AfficherScore(int nbEtoiles, bool displayLegumes = false) { TextNormal.fontSize = Screen.height / 25; TextNormal.alignment = TextAnchor.MiddleCenter; float texWidth = Screen.width * 70 / 100; float texHeight = Screen.height * 60 / 100; float singleLine = texHeight * 10 / 100; float doubleLine = texHeight * 20 / 100; float posY = singleLine; float etoileSize = Screen.width * 5 / 100; float etoileGroupWidth = nbEtoiles * etoileSize * 2; // si on veut afficher score legumes la box s'agrandit if (displayLegumes) { print("dispLeg"); texHeight = Screen.height * 80 / 100; } // group of everything GUI.BeginGroup(new Rect(Screen.width / 2 - (texWidth / 2), Screen.height / 2 - (texHeight / 2), texWidth, texHeight)); // texture dialogue GUI.DrawTexture(new Rect(0, 0, texWidth, texHeight), Tex_dialogue, ScaleMode.StretchToFill, true, 0); // group of etoiles // we add etoileSize/2 because there is an extra space in the group width GUI.BeginGroup(new Rect(texWidth / 2 - etoileGroupWidth / 2 + etoileSize / 2, posY, etoileGroupWidth, etoileSize)); for (int i = 0; i < nbEtoiles; i++) { Rect etoileRect = new Rect(i * etoileSize * 2, 0, etoileSize, etoileSize); GUI.DrawTexture(etoileRect, etoile, ScaleMode.StretchToFill); } GUI.EndGroup(); posY += etoileSize + singleLine; int n = 2; switch (n) { case 1: GUI.Label(new Rect(0, posY, texWidth, 15), "Tu peux faire mieux...", TextNormal); break; case 2: GUI.Label(new Rect(0, posY, texWidth, 15), "C'est presque ça!", TextNormal); break; case 3: GUI.Label(new Rect(0, posY, texWidth, 15), "Excellent!", TextNormal); break; } posY += doubleLine; tempsPartie = chrono.Elapsed.Minutes * 60 + chrono.Elapsed.Seconds; GUI.Label(new Rect(0, posY, texWidth, 15), "Temps : " + tempsPartie + " secondes", TextNormal); posY += singleLine; GUI.Label(new Rect(0, posY, texWidth, 15), "Nombre d'erreurs : " + nbErreurs, TextNormal); posY += singleLine; GUI.Label(new Rect(0, posY, texWidth, 15), "Nombre d'aides : " + nbAppelsAide, TextNormal); posY += singleLine; if (displayLegumes) { posY += doubleLine; QueteJardin jardinScript = GameObject.FindGameObjectWithTag("GameManager").GetComponent <QueteJardin>(); GUI.Label(new Rect(0, posY, texWidth, 15), jardinScript.ScoreText(), TextNormal); } GUI.EndGroup(); }
// verifie si on a valider la quete ds la phase 1 ou 2 quand on appui sur lebouton de validation void ValiderLegumes() { if (Input.touchCount == 1) { if (validation.HitTest(Input.GetTouch(0).position)) { QueteJardin scriptQueteJardin = GetComponent <QueteJardin>(); #region plantation 1 if (GameManagerJardin.curGameState == GameManagerJardin.GameState.planterP1) { // si on a plante le legume obligatoire if (scriptQueteJardin.VerifierLegumeObligatoire()) { // tous les legumes ont ete arrosés if (scriptQueteJardin.VerifierLegumesArroses()) { // on passe a la phase de transition selectedParcelle = null; NePasAfficherUILegumes(); NePasAfficherBoutons(); scriptQueteJardin.InitQueteP2(); // jouer un son good pr valider GameManagerJardin.sonDragOK.Play(); //ChangeState(GameManagerJardin.GameState.planterP1, GameManagerJardin.GameState.dialogueTransition1); ChangeState(GameManagerJardin.GameState.planterP1, GameManagerJardin.GameState.queteJessicaP2); } // un legume n'a pas été arrosé else { gmJardin.SetAlerte(GameManagerJardin.AlerteState.arroserLegumes); // jouer un son alerte arrosage GameManagerJardin.sonErreur.Play(); } } // le légume obligatoire n'a pas été planté else { gmJardin.SetAlerte(GameManagerJardin.AlerteState.planterLegumeObligatoire); // jouer un son alerte planter legumes obligatoire GameManagerJardin.sonErreur.Play(); } } #endregion #region plantation 2 else if (GameManagerJardin.curGameState == GameManagerJardin.GameState.planterP2) { // verifier ici si la liste de legumes plante a la p1 a ete replante correctement en p2 // si on a plante le legume obligatoire if (scriptQueteJardin.VerifierLegumeObligatoire()) { // tous les legumes ont ete arrosés if (scriptQueteJardin.VerifierLegumesArroses()) { // on passe au score selectedParcelle = null; NePasAfficherUILegumes(); NePasAfficherBoutons(); // jouer un son good pr valider GameManagerJardin.sonDragOK.Play(); DisplayRejouer(true); ChangeState(GameManagerJardin.GameState.planterP1, GameManagerJardin.GameState.score); } // un legume n'a pas été arrosé else { gmJardin.SetAlerte(GameManagerJardin.AlerteState.arroserLegumes); // jouer un son alerte arrosage GameManagerJardin.sonErreur.Play(); } } // le légume obligatoire n'a pas été planté else { gmJardin.SetAlerte(GameManagerJardin.AlerteState.planterLegumeObligatoire); // jouer un son alerte planter legumes obligatoire GameManagerJardin.sonErreur.Play(); } } #endregion } } }