void Start() { SE = GetComponent <AudioSource>(); MenuPrincipal = GameObject.Find("MenuPrincipal"); LevelSelect = GameObject.Find("LevelSelect"); Play = GameObject.Find("Jouer"); Recettes = GameObject.Find("Recettes"); Credits = GameObject.Find("Credits"); Highscore = GameObject.Find("Highscore"); Quitter = GameObject.Find("Quitter"); Reset = GameObject.Find("Reset"); Loading = GameObject.Find("Loading"); Level2 = LevelSelect.transform.Find("Level2").GetComponent <Button>(); Level3 = LevelSelect.transform.Find("Level3").GetComponent <Button>(); Level4 = LevelSelect.transform.Find("Level4").GetComponent <Button>(); Level5 = LevelSelect.transform.Find("Level5").GetComponent <Button>(); Tutoriel = LevelSelect.transform.Find("Tutoriel").GetComponent <Button>(); Level2.interactable = false; Level3.interactable = false; Level4.interactable = false; Level5.interactable = false; Play.SetActive(false); Recettes.SetActive(false); Credits.SetActive(false); Highscore.SetActive(false); Loading.SetActive(false); _DataBase = gameObject.GetComponent <DataBase>(); Status = GameState.MainMenu; StartCoroutine("SpawnTimer"); }
public bool AddIngredient(int player, Ingredients ingredient) { bool achieved = false; if (player == 0) { if (currentJoueur1 == null) { currentJoueur1 = GetNext(0); } if (currentJoueur1 != null) { achieved = currentJoueur1.ConsumeIngredient(ingredient); if (achieved && ingredientAdded != null) { ingredientAdded.Invoke(0); } } } if (player == 1) { if (currentJoueur2 == null) { currentJoueur2 = GetNext(1); } if (currentJoueur2 != null) { achieved = currentJoueur2.ConsumeIngredient(ingredient); if (achieved && ingredientAdded != null) { ingredientAdded.Invoke(1); } } } if (!achieved) { if (player == 0 && currentJoueur1 != null) { currentJoueur1 = Instantiate <Recettes>(currentJ1Original); if (ingredientMissed != null) { ingredientMissed.Invoke(0); } } else if (player == 1 && currentJoueur2 != null) { currentJoueur2 = Instantiate <Recettes>(currentJ2Original); if (ingredientMissed != null) { ingredientMissed.Invoke(1); } } } return(achieved); }
public void Init() { if (type == Type.Random || level == null) { level = ScriptableObject.CreateInstance <Level>(); level.time = 10f; } else { level = Instantiate <Level>(level); } currentJoueur1 = GetNext(0); currentJoueur2 = GetNext(1); }
public List <CommentsByUser> CommentUsers(Recettes rec) { model.UsersComment = new List <CommentsByUser>(); List <Comments> temp = new List <Comments>(); temp = db.Comments.Where(c => c.recettesId == rec.id).ToList(); foreach (var item in temp) { model.UsersComment.Add(new CommentsByUser { Bloggers = db.Users.SingleOrDefault(c => c.Id == item.userId), Commentaires = item }); } return(model.UsersComment); }
Recettes GetNext(int player) { if (player == 0) { Recettes r = null; if (type == Type.Normal && level.recetteJoueur1 != null && level.recetteJoueur1.Count > 0) { r = Instantiate <Recettes>(level.recetteJoueur1[0]); currentJ1Original = level.recetteJoueur1[0]; level.recetteJoueur1.RemoveAt(0); } else if (type == Type.Random) { r = allRecipes[Random.Range(0, allRecipes.Length)]; currentJ1Original = r; r = Instantiate <Recettes>(r); Debug.Log("New Recipe: " + r.name); } return(r); } if (player == 1) { Recettes r = null; if (type == Type.Normal && level.recetteJoueur2 != null && level.recetteJoueur2.Count > 0) { r = Instantiate <Recettes>(level.recetteJoueur2[0]); currentJ2Original = level.recetteJoueur2[0]; level.recetteJoueur2.RemoveAt(0); } else if (type == Type.Random) { r = allRecipes[Random.Range(0, allRecipes.Length)]; currentJ2Original = r; r = Instantiate <Recettes>(r); Debug.Log("New Recipe: " + r.name); } return(r); } return(null); }
public bool Valider(int player) { if (player == 0 && currentJoueur1.IsGood()) { EventManager.TriggerEvent("ReciepeWin", new { type = player }); recipesDone++; score += currentJoueur1.score; if (type == Type.Random) { level.time += 1.5f; } currentJoueur1 = GetNext(0); if (joueur1Ended != null) { joueur1Ended.Invoke(currentJoueur1); } return(true); } if (player == 1 && currentJoueur2.IsGood()) { EventManager.TriggerEvent("ReciepeWin", new { type = player }); Debug.Log("J2 Validé!"); recipesDone++; score += currentJoueur2.score; if (type == Type.Random) { level.time += 1.5f; } currentJoueur2 = GetNext(1); if (joueur2Ended != null) { joueur2Ended.Invoke(currentJoueur2); } return(true); } return(false); }
public CommentsByUser CommentUsers(Recettes rec, List <CommentsByUser> Blogger) { CommentsByUser item = new CommentsByUser(); return(item); }
void OnRecipeEnd(Recettes r) { // TODO : MORE FX }
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; } }