Exemplo n.º 1
0
        public ArmyOrdersWindow(IGuiServices guiServices,
                                ITexts texts,
                                bool isTerrainActionButtonVisible,
                                bool isRecruitButtonVisible) : base(guiServices)
        {
            var dict = new Dictionary <string, Action <HandledEventArgs> >
            {
                {
                    texts.Get("move"), args =>
                    {
                        MoveClicked?.Invoke(args);
                        Closing?.Invoke(args);
                    }
                },
                {
                    texts.Get("fastMove"), args =>
                    {
                        FastMoveClicked?.Invoke(args);
                        Closing?.Invoke(args);
                    }
                },
                {
                    texts.Get("attack"), args =>
                    {
                        AttackClicked?.Invoke(args);
                        Closing?.Invoke(args);
                    }
                }
            };

            if (isRecruitButtonVisible)
            {
                dict.Add(texts.Get("recruit"), args =>
                {
                    RecruitClicked?.Invoke(args);
                    Closing?.Invoke(args);
                });
            }
            else
            {
                dict.Add(texts.Get("hunt"), args =>
                {
                    HuntClicked?.Invoke(args);
                    Closing?.Invoke(args);
                });
            }

            dict.Add(texts.Get("camp"), args =>
            {
                CampClicked?.Invoke(args);
                Closing?.Invoke(args);
            });

            dict.Add(texts.Get("equipment"), args =>
            {
                EquipmentClicked?.Invoke(args);
                Closing?.Invoke(args);
            });

            if (isTerrainActionButtonVisible)
            {
                dict.Add(texts.Get("action"), args =>
                {
                    ActionClicked?.Invoke(args);
                    Closing?.Invoke(args);
                });
            }

            dict.Add(texts.Get("exit"), args =>
            {
                ExitClicked?.Invoke(args);
                Closing?.Invoke(args);
            });

            ButtonNames = dict;
        }
Exemplo n.º 2
0
    void Update()
    {
        #region moving
        if (UnityEngine.Input.GetKey(KeyCode.W))
        {
            MoveClicked?.Invoke(Vector2.up);
        }
        else if (UnityEngine.Input.GetKey(KeyCode.A))
        {
            MoveClicked?.Invoke(Vector2.left);
        }
        else if (UnityEngine.Input.GetKey(KeyCode.S))
        {
            MoveClicked?.Invoke(Vector2.down);
        }
        else if (UnityEngine.Input.GetKey(KeyCode.D))
        {
            MoveClicked?.Invoke(Vector2.right);
        }
        #endregion

        #region mouse click
        if (!EventSystem.current.IsPointerOverGameObject())
        {
            if (UnityEngine.Input.GetMouseButtonDown(0))
            {
                PlayerShoot?.Invoke();
            }
            if (UnityEngine.Input.GetKeyDown(KeyCode.E))
            {
                PlayerInteracted?.Invoke();
            }
        }
        #endregion

        #region mouse move
        float mouseMove = UnityEngine.Input.GetAxis("Mouse X");
        if (mouseMove != 0)
        {
            PlayerMovedMouse?.Invoke(mouseMove);
        }
        //Vector3 currentMousePos = UnityEngine.Input.mousePosition;
        //if (currentMousePos.x != mousePos.x)
        //{
        //    float difference = currentMousePos.x - mousePos.x;
        //    PlayerMovedMouse?.Invoke(difference);
        //}
        //mousePos = currentMousePos;
        #endregion

        if (UnityEngine.Input.GetKeyDown(KeyCode.Tab))
        {
            inventoryOpened = !inventoryOpened;
            InventoryModeChangedTo?.Invoke(inventoryOpened);
        }
        if (UnityEngine.Input.GetKeyDown(KeyCode.P))
        {
            ingamePresetMenuOpened = !ingamePresetMenuOpened;
            IngamePreserMenuClick?.Invoke(ingamePresetMenuOpened);
        }
    }