예제 #1
0
    private IEnumerator PerformLevelInit()
    {
        GameObject levelStartController = GameObject.FindGameObjectWithTag("LevelStartController");

        if (levelStartController != null)
        {
            StartSequence startSequence = levelStartController.GetComponent <StartSequence> ();
            AmazeballCam  camController = GameObject.FindGameObjectWithTag("CameraRig").GetComponent <AmazeballCam> ();
            GameObject    ball          = GameObject.FindGameObjectWithTag("Player");

            //disable player and controls
            camController.enabled = false;
            ball.GetComponent <Renderer> ().enabled      = false;
            ball.GetComponent <Rigidbody> ().isKinematic = true;

            startSequence.init();
            while (!startSequence.IsCompleted())
            {
                yield return(new WaitForEndOfFrame());
            }

            //enable player and controls
            camController.enabled = true;
            ball.GetComponent <Renderer> ().enabled      = true;
            ball.GetComponent <Rigidbody> ().isKinematic = false;
        }

        SetupLevel();
    }
예제 #2
0
    //A reference to the shattering particle effect that should be used when the ball breaks
    //public ParticleSystem shatterParticles;

    public override void Apply(BallController ball)
    {
        base.Apply(ball);
        cam = GameObject.FindWithTag("CameraRig").GetComponent <AmazeballCam>();
        //enable laser snapping
        laserSnapTo = ball.GetComponent <LaserSnapTo> ();
        laserSnapTo.Enable();
        //enable ball shattering
        //ball.gameObject.AddComponent<BallShatterer>();
    }
예제 #3
0
 void Awake()
 {
     flashColor = bounceLights [0].material.GetColor("_EmissionColor");
     offColor   = flashColor * Config.softDimIntensity;
     TurnLightsOff();
     if (autoCorrectCamera)
     {
         cam = GameObject.FindGameObjectWithTag("CameraRig").GetComponent <AmazeballCam>();
     }
 }
예제 #4
0
    private IEnumerator CompleteLevel(Collider ball)
    {
        if (freezeCam)
        {
            AmazeballCam cam = GameObject.FindGameObjectWithTag("CameraRig").GetComponent <AmazeballCam>();
            cam.moveSpeed = 0f;
        }
        yield return(new WaitForSeconds(delay));

        LevelCompleteScreen.controller.LevelComplete();
    }
예제 #5
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();
    }
예제 #6
0
 void Awake()
 {
     cameraRig = GameObject.FindGameObjectWithTag("CameraRig").GetComponent <AmazeballCam> ();
 }
예제 #7
0
 void Awake()
 {
     cameraRig          = GameObject.FindGameObjectWithTag("CameraRig").GetComponent <AmazeballCam> ();
     camLockCentreAngle = transform.eulerAngles.y;
 }