Beispiel #1
0
        private bool IsNeedToStartBattle(out bool isNeedToStartBattle)
        {
            isNeedToStartBattle = false;

            Remoting.Game adp = null;
            if (Remoting.GameSetting._isServer)
            {
                adp = new Heroes.Remoting.Game();
            }
            else
            {
                Heroes.Remoting.RegisterServer register = new Heroes.Remoting.RegisterServer();
                register._hostName = Remoting.GameSetting._serverHostName;

                adp = (Heroes.Remoting.Game)register.GetObject(
                    typeof(Heroes.Remoting.Game),
                    Heroes.Remoting.Game.CLASSNAME);

                if (adp == null)
                {
                    MessageBox.Show("Error");
                    return false;
                }
            }

            try
            {
                adp.IsNeedToStartBattle(out isNeedToStartBattle);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }

            return true;
        }
Beispiel #2
0
        private bool GetCurrentPlayer(out int playerId)
        {
            playerId = 0;

            Heroes.Remoting.Game adp = null;

            if (Remoting.GameSetting._isServer)
            {
                adp = new Heroes.Remoting.Game();
            }
            else
            {
                Heroes.Remoting.RegisterServer register = new Heroes.Remoting.RegisterServer();
                register._hostName = Remoting.GameSetting._serverHostName;

                adp = (Heroes.Remoting.Game)register.GetObject(
                    typeof(Heroes.Remoting.Game),
                    Heroes.Remoting.Game.CLASSNAME);

                if (adp == null)
                {
                    MessageBox.Show("Error");
                    return false;
                }
            }

            try
            {
                adp.GetCurrentPlayer(out playerId);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }

            return true;
        }
Beispiel #3
0
        private bool DequeueBattleCommand(int playerId, out BattleCommand cmd)
        {
            cmd = null;

            Remoting.Game adp = null;
            if (Remoting.GameSetting._isServer)
            {
                adp = new Heroes.Remoting.Game();
            }
            else
            {
                Heroes.Remoting.RegisterServer register = new Heroes.Remoting.RegisterServer();
                register._hostName = Remoting.GameSetting._serverHostName;

                adp = (Heroes.Remoting.Game)register.GetObject(
                    typeof(Heroes.Remoting.Game),
                    Heroes.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;
        }
Beispiel #4
0
        private bool EnqueueBattleCommand(int playerId, frmBattle.CommandIssuedEventArg e)
        {
            BattleCommand cmd = new BattleCommand(e._x, e._y, (int)e._button, e._doubleClick, e._cmdType);

            Remoting.Game adp = null;
            if (Remoting.GameSetting._isServer)
            {
                adp = new Heroes.Remoting.Game();
            }
            else
            {
                Heroes.Remoting.RegisterServer register = new Heroes.Remoting.RegisterServer();
                register._hostName = Remoting.GameSetting._serverHostName;

                adp = (Heroes.Remoting.Game)register.GetObject(
                    typeof(Heroes.Remoting.Game),
                    Heroes.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;
        }
Beispiel #5
0
        private bool SetBattle(Heroes.Core.Player attackPlayerMap, Heroes.Core.Hero attackHeroMap, Hashtable attackArmiesMap,
            Heroes.Core.Player defendPlayerMap, Heroes.Core.Hero defendHeroMap, Heroes.Core.Town defendCastleMap, Hashtable defendArmiesMap)
        {
            Heroes.Core.Player attackPlayer = null;
            Heroes.Core.Hero attackHero = null;
            Hashtable attackArmies = null;
            Heroes.Core.Player defendPlayer = null;
            Heroes.Core.Hero defendHero = null;
            Heroes.Core.Town defendCastle = null;
            Hashtable defendArmies = null;

            Heroes.Remoting.Game adp = null;

            if (Remoting.GameSetting._isServer)
            {
                adp = new Heroes.Remoting.Game();

                attackPlayer = attackPlayerMap;
                attackHero = attackHeroMap;
                attackArmies = attackArmiesMap;
                defendPlayer = defendPlayerMap;
                defendHero = defendHeroMap;
                defendCastle = defendCastleMap;
                defendArmies = defendArmiesMap;
            }
            else
            {
                Remoting.GameSetting.ConvertBattleToNetwork(attackPlayerMap, attackHeroMap, attackArmiesMap,
                    defendPlayerMap, defendHeroMap, defendCastleMap, defendArmiesMap,
                    out attackPlayer, out attackHero, out attackArmies,
                    out defendPlayer, out defendHero, out defendCastle, out defendArmies);

                Heroes.Remoting.RegisterServer register = new Heroes.Remoting.RegisterServer();
                register._hostName = Remoting.GameSetting._serverHostName;

                adp = (Heroes.Remoting.Game)register.GetObject(
                    typeof(Heroes.Remoting.Game),
                    Heroes.Remoting.Game.CLASSNAME);

                if (adp == null)
                {
                    MessageBox.Show("Error");
                    return false;
                }
            }

            try
            {
                adp.SetBattle(attackPlayer, attackHero, attackArmies,
                    defendPlayer, defendHero, defendCastle, defendArmies);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }

            return true;
        }