public bool ProcessInput()
        {
            bool inputReceived = false;

            foreach (var binding in getKeyDownBindings)
            {
                if (Input.GetKeyDown(binding.Key))
                {
                    inputReceived = true;
                    virtualController.GotKeyDown(binding.Value);
                }
            }

            foreach (var binding in getKeyUpBindings)
            {
                if (Input.GetKeyUp(binding.Key))
                {
                    inputReceived = true;
                    virtualController.GotKeyUp(binding.Value);
                }
            }

            if (Input.GetAxis(HORIZONTAL_AXIS) > 0.5f)
            {
                inputReceived = true;
                movedByAxis   = true;
                virtualController.InputReceived(InputLabels.MoveRightPressed);
            }
            else if (Input.GetAxis(HORIZONTAL_AXIS) < -0.5f)
            {
                inputReceived = true;
                movedByAxis   = true;
                virtualController.InputReceived(InputLabels.MoveLeftPressed);
            }
            else if (movedByAxis)
            {
                movedByAxis = false;
                virtualController.InputReceived(InputLabels.MoveReleased);
            }

            if (Input.GetAxis(SHOOT) > 0.5f)
            {
                if (shotByAxis == false)
                {
                    shotByAxis    = true;
                    inputReceived = true;
                    virtualController.InputReceived(InputLabels.ShootPressed);
                }
            }
            else if (shotByAxis)
            {
                shotByAxis = false;
                virtualController.InputReceived(InputLabels.ShootReleased);
            }

            return(inputReceived);
        }
Exemple #2
0
        public bool ProcessInput()
        {
            bool inputReceived = false;

            foreach (var binding in getKeyDownBindings)
            {
                if (Input.GetKeyDown(binding.Key))
                {
                    inputReceived = true;
                    virtualController.GotKeyDown(binding.Value);
                }
            }

            foreach (var binding in getKeyUpBindings)
            {
                if (Input.GetKeyUp(binding.Key))
                {
                    inputReceived = true;
                    virtualController.GotKeyUp(binding.Value);
                }
            }

            if (Input.GetKeyDown(MOVE_LEFT) || Input.GetKey(MOVE_LEFT))
            {
                virtualController.InputReceived(InputLabels.MoveLeftPressed);
                inputReceived = true;
                movedByKey    = true;
            }
            else if (Input.GetKeyDown(MOVE_RIGHT) || (Input.GetKey(MOVE_RIGHT) && !Input.GetKeyUp(MOVE_RIGHT)))
            {
                virtualController.InputReceived(InputLabels.MoveRightPressed);
                inputReceived = true;
                movedByKey    = true;
            }
            else if (movedByKey)
            {
                virtualController.InputReceived(InputLabels.MoveReleased);
                movedByKey = false;
            }

            return(inputReceived);
        }