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); } }