/// <see cref="IMultiplayerService.CreateNewGame"/> public void CreateNewGame(string mapFile, GameTypeEnum gameType, GameSpeedEnum gameSpeed) { /// TODO: this is only a PROTOTYPE implementation! this.scenarioManager.OpenScenario(mapFile); this.scenarioManager.ActiveScenario.Map.FinalizeMap(); this.playerManager = new PlayerManager(this.scenarioManager.ActiveScenario); this.playerManager[0].ConnectRandomPlayer(RaceEnum.Terran); this.playerManager[1].ConnectRandomPlayer(RaceEnum.Terran); this.playerManager[2].ConnectRandomPlayer(RaceEnum.Terran); this.playerManager[3].ConnectRandomPlayer(RaceEnum.Terran); this.playerManager.Lock(); this.selectionManager.Reset(this.playerManager[0].Player); this.fogOfWarBC.StartFogOfWar(this.playerManager[0].Player); this.mapWindowBC.ScrollTo(this.playerManager[0].StartPosition); this.commandManager.NewCommand += this.PostCommand; this.commandDispatcher = new CommandDispatcher(); this.triggeredScheduler = new TriggeredScheduler(1000 / (int)gameSpeed); this.triggeredScheduler.AddScheduledFunction(this.pathfinder.Update); this.triggeredScheduler.AddScheduledFunction(this.ExecuteCommands); this.triggeredScheduler.AddScheduledFunction(this.scenarioManager.ActiveScenario.Update); this.triggeredScheduler.AddScheduledFunction(this.commandManager.Update); this.triggeredScheduler.AddScheduledFunction(this.fogOfWarBC.ExecuteUpdateIteration); this.triggeredScheduler.AddScheduledFunction(() => { if (this.GameUpdated != null) { this.GameUpdated(); } }); this.testDssTaskCanFinishEvt = new ManualResetEvent(false); this.dssTask = this.taskManager.StartTask(this.TestDssTaskMethod, "DssThread"); }
/// <summary> /// This event is fired when Table Options Control _ Load /// </summary> private void TableOptionsControl_Load(object sender, EventArgs e) { // Get the GameSpeed from the Security SecureUserData security = new SecureUserData(); // set the gameSpeed GameSpeedEnum gameSpeed = security.GameSpeed; // Setup the GameSpeedControl this.GameSpeedControl.SelectedIndex = FindGameSpeedIndex(gameSpeed); this.GameSpeedControl.SelectedIndexListener = this; }
/// <summary> /// This method returns the Game Speed /// </summary> private GameSpeedEnum ParseGameSpeed(object selectedItem) { // initial value GameSpeedEnum gameSpeed = GameSpeedEnum.Manuel_Deal; // If the selectedItem object exists if (NullHelper.Exists(selectedItem)) { // set the dataType string gameSpeedString = selectedItem.ToString(); // Determine the action by the gameSpeedString switch (gameSpeedString) { case "Manuel Deal": // set the return value gameSpeed = GameSpeedEnum.Manuel_Deal; // required break; case "Very Slow": // set the return value gameSpeed = GameSpeedEnum.Very_Slow; // required break; case "Slow": // set the return value gameSpeed = GameSpeedEnum.Slow; // required break; case "Normal": // set the return value gameSpeed = GameSpeedEnum.Normal; // required break; case "Fast": // set the return value gameSpeed = GameSpeedEnum.Fast; // required break; case "Very Fast": // set the return value gameSpeed = GameSpeedEnum.Very_Fast; // required break; } } // parse the gameSpeed return(gameSpeed); }