Пример #1
0
        private void ResetInputFlags()
        {
            // Reset keyboard
            for (int i = 0; i < keyCodes.Length; i++)
            {
                InputTuple data = keyTable[keyCodes[i]];
                data.JustPressed = false;
                data.Released    = false;
            }

            // Reset mouse
            leftMouseButton.JustPressed = false;
            leftMouseButton.Released    = false;

            // Reset tapping
            tapSwitch = false;
        }
Пример #2
0
        public FytInput()
        {
            cachedCamera = Camera.main;

            leftMouseButton = new InputTuple();

            keyTable = new Dictionary <KeyCode, InputTuple>();
            keyCodes = (KeyCode[])Enum.GetValues(typeof(KeyCode));

            for (int i = 0; i < keyCodes.Length; i++)
            {
                keyTable[keyCodes[i]] = new InputTuple();
            }

            dragPossible       = false;
            drag               = false;
            screenDragPosition = Vector3.zero;
            worldDragPosition  = Vector3.zero;
            tapSwitch          = false;
        }
Пример #3
0
        public void Poll()
        {
            // Handle keyboard
            for (int i = 0; i < keyCodes.Length; i++)
            {
                InputTuple data = keyTable[keyCodes[i]];
                bool       previouslyPressed = data.Pressed;
                data.Pressed = Input.GetKey(keyCodes[i]);
                if (!previouslyPressed && data.Pressed)
                {
                    data.JustPressed = true;
                }
                else if (previouslyPressed && !data.Pressed)
                {
                    data.Released = true;
                }
            }

            // Handle left mouse button, dragging, and tapping
            bool leftMousePreviouslyPressed = leftMouseButton.Pressed;

            leftMouseButton.Pressed = Input.GetMouseButton(0);
            if (!leftMousePreviouslyPressed && leftMouseButton.Pressed)
            {
                leftMouseButton.JustPressed = true;
                drag         = false; // Reset dragging to false...
                dragPossible = true;
                // Make drag positions equal to mouse positions!
                RepositionDragVectors();
            }
            else if (leftMousePreviouslyPressed && !leftMouseButton.Pressed)
            {
                leftMouseButton.Released = true;
                if (!drag)
                {
                    tapSwitch = true;
                }
                drag         = false; // Reset dragging to false...
                dragPossible = false;
            }
        }