예제 #1
0
        public override bool HandleInput()
        {
            if (State == GameState.Play)
            {
                if (InputManager1.IsInputReleasedNew(tmPlayer.PlayerIndex, GuiInput.ExitScreen))
                {
                    GameOver(false);
                }

                var player = Entities[0];
                player.Velocity.X = player.Velocity.Y = 0;
                var stick = InputManager.GetGamepadLeftStick(tmPlayer.PlayerIndex);
                player.Velocity.X = stick.X * entityData[(int)EntityType.Player].Speed;
                player.Velocity.Y = -stick.Y * entityData[(int)EntityType.Player].Speed;
                Entities[0]       = player;

                playerShootTimer -= Services.ElapsedTime;
                if (playerShootTimer <= 0)
                {
                    stick = InputManager.GetGamepadRightStick(tmPlayer.PlayerIndex);
                    if (stick.X != 0 || stick.Y != 0)
                    {
                        stick.Normalize();
                        stick.Y = -stick.Y;
                        SpawnNewEntity(EntityType.PlayerBullet, player.Position, stick * entityData[(int)EntityType.PlayerBullet].Speed);
                        playerShootTimer = 0.05f;
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #2
0
    private IEnumerator ShowPlayerTurn()
    {
        //Before Waiting
        Cursor.lockState = CursorLockMode.Locked;                                //Restricts mouse movement
        InputManager1 inputManager = gameObject.GetComponent <InputManager1> (); //Disable map, notebook etc

        if (inputManager != null)
        {
            inputManager.enabled = false;
        }
        Time.timeScale = 0;                                             //Stops timers
        playerTurnPanel.SetActive(true);                                //Shows player turn
        Text playerTurnText = playerTurnPanel.transform.GetChild(1).GetComponent <Text> ();

        playerTurnText.text = "Player " + MultiplayerManager.instance.GetTurnManager().GetPlayerTurn();
        Camera.main.GetComponent <Blur> ().enabled = true;              //Blur camera

        //Waiting
        yield return(new WaitForSecondsRealtime(3));

        //After waiting
        playerTurnPanel.SetActive(false);                       //Remove player turn GUI
        Camera.main.GetComponent <Blur> ().enabled = false;     //Unblur camera
        Time.timeScale   = 1;                                   //Reenable timer
        Cursor.lockState = CursorLockMode.None;                 //enables mouse movement
        if (inputManager != null)                               //enable map, notebook etc
        {
            inputManager.enabled = true;
        }
    }
예제 #3
0
        public override bool HandleInput()
        {
            bool result = false;

            if (State == GameState.Play)
            {
                var left = InputManager.GetGamepadLeftStick(tmPlayer.PlayerIndex);
                if (left.Y != 0 || left.X != 0)
                {
                    paddlePos1 -= left.Y * paddleSpeed;
                    cpu1        = false;
                    result      = true;
                }

                var right = InputManager.GetGamepadRightStick(tmPlayer.PlayerIndex);
                if (right.Y != 0 || right.X != 0)
                {
                    paddlePos2 -= right.Y * paddleSpeed;
                    cpu2        = false;
                    result      = true;
                }

                var mouse = InputManager.GetMousePosDelta(tmPlayer.PlayerIndex);
                if (mouse.Y != 0)
                {
                    paddlePos2 += mouse.Y;
                    cpu2        = false;
                    result      = true;
                }

                if (InputManager1.IsInputReleasedNew(tmPlayer.PlayerIndex, GuiInput.ExitScreen))
                {
                    GameOver(false);
                    result = true;
                }
            }

            return(result ||
                   InputManager.IsButtonPressed(tmPlayer.PlayerIndex, Buttons.A) ||
                   InputManager.IsButtonPressed(tmPlayer.PlayerIndex, Buttons.X) ||
                   InputManager.IsButtonPressed(tmPlayer.PlayerIndex, Buttons.Y));
        }