Example #1
0
        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;
        }
Example #2
0
        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;
        }
Example #3
0
        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;
        }
Example #4
0
        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;
        }
Example #5
0
        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;
        }
Example #6
0
        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;
        }
Example #7
0
        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;
        }
Example #8
0
        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;
        }