Esempio n. 1
0
 public Player(IGamePlayer player, int id, BaseGame game, int team) : base(id, game, team, "", "", 1000, 0, 1, 0)
 {
     this.m_rect   = new Rectangle(-15, -20, 30, 30);
     this.m_player = player;
     this.m_player.GamePlayerId = id;
     this.m_isActive            = true;
     this.m_canGetProp          = true;
     this.Grade                  = player.PlayerCharacter.Grade;
     this.TotalAllHurt           = 0;
     this.TotalAllHitTargetCount = 0;
     this.TotalAllShootCount     = 0;
     this.TotalAllKill           = 0;
     this.TotalAllExperience     = 0;
     this.TotalAllScore          = 0;
     this.TotalAllCure           = 0;
     this.m_weapon               = this.m_player.MainWeapon;
     if (this.m_weapon != null)
     {
         this.m_mainBallId = this.m_weapon.Property1;
         this.m_spBallId   = this.m_weapon.Property2;
     }
     this.m_loadingProcess = 0;
     this.InitBuffer(this.m_player.EquipEffect);
     this.m_energy   = this.m_player.PlayerCharacter.Agility / 30 + 240;
     this.m_maxBlood = (int)((double)(950 + this.m_player.PlayerCharacter.Grade * 50 + this.LevelPlusBlood + this.m_player.PlayerCharacter.Defence / 10) * this.m_player.GetBaseBlood());
 }
        public void GetPlayerName()
        {
            var playerName = "Alice";

            _player = new GamePlayer(playerName);
            Assert.AreEqual(playerName, _player.Name);
        }
Esempio n. 3
0
        public void HandleGameRoomCreate(GSPacketIn pkg)
        {
            int roomId = pkg.ReadInt();
            int gameType = pkg.ReadInt();
            int count = pkg.ReadInt();

            IGamePlayer[] players = new IGamePlayer[count];
            for (int i = 0; i < count; i++)
            {
                PlayerInfo info = new PlayerInfo();
                info.ID = pkg.ReadInt();
                info.Attack = pkg.ReadInt();
                info.Defence = pkg.ReadInt();
                info.Agility = pkg.ReadInt();
                info.Luck = pkg.ReadInt();

                double baseAttack = pkg.ReadDouble();
                double baseDefence = pkg.ReadDouble();
                double baseAgility = pkg.ReadDouble();
                double baseBlood = pkg.ReadDouble();
                int templateId = pkg.ReadInt();

                ItemTemplateInfo itemTemplate = ItemMgr.FindItemTemplate(templateId);
                ItemInfo item = new ItemInfo(itemTemplate);

                players[i] = new ProxyPlayer(info, item, baseAttack, baseDefence, baseAgility, baseBlood);
            }

            ProxyRoomMgr.CreateRoom(players, roomId, this);
        }
Esempio n. 4
0
        /// <summary>
        /// キーを指定してリモートプレイヤーを検索
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public IRemoteGamePlayer FindRemotePlayer(string key)
        {
            IGamePlayer p = null;

            _players.TryGetValue(key, out p);
            return(p as IRemoteGamePlayer);
        }
Esempio n. 5
0
        public Player(IGamePlayer player, int id, BaseGame game, int team)
            : base(id, game, team, "", "", 1000, 0, 1)                   //TODO   lastPatemer    direction
        {
            m_rect = new Rectangle(-15, -20, 30, 30);
            m_player = player;
            m_player.GamePlayerId = id;
            m_isActive = true;
            m_canGetProp = true;
            Grade = player.PlayerCharacter.Grade;

            TotalAllHurt = 0;
            TotalAllHitTargetCount = 0;
            TotalAllShootCount = 0;
            TotalAllKill = 0;
            TotalAllExperience = 0;
            TotalAllScore = 0;
            TotalAllCure = 0;
            m_weapon = m_player.MainWeapon;
            if (m_weapon != null)
            {
                var ballConfig = BallConfigMgr.FindBall(m_weapon.TemplateID);
                m_mainBallId = ballConfig.Common;
                m_spBallId = ballConfig.Special;
                //m_mainBallId = m_weapon.Property1;
                //m_spBallId = m_weapon.Property2;
            }
            m_loadingProcess = 0;

            InitBuffer(m_player.EquipEffect);
            m_energy = (m_player.PlayerCharacter.Agility / 30 + 240);
            m_maxBlood = (int)((950 + m_player.PlayerCharacter.Grade * 50 + LevelPlusBlood + m_player.PlayerCharacter.Defence / 10) * m_player.GetBaseBlood());
        }
Esempio n. 6
0
        public bool RemovePlayer(IGamePlayer player)
        {
            bool result = false;
            List <IGamePlayer> players;

            Monitor.Enter(players = this.m_players);
            try
            {
                if (this.m_players.Remove(player))
                {
                    result = true;
                }
            }
            finally
            {
                Monitor.Exit(players);
            }
            if (this.PlayerCount == 0)
            {
                ProxyRoomMgr.RemoveRoom(this);
                this.Dispose();
            }
            else
            {
                this.m_client.SendRemovePlayer(player.PlayerCharacter.ID, this.m_orientRoomId);
            }
            return(result);
        }
        public void InitializePlayer()
        {
            var playerName = "Alice";

            _player = new GamePlayer(playerName);
            Assert.IsNotNull(_player);
        }
Esempio n. 8
0
        public int GetDamageFromMonster(IGameMonster i_monster, IGamePlayer i_player)
        {
            int monsterAttack = i_monster.AttackPower;
            int playerDefense = i_player.GetDefenseForType(i_monster.AttackType);

            return(Mathf.Max(1, monsterAttack - playerDefense));
        }
Esempio n. 9
0
        private static void WonderStage(IGamePlayer player)
        {
            Console.WriteLine(string.Format("({0} {1} {2} stage(s))", player.Wonder.Name, player.Wonder.SelectedSide, player.Wonder.StagesBuilt));
            if (player.Wonder.NextStage == null)
            {
                return;
            }
            var sb = new StringBuilder();

            sb.Append(" -> ");
            var separator = "";

            if (player.Wonder.NextStage.Costs.Any())
            {
                var rc = string.Empty;
                foreach (var r in player.Wonder.NextStage.Costs)
                {
                    rc       += separator + r.ToString();
                    separator = ";";
                }
                sb.AppendFormat("Costs = {0}", rc);
            }
            sb.Append(" => ");
            separator = "";
            foreach (var e in player.Wonder.NextStage.Effects)
            {
                sb.Append(separator + e.Type.ToString());
                separator = ";";
            }
            Console.WriteLine(sb.ToString());
        }
Esempio n. 10
0
        private IEffect ValidSpecialCase(IGamePlayer player, SpecialCaseType specialCase, Age age)
        {
            IEffect result = null;

            if (specialCase == SpecialCaseType.None)
            {
                return(result);
            }
            var effects = player.GetNonResourceEffects().Where(e => (int)specialCase == (int)e.Type).ToList();

            foreach (var e in effects)
            {
                switch (specialCase)
                {
                //This is the only special case so far and it only works for building structure
                case SpecialCaseType.PlayCardForFreeOncePerAge:
                    if (e.Info == null || (e.Info is Age && ((Age)e.Info) != age))
                    {
                        result = e;
                        continue;
                    }
                    break;

                default:
                    break;
                }
            }
            return(result);
        }
        public void GetPlayerID()
        {
            var playerName = "Alice";

            _player = new GamePlayer(playerName);
            Assert.AreNotEqual(Guid.Empty, _player.Id);
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            Subject realSub = new RealSubject();
            Subject proxy   = new Proxy(realSub);

            proxy.request();


            IGamePlayer player = new GamePlayer("张三");
            //然后再定义一个代练者
            IGamePlayer constraintProxy = player.getProxy();

            //开始打游戏,记下时间戳
            Console.WriteLine("开始时间是:" + DateTime.Now);
            constraintProxy.login("zhangSan", "password");
            //开始杀怪
            constraintProxy.killBoss();
            //升级
            constraintProxy.upgrade();
            //记录结束游戏时间
            Console.WriteLine("结束时间是:" + DateTime.Now);


            DynamicProxy      proxy1 = new DynamicProxy(typeof(DynamicGamePlayer), new DynamicGamePlayer("张三"));
            DynamicGamePlayer plane  = (DynamicGamePlayer)proxy1.GetTransparentProxy();

            plane.login("zhangSan", "password");
            plane.killBoss();
            plane.upgrade();
            Console.ReadLine();
        }
Esempio n. 13
0
 private void GetCardRewards(ITurnPlayer player, IGamePlayer rightNeighbor, IGamePlayer leftNeighbor, IList <IStructureCard> discardedCards)
 {
     foreach (var p in player.SelectedCard.Production)
     {
         GetOneTimeRewards(p, player, rightNeighbor, leftNeighbor, age, discardedCards);
     }
 }
Esempio n. 14
0
        public static string PlayerSummary(this IGamePlayer gamePlayer)
        {
            string summary;

            if (gamePlayer is HumanPlayer)
            {
                summary = "Human player";
            }
            else if (gamePlayer is WeightedAiGamePlayer)
            {
                summary = $"Weighted AI player: {gamePlayer.Name}";
            }
            else if (gamePlayer is NeuralNetAiGamePlayer)
            {
                summary = $"Neural Net AI player: {gamePlayer.Name}";
            }
            else if (gamePlayer is RandomGamePlayer)
            {
                summary = "Random move player";
            }
            else
            {
                summary = "Unknown player";
            }
            return(summary);
        }
Esempio n. 15
0
        static void Main(string[] args)
        {
            IGamePlayer player = new GamePlayer("Jack");
            IGamePlayer proxy  = player.getProxy();

            player.login("Jack", "123");
        }
        public int[] DisplayEnterMoveScreen(IGamePlayer player)
        {
            int[] moves = new int[2];
            Console.WriteLine("Player:" + player.Name);
            Console.WriteLine("X value:");
            var input = Console.ReadLine();
            int x;

            if (int.TryParse(input.Trim().ToLower(), out x))
            {
                moves[0] = x;
            }
            else
            {
                InvalidInput();
                DisplayEnterMoveScreen(player);
            }

            Console.WriteLine("Y value:");
            int y;

            input = null;
            input = Console.ReadLine();
            if (int.TryParse(input.Trim().ToLower(), out y))
            {
                moves[1] = y;
            }
            else
            {
                InvalidInput();
                DisplayEnterMoveScreen(player);
            }
            return(moves);
        }
Esempio n. 17
0
        public void HandleGameRoomCreate(GSPacketIn pkg)
        {
            int roomId   = pkg.ReadInt();
            int gameType = pkg.ReadInt();
            int count    = pkg.ReadInt();

            IGamePlayer[] players = new IGamePlayer[count];
            for (int i = 0; i < count; i++)
            {
                PlayerInfo info = new PlayerInfo();
                info.ID      = pkg.ReadInt();
                info.Attack  = pkg.ReadInt();
                info.Defence = pkg.ReadInt();
                info.Agility = pkg.ReadInt();
                info.Luck    = pkg.ReadInt();

                double baseAttack  = pkg.ReadDouble();
                double baseDefence = pkg.ReadDouble();
                double baseAgility = pkg.ReadDouble();
                double baseBlood   = pkg.ReadDouble();
                int    templateId  = pkg.ReadInt();

                ItemTemplateInfo itemTemplate = ItemMgr.FindItemTemplate(templateId);
                ItemInfo         item         = new ItemInfo(itemTemplate);

                players[i] = new ProxyPlayer(info, item, baseAttack, baseDefence, baseAgility, baseBlood);
            }

            ProxyRoomMgr.CreateRoom(players, roomId, this);
        }
Esempio n. 18
0
        public void WhenProcessingPlayerMove_AnyMatchingCurrentMonsters_GetAttacked()
        {
            IGamePlayer       mockPlayer = Substitute.For <IGamePlayer>();
            List <IGamePiece> mockMove   = new List <IGamePiece>();

            List <IGameMonster> mockCurrentMonsters = new List <IGameMonster>();

            mockCurrentMonsters.Add(GetMockMonsterWithMatchCombo(true));
            mockCurrentMonsters.Add(GetMockMonsterWithMatchCombo(false));
            mockCurrentMonsters.Add(GetMockMonsterWithMatchCombo(false));

            List <IGameMonster> mockRemainingMonsters = new List <IGameMonster>();

            mockRemainingMonsters.Add(GetMockMonsterWithMatchCombo(true));
            mockRemainingMonsters.Add(GetMockMonsterWithMatchCombo(false));
            mockRemainingMonsters.Add(GetMockMonsterWithMatchCombo(false));

            systemUnderTest.CurrentMonsters   = mockCurrentMonsters;
            systemUnderTest.RemainingMonsters = mockRemainingMonsters;

            systemUnderTest.ProcessPlayerMove(mockPlayer, mockMove);

            mockCurrentMonsters[0].Received(1).AttackedByPlayer(mockPlayer);
            mockCurrentMonsters[1].Received(0).AttackedByPlayer(mockPlayer);
            mockCurrentMonsters[2].Received(0).AttackedByPlayer(mockPlayer);

            mockRemainingMonsters[0].Received(0).AttackedByPlayer(mockPlayer);
            mockRemainingMonsters[1].Received(0).AttackedByPlayer(mockPlayer);
            mockRemainingMonsters[2].Received(0).AttackedByPlayer(mockPlayer);
        }
Esempio n. 19
0
        private void SaveEventOperations(IGamePlayer player, IGamePlayer rightNeighbor, IGamePlayer leftNeighbor, IList <BorrowResourceData> data)
        {
            foreach (var entry in data)
            {
                var discountType = Enumerator.GetTradeDiscountType(entry.ResourceType);
                var coinsToPay   = player.HasDiscount(entry.ChosenNeighbor, discountType) ? ConstantValues.COIN_VALUE_FOR_SHARE_DISCOUNT : ConstantValues.COIN_VALUE_FOR_SHARE_DEFAULT;

                IGamePlayer neighborPlayer = null;
                switch (entry.ChosenNeighbor)
                {
                case PlayerDirection.ToTheLeft:
                    neighborPlayer = leftNeighbor;
                    break;

                case PlayerDirection.ToTheRight:
                    neighborPlayer = rightNeighbor;
                    break;

                default:
                    break;
                }
                if (neighborPlayer == null)
                {
                    continue;
                }

                LoggerHelper.DebugFormat("Player {0} will pay {1} coins to {2} for using the resource {3}", player.Name, coinsToPay, neighborPlayer.Name, entry.ResourceType);
                this.unitOfWork.AddEvent(new PayCoinEvent(player, coinsToPay));
                this.unitOfWork.AddEvent(new ReceiveCoinEvent(neighborPlayer, coinsToPay));
            }
        }
Esempio n. 20
0
        public void InitiateGameResources()
        {
            _squares = new GameSquare[3][];
            for (int i = 0; i < 3; i++)
            {
                _squares[i] = new GameSquare[3];
                for (int j = 0; j < 3; j++)
                {
                    _squares[i][j] = new GameSquare();
                }
            }

            _board = new GameBoard(_squares);

            _playerOne = new GamePlayer("Alice");

            _players = new List <IGamePlayer>()
            {
                _playerOne,
                new GamePlayer("Bob")
            };
            var playerOneToken = NoughtCrossToken.X;

            _victoryCalculator = new GameVictoryCalculator(GameWinStates.GetStates());
            _Game = new GameEngine(_players, _board, _playerOne.Id, playerOneToken, _victoryCalculator);
            _playerOne.SetPlayerToken(playerOneToken);
        }
Esempio n. 21
0
        public InteractiveGuideForm()
        {
            InitializeComponent();

            Player = new ExpectimaxPlayer();

            GridButtons = new Button[, ]
            {
                { button4, button5, button6, button7 },
                { button8, button9, button10, button11 },
                { button12, button13, button14, button15 },
                { button16, button17, button18, button19 }
            };

            ControlButtons = new Button[]
            {
                button1, button2, button3
            };

            ActionLabels = new Label[]
            {
                label1, label2, label3, label4
            };

            ChangeMode(Mode.Play);
            StartNewGame();
        }
Esempio n. 22
0
        public Player(IGamePlayer player, int id, BaseGame game, int team)
            : base(id, game, team, "", "", 1000, 0, 1)                   //TODO   lastPatemer    direction
        {
            m_rect   = new Rectangle(-15, -20, 30, 30);
            m_player = player;
            m_player.GamePlayerId = id;
            m_isActive            = true;
            m_canGetProp          = true;
            Grade = player.PlayerCharacter.Grade;

            TotalAllHurt           = 0;
            TotalAllHitTargetCount = 0;
            TotalAllShootCount     = 0;
            TotalAllKill           = 0;
            TotalAllExperience     = 0;
            TotalAllScore          = 0;
            TotalAllCure           = 0;
            m_weapon = m_player.MainWeapon;
            if (m_weapon != null)
            {
                var ballConfig = BallConfigMgr.FindBall(m_weapon.TemplateID);
                m_mainBallId = ballConfig.Common;
                m_spBallId   = ballConfig.Special;
                //m_mainBallId = m_weapon.Property1;
                //m_spBallId = m_weapon.Property2;
            }
            m_loadingProcess = 0;

            InitBuffer(m_player.EquipEffect);
            m_energy   = (m_player.PlayerCharacter.Agility / 30 + 240);
            m_maxBlood = (int)((950 + m_player.PlayerCharacter.Grade * 50 + LevelPlusBlood + m_player.PlayerCharacter.Defence / 10) * m_player.GetBaseBlood());
        }
Esempio n. 23
0
        private void CollectTokens(IGamePlayer winner, IGamePlayer loser, Age age)
        {
            var token = ConflictToken.AgeOneVictory;

            switch (age)
            {
            case Age.I:
                token = ConflictToken.AgeOneVictory;
                break;

            case Age.II:
                token = ConflictToken.AgeTwoVictory;
                break;

            case Age.III:
                token = ConflictToken.AgeThreeVictory;
                break;

            default:
                break;
            }
            LoggerHelper.DebugFormat("{0} wins and receives a {1} token. {2} loses.", winner.Name, token, loser.Name);
            winner.ConflictTokens.Add(token);
            loser.ConflictTokens.Add(ConflictToken.Defeat);
        }
Esempio n. 24
0
        static void CurrentResources(IGamePlayer player, bool shareable = false)
        {
            var sb        = new StringBuilder();
            var separator = "";

            foreach (var r in player.GetResourcesAvailable(shareable))
            {
                sb.AppendFormat("{0}{1}", separator, r.ToString());
                separator = ";";
            }

            foreach (var c in player.GetChoosableResources(shareable))
            {
                if (!Enumerator.ContainsEnumeratorValue <ResourceType>((int)c.First()))
                {
                    continue;
                }

                sb.Append(separator);
                var chooseSeparator = "";
                foreach (var r in c)
                {
                    sb.AppendFormat("{0}{1}", chooseSeparator, r.ToString());
                    chooseSeparator = "/";
                }
                separator = ";";
            }
            Console.WriteLine(string.Format("Resources: {0}", sb.ToString()));
        }
Esempio n. 25
0
 public void SendGamePlayerId(IGamePlayer player)
 {
     this.SendTCP(new GSPacketIn(33)
     {
         Parameter1 = player.PlayerCharacter.ID,
         Parameter2 = player.GamePlayerId
     });
 }
Esempio n. 26
0
        public void AttackedByPlayer(IGamePlayer i_player)
        {
            int playerAttackPower = Mathf.Max(i_player.GetAttackPowerForType(DefenseType), 0);
            int damage            = Mathf.Max(playerAttackPower - Defense, 1);

            RemainingHP -= damage;
            SendModelChangedEvent();
        }
Esempio n. 27
0
        private GameSimulator(int gamesToPlay, IGamePlayer player)
        {
            Validate.IsTrue(gamesToPlay >= 0, "Cannot simulate a negative number of games");
            Validate.IsNotNull(player, "player");

            GamesToPlay = gamesToPlay;
            Player      = player;
        }
Esempio n. 28
0
 private IList <ResourceType> BorrowResourceFromNeighbor(IGamePlayer neighbor, IList <ResourceType> resources)
 {
     if (!resources.Any())
     {
         return(new List <ResourceType>());
     }
     return(neighbor.CheckResourceAvailability(resources, true));
 }
Esempio n. 29
0
        public void SendToGameAllPlayer(int gameId, IGamePlayer except, GSPacketIn content)
        {
            GSPacketIn pkg = new GSPacketIn(71, gameId);

            pkg.Parameter1 = ((except != null) ? except.GamePlayerId : -1);
            pkg.WritePacket(content);
            this.SendTCP(pkg);
        }
Esempio n. 30
0
 public void AddPlayer(IGamePlayer p)
 {
     lock (this)
     {
         playerContexts[p] = new PlayerContext(p, context);
         p.BindEvents(this);
     }
 }
Esempio n. 31
0
        public void SendGamePlayerId(IGamePlayer player)
        {
            GSPacketIn pkg = new GSPacketIn((byte)eFightPackageType.SEND_GAME_PLAYER_ID);

            pkg.Parameter1 = player.PlayerCharacter.ID;
            pkg.Parameter2 = player.GamePlayerId;
            SendTCP(pkg);
        }
Esempio n. 32
0
 /// <summary>
 /// Creates a simulation where each game will start from a fixed state.
 /// </summary>
 /// <param name="gamesToPlay">the number of games to play</param>
 /// <param name="initialState">the starting state for each game</param>
 /// <param name="player">the player providing action decisions</param>
 public GameSimulator(
     int gamesToPlay,
     GameState initialState,
     IGamePlayer player)
     : this(gamesToPlay, player)
 {
     GetInitialState = () => initialState;
 }
Esempio n. 33
0
 public ProxyRoom(int roomId, int orientRoomId, IGamePlayer[] players, ServerClient client)
 {
     m_roomId = roomId;
     m_orientRoomId = orientRoomId;
     m_players = new List<IGamePlayer>();
     m_players.AddRange(players);
     m_client = client;
        // GetBaseProperty();
 }
Esempio n. 34
0
 public override void SendToAll(Game.Base.Packets.GSPacketIn pkg, IGamePlayer except)
 {
     if (m_roomRed != null)
     {
         m_roomRed.SendToAll(pkg, except);
     }
     if (m_roomBlue != null)
     {
         m_roomBlue.SendToAll(pkg, except);
     }
 }
Esempio n. 35
0
 public override void SendToTeam(Game.Base.Packets.GSPacketIn pkg, int team, IGamePlayer except)
 {
     if (team == 1)
     {
         m_roomRed.SendToAll(pkg, except);
     }
     else
     {
         m_roomBlue.SendToAll(pkg, except);
     }
 }
Esempio n. 36
0
        public bool RemovePlayer(IGamePlayer player)
        {
            bool result = false;

            lock (m_players)
            {
                if (m_players.Remove(player))
                {
                    result = true;
                }
            }
            if (PlayerCount == 0)
            {
                ProxyRoomMgr.RemoveRoom(this);
            }
            return result;
        }
Esempio n. 37
0
        private void SendCreateGameToSingle(PVEGame game, IGamePlayer gamePlayer)
        {
            GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD);
            pkg.WriteByte((byte)eTankCmdType.GAME_ROOM_INFO);
            pkg.WriteInt(game.Map.Info.ID);
            pkg.WriteInt((byte)game.RoomType);
            pkg.WriteInt((byte)game.GameType);
            pkg.WriteInt(game.TimeType);
            List<Player> players = game.GetAllFightPlayers();
            pkg.WriteInt(players.Count);
            foreach (Player p in players)
            {
                IGamePlayer gp = p.PlayerDetail;
                pkg.WriteInt(gp.PlayerCharacter.ID);
                //zoneid
                //pkg.WriteInt(4);
                pkg.WriteString(gp.PlayerCharacter.NickName);
                //isvip
                pkg.WriteBoolean(true);
                pkg.WriteInt(5);
                pkg.WriteBoolean(gp.PlayerCharacter.Sex);
                pkg.WriteInt(gp.PlayerCharacter.Hide);
                pkg.WriteString(gp.PlayerCharacter.Style);
                pkg.WriteString(gp.PlayerCharacter.Colors);
                pkg.WriteString(gp.PlayerCharacter.Skin);
                pkg.WriteInt(gp.PlayerCharacter.Grade);
                pkg.WriteInt(gp.PlayerCharacter.Repute);
                if (gp.MainWeapon == null)
                {
                    pkg.WriteInt(0);
                }
                else
                {
                    pkg.WriteInt(gp.MainWeapon.TemplateID);
                    pkg.WriteInt(0);
                    pkg.WriteString("");
                    pkg.WriteDateTime(DateTime.MinValue);
                }
                pkg.WriteInt(0);
                pkg.WriteInt(gp.PlayerCharacter.ConsortiaID);
                pkg.WriteString(gp.PlayerCharacter.ConsortiaName);
                pkg.WriteInt(gp.PlayerCharacter.ConsortiaLevel);
                pkg.WriteInt(gp.PlayerCharacter.ConsortiaRepute);

                pkg.WriteInt(p.Team);
                pkg.WriteInt(p.Id);
                pkg.WriteInt(p.MaxBlood);
                pkg.WriteBoolean(p.Ready);
            }

            MissionInfo missionInfo = game.Misssions[game.SessionId - 1];
            pkg.WriteString(missionInfo.Name);
            pkg.WriteString(missionInfo.Name);
            pkg.WriteString(missionInfo.Success);
            pkg.WriteString(missionInfo.Failure);
            pkg.WriteString(missionInfo.Description);
            pkg.WriteInt(game.TotalMissionCount);
            pkg.WriteInt(game.SessionId - 1);
            gamePlayer.SendTCP(pkg);
        }
Esempio n. 38
0
 public void SendPlayerInfoInGame(PVEGame game, IGamePlayer gp, Player p)
 {
     GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD);
     pkg.WriteByte((byte)eTankCmdType.PLAY_INFO_IN_GAME);
     pkg.WriteInt(gp.PlayerCharacter.ID);
     //zoneid
     pkg.WriteInt(4);
     pkg.WriteInt(p.Team);
     pkg.WriteInt(p.Id);
     pkg.WriteInt(p.MaxBlood);
     pkg.WriteBoolean(p.Ready);
     game.SendToAll(pkg);
 }
Esempio n. 39
0
 public override Player AddPlayer(IGamePlayer gp)
 {
     if (CanAddPlayer())
     {
         Player fp = new Player(gp, PhysicalId++, this, 1);
         //fp.Reset();
         fp.Direction = m_random.Next(0, 1) == 0 ? 1 : -1;
         AddPlayer(gp, fp);
         SendCreateGameToSingle(this, gp);
         SendPlayerInfoInGame(this, gp, fp);
         return fp;
     }
     else
     {
         return null;
     }
 }
Esempio n. 40
0
        public override Player RemovePlayer(IGamePlayer gp, bool isKick)
        {
            Player player = GetPlayer(gp);

            if (player != null)
            {
                player.PlayerDetail.RemoveGP(gp.PlayerCharacter.Grade * 12);
                string msg = null;
                string msg1 = null;
                if (player.IsLiving && GameState == eGameState.Playing)
                {

                    msg = LanguageMgr.GetTranslation("AbstractPacketLib.SendGamePlayerLeave.Msg4", gp.PlayerCharacter.Grade * 12);
                    msg1 = LanguageMgr.GetTranslation("AbstractPacketLib.SendGamePlayerLeave.Msg5", gp.PlayerCharacter.NickName, gp.PlayerCharacter.Grade * 12);
                    SendMessage(gp, msg, msg1, 3);
                }
                else
                {
                    msg1 = LanguageMgr.GetTranslation("AbstractPacketLib.SendGamePlayerLeave.Msg1", gp.PlayerCharacter.NickName);
                    SendMessage(gp, msg, msg1, 3);
                }
                base.RemovePlayer(gp, isKick);
            }


            return player;
        }
Esempio n. 41
0
        public virtual void SendToAll(GSPacketIn pkg, IGamePlayer except)
        {
            if (pkg.Parameter2 == 0)
            {
                pkg.Parameter2 = LifeTime;
            }

            List<Player> temp = GetAllFightPlayers();
            foreach (Player p in temp)
            {
                if (p.IsActive && p.PlayerDetail != except)
                {
                    p.PlayerDetail.SendTCP(pkg);
                }
            }
        }
Esempio n. 42
0
 public Player GetPlayer(IGamePlayer gp)
 {
     Player player = null;
     lock (m_players)
     {
         foreach (Player p in m_players.Values)
         {
             if (p.PlayerDetail == gp)
             {
                 player = p;
                 // m_players.Remove(p.Id);
                 break;
             }
         }
     }
     return player;
 }
Esempio n. 43
0
 internal void SendMessage(IGamePlayer player, string msg, string msg1, int type)
 {
     if (msg != null)
     {
         GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CHAT);
         pkg.WriteInt(type);
         pkg.WriteString(msg);
         player.SendTCP(pkg);
     }
     if (msg1 != null)
     {
         GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CHAT);
         pkg.WriteInt(type);
         pkg.WriteString(msg1);
         SendToAll(pkg, player);
     }
 }
Esempio n. 44
0
 public void SendToRoom(int roomId, GSPacketIn pkg, IGamePlayer except)
 {
     GSPacketIn p = new GSPacketIn((byte)eFightPackageType.SEND_TO_ROOM, roomId);
     if (except != null)
     {
         p.Parameter1 = except.PlayerCharacter.ID;
         p.Parameter2 = except.GamePlayerId;
     }
     else
     {
         p.Parameter1 = 0;
         p.Parameter2 = 0;
     }
     p.WritePacket(pkg);
     SendTCP(p);
 }
Esempio n. 45
0
        public void HandleGameRoomCreate(GSPacketIn pkg)
        {
            int roomId = pkg.ReadInt();
            int gameType = pkg.ReadInt();
            int guildId = pkg.ReadInt();

            int count = pkg.ReadInt();
            int totalLevel = 0;
            IGamePlayer[] players = new IGamePlayer[count];
            for (int i = 0; i < count; i++)
            {
                PlayerInfo info = new PlayerInfo();
                info.ID = pkg.ReadInt();
                info.NickName = pkg.ReadString();
                info.Sex = pkg.ReadBoolean();
                info.Hide = pkg.ReadInt();
                info.Style = pkg.ReadString();
                info.Colors = pkg.ReadString();
                info.Skin = pkg.ReadString();
                info.Offer = pkg.ReadInt();
                info.GP = pkg.ReadInt();
                info.Grade = pkg.ReadInt();
                info.Repute = pkg.ReadInt();
                info.ConsortiaID = pkg.ReadInt();
                info.ConsortiaName = pkg.ReadString();
                info.ConsortiaLevel = pkg.ReadInt();
                info.ConsortiaRepute = pkg.ReadInt();

                info.Attack = pkg.ReadInt();
                info.Defence = pkg.ReadInt();
                info.Agility = pkg.ReadInt();
                info.Luck = pkg.ReadInt();

                double baseAttack = pkg.ReadDouble();
                double baseDefence = pkg.ReadDouble();
                double baseAgility = pkg.ReadDouble();
                double baseBlood = pkg.ReadDouble();
                int templateId = pkg.ReadInt();
                bool canUserProp = pkg.ReadBoolean();
                int secondWeapon = pkg.ReadInt();
                int strengthLevel = pkg.ReadInt();


                double gprate = pkg.ReadDouble();
                double offerrate = pkg.ReadDouble();
                double rate = pkg.ReadDouble();
                int serverid = pkg.ReadInt();

                ItemTemplateInfo itemTemplate = ItemMgr.FindItemTemplate(templateId);
                ItemInfo item = null;
                if (secondWeapon != 0)
                {
                    ItemTemplateInfo secondWeaponTemp = ItemMgr.FindItemTemplate(secondWeapon);
                    item = ItemInfo.CreateFromTemplate(secondWeaponTemp, 1, 1);
                    item.StrengthenLevel = strengthLevel;
                }

                List<BufferInfo> infos = new List<BufferInfo>();

                int buffercout = pkg.ReadInt();
                for (int j = 0; j < buffercout; j++)
                {
                    BufferInfo buffinfo = new BufferInfo();
                    buffinfo.Type = pkg.ReadInt();
                    buffinfo.IsExist = pkg.ReadBoolean();
                    buffinfo.BeginDate = pkg.ReadDateTime();
                    buffinfo.ValidDate = pkg.ReadInt();
                    buffinfo.Value = pkg.ReadInt();
                    if (info != null)
                        infos.Add(buffinfo);
                }

                players[i] = new ProxyPlayer(this, info, itemTemplate, item, baseAttack, baseDefence, baseAgility, baseBlood, gprate, offerrate, rate, infos, serverid);
                players[i].CanUseProp = canUserProp;

                int ec = pkg.ReadInt();
                for (int j = 0; j < ec; j++)
                {
                    players[i].EquipEffect.Add(pkg.ReadInt());
                }
                totalLevel += info.Grade;
            }

            ProxyRoom room = new ProxyRoom(ProxyRoomMgr.NextRoomId(), roomId, players, this);
            room.GuildId = guildId;
            room.GameType = (eGameType)gameType;

            lock (m_rooms)
            {
                if (!m_rooms.ContainsKey(roomId))
                {
                    m_rooms.Add(roomId, room);
                }
                else
                {
                    room = null;
                }
            }

            if (room != null)
            {
                ProxyRoomMgr.AddRoom(room);
            }
            else
            {
                log.ErrorFormat("Room already exists:{0}", roomId);
            }
        }
Esempio n. 46
0
 public virtual Player AddPlayer(IGamePlayer player) { return null; }
Esempio n. 47
0
 public virtual Player RemovePlayer(IGamePlayer player, bool IsKick) { return null; }
Esempio n. 48
0
 public Host(IGamePlayer player1, IGamePlayer player2)
 {
     Player = new IGamePlayer[] { player1, player2 };
 }
Esempio n. 49
0
 public void SendToAll(GSPacketIn pkg, IGamePlayer except)
 {
     m_client.SendToRoom(m_orientRoomId, pkg, except);
 }
Esempio n. 50
0
 private void SendCreateGameToSingle(PVEGame game, IGamePlayer gamePlayer)
 {
     GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD);
     pkg.WriteByte((byte)eTankCmdType.GAME_ROOM_INFO);
     pkg.WriteInt(game.Map.Info.ID);
     pkg.WriteInt((byte)game.RoomType);
     pkg.WriteInt((byte)game.GameType);
     pkg.WriteInt(game.TimeType);
     List<Player> players = game.GetAllFightPlayers();
     pkg.WriteInt(players.Count);
     foreach (Player p in players)
     {
         IGamePlayer gp = p.PlayerDetail;
         pkg.WriteInt(gp.PlayerCharacter.ID);
         pkg.WriteString(gp.PlayerCharacter.NickName);
         pkg.WriteBoolean(false);//_loc_10 = _loc_2.readBoolean();
         pkg.WriteByte(gp.PlayerCharacter.typeVIP);
         pkg.WriteInt(gp.PlayerCharacter.VIPLevel);
         pkg.WriteBoolean(gp.PlayerCharacter.Sex);
         pkg.WriteInt(gp.PlayerCharacter.Hide);
         pkg.WriteString(gp.PlayerCharacter.Style);
         pkg.WriteString(gp.PlayerCharacter.Colors);
         pkg.WriteString(gp.PlayerCharacter.Skin);
         pkg.WriteInt(gp.PlayerCharacter.Grade);
         pkg.WriteInt(gp.PlayerCharacter.Repute);
         if (gp.MainWeapon == null)
         {
             pkg.WriteInt(0);
         }
         else
         {
             pkg.WriteInt(gp.MainWeapon.TemplateID);
             pkg.WriteInt(gp.MainWeapon.RefineryLevel);
             pkg.WriteString(gp.MainWeapon.Name);
             pkg.WriteDateTime(DateTime.MinValue);
         }
         if (gp.SecondWeapon == null)
         {
             pkg.WriteInt(0);
         }
         else
         {
             pkg.WriteInt(gp.SecondWeapon.TemplateID);
         }
         pkg.WriteInt(gp.PlayerCharacter.ConsortiaID);
         pkg.WriteString(gp.PlayerCharacter.ConsortiaName);
         pkg.WriteInt(0);//_loc_8.badgeID = _loc_2.readInt();
         pkg.WriteInt(0);//_loc_14 = _loc_2.readInt();
         pkg.WriteInt(0);//_loc_15 = _loc_2.readInt();
         pkg.WriteBoolean(false);//_loc_8.DailyLeagueFirst = _loc_2.readBoolean();
         pkg.WriteInt(0);//_loc_8.DailyLeagueLastScore = _loc_2.readInt();
         pkg.WriteInt(p.Team);
         pkg.WriteInt(p.Id);
         pkg.WriteInt(p.MaxBlood);
         pkg.WriteBoolean(p.Ready);
     }
     int index = game.SessionId - 1;
     MissionInfo missionInfo = game.Misssions[index];
     pkg.WriteString(missionInfo.Name);
     pkg.WriteString(missionInfo.Name);
     pkg.WriteString(missionInfo.Success);
     pkg.WriteString(missionInfo.Failure);
     pkg.WriteString(missionInfo.Description);
     pkg.WriteInt(game.TotalMissionCount);
     pkg.WriteInt(index);
     gamePlayer.SendTCP(pkg);
 }
Esempio n. 51
0
 public CreateRoomAction(IGamePlayer[] players,int oriendRoomId,ServerClient client)
 {
     m_players = players;
     m_orientRoomId = oriendRoomId;
     m_client = client;
 }
Esempio n. 52
0
 public void SendGamePlayerId(IGamePlayer player)
 {
     GSPacketIn pkg = new GSPacketIn((byte)eFightPackageType.SEND_GAME_PLAYER_ID);
     pkg.Parameter1 = player.PlayerCharacter.ID;
     pkg.Parameter2 = player.GamePlayerId;
     SendTCP(pkg);
 }
Esempio n. 53
0
 protected void AddPlayer(IGamePlayer gp, Player fp)
 {
     lock (m_players)
     {
         m_players.Add(fp.Id, fp);
         //玩家没有武器,则不加入到m_turnQueue中去
         if (fp.Weapon == null)
         {
             return;
         }
         m_turnQueue.Add(fp);
     }
 }
Esempio n. 54
0
        public override Player RemovePlayer(IGamePlayer gp, bool IsKick)
        {
            Player player = base.RemovePlayer(gp, IsKick);
            if (player != null && player.IsLiving && GameState != eGameState.Loading)
            {

                gp.RemoveGP(gp.PlayerCharacter.Grade * 12);
                string msg = null;
                string msg1 = null;
                if (RoomType == eRoomType.Match)
                {
                    if (GameType == eGameType.Guild)
                    {
                        msg = LanguageMgr.GetTranslation("AbstractPacketLib.SendGamePlayerLeave.Msg6", gp.PlayerCharacter.Grade * 12, 15);
                        gp.RemoveOffer(15);
                        msg1 = LanguageMgr.GetTranslation("AbstractPacketLib.SendGamePlayerLeave.Msg7", gp.PlayerCharacter.NickName, gp.PlayerCharacter.Grade * 12, 15);

                    }
                    else if (GameType == eGameType.Free)
                    {
                        msg = LanguageMgr.GetTranslation("AbstractPacketLib.SendGamePlayerLeave.Msg6", gp.PlayerCharacter.Grade * 12, 5);
                        gp.RemoveOffer(5);
                        msg1 = LanguageMgr.GetTranslation("AbstractPacketLib.SendGamePlayerLeave.Msg7", gp.PlayerCharacter.NickName, gp.PlayerCharacter.Grade * 12, 5);
                    }
                }
                else
                {
                    msg = LanguageMgr.GetTranslation("AbstractPacketLib.SendGamePlayerLeave.Msg4", gp.PlayerCharacter.Grade * 12);
                    msg1 = LanguageMgr.GetTranslation("AbstractPacketLib.SendGamePlayerLeave.Msg5", gp.PlayerCharacter.NickName, gp.PlayerCharacter.Grade * 12);
                }
                SendMessage(gp, msg, msg1, 3);

                if (GetSameTeam() == true)
                {
                    CurrentLiving.StopAttacking();
                    CheckState(0);
                }
            }
            return player;

        }
Esempio n. 55
0
 public override Player RemovePlayer(IGamePlayer gp, bool IsKick)
 {
     Player player = null;
     lock (m_players)
     {
         foreach (Player p in m_players.Values)
         {
             if (p.PlayerDetail == gp)
             {
                 player = p;
                 m_players.Remove(p.Id);
                 break;
             }
         }
     }
     if (player != null)
     {
         AddAction(new RemovePlayerAction(player));
     }
     return player;
 }
 public static SurrogateForIGamePlayer Convert(IGamePlayer value)
 {
     if (value == null) return null;
     return new SurrogateForIGamePlayer { Target = ((GamePlayerRef)value).Target };
 }
Esempio n. 57
0
 public virtual void SendToTeam(GSPacketIn pkg, int team, IGamePlayer except)
 {
     List<Player> temp = GetAllFightPlayers();
     foreach (Player p in temp)
     {
         if (p.IsActive && p.PlayerDetail != except && p.Team == team)
         {
             p.PlayerDetail.SendTCP(pkg);
         }
     }
 }
Esempio n. 58
0
 private void SendCreateGameToSingle(PVEGame game, IGamePlayer gamePlayer)
 {
     GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD);
     pkg.WriteByte((byte)eTankCmdType.GAME_ROOM_INFO);
     pkg.WriteInt(game.Map.Info.ID);
     pkg.WriteInt((byte)game.RoomType);
     pkg.WriteInt((byte)game.GameType);
     pkg.WriteInt(game.TimeType);
     List<Player> players = game.GetAllFightPlayers();
     pkg.WriteInt(players.Count);
     foreach (Player p in players)
     {
         IGamePlayer gp = p.PlayerDetail;
         pkg.WriteInt(gp.PlayerCharacter.ID);
         pkg.WriteString(gp.PlayerCharacter.NickName);
         pkg.WriteBoolean(false);//_loc_10 = _loc_2.readBoolean();
         pkg.WriteByte(gp.PlayerCharacter.typeVIP);
         pkg.WriteInt(gp.PlayerCharacter.VIPLevel);
         pkg.WriteBoolean(gp.PlayerCharacter.Sex);
         pkg.WriteInt(gp.PlayerCharacter.Hide);
         pkg.WriteString(gp.PlayerCharacter.Style);
         pkg.WriteString(gp.PlayerCharacter.Colors);
         pkg.WriteString(gp.PlayerCharacter.Skin);
         pkg.WriteInt(gp.PlayerCharacter.Grade);
         pkg.WriteInt(gp.PlayerCharacter.Repute);
         if (gp.MainWeapon == null)
         {
             pkg.WriteInt(0);
         }
         else
         {
             pkg.WriteInt(gp.MainWeapon.TemplateID);
             pkg.WriteInt(gp.MainWeapon.RefineryLevel);
             pkg.WriteString(gp.MainWeapon.Name);
             pkg.WriteDateTime(DateTime.MinValue);
         }
         if (gp.SecondWeapon == null)
         {
             pkg.WriteInt(0);
         }
         else
         {
             pkg.WriteInt(gp.SecondWeapon.TemplateID);
         }
         pkg.WriteInt(gp.PlayerCharacter.ConsortiaID);
         pkg.WriteString(gp.PlayerCharacter.ConsortiaName);
         pkg.WriteInt(0);//_loc_8.badgeID = _loc_2.readInt();
         pkg.WriteInt(0);//_loc_14 = _loc_2.readInt();
         pkg.WriteInt(0);//_loc_15 = _loc_2.readInt();
         pkg.WriteBoolean(false);//_loc_8.DailyLeagueFirst = _loc_2.readBoolean();
         pkg.WriteInt(0);//_loc_8.DailyLeagueLastScore = _loc_2.readInt();
         pkg.WriteInt(p.Team);
         pkg.WriteInt(p.Id);
         pkg.WriteInt(p.MaxBlood);
         pkg.WriteBoolean(p.Ready);
     }
     int index = game.SessionId - 1;
     /*
     if ((index == 0) || (index > Missions.Count))
     {
         StringBuilder sb = new StringBuilder();
         foreach (MissionInfo mi in Missions.Values)
         {
             sb.Append(mi.Id).Append(",");
         }
         log.Error(string.Format("PVEGame.SendCreateGameToSingle KeyNotFoundException, game.SessionId : {0}, index : {1}, Missions.Ids : {2}, Missions.Count : {3}", new object[] { game.SessionId, index, sb.ToString(), this.Missions.Count }));
         if (index == 0)
         {
             index = 1;
         }
         if (index == Missions.Count)
         {
             index = Missions.Count;
         }
     }
     */
     MissionInfo missionInfo = game.Misssions[index];
     pkg.WriteString(missionInfo.Name);
     pkg.WriteString(missionInfo.Name);
     pkg.WriteString(missionInfo.Success);
     pkg.WriteString(missionInfo.Failure);
     pkg.WriteString(missionInfo.Description);
     pkg.WriteInt(game.TotalMissionCount);
     pkg.WriteInt(index);
     gamePlayer.SendTCP(pkg);
 }