示例#1
0
 void OnTriggerEnter(Collider coll)
 {
     if (coll.CompareTag("Player"))
     {
         if (camLock)
         {
             cameraRig.constrainCameraAngle(camLockCentreAngle, camLockAngle, camLockTime);
         }
         if (camTilt)
         {
             cameraRig.adjustNeutralTilt(camTiltAngle, camTiltTime);
         }
         if (camZoom)
         {
             cameraRig.zoomCamera(camZoomAmount, camZoomTime);
         }
     }
 }
示例#2
0
    private IEnumerator Launch(Rigidbody rb)
    {
        //disable player control of the ball
        BallInputReader ballInput = rb.GetComponent <BallInputReader> ();

        ballInput.enabled = false;
        rb.GetComponent <BrakeController> ().ReleaseBrakes();

        //position ball within the centre of the cannon correctly
        rb.velocity   = Vector3.zero;
        rb.useGravity = false;
        rb.transform.DOMove(this.transform.position + new Vector3(0, 1f, 0), 5f).Play();

        //take control of camera and move it to the right place, player can still pan camera
        AmazeballCam camController            = GameObject.FindGameObjectWithTag("CameraRig").GetComponent <AmazeballCam>();
        ProtectCameraFromWallClip wallClipper = camController.GetComponent <ProtectCameraFromWallClip> ();

        wallClipper.enabled = false;
        float camMoveSpeed = camController.moveSpeed;

        camController.moveSpeed = 0f;
        camController.constrainCameraAngle(camLaunchAngle, 0f, 5f);
        camController.transform.DOLookAt(this.transform.position, 2f).Play();
        camController.movePivot(new Vector3(0f, -2f, 0f));

        //flashing lights etc.
        yield return(new WaitForSeconds(1f));

        StartCoroutine("FlashLight");
        yield return(new WaitForSeconds(1.5f));

        for (int i = 0; i < 4; i++)
        {
            SetEmissionColor(launchLights[i], startColor);
        }
        yield return(new WaitForSeconds(1.5f));

        for (int i = 4; i < launchLights.Length; i++)
        {
            SetEmissionColor(launchLights[i], startColor);
        }
        yield return(new WaitForSeconds(1f));

        StopCoroutine("FlashLight");

        //prepare ball and camera for launching
        rb.useGravity           = true;
        camController.moveSpeed = camMoveSpeed * 2;
        camController.transform.DOLocalRotate(new Vector3(0f, camController.transform.localEulerAngles.y, 0f), 1f).Play();
        camController.movePivot(new Vector3(0f, 2f, 0f));

        //launch ball
        rb.AddForce(Vector3.up * launchPower * rb.mass, ForceMode.Impulse);
        camController.constrainCameraAngle(0f, camAirborneLockAngle, 0f);

        //wait until a VerticalCannonLanding script lets the cannon know the ball has landed
        hasLanded = false;
        while (!hasLanded)
        {
            yield return(new WaitForEndOfFrame());
        }
        //re-enable regular ball control and camera function
        camController.moveSpeed = camMoveSpeed;
        ballInput.enabled       = true;
        wallClipper.enabled     = true;
        camController.removeAngleConstraint();
    }