AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
LevelControl.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 using UnityEngine.SceneManagement;
5 using Communicator;
6 namespace AirControl
7 {
11  public class LevelControl:MonoBehaviour
12  {
13 
17  void Update()
18  {
19  if(StaticLevelSchema.LevelReload){
20  RestartLevel();
21  //set back the transaction to deault to avoid multiple firing
22  StaticLevelSchema.LevelReload = false;
23  }
24  }
25 
29  public void RestartLevel() //Restarts the level
30  {
31  //resetting rewards before reload
32  StaticOutputSchema.Reward=0;
33  SceneManager.UnloadSceneAsync(SceneManager.GetActiveScene().name);
34  SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().name);
35  //resetting rewards after reload
36  StaticOutputSchema.Reward=0;
37  }
38 
43  void applicationQuit()
44  {
45  #if UNITY_EDITOR
46  UnityEditor.EditorApplication.isPlaying = false;
47  #elif UNITY_WEBPLAYER
48  Application.OpenURL(webplayerQuitURL);
49  #else
50  Application.Quit();
51  #endif
52  }
53 
54  }
55 }
56 
AirControl.LevelControl
Level related controls
Definition: LevelControl.cs:11
AirControl
Definition: AirplaneSelector.cs:8
Communicator
Definition: InputHandle.cs:10
AirControl.LevelControl.RestartLevel
void RestartLevel()
Reset the level to startover
Definition: LevelControl.cs:29