diff --git a/Assets/Scripts/REFACTORING/Story/OutsideWizard/WizardLetter.cs b/Assets/Scripts/REFACTORING/Story/OutsideWizard/WizardLetter.cs new file mode 100644 index 00000000..0931e74e --- /dev/null +++ b/Assets/Scripts/REFACTORING/Story/OutsideWizard/WizardLetter.cs @@ -0,0 +1,52 @@ +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(); + } +} + diff --git a/Assets/Scripts/REFACTORING/Story/OutsideWizard/WizardLetter.cs.meta b/Assets/Scripts/REFACTORING/Story/OutsideWizard/WizardLetter.cs.meta new file mode 100644 index 00000000..eb14dac2 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Story/OutsideWizard/WizardLetter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 882134c91e77a0f4b913091e3ef95538 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: