//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 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); * }*/ }