private void SingleStart() { if (GameRunning) { MessageBox.Show(this, "Stop the current game first.", "<°)))><", MessageBoxButtons.AbortRetryIgnore); return; } GameRunning = true; Root r = Root.Instance; r.Authoritive = true; r.ClientClient(new string[] {}); Flow f = new SpaceWar2006.Flows.Game( ((IRuleCreator)CurrentGameSettings).CreateRule(), CreateMap(), (int)HostBots.Value, false ); r.CurrentFlow = f; f.Start(); r.ClientLoop(); r.ResourceManager.UnloadAll(); r.UserInterface.Dispose(); r.UserInterface = null; r.ClientPostProcessor = null; GameRunning = false; }
private void DemoPlay_Click(object sender, EventArgs e) { if (GameRunning) { MessageBox.Show(this, "Stop the current game first.", "<°)))><", MessageBoxButtons.AbortRetryIgnore); return; } string name = "demos/" + DemoList.SelectedItems[0].SubItems[0].Text; GameRunning = true; Root r = Root.Instance; r.Authoritive = true; r.ClientClient(new string[] { }); SpaceWar2006.Flows.Game g = new SpaceWar2006.Flows.Game(null, name, true, false); Root.Instance.CurrentFlow = g; if (DemoRecord.Checked) { r.LockTimeDelta = 1.0f / (float)DemoRecordFps.Value; r.ClientRecordVideo = 1; } g.Start(); r.ClientLoop(); r.LockTimeDelta = -1; r.ClientRecordVideo = -1; r.ResourceManager.UnloadAll(); r.UserInterface.Dispose(); r.UserInterface = null; GameRunning = false; }
private void ServerStart_Click(object sender, EventArgs e) { if (HostSinglePlayer.Checked) { SingleStart(); return; } if (GameRunning) { Root.Instance.Quit = true; return; } //start non-dedicated or dedicated server GameRunning = true; ServerStart.Text = "Stop"; Helper h = null; if (HostDedicated.Checked) { //SimpleUserInterface sui = new SimpleUserInterface(); Cheetah.Root.Instance.LocalObjects.Add(h = new Helper()); } Root r = Root.Instance; if (HostNonDedicated.Checked) { //bring up the userinterface //ViewerForm vf = new ViewerForm(); //vf.Show(); //r.ClientClient(new string[] { }, vf.glControl1); r.ClientClient(new string[] {}); } r.ServerServer(new string[] { }); r.Authoritive = true; r.Scene = new Scene(); if (HostRecordDemo.Checked) { string name = string.Format("{2}{3,02}{4,2}{5,2}{6,2}-{0}-{1}.demo", ((Type)HostRule.SelectedItem).Name, ((Type)HostMap.SelectedItem).Name, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute); name = name.Replace(' ', '0'); FileSystemNode demo = Root.Instance.FileSystem.Get("demos"); demo = demo.CreateFile(name); Root.Instance.Recorder = new DemoRecorder(demo.getStream(), true, 20); } Flow f; if (CurrentGameSettings is IRuleCreator) { if (HostDedicated.Checked) { f = new SpaceWar2006.Flows.GameServer( ((IRuleCreator)CurrentGameSettings).CreateRule(), CreateMap(), (int)HostBots.Value ); } else { f = new SpaceWar2006.Flows.Game( ((IRuleCreator)CurrentGameSettings).CreateRule(), CreateMap(), (int)HostBots.Value, false ); } } else { if (HostNonDedicated.Checked) { throw new Exception(); } f = new SpaceWar2006.Flows.GameServer(); } Root.Instance.ResourceManager.LoadConfig("config/global.config").Set("server.password", this.HostPassword.Text); r.CurrentFlow = f; f.Start(); r.ServerRun(HostDedicated.Checked); f.Stop(); r.ServerStop(); r.ResourceManager.UnloadAll(); if (r.UserInterface != null) { r.Dispose(); r.UserInterface = null; } if (h != null) { Cheetah.Root.Instance.LocalObjects.Remove(h); } Root.Instance.Recorder = null; GameRunning = false; if (HostRecordDemo.Checked) { LoadDemos(); } ServerStart.Text = "Start"; //StatusBar.Text = "Dedicated Server stopped. Ready."; }
private void SingleStart() { if (GameRunning) { MessageBox.Show(this, "Stop the current game first.", "<°)))><", MessageBoxButtons.AbortRetryIgnore); return; } GameRunning = true; Root r = Root.Instance; r.Authoritive = true; r.ClientClient(new string[] {}); Flow f = new SpaceWar2006.Flows.Game( ((IRuleCreator)CurrentGameSettings).CreateRule(), CreateMap(), (int)HostBots.Value, false ); r.CurrentFlow = f; f.Start(); r.ClientLoop(); r.ResourceManager.UnloadAll(); r.UserInterface.Dispose(); r.UserInterface = null; r.ClientPostProcessor = null; GameRunning = false; }
private void ServerStart_Click(object sender, EventArgs e) { if (HostSinglePlayer.Checked) { SingleStart(); return; } if (GameRunning) { Root.Instance.Quit = true; return; } //start non-dedicated or dedicated server GameRunning = true; ServerStart.Text = "Stop"; Helper h=null; if(HostDedicated.Checked) { //SimpleUserInterface sui = new SimpleUserInterface(); Cheetah.Root.Instance.LocalObjects.Add(h = new Helper()); } Root r = Root.Instance; if(HostNonDedicated.Checked) { //bring up the userinterface //ViewerForm vf = new ViewerForm(); //vf.Show(); //r.ClientClient(new string[] { }, vf.glControl1); r.ClientClient(new string[]{}); } r.ServerServer(new string[] { }); r.Authoritive = true; r.Scene = new Scene(); if (HostRecordDemo.Checked) { string name = string.Format("{2}{3,02}{4,2}{5,2}{6,2}-{0}-{1}.demo", ((Type)HostRule.SelectedItem).Name, ((Type)HostMap.SelectedItem).Name, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute); name=name.Replace(' ','0'); FileSystemNode demo=Root.Instance.FileSystem.Get("demos"); demo=demo.CreateFile(name); Root.Instance.Recorder = new DemoRecorder(demo.getStream(), true, 20); } Flow f; if (CurrentGameSettings is IRuleCreator) { if (HostDedicated.Checked) { f = new SpaceWar2006.Flows.GameServer( ((IRuleCreator)CurrentGameSettings).CreateRule(), CreateMap(), (int)HostBots.Value ); } else { f = new SpaceWar2006.Flows.Game( ((IRuleCreator)CurrentGameSettings).CreateRule(), CreateMap(), (int)HostBots.Value, false ); } } else { if (HostNonDedicated.Checked) throw new Exception(); f = new SpaceWar2006.Flows.GameServer(); } Root.Instance.ResourceManager.LoadConfig("config/global.config").Set("server.password", this.HostPassword.Text); r.CurrentFlow = f; f.Start(); r.ServerRun(HostDedicated.Checked); f.Stop(); r.ServerStop(); r.ResourceManager.UnloadAll(); if (r.UserInterface != null) { r.Dispose(); r.UserInterface = null; } if(h!=null) Cheetah.Root.Instance.LocalObjects.Remove(h); Root.Instance.Recorder = null; GameRunning = false; if (HostRecordDemo.Checked) { LoadDemos(); } ServerStart.Text = "Start"; //StatusBar.Text = "Dedicated Server stopped. Ready."; }
private void DemoPlay_Click(object sender, EventArgs e) { if (GameRunning) { MessageBox.Show(this, "Stop the current game first.", "<°)))><", MessageBoxButtons.AbortRetryIgnore); return; } string name = "demos/" + DemoList.SelectedItems[0].SubItems[0].Text; GameRunning = true; Root r = Root.Instance; r.Authoritive = true; r.ClientClient(new string[] { }); SpaceWar2006.Flows.Game g = new SpaceWar2006.Flows.Game(null, name, true, false); Root.Instance.CurrentFlow = g; if (DemoRecord.Checked) { r.LockTimeDelta = 1.0f / (float)DemoRecordFps.Value; r.ClientRecordVideo = 1; } g.Start(); r.ClientLoop(); r.LockTimeDelta = -1; r.ClientRecordVideo = -1; r.ResourceManager.UnloadAll(); r.UserInterface.Dispose(); r.UserInterface = null; GameRunning = false; }