Exemplo n.º 1
0
    private void GetUserInput()
    {
        if (isInputable == true)
        {
            //TODO 如果更换控制方式(手机控制),只需要将horizontal与vertical修改即可
            horizontal = Input.GetAxis("Horizontal");
            axisX      = Input.GetAxis("Mouse X");
            axisY      = Input.GetAxis("Mouse Y");
            vertical   = Input.GetAxis("Vertical");

            if (Input.GetKeyDown(KeyCode.R))
            {
                Reload();
            }

            if (isCanFire == false)
            {
                isCanFireTimer += Time.deltaTime;
                if (isCanFireTimer >= reloadTime)
                {
                    isCanFireTimer = 0;
                    isCanFire      = true;
                    UpdateBulletUI();
                }
            }

            if (Input.GetButton("Fire1") && isCanFire)
            {
                UpdateBulletUI();
                if (currentGun.clipCurrentRemain <= 0)
                {
                    Reload();
                    return;
                }
                else
                {
                    playerMovement2.Move(WalkSpeed, PlayerMoveState.Walk);
                    PutGunTrigger();
                }
            }
            else
            {
                playerMovement2.Move(runSpeed, PlayerMoveState.Run);
            }
        }
        if (Input.GetKeyDown(KeyCode.Q))
        {
            KnapsackUIDisplayControl();
        }

        ////测试用的
        //if (Input.GetKeyDown(KeyCode.Tab))
        //{
        //    AddGun(gunType.rifle1);
        //}
    }
Exemplo n.º 2
0
    // Update is called once per frame
    public void UpdatePlayer()
    {
        /*if (isDead)
         *      return;*/

        //transform.localRotation = Quaternion.identity;

        /*playerCollision.WaterCollisionCheck();
         * playerCollision.PlatformCollisionCheck(playerJump.landingSpeed);
         * playerCollision.DebugRays();*/
        playerCollision.UpdateSettings();

        playerMovement.Move(playerCollision.collisionInfo.touchingObstacle);

        if (playerCollision.collisionInfo.touchingObstacle && slip)
        {
            playerCollision.collisionInfo.slopeAngle =
                playerCollision.collisionInfo.currentPlatform.transform.rotation.eulerAngles.z;
            // Vector2.SignedAngle(Vector2.up, playerCollision.collisionInfo.currentPlatform.transform.rotation.eulerAngles);//
            playerCollision.collisionInfo.slopeAngle = Mathf.DeltaAngle(0f, playerCollision.collisionInfo.slopeAngle);

            //print("initial slope angle = " + playerCollision.collisionInfo.slopeAngle);
            playerMovement.SlipPlayer(playerCollision.collisionInfo.slopeAngle);
        }

        //playerJump.UpdateSettings(playerCollision.collisionInfo.touchingObstacle);
        if (!playerCollision.collisionInfo.touchingObstacle)
        {
            transform.position -= new Vector3(0, landingSpeed * Time.deltaTime, 0);
        }
    }