예제 #1
0
    void GetInputs()
    {
        _shiftModifier   = Input.GetKey(KeyCode.LeftShift);
        _controlModifier = Input.GetKey(KeyCode.LeftControl);

        if (Input.GetKeyDown(KeyCode.KeypadPlus))
        {
            CommandMapper.IncrementSimulationSpeed();
        }
        else if (Input.GetKeyDown(KeyCode.KeypadMinus))
        {
            CommandMapper.DecrementSimulationSpeed();
        }
        else if (Input.GetKeyDown(KeyCode.Space))
        {
            CommandMapper.ToggleSimulation();
        }

        //48 <-> 57 == 0 - 9
        for (int i = 0; i < _alphaKeys.Length; i++)
        {
            if (Input.GetKeyDown(_alphaKeys[i]))
            {
                if (Input.GetKey(KeyCode.CapsLock))
                {
                    CreateGroup(i);
                }
                else
                {
                    SelectGroup(i);
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            CommandMapper.ToggleAlignmentPlane();
        }

        if (EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            _selectionBoxOrigin = Input.mousePosition;
        }
        if (Input.GetKeyUp(KeyCode.Mouse0))
        {
            if (_mouse0timer <= _doubleClickThreshold)
            {
                ProcessPrimaryKey();
            }
            else
            {
                CommandMapper.CloseSelectionBox();
            }

            _mouse0timer = 0f;
        }
        if (Input.GetKey(KeyCode.Mouse0))
        {
            _mouse0timer += Time.unscaledDeltaTime;

            if (_mouse0timer > _doubleClickThreshold)
            {
                CommandMapper.OpenSelectionBox(_selectionBoxOrigin);
            }
        }
        if (Input.GetKeyUp(KeyCode.Mouse1))
        {
            if (_mouse1timer <= _doubleClickThreshold)
            {
                ProcessSecondaryKey();
            }
            else
            {
                //OnSecondaryKeyUp after hold
            }

            _mouse1timer = 0f;
        }
        if (Input.GetKey(KeyCode.Mouse1))
        {
            _mouse1timer += Time.unscaledDeltaTime;

            if (_mouse1timer > _doubleClickThreshold)
            {
                //rotate heading of selected ships
                ShiftAlignmentPlane();
            }
        }
    }