using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; [RequireComponent(typeof(WindowController))] class WizardLetter : MonoBehaviour { public Item RequiredObject; public bool decided = false; public void Start() { } private void Update() { if(!decided) { if (InventoryUIManager.Instance != null && InventoryUIManager.Instance.FindItemInWarehouseByName(RequiredObject.name).Count > 0) { if (gameObject.GetComponent()) gameObject.GetComponent().isEnabled = false; if (gameObject.GetComponent()) gameObject.GetComponent().isEnabled = false; decided = true; } } // DANGEROUS - we make sure that dorwont be opened by force - work only when on the scene there is only one door!!! if (gameObject.GetComponent().isEnabled == false) TriggerDoor.ableToOpen = false; } private void OnTriggerEnter2D(Collider2D collision) { if (!gameObject.GetComponent().IsOpened() && InventoryUIManager.Instance.FindItemInWarehouseByName(RequiredObject.name).Count > 0) gameObject.GetComponent().OpenPanel(); } private void OnTriggerExit2D(Collider2D collision) { if (gameObject.GetComponent().IsOpened()) gameObject.GetComponent().DestroyPanel(); } }