Пример #1
0
    void Update()
    {
        if (!win)
        {
            if (paused)
            {
                print("paused");
                if (Input.GetKeyDown(KeyCode.P))
                {
                    unPause();
                    paused = false;
                }
                else if (Input.GetKeyDown(KeyCode.R))
                {
                    unPause();
                    paused = false;
                    InitGame.loseGame();
                }
                else
                {
                    return;
                }
            }
            else if (Input.GetKeyDown(KeyCode.P) && !paused)
            {
                paused = true;

                displayPause();
            }

            if (yPos == transform.position.y)
            {
                moveDirection.y = 0;
            }
            yPos = transform.position.y;
            CharacterController controller = GetComponent <CharacterController>();
            if (controller.isGrounded)
            {
                moveDirection  = new Vector3(-Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
                moveDirection  = transform.TransformDirection(moveDirection);
                moveDirection *= speed;
                if (Input.GetButton("Jump"))
                {
                    moveDirection.y = jumpSpeed;
                }
            }

            rotY += Input.GetAxis("Mouse Y") * 3f;
            rotY  = Mathf.Clamp(rotY, -80, 80);
            Quaternion yQuaternion = Quaternion.AngleAxis(rotY, -Vector3.right);
            cam.transform.localRotation = oRot * yQuaternion;

            transform.Rotate(0, 4 * Input.GetAxis("Mouse X"), 0);

            moveDirection.y -= gravity * Time.deltaTime;
            controller.Move(moveDirection * Time.deltaTime);
        }
    }
Пример #2
0
 void OnTriggerEnter(Collider other)
 {
     InitGame.loseGame();
 }