Exemplo n.º 1
0
Arquivo: Maua.cs Projeto: dmariaa/ESDM
        public void PetalSelect(string name)
        {
            GameObject petal;
            List <IMauaEventHandler> handlers = GameObjectFindHelper.FindGameObjectWithInterface <IMauaEventHandler>();

            if (name != selectedPetal)
            {
                string current = selectedPetal;
                selectedPetal = name;

                if (current != "")
                {
                    PetalExit(current);

                    petal = transform.Find(current).gameObject;

                    //ExecuteEvents.Execute<IMauaEventHandler>(eventHandler, null,
                    //    (handler, data) => { handler.PetalToggle(petal.GetComponent<MauaPetal>(), false); });

                    ExecuteEventHelper.BroadcastEvent(handlers, (handler, eventData) => { handler.PetalToggle(petal.GetComponent <MauaPetal>(), false); });
                }
            }

            petal = transform.Find(name).gameObject;

            // ExecuteEvents.Execute<IMauaEventHandler>(eventHandler, null,
            //    (handler, data) => { handler.PetalToggle(petal.GetComponent<MauaPetal>(), true); });

            ExecuteEventHelper.BroadcastEvent(handlers, (handler, eventData) => { handler.PetalToggle(petal.GetComponent <MauaPetal>(), true); });
        }
Exemplo n.º 2
0
 public void PetalToggle(MauaPetal petal, bool open)
 {
     if (playerHit)
     {
         List <IDoorEventHandler> handlers =
             GameObjectFindHelper.FindGameObjectWithInterface <IDoorEventHandler>();
         ExecuteEventHelper.BroadcastEvent(handlers, (handler, eventData) => { handler.DoorOpened(); });
     }
 }
Exemplo n.º 3
0
        private void Update()
        {
            _time = Mathf.Clamp(_time + Time.deltaTime * _direction, 0.0f, SecondsToOpen);

            _rectTransform.sizeDelta = new Vector2(
                Mathf.Lerp(_closedSize, _openedSize, _time / SecondsToOpen),
                _rectTransform.sizeDelta.y);

            if (IsOpened())
            {
                if (!closing)
                {
                    List <IInventoryPanelEventHandler> handlers = GameObjectFindHelper.FindGameObjectWithInterface <IInventoryPanelEventHandler>();
                    ExecuteEventHelper.BroadcastEvent(handlers, (handler, eventData) => { handler.InventoryPanelOpened(); });
                    closing = true;
                }

                Vector2Int slotPosition = _selectedSlot != null ? _selectedSlot.gridPosition : Vector2Int.zero;

                if (Input.GetKeyDown(KeyCode.W))
                {
                    slotPosition.x = Math.Min(Math.Max(slotPosition.x - 1, 0), 1);
                }
                else if (Input.GetKeyDown(KeyCode.S))
                {
                    slotPosition.x = Math.Min(Math.Max(slotPosition.x + 1, 0), 1);
                }
                else if (Input.GetKeyDown(KeyCode.A))
                {
                    slotPosition.y = Math.Min(Math.Max(slotPosition.y - 1, 0), 7);
                }
                else if (Input.GetKeyDown(KeyCode.D))
                {
                    slotPosition.y = Math.Min(Math.Max(slotPosition.y + 1, 0), 7);
                }
                else if (Input.GetKeyDown(KeyCode.Space))
                {
                }

                SelectSlot(transform.Find(String.Format("InventorySlot[{0}][{1}]", slotPosition.x, slotPosition.y)
                                          ).GetComponent <InventoryPanelSlot>()
                           );
            }
            else if (closing && IsClosed())
            {
                informationPanel?.GetComponent <ItemInformationPanel>().Hide();

                List <IInventoryPanelEventHandler> handlers = GameObjectFindHelper.FindGameObjectWithInterface <IInventoryPanelEventHandler>();
                ExecuteEventHelper.BroadcastEvent(handlers, (handler, eventData) => { handler.InventoryPanelClosed(); });

                closing = false;
            }
        }
Exemplo n.º 4
0
    public void ToggleHelp(bool show)
    {
        _helpPanel.SetActive(show);

        // Call gameobject listeners
        List <IKeyboardHelpPanelHandler> listeners = GameObjectFindHelper.FindGameObjectWithInterface <IKeyboardHelpPanelHandler>();

        ExecuteEventHelper.BroadcastEvent(listeners, (handler, data) => { handler.KeyboardHelpPanelToggle(show); });

        // Call scriptable object listeners
        ExecuteEventHelper.BroadcastEvent(_listeners, (handler, data) => { handler.KeyboardHelpPanelToggle(show); }, true);
    }
Exemplo n.º 5
0
        private void OnTriggerEnter2D(Collider2D other)
        {
            if (other.gameObject.name == "Stella")
            {
                playerHit = true;

                TextManager textManager = other.GetComponent <TextManager>();
                textManager.DisplayMessage("Necesito algo para abrir esta puerta", Color.white, 0);
                textManager.DisplayMessage("", Color.white, 3.0f);

                List <IDoorEventHandler> handlers = GameObjectFindHelper.FindGameObjectWithInterface <IDoorEventHandler>();
                ExecuteEventHelper.BroadcastEvent(handlers, (handler, eventData) => { handler.DoorHit(); });
            }
        }