public void GameLoop() { DateTime curr_time = DateTime.UtcNow; DateTime last_time = curr_time; running = true; while (running) { curr_time = DateTime.UtcNow; TimeSpan deltaTime; // caculate time span between current and last time if ((deltaTime = curr_time - last_time).TotalMilliseconds > 0) { PhysicEngine.Update(deltaTime); GSManager.Update(deltaTime); } // correct time into fps float TargetSecond = 1f / TargetFps; if (deltaTime.TotalSeconds < TargetSecond) { Thread.Sleep((int)(TargetSecond - deltaTime.TotalSeconds)); } last_time = curr_time; } }
public void Close() { if (loopTask != null) { loopTask.Wait(); } GSManager.Clear(); }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } }
static void Init() { Global.FontDefault = Global.FontDefault.Master.GetFont(Font.FontSizes.One); UIManager = new UIManager(); GSManager = new GSManager(); Player = new Player(); UIManager.Init(); World = new World(true); World.WorldMap.GenerateMap(); }
private void Awake() { gs = Object.FindObjectOfType <GSManager>(); data = Object.FindObjectOfType <DataManager>(); board = Object.FindObjectOfType <BoardManager>(); ui = Object.FindObjectOfType <UIManager>(); // Init EM runtime if needed (useful in case only this scene is built). if (!RuntimeManager.IsInitialized()) { RuntimeManager.Init(); } }
public void Close() { GSManager.Clear(); }