using System.Collections; using System.Collections.Generic; using UnityEngine; using System; using Assets.Scripts.Player; namespace Assets.Scripts.InteractableObjects { public class Chest : InteractableObject { bool gotItem = false; public override void handleInteraction(GameObject player){ if (gotItem) { GameObject.Find("UIHandler").GetComponent().showMessage("ERROR;"+TextHandler.getText("alreadyLooted")); } else { gameObject.transform.Find("Lid").GetComponent().Play("ChestOpen"); Item item; int luck = player.GetComponent().getPlayerStat("Luck").getAmount(); int type = new System.Random().Next(3); switch (type) { case 0: // Maybe add luck to increase chance for equipment item = new Equipment(luck); break; /*case 1: //Removed lore for now... no idea for lore break;*/ default: item = new Item(luck, false); break; } GameObject.Find("Inventory").GetComponent().addItem(item); } gotItem = true; } public bool saveChest(){ return gotItem; } public void loadChest(bool gotItem){ this.gotItem = gotItem; if(gotItem){ gameObject.transform.Find("Lid").GetComponent().Play("ChestOpen"); } } } }