private void OnTriggerStay(Collider other) { if (other.tag == "Player" && Input.GetKeyDown(KeyCode.E)) { player.AddItems(howMuchToAdd, nameOfItem); audioManager.Play("FruitPickup"); if (nameOfItem == "Fruit") { foods.food.Remove(gameObject); } Destroy(gameObject); } }
protected IEnumerator MakeTradeoverTime() { Debug.Log("Starting to make trade"); var loadStart = GUILoading.LoadStart(GUILoading.Mode.SmallInGame); while (loadStart.MoveNext()) { yield return(null); } GUILoading.ActivityInfo = "Making Trade... " + CharacterGoods.Count.ToString() + " character goods going to player"; //give stuff to player... foreach (BarterGoods good in CharacterGoods) { foreach (KeyValuePair <WIStack, int> goodPair in good) { if (goodPair.Key.HasTopItem) { Debug.Log("Adding " + goodPair.Key.TopItem.FileName + " to player inventory..."); } var addItem = PlayerInventory.AddItems(goodPair.Key, goodPair.Value); while (addItem.MoveNext()) { yield return(null); } } yield return(null); } //wait a tick... yield return(null); //give stuff to character... foreach (BarterGoods good in PlayerGoods) { foreach (KeyValuePair <WIStack, int> goodPair in good) { var enumerator = CharacterInventory.AddItems(goodPair.Key, goodPair.Value); while (enumerator.MoveNext()) { yield return(null); } } } //TODO determine what counts as a 'successful use' BarterManager.Use(true); PlayerBank.Absorb(CharacterGoodsBank); CharacterBank.Absorb(PlayerGoodsBank); ClearGoodsAndCurrency(); MadeTradeThisSession = true; Player.Get.AvatarActions.ReceiveAction(AvatarAction.BarterMakeTrade, WorldClock.AdjustedRealTime); var loadFinish = GUILoading.LoadFinish(); while (loadFinish.MoveNext()) { yield return(null); } Debug.Log("Finished making trade"); mMakingTrade = false; yield break; }