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<DoorBehaviour>()) gameObject.GetComponent<DoorBehaviour>().isEnabled = false; if (gameObject.GetComponent<AnimatedDoorBehaviour>()) gameObject.GetComponent<AnimatedDoorBehaviour>().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<AnimatedDoorBehaviour>().isEnabled == false) TriggerDoor.ableToOpen = false; } private void OnTriggerEnter2D(Collider2D collision) { if (!gameObject.GetComponent<WindowController>().IsOpened() && InventoryUIManager.Instance.FindItemInWarehouseByName(RequiredObject.name).Count > 0) gameObject.GetComponent<WindowController>().OpenPanel(); } private void OnTriggerExit2D(Collider2D collision) { if (gameObject.GetComponent<WindowController>().IsOpened()) gameObject.GetComponent<WindowController>().DestroyPanel(); } }