//Stops the level after a crash public void StopLevel() { levelGenerator.StopGeneration(2); StartCoroutine(FunctionLibrary.CallWithDelay(guiManager.ShowCrashScreen, levelGenerator.CurrentDistance(), 2.5f)); }
//Revives the player, launches a sonic wave, and continue the level generation public void ReviveUsed() { playerManager.Revive(); StartCoroutine(FunctionLibrary.CallWithDelay(levelGenerator.ContinueGeneration, 0.75f)); }
//Sinks the submarine until it crashes to the sand private void Sink() { float crashDepth = maxDepth - 0.8f; float crashDepthEdge = 0.5f; float distance = this.transform.position.y - crashDepth; //If the sub is too close to minDepth if (distanceToMin < depthEdge) { //Calculate maximum speed at this depth (without this, the sub would leave the gameplay are) newSpeed = maxVerticalSpeed * (minDepth - this.transform.position.y) / depthEdge; //If the newSpeed is greater the the current speed if (newSpeed < speed) { //Make newSpeed the current speed speed = newSpeed; } } //If the distance to the sand is greater than 0.1 if (distance > 0.1f) { //Reduce speed speed -= Time.deltaTime * maxVerticalSpeed * 0.6f; //If the distance to the sand smaller than the crashDepthEdge if (distance < crashDepthEdge) { //Calculate new speed for impact newSpeed = maxVerticalSpeed * (crashDepth - this.transform.position.y) / crashDepthEdge; //If newSpeed is greater than speed if (newSpeed > speed) { //Apply new speed to speed speed = newSpeed; } } //Apply the above to the submarine MoveAndRotate(); //If distance to sand smaller than 0.2 if (distance < 0.25f) { //Enable smoke emission smoke.enableEmission = true; } } //If the distance to the sand is smaller than 0.1 else { //Disable this function from calling, and stop the level playerStatus = PlayerStatus.Crashed; levelManager.StopLevel(); //Disable the smoke StartCoroutine(FunctionLibrary.CallWithDelay(DisableSmoke, 2)); } }