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(); }
//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>(); }
void Awake() { flashColor = bounceLights [0].material.GetColor("_EmissionColor"); offColor = flashColor * Config.softDimIntensity; TurnLightsOff(); if (autoCorrectCamera) { cam = GameObject.FindGameObjectWithTag("CameraRig").GetComponent <AmazeballCam>(); } }
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(); }
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(); }
void Awake() { cameraRig = GameObject.FindGameObjectWithTag("CameraRig").GetComponent <AmazeballCam> (); }
void Awake() { cameraRig = GameObject.FindGameObjectWithTag("CameraRig").GetComponent <AmazeballCam> (); camLockCentreAngle = transform.eulerAngles.y; }