예제 #1
0
        public void Execute()
        {
            if (m_room.CanStart())
            {
                List <GamePlayer> players = m_room.GetPlayers();
                if (m_room.RoomType == eRoomType.Freedom)
                {
                    List <IGamePlayer> red  = new List <IGamePlayer>();
                    List <IGamePlayer> blue = new List <IGamePlayer>();
                    foreach (GamePlayer p in players)
                    {
                        if (p != null)
                        {
                            if (p.CurrentRoomTeam == 1)
                            {
                                red.Add(p);
                            }
                            else
                            {
                                blue.Add(p);
                            }
                        }
                    }

                    BaseGame game = GameMgr.StartPVPGame(m_room.RoomId, red, blue, m_room.MapId, m_room.RoomType, m_room.GameType, m_room.TimeMode);
                    StartGame(game);
                }
                else if (m_room.RoomType == eRoomType.Exploration || m_room.RoomType == eRoomType.Boss || m_room.RoomType == eRoomType.Treasure)
                {
                    List <IGamePlayer> matchPlayers = new List <IGamePlayer>();
                    foreach (GamePlayer p in players)
                    {
                        if (p != null)
                        {
                            matchPlayers.Add(p);
                        }
                    }
                    //更新房间的时间类型
                    UpdatePveRoomTimeMode();
                    BaseGame game = GameMgr.StartPVEGame(m_room.RoomId, matchPlayers, m_room.MapId, m_room.RoomType, m_room.GameType, m_room.TimeMode, m_room.HardLevel, m_room.LevelLimits);
                    StartGame(game);
                }
                else if (m_room.RoomType == eRoomType.Match)
                {
                    m_room.UpdateAvgLevel();
                    // m_room.GameType = eGameType.Guild;

                    BattleServer server = BattleMgr.AddRoom(m_room);
                    if (server != null)
                    {
                        m_room.BattleServer = server;
                        m_room.IsPlaying    = true;
                        m_room.SendStartPickUp();
                    }
                    else
                    {
                        GSPacketIn pkg = m_room.Host.Out.SendMessage(eMessageType.ChatERROR, "没有可用的战场服务器!");
                        m_room.SendToAll(pkg, m_room.Host);
                        m_room.SendCancelPickUp();
                    }
                }

                RoomMgr.WaitingRoom.SendUpdateRoom(m_room);
            }
        }
예제 #2
0
        public void SendAddRoom(Game.Server.Rooms.BaseRoom room)
        {
            GSPacketIn pkg = new GSPacketIn((int)eFightPackageType.ROOM_CREATE);

            pkg.WriteInt(room.RoomId);
            pkg.WriteInt((int)room.GameType);
            pkg.WriteInt(room.GuildId);

            List <GamePlayer> players = room.GetPlayers();

            pkg.WriteInt(players.Count);
            foreach (GamePlayer p in players)
            {
                pkg.WriteInt(p.PlayerCharacter.ID);//改为唯一ID
                pkg.WriteString(p.PlayerCharacter.NickName);
                pkg.WriteBoolean(p.PlayerCharacter.Sex);

                pkg.WriteInt(p.PlayerCharacter.Hide);
                pkg.WriteString(p.PlayerCharacter.Style);
                pkg.WriteString(p.PlayerCharacter.Colors);
                pkg.WriteString(p.PlayerCharacter.Skin);
                pkg.WriteInt(p.PlayerCharacter.Offer);
                pkg.WriteInt(p.PlayerCharacter.GP);
                pkg.WriteInt(p.PlayerCharacter.Grade);
                pkg.WriteInt(p.PlayerCharacter.Repute);
                pkg.WriteInt(p.PlayerCharacter.ConsortiaID);
                pkg.WriteString(p.PlayerCharacter.ConsortiaName);
                pkg.WriteInt(p.PlayerCharacter.ConsortiaLevel);
                pkg.WriteInt(p.PlayerCharacter.ConsortiaRepute);

                pkg.WriteInt(p.PlayerCharacter.Attack);
                pkg.WriteInt(p.PlayerCharacter.Defence);
                pkg.WriteInt(p.PlayerCharacter.Agility);
                pkg.WriteInt(p.PlayerCharacter.Luck);
                pkg.WriteDouble(p.GetBaseAttack());
                pkg.WriteDouble(p.GetBaseDefence());
                pkg.WriteDouble(p.GetBaseAgility());
                pkg.WriteDouble(p.GetBaseBlood());
                pkg.WriteInt(p.MainWeapon.TemplateID);
                pkg.WriteBoolean(p.CanUseProp);
                if (p.SecondWeapon != null)
                {
                    pkg.WriteInt(p.SecondWeapon.TemplateID);
                    pkg.WriteInt(p.SecondWeapon.StrengthenLevel);
                }
                else
                {
                    pkg.WriteInt(0);
                    pkg.WriteInt(0);
                }
                pkg.WriteDouble(RateMgr.GetRate(eRateType.Experience_Rate) * AntiAddictionMgr.GetAntiAddictionCoefficient(p.PlayerCharacter.AntiAddiction) * (p.GPAddPlus == 0 ? 1 : p.GPAddPlus));
                pkg.WriteDouble(AntiAddictionMgr.GetAntiAddictionCoefficient(p.PlayerCharacter.AntiAddiction) * (p.OfferAddPlus == 0 ? 1 : p.OfferAddPlus));
                pkg.WriteDouble(RateMgr.GetRate(eRateType.Experience_Rate));
                pkg.WriteInt(GameServer.Instance.Configuration.ServerID);


                List <AbstractBuffer> infos = p.BufferList.GetAllBuffer();
                pkg.WriteInt(infos.Count);
                foreach (AbstractBuffer bufferInfo in infos)
                {
                    BufferInfo info = bufferInfo.Info;
                    pkg.WriteInt(info.Type);
                    pkg.WriteBoolean(info.IsExist);
                    pkg.WriteDateTime(info.BeginDate);
                    pkg.WriteInt(info.ValidDate);
                    pkg.WriteInt(info.Value);
                }

                pkg.WriteInt(p.EquipEffect.Count);
                foreach (int i in p.EquipEffect)
                {
                    pkg.WriteInt(i);
                }
            }
            SendTCP(pkg);
        }