Beispiel #1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     /*If we collide with an item then we want to add it to the Inventory*/
     if (collision.gameObject.tag == "Item")
     {
         string   ItemName = collision.gameObject.name;
         ItemBase Item     = new ItemBase();
         ItemManager.items.TryGetValue(ItemName, out Item);
         Sprite ItemSprite = collision.GetComponent <SpriteRenderer>().sprite;
         if (cInventory.HasItem(Item.GetName()) && Item.GetStackable() == true)
         {
             Item.AddAmount(1);
             cInventory.UpdateUI();
         }
         else
         {
             //Item.SetAmount(1);
             //Item.SetSpriteImage(ItemSprite);
             cInventory.AddItem(Item);
             cInventory.UpdateUI();
         }
         Debug.Log("COLLISION!");
     }
     // if we collide with a bed then show the sleep menu and pause the game
     if (collision.gameObject.tag == "Bed")
     {
         SleepUI.SetActive(true);
         PauseMenuScript.GameIsPaused = true;
         //cClock.NightUpdate();
         //Debug.Log("COLLISION!");
     }
     // if we collide with the sell chest then enable it
     if (collision.gameObject.tag == "SellChest")
     {
         cChest.DisabledNEnable();
         if (!cInventory.ImageParent.gameObject.activeInHierarchy)
         {
             cInventory.DisabledNEnable();
         }
     }
     // if we collide with the shop then enable the shop
     if (collision.gameObject.tag == "SeedShop")
     {
         SeedShopUI.SetActive(true);
     }
     if (collision.gameObject.tag == "ToolShop")
     {
         ToolShopUI.SetActive(true);
     }
 }