示例#1
0
        void ManageOrdersExecuter()
        {
            if (SecondClickListener.Instance.ListenToClick)
            {
                return;
            }

            // over UI
            if (EventSystem.current != null && EventSystem.current.IsPointerOverGameObject())
            {
                return;
            }

            if (Input.GetMouseButtonDown(1))
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit, Mathf.Infinity, LayerMask.GetMask("Entity")))
                {
                    SelectedGroupsActionsCaller.OnEntityClick(hit.transform.GetComponent <Entity>());
                }
                else if (Physics.Raycast(ray, out hit, Mathf.Infinity, LayerMask.GetMask("Terrain")))
                {
                    SelectedGroupsActionsCaller.OrderMoveToPosition(hit.point);

                    if (SelectionManager.Instance.HasSelection)
                    {
                        DisplayMoveToOrderFeedback(hit.point);
                    }
                }
            }
        }
示例#2
0
        private void ManageHotkeyInputs()
        {
            foreach (var kvp in _commands)
            {
                if (Input.GetKeyDown(kvp.Key))
                {
                    kvp.Value?.Invoke();

                    // if a key change the selection, and so the hotkeys, System throws an exception.
                    // To avoid that, we return after one hotkey has been pressed.
                    return;
                }
            }

            if (Input.GetKeyDown(_killEntityKeyCode))
            {
                SelectedGroupsActionsCaller.KillSelectedEntities();
            }
        }
示例#3
0
        public static Action ToOrder(this OverallAction overallAction)
        {
            switch (overallAction)
            {
            case OverallAction.Stop:
                return(() => SelectedGroupsActionsCaller.OrderStop());

            case OverallAction.Move:
                return(() => SecondClickListener.Instance.ListenToMove());

            case OverallAction.Attack:
                return(() => SecondClickListener.Instance.ListenToAttack());

            case OverallAction.Patrol:
                return(() => SecondClickListener.Instance.ListenToPatrol());

            case OverallAction.MoveAggressively:
                return(() => SecondClickListener.Instance.ListenToMoveAggresively());

            default:
                throw new NotImplementedException(string.Format("Please, implement {0} enum.", overallAction));
            }
        }