Ejemplo n.º 1
0
    void FixedUpdate()
    {
        if (!aiControlled)
        {
            float sprint         = Input.GetAxis(playerConfig.sprintKey);
            float moveHorizontal = Input.GetAxis(playerConfig.horizontalL);
            float moveVertical   = Input.GetAxis(playerConfig.verticalL);
            // Movement
            playerMovement.MovePlayer(moveHorizontal, moveVertical);

            /*
             * Looking direction - player does not have to move in the direction
             * that the player character is looking, this can be toggled
             * on or off in the global settings under "Use Left To Rotate".
             */
            float lookHorizontal;
            float lookVertical;
            if (useLeftToRotate)
            {
                lookHorizontal = moveHorizontal;
                lookVertical   = moveVertical;
            }
            else
            {
                lookHorizontal = Input.GetAxisRaw(playerConfig.horizontalR);
                lookVertical   = Input.GetAxisRaw(playerConfig.verticalR);
            }
            playerRotator.Rotate(lookHorizontal, lookVertical);

            // Sprint
            playerMovement.Sprint(sprint);


            // Sword, Shield, Weapon
            if (Input.GetButtonDown(playerConfig.swordKey))
            {
                UseSword();
            }
            if (Input.GetButtonDown(playerConfig.shieldKey))
            {
                UseShield();
            }
            if (Input.GetAxis(playerConfig.shootKey) > 0.1)
            {
                Shoot();
            }
            if (Input.GetButtonDown(playerConfig.changeGunKey))
            {
                NextGun();
            }
            if (Input.GetButtonDown(playerConfig.reloadGunKey))
            {
                Reload();
            }
        }
    }