コード例 #1
0
ファイル: PlayerInput.cs プロジェクト: Squox/Higgs-KGA-Spel
    private void CheckPlayerInput()
    {
        PlayerPhysics.MoveDirectionX = 0;
        PlayerPhysics.MoveDirectionY = 0;

        if (PlayerController.Health > 0 && !PlayerController.CanExit)
        {
            PlayerPhysics.MoveDirectionX = Input.GetAxisRaw("Horizontal");

            if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                PlayerController.IsDoged = true;
            }

            if (Input.GetKeyUp(KeyCode.LeftShift))
            {
                PlayerController.IsDoged = false;
            }

            if (Input.GetKeyDown(KeyCode.I))
            {
                powerShot = StartCoroutine(playerController.EmpoweredShot());
            }

            if (Input.GetKeyUp(KeyCode.I) && !FireEmpowered())
            {
                if (powerShot != null)
                {
                    PlayerController.PowerShot = false;
                    PlayerController.ShotCount = 0;
                    StopCoroutine(powerShot);
                }

                StartCoroutine(playerController.Shoot());
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            PlayerPhysics.Jump();

            if (PlayerController.CanExit || PlayerController.CanRestart)
            {
                playerController.VictoryScreen.SetActive(false);
                playerController.DeathScreen.SetActive(false);
                Gamemanager.RestartGame();
            }
        }

        if (Input.GetKey(KeyCode.Space) && PlayerPhysics.InWater)
        {
            PlayerPhysics.Swim();
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (PlayerController.CanExit)
            {
                playerController.VictoryScreen.SetActive(false);
                Gamemanager.LastLevel++;
                Gamemanager.SavePlayer(playerController, Gamemanager.LastLevel);
                Gamemanager.ExitLevel();
            }
            else if (PlayerController.CanUnpause)
            {
                StartCoroutine(playerController.Unpause());
            }
            else if (PlayerController.Health < 1 && PlayerController.CanRestart)
            {
                playerController.DeathScreen.SetActive(false);
                Gamemanager.SavePlayer(playerController, Gamemanager.LastLevel);
                Gamemanager.ExitLevel();
            }
            else if (PlayerController.Health > 0 && !PlayerController.CanUnpause)
            {
                StartCoroutine(playerController.Pause());
            }
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            if (PlayerController.CanUnpause)
            {
                playerController.PauseScreen.SetActive(false);
                Audiomanager.StopMusic();
                Gamemanager.SavePlayer(playerController, Gamemanager.LastLevel);
                Gamemanager.ExitLevel();
            }
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            Interact = true;
        }
        else if (Input.GetKeyUp(KeyCode.E))
        {
            Interact = false;
        }

        if (OnLadder)
        {
            PlayerPhysics.MoveDirectionY = Input.GetAxisRaw("Vertical");
        }
    }