diff --git a/Assets/Scipts/GameMode.cs b/Assets/Scipts/GameMode.cs index 3912883..66f578b 100644 --- a/Assets/Scipts/GameMode.cs +++ b/Assets/Scipts/GameMode.cs @@ -43,16 +43,10 @@ public class GameMode : MonoBehaviour { } if (maxDistance < DistanceToWin) { - //GameWinHere - } - } - - void CheckIngredients() - { - - foreach(GameObject gamePlayer in Players) - { - + if (recipe.CheckVictory()) + { + //Win Game here + } } } } diff --git a/Assets/Scipts/Recipe.cs b/Assets/Scipts/Recipe.cs index 219ee2e..ba8aee7 100644 --- a/Assets/Scipts/Recipe.cs +++ b/Assets/Scipts/Recipe.cs @@ -13,6 +13,7 @@ public class Recipe : MonoBehaviour { public Frame[] Frames; public int[] Qtys; + public int[] heldQtys; public GameObject RecipeCanvas; @@ -56,13 +57,34 @@ public class Recipe : MonoBehaviour { localPlayer.heldVeggie = null; Inventory.gameObject.SetActive(false); } + public void friendlyPickup(string VeggieName, int change) + { + StartCoroutine(ItemLookup(VeggieName, change)); + } + + IEnumerator ItemLookup(string VeggieName, int change) + { + for (int i = 0; i < Veggies.Length; i++) + { + if(Veggies[i].Name == VeggieName) + { + heldQtys[i] += change; + } + } + yield return new WaitForEndOfFrame(); + } - public void CheckInventory(List Players) + public bool CheckVictory() { - foreach(GameObject player in Players) + bool winning = true; + for (int i = 0; i < Veggies.Length; i++) { - Player PS = player.GetComponent(); + if (Qtys[i] != heldQtys[i]) + { + winning = false; + } } + return winning; } }