Browse Source

Victory conditions finished

master
MB 5 years ago
parent
commit
355e4452a6
2 changed files with 29 additions and 13 deletions
  1. +4
    -10
      Assets/Scipts/GameMode.cs
  2. +25
    -3
      Assets/Scipts/Recipe.cs

+ 4
- 10
Assets/Scipts/GameMode.cs View File

@ -43,16 +43,10 @@ public class GameMode : MonoBehaviour {
} }
if (maxDistance < DistanceToWin) if (maxDistance < DistanceToWin)
{ {
//GameWinHere
}
}
void CheckIngredients()
{
foreach(GameObject gamePlayer in Players)
{
if (recipe.CheckVictory())
{
//Win Game here
}
} }
} }
} }

+ 25
- 3
Assets/Scipts/Recipe.cs View File

@ -13,6 +13,7 @@ public class Recipe : MonoBehaviour {
public Frame[] Frames; public Frame[] Frames;
public int[] Qtys; public int[] Qtys;
public int[] heldQtys;
public GameObject RecipeCanvas; public GameObject RecipeCanvas;
@ -56,13 +57,34 @@ public class Recipe : MonoBehaviour {
localPlayer.heldVeggie = null; localPlayer.heldVeggie = null;
Inventory.gameObject.SetActive(false); 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<GameObject> Players)
public bool CheckVictory()
{ {
foreach(GameObject player in Players)
bool winning = true;
for (int i = 0; i < Veggies.Length; i++)
{ {
Player PS = player.GetComponent<Player>();
if (Qtys[i] != heldQtys[i])
{
winning = false;
}
} }
return winning;
} }
} }

Loading…
Cancel
Save