IEnumerator LoadLevelData() //Spécificité des niveaux. { _DataBase.ResetTable(); Carte = GameObject.Find("Recettes"); Bar1 = GameObject.Find("Bar1"); Bar2 = GameObject.Find("Bar2"); Carte.SetActive(false); switch (LevelChoisi) { case 1: GameObject.Find("Timer").GetComponent <Countdown>().timeLeft = 180; break; case 2: GameObject.Find("Timer").GetComponent <Countdown>().timeLeft = 90; break; case 3: GameObject.Find("Timer").GetComponent <Countdown>().timeLeft = 90; break; case 4: GameObject.Find("Timer").GetComponent <Countdown>().timeLeft = 180; break; case 5: GameObject.Find("Timer").GetComponent <Countdown>().timeLeft = 180; break; } Bar2.SetActive(false); yield return(new WaitForSeconds(0.2f)); GameManager.Loading.SetActive(false); GameManager.Status = GameState.Playing; }
void Update() { StartCoroutine("BGM"); Debug.Log(Status); if (SceneManager.GetActiveScene().name != "MenuPrincipal") { MenuPrincipal.SetActive(false); } switch (Status) { case GameState.MainMenu: MenuPrincipal.SetActive(true); Play.SetActive(false); Recettes.SetActive(false); Credits.SetActive(false); Highscore.SetActive(false); break; case GameState.SelectLevel: CheckSave(); Play.SetActive(true); break; case GameState.Recettes: Recettes.SetActive(true); break; case GameState.Credits: Credits.SetActive(true); break; case GameState.Highscore: CheckSave(); Highscore.SetActive(true); Highscore.transform.Find("HighscoreText").GetComponent <Text>().text = String.Format("Votre Highscore est : \n\n Level 1 : {0} \n Level 2 : {1} \n Level 3 : {2} \n Level 4 : {3} \n Level 5 : {4}", _DataBase.Tab_Score[0], _DataBase.Tab_Score[1], _DataBase.Tab_Score[2], _DataBase.Tab_Score[3], _DataBase.Tab_Score[4]); break; case GameState.Quitter: Application.Quit(); break; case GameState.Reset: _DataBase.ResetScore(); _DataBase.GetSave(); CheckSave(); Status = GameState.MainMenu; break; case GameState.Start: Loading.SetActive(true); MenuPrincipal.SetActive(true); Play.SetActive(false); Recettes.SetActive(false); Credits.SetActive(false); Highscore.SetActive(false); Loading.GetComponent <LoadingScreen>().Loading(0); GameManager.Status = GameState.Loading; break; case GameState.Playing: if (SceneManager.GetActiveScene().name == "Jeu") { Rnd = new System.Random(seed++); AddCustomer(); if (Input.GetMouseButtonDown(0)) { Vector3 CAM_POS = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0)); Collider2D Collider = Physics2D.OverlapPoint(CAM_POS); if (Collider) { switch (Collider.tag) { case "Customer": Collider.gameObject.GetComponent <Customer>().CheckOrder(ID_Cocktail); Items = new int[3] { 0, 0, 0 }; ID_Cocktail = -1; Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); break; case "Items": if (Bar1.activeInHierarchy == true) { Items[Collider.gameObject.GetComponent <Item>().IndexItemID] = 0; DestroyObject(Collider.gameObject); } else if (Bar2.activeInHierarchy == true) { if (GameObject.Find("DragManager").GetComponent <DragHandler>().ItemObject == null) { GameObject.Find("DragManager").GetComponent <DragHandler>().ItemObject = Collider.transform; Collider.transform.position = new Vector3(2.5f, -1.5f, 0); GameObject.Find("DragManager").GetComponent <DragHandler>().StartPos = Collider.transform.position; GameObject.Find("DragManager").GetComponent <DragHandler>().StartRotation = new Vector3(Collider.transform.eulerAngles.x, Collider.transform.eulerAngles.y, Collider.transform.eulerAngles.z); } } break; case "Shaker": GameObject[] ObjectItems = GameObject.FindGameObjectsWithTag("Items"); int PouredNumber = ObjectItems.Length; foreach (GameObject ObjectItem in ObjectItems) { if (ObjectItem.GetComponent <Item>().IsPoured == false && ObjectItem.GetComponent <Item>().AlreadyPoured == false) { PouredNumber--; } } if (PouredNumber == ObjectItems.Length) // Si toutes les ingérdients on été verser { ID_Cocktail = Shaker(); } else if (PouredNumber != 0) // manque des ingrédients { ID_Cocktail = 0; } else // rien { ID_Cocktail = -1; } Debug.Log(ID_Cocktail); DestroyObject(ItemBar_0); DestroyObject(ItemBar_1); DestroyObject(ItemBar_2); Items = new int[3] { 0, 0, 0 }; Bar2.SetActive(false); Bar1.SetActive(true); GameObject.Find("DragManager").GetComponent <BoxCollider2D>().enabled = false; GameObject.Find("DragManager").GetComponent <DragHandler>().enabled = false; if (ID_Cocktail != -1) { Vector3 TMP_POS = Camera.main.ScreenToWorldPoint(Input.mousePosition); if (ID_Cocktail == 0) { GameObject.Find("Barman").GetComponent <AudioSource>().clip = bad; GameObject.Find("Barman").GetComponent <AudioSource>().Play(); Instantiate(Resources.Load <GameObject>("Prefab/FxParticle/ParticleBad"), new Vector3(TMP_POS.x, TMP_POS.y, -1), transform.rotation); } else { GameObject.Find("Barman").GetComponent <AudioSource>().clip = good; GameObject.Find("Barman").GetComponent <AudioSource>().Play(); Instantiate(Resources.Load <GameObject>("Prefab/FxParticle/ParticleGood"), new Vector3(TMP_POS.x, TMP_POS.y, -1), transform.rotation); } Sprite Cursor_Sprite = Resources.Load <Sprite>("Prefab/Boissons/" + ID_Cocktail); Cursor.SetCursor(Cursor_Sprite.texture, new Vector2(Cursor_Sprite.texture.width / 2, Cursor_Sprite.texture.height / 2), CursorMode.ForceSoftware); } break; case "BorderCollider": Bar2.SetActive(false); ItemBar_0.transform.position = new Vector3(3.5f, -1.5f, 0); ItemBar_0.transform.localScale = ItemBar_0.GetComponent <Item>().DefaultScale; ItemBar_1.transform.position = new Vector3(2.5f, -1.5f, 0); ItemBar_1.transform.localScale = ItemBar_0.GetComponent <Item>().DefaultScale; ItemBar_2.transform.position = new Vector3(1.5f, -1.5f, 0); ItemBar_2.transform.localScale = ItemBar_0.GetComponent <Item>().DefaultScale; Bar1.SetActive(true); break; } } } } break; case GameState.GameClear: Items = new int[3] { 0, 0, 0 }; _DataBase.SaveScore(LevelChoisi, Score); CheckSave(); Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); SpawnTimerSecs = 1; if (Score >= OffsetScoreRequired[LevelChoisi - 1, 0] && Score < OffsetScoreRequired[LevelChoisi - 1, 1]) { Stars = 1; } else if (Score >= OffsetScoreRequired[LevelChoisi - 1, 1] && Score < OffsetScoreRequired[LevelChoisi - 1, 2]) { Stars = 2; } else if (Score >= OffsetScoreRequired[LevelChoisi - 1, 2]) { Stars = 3; } Loading.SetActive(true); Loading.GetComponent <LoadingScreen>().Loading(0); GameManager.Status = GameState.Loading; break; case GameState.Tuto: Loading.SetActive(true); MenuPrincipal.SetActive(true); Play.SetActive(false); Recettes.SetActive(false); Credits.SetActive(false); Highscore.SetActive(false); Loading.GetComponent <LoadingScreen>().Loading(1); GameManager.Status = GameState.Loading; break; case GameState.FinTuto: GameObject.Find("Tuto6").SetActive(false); Loading.SetActive(true); MenuPrincipal.SetActive(true); Play.SetActive(false); Recettes.SetActive(false); Credits.SetActive(false); Highscore.SetActive(false); Loading.GetComponent <LoadingScreen>().Loading(0); GameManager.Status = GameState.MainMenu; break; } }
public void OnClickBartender() { if (LevelChoisi >= 4 && (ItemBar_0 != null || ItemBar_1 != null || ItemBar_2 != null)) { GameObject.Find("DragManager").GetComponent <BoxCollider2D>().enabled = false; GameObject.Find("DragManager").GetComponent <DragHandler>().enabled = false; Bar2.SetActive(true); Bar1.SetActive(false); if (Items[0] > 0) { ItemBar_0.transform.position = new Vector3(-8, -1.5f, 0); if (Items[0] == 11 || Items[0] == 12) { ItemBar_0.transform.localScale += transform.localScale * 0.08f; } else { ItemBar_0.transform.localScale += transform.localScale * 0.8f; } ItemBar_0.GetComponent <SpriteRenderer>().sortingLayerName = "Bouteilles2"; } if (Items[1] > 0) { ItemBar_1.transform.position = new Vector3(-6, -1.5f, 0); if (Items[1] == 11 || Items[1] == 12) { ItemBar_1.transform.localScale += transform.localScale * 0.08f; } else { ItemBar_1.transform.localScale += transform.localScale * 0.8f; } ItemBar_1.GetComponent <SpriteRenderer>().sortingLayerName = "Bouteilles2"; } if (Items[2] > 0) { ItemBar_2.transform.position = new Vector3(-4, -1.5f, 0); if (Items[2] == 11 || Items[2] == 12) { ItemBar_2.transform.localScale += transform.localScale * 0.08f; } else { ItemBar_2.transform.localScale += transform.localScale * 0.8f; } ItemBar_2.GetComponent <SpriteRenderer>().sortingLayerName = "Bouteilles2"; } } else { ID_Cocktail = Shaker(); DestroyObject(ItemBar_0); DestroyObject(ItemBar_1); DestroyObject(ItemBar_2); Items = new int[3] { 0, 0, 0 }; Debug.Log("Cocktail ID : " + ID_Cocktail); } if (ID_Cocktail != -1) { Vector3 TMP_POS = Camera.main.ScreenToWorldPoint(Input.mousePosition); if (ID_Cocktail == 0) { GameObject.Find("Barman").GetComponent <AudioSource>().clip = bad; GameObject.Find("Barman").GetComponent <AudioSource>().Play(); Instantiate(Resources.Load <GameObject>("Prefab/FxParticle/ParticleBad"), new Vector3(TMP_POS.x, TMP_POS.y, -1), transform.rotation); } else { GameObject.Find("Barman").GetComponent <AudioSource>().clip = good; GameObject.Find("Barman").GetComponent <AudioSource>().Play(); Instantiate(Resources.Load <GameObject>("Prefab/FxParticle/ParticleGood"), new Vector3(TMP_POS.x, TMP_POS.y, -1), transform.rotation); } Sprite Cursor_Sprite = Resources.Load <Sprite>("Prefab/Boissons/" + ID_Cocktail); Cursor.SetCursor(Cursor_Sprite.texture, new Vector2(Cursor_Sprite.texture.width / 2, Cursor_Sprite.texture.height / 2), CursorMode.ForceSoftware); } }