//Start out by setting the skybox to the custom space backdrop //Also play the satellite's audio from the Audio Source void Start() { ScreenChanges.launch_sounds(); sky = RenderSettings.skybox; sky.SetFloat("_AtmosphereThickness", 0); audio.Play(); }
//Reset the audio. Call this from the button on the Lose Screen public void reset() { audio.volume = 1; if (audio.isPlaying) { ScreenChanges.launch_sounds(); } }
/* This function checks if the rocket has reached a win or lose condition * and loads a corresponding scene */ void check_win_lose(float old_y_pos, float new_y_pos) { //Check for leaving the atmosphere if (new_y_pos > atmosphere_height) { Skybox.leavingAtmosphere(); } //This statement handles an edge case where it is out of the atmosphere, but still too low if (new_y_pos - old_y_pos <= -10 && new_y_pos > atmosphere_height && new_y_pos < min_height) { launch = false; Skybox.globalAtmosphereThickness = 0; ScreenChanges.staticSpecificScene("Lose_Screen_Low"); } // Check for lose conditions: Too High if (new_y_pos > max_height) { launch = false; ScreenChanges.staticSpecificScene("Lose_Screen_High"); } // Check for lose conditions: Too Low or just right when it starts to turn if (new_y_pos - old_y_pos <= -10) { if (new_y_pos < atmosphere_height) // If it's too low, switch contexts to the losing screen { launch = false; ScreenChanges.staticSpecificScene("Lose_Screen_Low"); } else if (new_y_pos < min_height) { launch = false; ScreenChanges.staticSpecificScene("Lose_Screen_Low"); } else // Otherwise it's just right! { launch = false; //Load up the appropriate win screen, based on the user's selected mission if (GameState.get_mission() == "Satellite") { ScreenChanges.staticSpecificScene("Win_Screen_Satellite"); } else if (GameState.get_mission() == "Shuttle") { ScreenChanges.staticSpecificScene("Win_Screen_Shuttle"); } else if (GameState.get_mission() == "Mars") { ScreenChanges.staticSpecificScene("Win_Screen_Mars"); } } } }
//Start out by getting the inputs from the analog controller //But only if the controller is connected (i.e. serial != null) void Start() { Cursor.visible = false; if (serial != null) { serial.OnButtonPressed += Serial_OnButtonPressed; serial.OnSlideChanged += Serial_OnSlideChanged; serial.OnKnobChanged += Serial_OnKnobChanged; } else if (SceneManager.GetActiveScene().name != "ErrorScreen") { ScreenChanges.staticSpecificScene("ErrorScreen"); } }
/* This function is called once per frame and is used to * update the game */ void FixedUpdate() { initialX = transform.position.x; initialY = transform.position.y; rocketX = transform.position.x; rocketY = transform.position.y; rocketZ = transform.position.z; //If the rocket is not in launch mode, keep it in a state of reset if (launch == false) { // Set the initial conditions for the launch Camera.reset(); Skybox.reset(); velocity = RocketState.fuel + 20; angleRad = (180 - RocketState.angle) * ((float)Math.PI) / 180; } // When the launchPad animation is done... if (LaunchPad.animationDone == true) { // Set the launch mode, play the particle system and rocket sounds GUISwitch.launch_mode(); particleSyst.Play(); smoke.Play(); ScreenChanges.launch_sounds(); LaunchPad.reset(); } Vector3 rocket_direction = (transform.position - prevPos).normalized; // Handles moving rocket if (particleSyst.isPlaying) { // Change camera position and modify stars Camera.launchShift(); stars.transform.forward = cam.forward; StartExplosion.Explode(); // update position of rocket rocket_direction = (transform.position - prevPos).normalized; Vector3 input_angle_vector = (new Vector3((float)Math.Cos(angleRad), (float)Math.Sin(angleRad), 0).normalized) * velocity; Quaternion input_angle_rotation = Quaternion.LookRotation(Vector3.forward, input_angle_vector); Vector3 move = transform.position; // Update the position based on the different parts of the launch sequence if (Math.Pow(gameTime, 3) < velocity || transform.position.y < LaunchPadHeight) { move = launchPhase_TakeOff(); } else if (turning && Quaternion.Angle(transform.rotation, input_angle_rotation) > 5f) { move = launchPhase_TurnToAngle(input_angle_vector, input_angle_rotation); } else { move = launchPhase_PhysicsTrajectory(rocket_direction); } // Reorient the camera GameObject.Find("HUD").transform.forward = cam.forward; // update position variables prevPos = transform.position; transform.position = move; // Check win/lose conditions check_win_lose(prevPos.y, transform.position.y); } // Handles dropping fuel pods - This incomplete functionality has been removed for the first release /*if ( (Input.GetKeyDown(KeyCode.Space)) ) { * dropPod (rocket_direction); * // Adjust the rockets trajectory if users drops fuel pod too early/late * changeAngle (0,rocket_direction,turning); * }*/ }