Ejemplo n.º 1
0
        public void Awake()
        {
            window           = InventoryManager.instance.craftingStandard.window;
            triggerer        = GetComponent <ObjectTriggerer>();
            triggerer.window = window;
            triggerer.handleWindowDirectly = false; // We're in charge now :)

            window.OnHide += () =>
            {
                currentCraftingStation = null;
            };

            triggerer.OnTriggerUse += () =>
            {
                window.Toggle();

                if (window.isVisible)
                {
                    currentCraftingStation = this;
                    InventoryManager.instance.craftingStandard.SetCraftingCategory(category);
                }
            };
            triggerer.OnTriggerUnUse += () =>
            {
                if (currentCraftingStation == this)
                {
                    window.Hide();
                }
            };
        }
        public void Awake()
        {
            window = InventoryManager.instance.craftingStandard.window;
            triggerer = GetComponent<ObjectTriggerer>();
            triggerer.window = window;
            triggerer.handleWindowDirectly = false; // We're in charge now :)

            window.OnHide += () =>
            {
                currentCraftingStation = null;
            };

            triggerer.OnTriggerUse += () =>
            {
                window.Toggle();

                if (window.isVisible)
                {
                    currentCraftingStation = this;
                    InventoryManager.instance.craftingStandard.SetCraftingCategory(category);
                }
            };
            triggerer.OnTriggerUnUse += () =>
            {
                if (currentCraftingStation == this)
                    window.Hide();
            };
        }
        public virtual void Use(bool fireEvents = true)
        {
            if (isActive)
            {
                return;
            }

            if (handleWindowDirectly && fireEvents)
            {
                if (toggleWhenTriggered)
                {
                    window.Toggle();
                }
                else if (window.isVisible == false)
                {
                    window.Show();
                }
            }

            if (useAnimation != null)
            {
                animator.Play(useAnimation.name);
            }

            if (useAudioClip != null)
            {
                InventoryUIUtility.AudioPlayOneShot(useAudioClip);
            }

            isActive = true;

            if (OnTriggerUse != null && fireEvents)
            {
                OnTriggerUse();
            }
        }