/* 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");
             }
         }
     }
 }
Exemplo n.º 2
0
 //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");
     }
 }