using System.Collections; using System.Collections.Generic; using UnityEngine; using System; using Assets.Scripts.Player; namespace Assets.Scripts { public class Chest : MonoBehaviour { bool gotItem = false; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } public void interact(){ if (gotItem) { GameObject.Find("UIHandler").GetComponent().showMessage("ERROR;"+TextHandler.getText("alreadyLooted")); } else { gameObject.transform.parent.Find("Lid").GetComponent().Play("ChestOpen"); Item item; int luck = GameObject.Find("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.parent.Find("Lid").GetComponent().Play("ChestOpen"); } } } }