private bool RemoteCreateGame(out Heroes.Core.Player player) { player = null; Heroes.Core.Remoting.RegisterServer register = new Heroes.Core.Remoting.RegisterServer(); register._hostName = this.txtServerIp.Text; Heroes.Core.Remoting.Game adp = null; adp = (Heroes.Core.Remoting.Game)register.GetObject( typeof(Heroes.Core.Remoting.Game), Heroes.Core.Remoting.Game.CLASSNAME); if (adp == null) { MessageBox.Show("Error"); return false; } try { adp.CreateGame(out player); } catch (Exception ex) { MessageBox.Show(ex.Message); return false; } return true; }
private bool RemoteStartGame() { Heroes.Core.Remoting.RegisterServer register = new Heroes.Core.Remoting.RegisterServer(); register._hostName = Setting._remoteHostName; Heroes.Core.Remoting.Game adp = null; adp = (Heroes.Core.Remoting.Game)register.GetObject( typeof(Heroes.Core.Remoting.Game), Heroes.Core.Remoting.Game.CLASSNAME); if (adp == null) { MessageBox.Show("Error"); return false; } try { adp.StartGame(); } catch (Exception ex) { MessageBox.Show(ex.Message); return false; } return true; }
private bool RemoteIsNeedToStartBattle(int playerId, out bool b) { b = false; Heroes.Core.Remoting.RegisterServer register = new Heroes.Core.Remoting.RegisterServer(); register._hostName = Setting._remoteHostName; Heroes.Core.Remoting.Game adp = null; adp = (Heroes.Core.Remoting.Game)register.GetObject( typeof(Heroes.Core.Remoting.Game), Heroes.Core.Remoting.Game.CLASSNAME); if (adp == null) { MessageBox.Show("Error"); return false; } try { b = adp.IsNeedToStartBattle(playerId); } catch (Exception ex) { MessageBox.Show(ex.Message); return false; } return true; }
private bool RemoteGetBattle(out Heroes.Core.Hero attackHero, out Heroes.Core.Hero defendHero) { attackHero = null; defendHero = null; Heroes.Core.Remoting.RegisterServer register = new Heroes.Core.Remoting.RegisterServer(); register._hostName = Setting._remoteHostName; Heroes.Core.Remoting.Game adp = null; adp = (Heroes.Core.Remoting.Game)register.GetObject( typeof(Heroes.Core.Remoting.Game), Heroes.Core.Remoting.Game.CLASSNAME); if (adp == null) { MessageBox.Show("Error"); return false; } try { adp.GetBattle(out attackHero, out defendHero); } catch (Exception ex) { MessageBox.Show(ex.Message); return false; } return true; }
private bool RemoteGetArtifact(Heroes.Core.Heros.ArtifactLevelEnum level, out int id) { id = 0; Heroes.Core.Remoting.RegisterServer register = new Heroes.Core.Remoting.RegisterServer(); register._hostName = Setting._remoteHostName; Heroes.Core.Remoting.Game adp = null; adp = (Heroes.Core.Remoting.Game)register.GetObject( typeof(Heroes.Core.Remoting.Game), Heroes.Core.Remoting.Game.CLASSNAME); if (adp == null) { MessageBox.Show("Error"); return false; } try { id = adp.GetRndArtifactId((int)level); } catch (Exception ex) { MessageBox.Show(ex.Message); return false; } return true; }
private bool RemoteGetAllPlayers(out Hashtable players) { players = null; Heroes.Core.Remoting.RegisterServer register = new Heroes.Core.Remoting.RegisterServer(); register._hostName = Setting._remoteHostName; Heroes.Core.Remoting.Game adp = null; adp = (Heroes.Core.Remoting.Game)register.GetObject( typeof(Heroes.Core.Remoting.Game), Heroes.Core.Remoting.Game.CLASSNAME); if (adp == null) { MessageBox.Show("Error"); return false; } try { players = adp.GetAllPlayers(); } catch (Exception ex) { MessageBox.Show(ex.Message); return false; } return true; }
private bool EnqueueBattleCommand(int playerId, frmBattle.CommandIssuedEventArg e) { Heroes.Core.Remoting.BattleCommand cmd = new Heroes.Core.Remoting.BattleCommand(e._x, e._y, (int)e._button, e._doubleClick, e._cmdType, e._spell); Heroes.Core.Remoting.RegisterServer register = new Heroes.Core.Remoting.RegisterServer(); register._hostName = Setting._remoteHostName; Heroes.Core.Remoting.Game adp = null; adp = (Heroes.Core.Remoting.Game)register.GetObject( typeof(Heroes.Core.Remoting.Game), Heroes.Core.Remoting.Game.CLASSNAME); if (adp == null) { MessageBox.Show("Error"); return false; } try { adp.EnqueueBattleCommand(playerId, cmd); } catch (Exception ex) { MessageBox.Show(ex.Message); return false; } return true; }
private bool DequeueBattleCommand(int playerId, out Heroes.Core.Remoting.BattleCommand cmd) { cmd = null; Heroes.Core.Remoting.RegisterServer register = new Heroes.Core.Remoting.RegisterServer(); register._hostName = Setting._remoteHostName; Heroes.Core.Remoting.Game adp = null; adp = (Heroes.Core.Remoting.Game)register.GetObject( typeof(Heroes.Core.Remoting.Game), Heroes.Core.Remoting.Game.CLASSNAME); if (adp == null) { MessageBox.Show("Error"); return false; } try { adp.DequeueBattleCommand(playerId, out cmd); } catch (Exception ex) { MessageBox.Show(ex.Message); return false; } return true; }
static void Main(string[] args) { try { Console.WriteLine("Heroes Remoting Server"); Console.WriteLine(); Console.WriteLine("Get Settings..."); string appStartupPath = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); if (!Heroes.Core.Setting.GetSettings(appStartupPath)) { Console.WriteLine("Error"); System.Console.WriteLine("Press return to exit."); System.Console.ReadLine(); return; } Console.WriteLine("Get remoting settings..."); Heroes.Core.Remoting.RegisterServer register = new Heroes.Core.Remoting.RegisterServer(); if (!register.GetSetting()) { Console.WriteLine("Error"); System.Console.WriteLine("Press return to exit."); System.Console.ReadLine(); return; } Console.WriteLine("URL = '{0}'", register.GetUrl("")); Console.WriteLine(); Console.WriteLine("Register server..."); register.RegisterServer(); Console.WriteLine(); Console.WriteLine("Register services..."); register.RegisterServices(); Console.WriteLine(); Console.WriteLine("Services Available:"); register.ListServices(); Console.WriteLine(); Console.WriteLine("Server started."); string s = ""; while (true) { System.Console.WriteLine("Type quit to exit."); s = System.Console.ReadLine(); if (string.Compare(s, "quit", true) == 0) { break; } } } catch (Exception ex) { Console.WriteLine(ex.Message); System.Console.ReadLine(); } }