Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        //Camera movement
        float camYVal = Input.GetAxis(camY);

        if (camYVal != 0)
        {
            Debug.Log("camY " + camYVal);
        }

        float camXVal = Input.GetAxis(camX);

        if (camXVal != 0)
        {
            Debug.Log("camX " + camXVal);
        }

        if (camYVal != 0 || camXVal != 0)
        {
            cc.RotateCamera(camYVal, camXVal);
        }

        if (Input.GetButtonDown(reset))
        {
            Debug.Log("Reset");
            cc.ResetCameraRotation();
        }

        //Car movement
        float verticalVal = Input.GetAxis(vertical);

        if (verticalVal != 0)
        {
            Debug.Log("vetical " + verticalVal);
        }

        float horizontalVal = Input.GetAxis(horizontal);

        if (horizontalVal != 0 && IsDriving && IsOnGround)
        {
            //Debug.Log("horixontal "+ horizontalVal);
            mb.steer(horizontalVal);
            Debug.Log("steer");
        }

        if (horizontalVal != 0 && !IsOnGround || verticalVal != 0 && !IsOnGround)
        {
            mb.AerialSteer(verticalVal, horizontalVal);
        }


        if (Input.GetButton(accelerate) && IsOnGround)
        {
            //Debug.Log("Accelerate");
            IsDriving = true;
            mb.Accelerate();
        }
        if (Input.GetButtonUp(accelerate))
        {
            //Debug.Log("Accelerate");
            IsDriving = true;
            mb.Accelerate();
        }
        else if (IsDriving && IsOnGround)
        {
            Debug.Log("Decelerate");
            mb.Decelerate();
        }

        if (IsDriving && !IsOnGround)
        {
            mb.ResetAcceleration();
        }

        if (Input.GetButton(reverse))
        {
            if (IsDriving)
            {
                Debug.Log("Break");
                mb.Break();
            }
            else
            {
                Debug.Log("Reverse");
                //IsDriving = true;
                //mb.Reverse();
            }
        }

        //Abilities
        if (Input.GetButtonDown(jump) && IsOnGround)
        {
            Debug.Log("Jump");
            mb.Jump();
        }

        if (Input.GetButtonDown(shoot))
        {
            Debug.Log("Shoot");
            hb.ShootHook();
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        //******Camera movement******
        float camYVal = Input.GetAxis(camY);

        if (camYVal != 0)
        {
            //Debug.Log("camY "+ camYVal);
        }

        float camXVal = Input.GetAxis(camX);

        if (camXVal != 0)
        {
            //Debug.Log("camX "+ camXVal);
        }

        if (camYVal != 0 || camXVal != 0)
        {
            cc.RotateCamera(camYVal, camXVal);
        }

        if (Input.GetButtonDown(reset))
        {
            //Debug.Log("Reset");
            cc.ResetCameraRotation();
            //sc.rotateCarTowardsHook();
        }

        if (Input.GetKeyDown("z"))
        {
            Debug.Log("zooom");
            cc.GoToFarView();
        }

        // ******Car movement******
        verticalVal   = Input.GetAxis(vertical);
        horizontalVal = Input.GetAxis(horizontal);
        if (IsGrounded)
        {
            //Steering
            if (IsDriving && HasTiltedHorizontal)
            {
                dc.Steer(horizontalVal);
                Debug.Log("steer");
            }
            else
            {
                dc.Steer(0);
            }


            //turning
            if (!IsDriving && HasTiltedHorizontal)
            {
                dc.Turn(horizontalVal);
            }
            else
            {
                dc.ResetTurningStiffness();
            }
        }
        else if (!IsGrounded && (HasTiltedHorizontal || HasTiltedVertical))
        {
            //Debug.Log("air steer");
            dc.AerialSteer(horizontalVal, verticalVal);
        }

        //Accelerate
        if (Input.GetButton(accelerate) && IsGrounded)
        {
            //Debug.Log("Accelerate");
            IsDriving = true;
            dc.Accelerate(1);
        }
        if (Input.GetButtonUp(accelerate))
        {
            //Debug.Log("Accelerate");
            dc.Accelerate(0);
        }

        //Reverse or Brake
        if (Input.GetButtonDown(reverse))
        {
            if (IsDriving)
            {
                BrakeNotReverse = true;
            }
            else
            {
                BrakeNotReverse = false;
            }
        }

        if (Input.GetButton(reverse) && IsGrounded)
        {
            if (BrakeNotReverse)
            {
                Debug.Log("Brake");
                dc.Brake(1);
            }
            else
            {
                IsDriving = true;
                dc.Reverse(1);
            }
        }

        if (Input.GetButtonUp(reverse))
        {
            dc.Brake(0);
            dc.Reverse(0);
        }

        //*****Abilities*****
        if (Input.GetButtonDown(jump) && !HasJumped)
        {
            Debug.Log("Jump");
            dc.Jump();
            HasJumped = true;
        }

        if (Input.GetButtonDown(shoot))
        {
            //Debug.Log("Shoot");
            hb.ShootHook();
        }

        if (Input.GetButtonDown(aimMode))
        {
            //Debug.Log("Shoot");
            cc.GoToAimView();
        }

        //Check States
        IsGrounded          = dc.CheckWheelsGrounded();
        HasJumped           = !IsGrounded;
        HasHit              = hb.GetIsHooked();
        HasTiltedHorizontal = SetStickBool(horizontalVal);
        HasTiltedVertical   = SetStickBool(verticalVal);
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        verticalVal   = Input.GetAxis(vertical);
        horizontalVal = Input.GetAxis(horizontal);

        camYVal = Input.GetAxis(camY);
        camXVal = Input.GetAxis(camX);

        //on the ground

        //in the air

        // aiming

        //when aiming in the air

        //when swinging


        //******Camera movement******
        CameraControl();

// ******Car movement******

        if (IsGrounded)
        {
            //Steering
            if (IsDriving && HasTiltedHorizontal)
            {
                dc.Steer(horizontalVal);
            }
            else
            {
                dc.Steer(0);
            }


            //turning
            if (!IsDriving && HasTiltedHorizontal)
            {
                dc.Turn(horizontalVal);
            }
            else
            {
                dc.ResetTurningStiffness();
            }
        }
        else if (!IsGrounded && (HasTiltedHorizontal || HasTiltedVertical))
        {
            //Debug.Log("air steer");
            dc.AerialSteer(horizontalVal, verticalVal);
        }

        //Accelerate
        if (Input.GetButton(accelerate))
        {
            //Debug.Log("Accelerate");
            IsDriving = true;
            dc.Accelerate(1);
        }
        if (Input.GetButtonUp(accelerate))
        {
            //Debug.Log("Accelerate");
            dc.Accelerate(0);
        }

        //Reverse or Brake
        if (Input.GetButtonDown(reverse))
        {
            if (IsDriving)
            {
                BrakeNotReverse = true;
            }
            else
            {
                BrakeNotReverse = false;
            }
        }

        if (Input.GetButton(reverse) && IsGrounded)
        {
            if (BrakeNotReverse)
            {
                //Debug.Log("Brake");
                dc.Brake(1);
            }
            else
            {
                IsDriving = true;
                dc.Reverse(1);
            }
        }

        if (Input.GetButtonUp(reverse))
        {
            dc.Brake(0);
            dc.Reverse(0);
        }

//*****Abilities*****
        if (Input.GetButtonDown(jump) && !HasJumped)
        {
            //Debug.Log("Jump");
            dc.Jump();
            HasJumped = true;
        }


        if (Input.GetButtonDown(shoot))
        {
            hb.ResetHook();
            if (!IsGrounded)
            {
                dc.StopCarTorque();
                cc.AddCameraRotationToPlayer();
            }
            hb.SetCrosshair(true);
            cc.GoToAimView();
        }
        if (Input.GetButton(shoot))
        {
            hb.HookRayCast();
        }
        if (Input.GetButtonUp(shoot))
        {
            hb.ShootHook();
            if (hb.GetIsHooked())
            {
                cc.GoToFarView();
            }
            else
            {
                cc.GoToDefView();
            }
            hb.SetCrosshair(false);
        }


        if (Input.GetButtonDown(aimMode))
        {
            //Debug.Log("Shoot");
            cc.GoToFarView();
        }

        //Check States
        IsGrounded          = dc.CheckWheelsGrounded();
        HasJumped           = !IsGrounded;
        IsHooked            = hb.GetIsHooked();
        HasTiltedHorizontal = SetStickBool(horizontalVal);
        HasTiltedVertical   = SetStickBool(verticalVal);
    }