public static void UpdateWorld(World pWorld, float pTime) { PreloadWorld(pWorld); const float stepSize = 1.0f / 30f; float time = 0f; while(time < pTime) { pWorld.Update(stepSize); time += stepSize; } }
private static void TextView(string[] args) { System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; DateTime startTime = DateTime.Now; D.onDLog += (pMessage) => Console.WriteLine ("" + pMessage); string macroFileName = "macro1.txt"; string saveFileName = ""; for (int i = 0; i < args.Length; i++) { string s = args [i]; if (s == "-autopilot") { _autoPilot = true; _autoAnswer = true; _timeLimit = Convert.ToSingle (args [++i]); } else if (s == "-macro") { macroFileName = args [++i]; } else if (s == "-load") { saveFileName = args [++i]; } } StreamReader macroFile = File.OpenText ("../" + macroFileName); while (!macroFile.EndOfStream) { string line = macroFile.ReadLine (); _macro.Add (line); } // Instantiate IEnumerable<float> loader = null; InitialSaveFileCreator saveCreator = new InitialSaveFileCreator (); if(saveFileName != "") { //IEnumerable<float> loader = saveCreator.LoadFromFile("../../../../../assembla/MimanUnity2/Saves/Quicksave.json"); loader = saveCreator.LoadFromFile(saveFileName); } else { loader = saveCreator.LoadRelayFromDirectory ("../../../../../assembla/MimanUnity2/InitData/"); } // Load files Console.ForegroundColor = ConsoleColor.DarkCyan; foreach (float f in loader) { Console.Write ("."); } Console.Write ("\n"); // Setup world and its runners _world = new World (saveCreator.GetLoadedRelay ()); SetupWorldListeners (); SmartWalkBehaviour.s_logger.AddListener (Console.WriteLine); LoadTranslationFiles(); // Preload foreach (string s in _world.Preload()) { //Console.WriteLine(s); } Console.WriteLine ("Loading took " + (DateTime.Now - startTime).TotalSeconds + " seconds"); Console.ForegroundColor = ConsoleColor.White; #if ONLY_STARTUP return; #endif // Run a few frames for (int i = 0; i < 30; i++) { _world.Update (NORMAL_DELTA_TIME); } if(saveFileName == "") { _world.dialogueRunner.StartConversation ("StoryStart"); } // Run while (_run) { try { PrintBranchingNode (); if (_autoPilot) { if (_macroPos < _macro.Count) { Eval (new string[] { "macro" }); } else { Eval (new string[] { "tick" }); } if (_world.settings.totalWorldTime > _timeLimit) { Eval (new string[] { "clock" }); Console.WriteLine ("Stopped by time limit (" + _timeLimit + " s.)"); break; } } else { Console.ForegroundColor = ConsoleColor.White; //Console.Write("\n> "); Console.Write ("\n" + _world.settings.gameTimeClock + " => "); string command = Console.ReadLine (); Eval (Split (command)); } } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine ("Error in World: " + e.Message + ", stack trace:\n" + e.StackTrace); Console.ForegroundColor = ConsoleColor.White; if (_autoPilot) { _run = false; } } } }
public static void UpdateWorldUntilGameTime(World pWorld, GameTime pGameTime) { PreloadWorld(pWorld); const float stepSize = 1f; //Console.WriteLine("Total world time: " + pWorld.settings.gameTimeClock.totalSeconds); //Console.WriteLine("pGameTime.totalSeconds: " + pGameTime.totalSeconds); int i = 1000; while(pWorld.settings.gameTimeClock.totalSeconds < pGameTime.totalSeconds) { i--; //Console.WriteLine("Total world time: " + pWorld.settings.gameTimeClock.totalSeconds); pWorld.Update(stepSize); } }