示例#1
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);
            }
        }
        public void HandleConsortiaUserPass(GSPacketIn packet)
        {
            int cid = packet.ReadInt();
            bool isInvite = packet.ReadBoolean();
            int consortiaID = packet.ReadInt();
            string consortiaName = packet.ReadString();
            int id = packet.ReadInt();
            string userName = packet.ReadString();
            int inviteUserID = packet.ReadInt();
            string inviteUserName = packet.ReadString();
            int dutyID = packet.ReadInt();
            string dutyName = packet.ReadString();
            int offer = packet.ReadInt();
            int richesOffer = packet.ReadInt();
            int richesRob = packet.ReadInt();
            DateTime lastDate = packet.ReadDateTime();
            int grade = packet.ReadInt();
            int level = packet.ReadInt();
            int state = packet.ReadInt();
            bool sex = packet.ReadBoolean();
            int right = packet.ReadInt();
            int win = packet.ReadInt();
            int total = packet.ReadInt();
            int escape = packet.ReadInt();
            int consortiaRepute = packet.ReadInt();

            GamePlayer[] players = WorldMgr.GetAllPlayers();
            foreach (GamePlayer p in players)
            {
                if (p.PlayerCharacter.ID == id)
                {
                    p.BeginChanges();

                    p.PlayerCharacter.ConsortiaID = consortiaID;
                    p.PlayerCharacter.ConsortiaName = consortiaName;
                    p.PlayerCharacter.DutyName = dutyName;
                    p.PlayerCharacter.DutyLevel = level;
                    p.PlayerCharacter.Right = right;
                    p.PlayerCharacter.ConsortiaRepute = consortiaRepute;
                    ConsortiaInfo consotia = ConsortiaMgr.FindConsortiaInfo(consortiaID);
                    if (consotia != null)
                        p.PlayerCharacter.ConsortiaLevel = consotia.Level;

                    p.CommitChanges();
                }

                if (p.PlayerCharacter.ConsortiaID == consortiaID)
                {
                    p.Out.SendTCP(packet);
                }
            }
        }