//adds and ingredient into the appliance public void addIngToApp(FoodObject food, HashSet <FoodObject> foodSet) { Transform onHead = player.GetChild(2); onHead.SetParent(null, true); StartCoroutine(Slerp(onHead)); food.subOneQ(); PlayerData.player.SetCurrentFood(food); food = new FoodObject(food); food.setQuantity(1); foreach (FoodObject ing in foodSet) { if (ing.getName() == food.getName()) { Debug.Log("match"); ing.addOneQ(); prevIng = food.getName(); return; } } foodSet.Add(food); prevIng = food.getName(); }
public void OnPointerDown(PointerEventData data) { float distance = Vector3.Distance(player.transform.position, gameObject.transform.position); if (distance <= range) { if (PlayerData.player.GetCurrentFood() != null && PlayerData.player.GetCounterFood(counterNum) == null) { // place ONE food on counter FoodObject food = PlayerData.player.GetCurrentFood(); food.subOneQ(); PlayerData.player.SetCurrentFood(food); FoodObject counter = new FoodObject(food); counter.setQuantity(1); PlayerData.player.SetCounterFood(counterNum, counter); Refresh(); } else if (PlayerData.player.GetCurrentFood() != null && PlayerData.player.GetCounterFood(counterNum) != null) { // stack food back if same name FoodObject food = PlayerData.player.GetCurrentFood(); if (PlayerData.player.GetCounterFood(counterNum).getName() == food.getName()) { food.addOneQ(); PlayerData.player.SetCurrentFood(food); PlayerData.player.SetCounterFood(counterNum, null); Refresh(); } } else if (PlayerData.player.GetCurrentFood() == null && PlayerData.player.GetCounterFood(counterNum) != null) { // remove food from counter PlayerData.player.SetCurrentFood(PlayerData.player.GetCounterFood(counterNum)); PlayerData.player.SetCounterFood(counterNum, null); Refresh(); } } }
public void EatFood() { Transform onHead = GameObject.FindWithTag("Player").transform.GetChild(2); onHead.SetParent(null, true); StartCoroutine(Slerp(onHead)); FoodObject toEat = PlayerData.player.GetCurrentFood(); PlayerData.player.SetHappiness(PlayerData.player.GetHappiness() + toEat.getHappiness()); if (toEat.getHappiness() > 0) { PlayerData.player.SetXP(PlayerData.player.GetXP() + toEat.getHappiness()); } toEat.subOneQ(); if (toEat.getQuantity() <= 0) { toEat = null; } PlayerData.player.SetCurrentFood(toEat); }