/// <summary>
    /// Monitors input that the player will give
    /// </summary>
    void inputUpdate()
    {
        if (Input.GetAxisRaw("Horizontal") > 0)
        {
            if (Input.GetButton("Jump"))
            {
                chickenController.dashRight();
            }

            chickenController.strafeRight();
        }
        else if (Input.GetAxisRaw("Horizontal") < 0)
        {
            if (Input.GetButton("Jump"))
            {
                chickenController.dashLeft();
            }

            chickenController.strafeLeft();
        }

        if (Input.GetAxisRaw("Vertical") > 0)
        {
            if (Input.GetButton("Jump"))
            {
                chickenController.attackForward();
            }

            chickenController.moveForward();
        }
        else if (Input.GetAxisRaw("Vertical") < 0)
        {
            if (Input.GetButton("Jump"))
            {
                chickenController.dashBack();
            }

            chickenController.moveBackward();
        }

        // Jump
        if (Input.GetButton("Jump"))
        {
            chickenController.attackForward();
        }

        // Right click
        // Target mode toggle
        if (Input.GetMouseButtonDown(1))
        {
            targetModeToggle();
        }

        // When the player is not currently targeting an object.
        if (chickenController.getTarget() == null)
        {
            // Rotate the chicken and camera concurrently on the X-axis with mouse movement.
            if (Input.GetAxis("Mouse X") != 0)
            {
                transform.Rotate(Vector3.up * Input.GetAxis("Mouse X") * mouseSensitivity, Space.World);
            }

            // Rotate the camera around the chicken on Y-axis with mouse movement.
            float mouseYAxis = Input.GetAxis("Mouse Y");

            if (mouseYAxis != 0)
            {
                //Debug.Log(mouseYAxis+" : "+ transform.Find("Main Camera").transform.localRotation);

                if ((mouseYAxis > 0 && transform.Find("Main Camera").transform.localRotation.x > -.2) ||
                    (mouseYAxis < 0 && transform.Find("Main Camera").transform.rotation.x < .4)
                    )
                {
                    transform.Find("Main Camera").transform.RotateAround(transform.position, transform.TransformDirection(-1, 0, 0), mouseYAxis * mouseSensitivity);

//					Quaternion rot = transform.Find("Main Camera").transform.localRotation;
//					rot.x = Mathf.Clamp(transform.Find("Main Camera").transform.localRotation.x, -.2f, .4f);
//					transform.Find("Main Camera").transform.localRotation = rot;
                }
            }

            // Update the positions of the X and Y axes.

            // Always look at the chicken.
            //transform.Find("Main Camera").transform.LookAt(transform.position);
        }
        else if (chickenController.getTarget() != null)
        {
            //transform.Find("Main Camera").transform.LookAt(chickenController.getTarget());
        }
    }
Example #2
0
 /// <summary>
 /// Update function for attacking the target
 /// If the AI has made the desicion that it wants to attack,
 /// it will start calling this function
 /// </summary>
 void attackUpdate()
 {
     control.attackForward();
 }