public static void Load() { foreach (var file in FileExplorer.FilesIn(FileExplorer.Saves)) { if (file != DefaultSaveName && !file.EndsWith("_map")) //make sure that we don't add any maps { Saves.Add(new GameSave(file)); } } DefaultSave = new GameSave(DefaultSaveName); }
protected override void OnLoad() { Console.Write("Loading..."); base.OnLoad(); KeyInput.SetWindow(this); MouseInput.SetWindow(this); // Load icon var iconData = BitmapLoader.LoadBytes(FileExplorer.FindIn(FileExplorer.Misc, "warsnu"), out var iconWidth, out var iconHeight); Icon = new WindowIcon(new Image(iconWidth, iconHeight, iconData)); MasterRenderer.Initialize(); SheetManager.InitSheets(); timer.Restart(); FontManager.Load(); timer.StopAndWrite("Loading Fonts"); timer.Restart(); AudioController.Load(); MusicController.Load(); timer.StopAndWrite("Loading Sound"); timer.Restart(); GameController.Load(); timer.StopAndWrite("Loading Rules"); SheetManager.FinishSheets(); MasterRenderer.InitRenderer(); GameController.CreateFirst(); Ready = true; Console.WriteLine(" Done!"); if (Program.OnlyLoad) { Program.Exit(); } }
public Game(GameSave save, MapType map, MissionType missionType, InteractionMode interactionMode, int seed = -1) { Log.Debug($"Loading new game (MissionType: '{missionType}', InteractionMode: '{interactionMode}')."); MissionType = missionType; InteractionMode = interactionMode; MapType = map; // If seed negative, calculate it. Seed = seed < 0 ? save.Seed + save.Level : seed; SharedRandom = new Random(Seed); ObjectiveType = MapType.AvailableObjectives[SharedRandom.Next(map.AvailableObjectives.Length)]; Save = save; Stats = new GameStats(save); Editor = InteractionMode == InteractionMode.EDITOR; SpellManager = new SpellCasterManager(this); ConditionManager = new ConditionManager(this); ScreenControl = new ScreenControl(this); World = new World(this, Seed, Save); if (!string.IsNullOrEmpty(map.MissionScript) && !Program.DisableScripts) { var scriptLoader = new MissionScriptLoader(FileExplorer.FindIn(FileExplorer.Scripts, map.MissionScript, ".cs"), map.MissionScript); script = scriptLoader.Start(this); } else { Log.Debug(Program.DisableScripts ? "Mission scripts are disabled." : "No mission script existing."); } if (ObjectiveType == ObjectiveType.SURVIVE_WAVES) { waveController = new WaveController(this); } }
static void run(string[] args) { FileExplorer.InitPaths(); Log.InitLogs(); Log.Debug("Starting program."); var newSettings = false; var enableCheats = false; for (int i = 0; i < args.Length; i++) { var arg = args[i]; if (arg == "-no-fullscreen") { NoFullscreen = true; } else if (arg == "-new-settings") { newSettings = true; } else if (arg == "-no-GL-errors") { noGLErrors = true; } else if (arg == "-editor") { StartEditor = true; } else if (arg == "-no-shroud") { DisableShroud = true; } else if (arg == "-ignore-tech") { IgnoreTech = true; } else if (arg == "-disable-scripts") { DisableScripts = true; } else if (arg == "-use-piece") { Piece = args[++i]; } else if (arg == "-map-type") { MapType = args[++i]; } else if (arg == "-enable-cheats") { enableCheats = true; } else if (arg == "-only-load") { OnlyLoad = true; } else { throw new ArgumentException($"Unknown command line argument {arg}."); } } Settings.Initialize(newSettings); Settings.EnableCheats |= enableCheats; var settings1 = new GameWindowSettings { UpdateFrequency = Settings.UpdatesPerSecond, IsMultiThreaded = Settings.EnableMultiThreading }; if (Settings.FrameLimiter != 0) { settings1.RenderFrequency = Settings.FrameLimiter; } var settings2 = new NativeWindowSettings { Title = Title, API = ContextAPI.OpenGL, APIVersion = new Version(3, 2), Size = new OpenTK.Mathematics.Vector2i(Settings.Width, Settings.Height), }; window = new Window(settings1, settings2); if (GL.GetInteger(GetPName.MajorVersion) < 3 && GL.GetInteger(GetPName.MinorVersion) < 2) { Console.WriteLine("OpenGL version is under 3.20."); Console.WriteLine("Please run the program with a graphics card that supports at least OpenGL 3.20."); Console.WriteLine("Press 'y' to start the game anyway (will probably crash) or press any key to exit."); var info = Console.ReadKey(true).KeyChar; if (info != 'y') { return; } } window.Run(); Log.Debug("Exiting program."); Log.Close(); }