public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.CurrentRoom == null) return 0; int id = packet.ReadInt(); GamePlayer player = Managers.WorldMgr.GetPlayerById(id); if (player == client.Player) return 0; List<GamePlayer> players = client.Player.CurrentRoom.GetPlayers(); foreach (GamePlayer p in players) { if (p == player) { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("friendnotinthesameserver.Sameroom")); return 0; } } GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_INVITE); if (player != null && player.CurrentRoom == null) { pkg.WriteInt(client.Player.PlayerCharacter.ID); pkg.WriteInt(client.Player.CurrentRoom.RoomId); pkg.WriteInt(client.Player.CurrentRoom.MapId); pkg.WriteByte((byte)client.Player.CurrentRoom.TimeMode); pkg.WriteByte((byte)client.Player.CurrentRoom.RoomType); pkg.WriteByte((byte)client.Player.CurrentRoom.HardLevel); pkg.WriteByte((byte)client.Player.CurrentRoom.LevelLimits); pkg.WriteString(client.Player.PlayerCharacter.NickName); pkg.WriteBoolean(true); pkg.WriteInt(5); pkg.WriteString(client.Player.CurrentRoom.Name); pkg.WriteString(client.Player.CurrentRoom.Password); //TrieuLSL BN IMInvite barrierNum pkg.WriteInt(50); player.Out.SendTCP(pkg); } else { if (player != null && player.CurrentRoom != null && player.CurrentRoom != client.Player.CurrentRoom) { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("friendnotinthesameserver.Room")); } else { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("friendnotinthesameserver.Fail")); } } return 0; }
public int HandlePacket(GameClient client, GSPacketIn packet) { //Lay Danh Sach tat ca cac phong GSPacketIn pkg = new GSPacketIn((byte)ePackageType.HOTSPRING_ROOM_LIST_GET); pkg.WriteInt(10); for (int i = 0; i < 10; i++) { //loc_2.roomNumber = _loc_3.readInt(); pkg.WriteInt(i); //_loc_2.roomID = _loc_3.readInt(); pkg.WriteInt(i); //_loc_2.roomName = _loc_3.readUTF(); pkg.WriteString("Room" + i); //_loc_2.roomPassword = _loc_3.readUTF(); pkg.WriteString(""); //_loc_2.effectiveTime = _loc_3.readInt(); pkg.WriteInt(1); //_loc_2.curCount = _loc_3.readInt(); pkg.WriteInt(1); //_loc_2.playerID = _loc_3.readInt(); pkg.WriteInt(client.Player.PlayerCharacter.ID); //_loc_2.playerName = _loc_3.readUTF(); pkg.WriteString("abc"); //_loc_2.startTime = _loc_3.readDate(); pkg.WriteDateTime(DateTime.Now.AddDays(-50)); //_loc_2.roomIntroduction = _loc_3.readUTF(); pkg.WriteString("Room Intro"); //_loc_2.roomType = _loc_3.readInt(); pkg.WriteInt(1); //_loc_2.maxCount = _loc_3.readInt(); pkg.WriteInt(10); } client.SendTCP(pkg); return 0; }
public static GSPacketIn SendBufferList(Player player, List<BufferInfo> infos) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.BUFF_OBTAIN, player.Id); pkg.WriteInt(infos.Count); foreach (BufferInfo info in infos) { pkg.WriteInt(info.Type); pkg.WriteBoolean(info.IsExist); pkg.WriteDateTime(info.BeginDate); pkg.WriteInt(info.ValidDate); pkg.WriteInt(info.Value); } return pkg; }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.PlayerCharacter.ConsortiaID == 0) return 0; int id = client.Player.PlayerCharacter.ConsortiaID; string consortiaName = client.Player.PlayerCharacter.ConsortiaName; bool result = false; string msg = "ConsortiaDisbandHandler.Failed"; using (ConsortiaBussiness db = new ConsortiaBussiness()) { if (db.DeleteConsortia(client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.ID, ref msg)) { result = true; msg = "ConsortiaDisbandHandler.Success1"; client.Player.ClearConsortia(); GameServer.Instance.LoginServer.SendConsortiaDelete(id); } } string temp = LanguageMgr.GetTranslation(msg); if (msg == "ConsortiaDisbandHandler.Success1") { temp += consortiaName + LanguageMgr.GetTranslation("ConsortiaDisbandHandler.Success2"); } packet.WriteBoolean(result); packet.WriteInt(client.Player.PlayerCharacter.ID); packet.WriteString(temp); client.Out.SendTCP(packet); return 0; }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.PlayerCharacter.ConsortiaID == 0) return 0; if (client.Player.PlayerCharacter.IsBanChat) { client.Out.SendMessage(eMessageType.ChatERROR, LanguageMgr.GetTranslation("ConsortiaChatHandler.IsBanChat")); return 1; } packet.ClientID = (client.Player.PlayerCharacter.ID); byte channel = packet.ReadByte(); string nick = packet.ReadString(); string msg = packet.ReadString(); packet.WriteInt(client.Player.PlayerCharacter.ConsortiaID); GamePlayer[] players = WorldMgr.GetAllPlayers(); foreach (GamePlayer p in players) { if (p.PlayerCharacter.ConsortiaID == client.Player.PlayerCharacter.ConsortiaID) p.Out.SendTCP(packet); } GameServer.Instance.LoginServer.SendPacket(packet); return 0; }
public override void OnTick(HotSpringRoom room) { try { if(room != null) { room.KickAllPlayer(); //using(PlayerBussiness db = new PlayerBussiness()) //{ // db.DisposeHotSpringRoomInfo(room.Info.ID); //} //GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(room.Info.GroomID); //GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(room.Info.BrideID); //GameServer.Instance.LoginServer.SendHotSpringRoomInfoToPlayer(room.Info.GroomID, false, room.Info); //GameServer.Instance.LoginServer.SendHotSpringRoomInfoToPlayer(room.Info.BrideID, false, room.Info); //HotSpringRoomMgr.RemoveHotSpringRoom(room); GSPacketIn pkg = new GSPacketIn((short)ePackageType.MARRY_ROOM_DISPOSE); pkg.WriteInt(room.Info.ID); WorldMgr.MarryScene.SendToALL(pkg); room.StopTimer(); } } catch(Exception ex) { if (log.IsErrorEnabled) log.Error("OnTick",ex); } }
public int HandlePacket(GameClient client, GSPacketIn packet) { int val = packet.ReadInt(); GSPacketIn pkg = new GSPacketIn(0xd4); pkg.WriteInt(val); client.SendTCP(pkg); return 0; }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.PlayerCharacter.ConsortiaID == 0) return 0; bool result = false; string msg = "ConsortiaSmithUpGradeHandler.Failed"; //using (ConsortiaBussiness db = new ConsortiaBussiness()) //{ // ConsortiaInfo info = db.GetConsortiaSingle(client.Player.PlayerCharacter.ConsortiaID); ConsortiaInfo info = Managers.ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID); if (info == null) { msg = "ConsortiaSmithUpGradeHandler.NoConsortia"; } else { using (ConsortiaBussiness cb = new ConsortiaBussiness()) { if (cb.UpGradeSmithConsortia(client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.ID, ref msg)) { info.SmithLevel++; GameServer.Instance.LoginServer.SendConsortiaSmithUpGrade(info); msg = "ConsortiaSmithUpGradeHandler.Success"; result = true; } } } if (info.SmithLevel >= 3) { string msg1 = LanguageMgr.GetTranslation("ConsortiaSmithUpGradeHandler.Notice", client.Player.PlayerCharacter.ConsortiaName, info.SmithLevel); GSPacketIn pkg = new GSPacketIn((byte)ePackageType.SYS_NOTICE); pkg.WriteInt(2); pkg.WriteString(msg1); GameServer.Instance.LoginServer.SendPacket(pkg); GamePlayer[] players = Game.Server.Managers.WorldMgr.GetAllPlayers(); foreach (GamePlayer p in players) { if (p != client.Player) p.Out.SendTCP(pkg); } } //} packet.WriteBoolean(result); packet.WriteString(LanguageMgr.GetTranslation(msg)); client.Out.SendTCP(packet); return 1; }
public void HandleCommand(BaseGame game, Player player, GSPacketIn packet) { if (game.GameState == eGameState.Loading) { player.LoadingProcess = packet.ReadInt(); if (player.LoadingProcess >= 100) { game.CheckState(0); } var pkg = new GSPacketIn((short)ePackageType.GAME_CMD); pkg.WriteByte((byte)eTankCmdType.LOAD); //var pkg = packet.Clone(); // pkg.ClearContext(); pkg.WriteInt(player.LoadingProcess); pkg.WriteInt(4); pkg.WriteInt(player.PlayerDetail.PlayerCharacter.ID); game.SendToAll(pkg); } }
public int HandlePacket(GameClient client, GSPacketIn packet) { var roomId = packet.ReadInt(); //if (client.Player.CurrentHotSpringRoom != null) //{ // client.Player.CurrentHotSpringRoom.ProcessData(client.Player, packet); //} GSPacketIn pkg = new GSPacketIn((byte)ePackageType.HOTSPRING_ROOM_ENTER_CONFIRM); pkg.WriteInt(roomId); client.SendTCP(pkg); return 0; }
protected override void ExecuteImp(BaseGame game, long tick) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD, m_living.Id); pkg.Parameter1 = m_living.Id; pkg.WriteByte((byte)eTankCmdType.LIVING_RANGEATTACKING); List<Living> playersAround = game.Map.FindPlayers(m_fx, m_tx, m_players); int count = playersAround.Count; foreach (Living p in playersAround) { if (m_living.IsFriendly(p) == true) count--; } pkg.WriteInt(count); m_living.SyncAtTime = false; try { foreach (Living p in playersAround) { p.SyncAtTime = false; if (m_living.IsFriendly(p) == true) continue; int dander = 0; p.IsFrost = false; game.SendGameUpdateFrozenState(p); int damage = MakeDamage(p); int critical = MakeCriticalDamage(p, damage); int totalDemageAmount = 0; if (p.TakeDamage(m_living, ref damage, ref critical, "范围攻击")) { totalDemageAmount = damage + critical; if (p is Player) { Player player = p as Player; dander = player.Dander; } } pkg.WriteInt(p.Id); pkg.WriteInt(totalDemageAmount); pkg.WriteInt(p.Blood); //同步怒气值 pkg.WriteInt(dander); //attackEffect pkg.WriteInt(new Random().Next(2)); } game.SendToAll(pkg); Finish(tick); } finally { m_living.SyncAtTime = true; foreach (Living p in playersAround) { p.SyncAtTime = true; } } }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.PlayerCharacter.ConsortiaID == 0) return 0; int dutyID = packet.ReadInt(); int updateType = packet.ReadByte(); //int level = packet.ReadInt(); bool result = false; string msg = "ConsortiaDutyUpdateHandler.Failed"; using (ConsortiaBussiness db = new ConsortiaBussiness()) { ConsortiaDutyInfo info = new ConsortiaDutyInfo(); info.ConsortiaID = client.Player.PlayerCharacter.ConsortiaID; info.DutyID = dutyID; info.IsExist = true; info.DutyName = ""; switch (updateType) { case 1: return 1; case 2: info.DutyName = packet.ReadString(); if (string.IsNullOrEmpty(info.DutyName) || System.Text.Encoding.Default.GetByteCount(info.DutyName) > 10) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ConsortiaDutyUpdateHandler.Long")); return 1; } info.Right = packet.ReadInt(); break; case 3: break; case 4: break; } if (db.UpdateConsortiaDuty(info, client.Player.PlayerCharacter.ID, updateType, ref msg)) { dutyID = info.DutyID; msg = "ConsortiaDutyUpdateHandler.Success"; result = true; GameServer.Instance.LoginServer.SendConsortiaDuty(info, updateType, client.Player.PlayerCharacter.ConsortiaID); } } packet.WriteBoolean(result); packet.WriteInt(dutyID); packet.WriteString(LanguageMgr.GetTranslation(msg)); client.Out.SendTCP(packet); return 0; }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.PlayerCharacter.ConsortiaID != 0) return 0; int id = packet.ReadInt(); bool result = false; int consortiaID = 0; string consortiaName = ""; string msg = "ConsortiaInvitePassHandler.Failed"; int tempID = 0; string tempName = ""; using (ConsortiaBussiness db = new ConsortiaBussiness()) { int consortiaRepute = 0; ConsortiaUserInfo info = new ConsortiaUserInfo(); if (db.PassConsortiaInviteUsers(id, client.Player.PlayerCharacter.ID, client.Player.PlayerCharacter.NickName, ref consortiaID, ref consortiaName, ref msg, info, ref tempID, ref tempName, ref consortiaRepute)) { client.Player.PlayerCharacter.ConsortiaID = consortiaID; client.Player.PlayerCharacter.ConsortiaName = consortiaName; client.Player.PlayerCharacter.DutyLevel = info.Level; client.Player.PlayerCharacter.DutyName = info.DutyName; client.Player.PlayerCharacter.Right = info.Right; ConsortiaInfo consotia = ConsortiaMgr.FindConsortiaInfo(consortiaID); if (consotia != null) client.Player.PlayerCharacter.ConsortiaLevel = consotia.Level; msg = "ConsortiaInvitePassHandler.Success"; result = true; info.UserID = client.Player.PlayerCharacter.ID; info.UserName = client.Player.PlayerCharacter.NickName; info.Grade = client.Player.PlayerCharacter.Grade; info.Offer = client.Player.PlayerCharacter.Offer; info.RichesOffer = client.Player.PlayerCharacter.RichesOffer; info.RichesRob = client.Player.PlayerCharacter.RichesRob; info.Win = client.Player.PlayerCharacter.Win; info.Total = client.Player.PlayerCharacter.Total; info.Escape = client.Player.PlayerCharacter.Escape; info.ConsortiaID = consortiaID; info.ConsortiaName = consortiaName; GameServer.Instance.LoginServer.SendConsortiaUserPass(tempID, tempName, info, true, consortiaRepute, client.Player.PlayerCharacter.UserName, client.Player.PlayerCharacter.FightPower); } } packet.WriteBoolean(result); packet.WriteInt(consortiaID); packet.WriteString(consortiaName); packet.WriteString(LanguageMgr.GetTranslation(msg)); client.Out.SendTCP(packet); return 0; }
//每两分钟向服务器端报告一次掉落物品数量 private static void OnTimeEvent(object source, ElapsedEventArgs e) { Dictionary<int, int> tempDic = new Dictionary<int, int>(); m_lock.AcquireWriterLock(Timeout.Infinite); try { foreach (KeyValuePair<int, MacroDropInfo> kvp in DropInfoMgr.DropInfo) { int templateId = kvp.Key; MacroDropInfo macroDropInfo = kvp.Value; if (macroDropInfo.SelfDropCount > 0) { tempDic.Add(templateId, macroDropInfo.SelfDropCount); macroDropInfo.SelfDropCount = 0; } } } catch (Exception ex) { if (log.IsErrorEnabled) log.Error("DropInfoMgr OnTimeEvent", ex); } finally { m_lock.ReleaseWriterLock(); } if(tempDic.Count > 0) { GSPacketIn pkg = new GSPacketIn((byte)eChatServerPacket.MACRO_DROP); pkg.WriteInt(tempDic.Count); foreach (KeyValuePair<int, int> kvp in tempDic) { pkg.WriteInt(kvp.Key); pkg.WriteInt(kvp.Value); } GameServer.Instance.LoginServer.SendPacket(pkg); } }
public GSPacketIn SendAASControl(bool result, bool IsAASInfo, bool IsMinor) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.AAS_CTRL); //pkg.WriteBoolean(result); //pkg.WriteBoolean(IsAASInfo); //pkg.WriteBoolean(IsMinor); //DDTank pkg.WriteBoolean(true); pkg.WriteInt(1); pkg.WriteBoolean(true); pkg.WriteBoolean(IsMinor); SendTCP(pkg); return pkg; }
internal void SendAddRoom(Game.Server.Rooms.BaseRoom room) { GSPacketIn pkg = new GSPacketIn((int)eFightPackageType.GAME_ROOM_CREATE); pkg.WriteInt(room.RoomId); pkg.WriteInt((int)room.GameType); pkg.WriteInt(room.Game.PlayerCount); List<GamePlayer> players = room.GetPlayersSafe(); foreach (GamePlayer p in players) { pkg.WriteInt(p.PlayerCharacter.ID);//改为唯一ID 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.CurrentWeapon.TemplateID); } SendTCP(pkg, room); }
public int HandlePacket(GameClient client, GSPacketIn packet) { int id = packet.ReadInt(); int rewardItemID = packet.ReadInt(); BaseQuest _baseQuest= client.Player.QuestInventory.FindQuest(id); int i=0;//未完成 if (_baseQuest!= null) { i= client.Player.QuestInventory.Finish(_baseQuest, rewardItemID) ? 1 : 0; } if (i == 1) { packet.WriteInt(id); client.Out.SendTCP(packet); } return i; }
public override void OnStarting(BaseSceneGame game, Game.Base.Packets.GSPacketIn data) { //base.OnStarting(game, data); TankData tank = game.Data; tank.Reset(); GamePlayer[] list = game.Data.GetAllPlayers(); int i = random.Next(list.Length); GamePlayer player = GetLowDelayPlayer(game, list[i]); //List<Point> pos = new List<Point>(); //pos.AddRange(Managers.MapMgr.GetMapPos(game.Data.MapIndex)); MapPoint pos = Managers.MapMgr.GetMapRandomPos(game.Data.MapIndex); tank.CurrentWind = random.Next(-40, 40); data.WriteInt(player.PlayerCharacter.ID); data.WriteInt(tank.CurrentWind); data.WriteByte((byte)game.Data.Count); Point temp = new Point(); int lastTeam = -1; foreach (GamePlayer p in list) { temp = GetRandom(pos, temp, lastTeam, p.CurrentTeamIndex); tank.Players[p].X = temp.X; tank.Players[p].Y = temp.Y; tank.CurrentMap.AddPhysical(tank.Players[p]); p.CanFly = true; p.Count = 2; data.WriteInt(p.PlayerCharacter.ID); data.WriteInt(tank.Players[p].X); data.WriteInt(tank.Players[p].Y); data.WriteInt(random.Next(0, 2) > 0 ? 1 : -1); data.WriteInt(tank.Players[p].Blood); data.WriteBoolean(game.Data.Players[p].IsCaptain); lastTeam = p.CurrentTeamIndex; } tank.CurrentIndex = player; game.BeginTimer(TIMEOUT); if (game.RoomType == eRoomType.PAIRUP && game.MatchGame != null) { game.MatchGame.StopTimer(); } }
public void SendSYSMessages(GamePlayer player, PlayerInfo spouse) { string name1 = player.PlayerCharacter.Sex ? player.PlayerCharacter.NickName : spouse.NickName; string name2 = player.PlayerCharacter.Sex ? spouse.NickName : player.PlayerCharacter.NickName; string msg = LanguageMgr.GetTranslation("MarryApplyReplyHandler.Msg1", name1, name2); GSPacketIn pkg = new GSPacketIn((byte)ePackageType.SYS_NOTICE); pkg.WriteInt(2); pkg.WriteString(msg); GameServer.Instance.LoginServer.SendPacket(pkg); GamePlayer[] players = Game.Server.Managers.WorldMgr.GetAllPlayers(); foreach (GamePlayer p in players) { p.Out.SendTCP(pkg); } }
public static void SendStartMessage(BattleGame game) { Game.Base.Packets.GSPacketIn pkg = new Game.Base.Packets.GSPacketIn((byte)ePackageType.GAME_CHAT); pkg.WriteInt(2); if (game.GameType == eGameType.Free) { foreach (Player p in game.GetAllFightPlayers()) { (p.PlayerDetail as ProxyPlayer).Rate = 1; GSPacketIn pkg1 = SendBufferList(p, (p.PlayerDetail as ProxyPlayer).Buffers); game.SendToAll(pkg1); } pkg.WriteString("撮合成功!您所在的小队开始了自由战"); } else { pkg.WriteString("撮合成功!您所在的小队开始了公会战"); } game.SendToAll(pkg, null); }
public int HandlePacket(GameClient client, GSPacketIn packet) { int num = packet.ReadInt(); try { TankHotSpringLogicProcessor processor = new TankHotSpringLogicProcessor(); HotSpringRoomInfo info = new HotSpringRoomInfo { RoomID = num }; client.Player.CurrentHotSpringRoom = new HotSpringRoom(info, processor); } catch { Console.WriteLine("System Error!"); } HotSpringRoom room = client.Player.CurrentHotSpringRoom; using (PlayerBussiness db = new PlayerBussiness()) { db.UpdateHotSpringRoomInfo(room.Info); } string str = packet.ReadString(); GSPacketIn pkg = new GSPacketIn(0xca); pkg.WriteInt(num); pkg.WriteInt(num); pkg.WriteString(room.Info.RoomName); pkg.WriteString(room.Info.Pwd); pkg.WriteInt(1); pkg.WriteInt(1); pkg.WriteInt(client.Player.PlayerCharacter.ID); pkg.WriteString(client.Player.PlayerCharacter.NickName); pkg.WriteDateTime(room.Info.BeginTime); pkg.WriteString(room.Info.RoomIntroduction); pkg.WriteInt(1); pkg.WriteInt(10); pkg.WriteDateTime(DateTime.Now); pkg.WriteInt(10); client.SendTCP(pkg); return 0; }
public static void SendStartMessage(BattleGame game) { Game.Base.Packets.GSPacketIn pkg = new Game.Base.Packets.GSPacketIn((byte)ePackageType.GAME_CHAT); pkg.WriteInt(2); if (game.GameType == eGameType.Free) { foreach (Player p in game.GetAllFightPlayers()) { (p.PlayerDetail as ProxyPlayer).Rate = 1; GSPacketIn pkg1 = SendBufferList(p, (p.PlayerDetail as ProxyPlayer).Buffers); game.SendToAll(pkg1); } pkg.WriteString("Bắt cặp thành công, Bắt đẩu chiến đấu!"); } else { pkg.WriteString("Kết nối thất bại!"); } game.SendToAll(pkg, null); }
public override void OnTick(HotSpringRoom room) { try { if (room != null) { room.KickAllPlayer(); GSPacketIn pkg = new GSPacketIn((short)ePackageType.HOTSPRING_ROOM_REMOVE); pkg.WriteInt(room.Info.RoomID); WorldMgr.HotSpring.SendToALL(pkg); room.StopTimer(); } } catch (Exception exception) { if (log.IsErrorEnabled) { log.Error("OnTick", exception); } } }
public int HandlePacket(GameClient client, GSPacketIn packet) { var roomId = packet.ReadInt(); var passString = packet.ReadString(); GSPacketIn pkg = new GSPacketIn((byte)ePackageType.HOTSPRING_ROOM_ENTER); pkg.WriteInt(roomId); pkg.WriteInt(roomId); //_loc_3.roomID = _loc_2.readInt(); //_loc_3.roomNumber = _loc_2.readInt(); //_loc_3.roomName = _loc_2.readUTF(); pkg.WriteString("RoomName"); //_loc_3.roomPassword = _loc_2.readUTF(); pkg.WriteString(""); //_loc_2.effectiveTime = _loc_3.readInt(); pkg.WriteInt(1); //_loc_2.curCount = _loc_3.readInt(); pkg.WriteInt(1); //_loc_2.playerID = _loc_3.readInt(); pkg.WriteInt(client.Player.PlayerCharacter.ID); //_loc_2.playerName = _loc_3.readUTF(); pkg.WriteString("abc"); //_loc_2.startTime = _loc_3.readDate(); pkg.WriteDateTime(DateTime.Now.AddDays(-50)); //_loc_2.roomIntroduction = _loc_3.readUTF(); pkg.WriteString("Room Intro"); //_loc_2.roomType = _loc_3.readInt(); pkg.WriteInt(1); //_loc_2.maxCount = _loc_3.readInt(); pkg.WriteInt(10); //this._playerEnterRoomTime = _loc_2.readDate(); //this._playerEffectiveTime = _loc_2.readInt(); pkg.WriteDateTime(DateTime.Now); pkg.WriteDateTime(DateTime.Now.AddDays(1)); client.SendTCP(pkg); return 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(info.ValidCount); } pkg.WriteInt(p.EquipEffect.Count); foreach (int i in p.EquipEffect) { pkg.WriteInt(i); } } SendTCP(pkg); }
public void SendChatMessage(string msg, GamePlayer player, bool team) { GSPacketIn pkg = new GSPacketIn((byte)eFightPackageType.CHAT, player.CurrentRoom.Game.Id); pkg.WriteInt(player.GamePlayerId); pkg.WriteBoolean(team); pkg.WriteString(msg); SendTCP(pkg); }
public void SendFindConsortiaAlly(int state, int gameid) { GSPacketIn pkg = new GSPacketIn((byte)eFightPackageType.FIND_CONSORTIA_ALLY, gameid); pkg.WriteInt(state); pkg.WriteInt((int)RateMgr.GetRate(eRateType.Riches_Rate)); SendTCP(pkg); }
public bool HandleCommand(TankGameLogicProcessor process, GamePlayer player, GSPacketIn packet) { if (player.CurrentGame.Data.CurrentIndex == player && player.CurrentGame.Data.Players[player].State != TankGameState.DEAD) { if (player.CurrentGame.Data.CurrentFire == null) player.CurrentGame.Data.CurrentFire = player; int x = packet.ReadInt(); int y = packet.ReadInt(); if (Math.Abs(player.CurrentGame.Data.Players[player].X - x) > 100) { //player.Out.SendMessage(eMessageType.ALERT, LanguageMgr.GetTranslation("Game.Server.SceneGames.TankHandle")); StatMgr.LogErrorPlayer(player.PlayerCharacter.ID, player.PlayerCharacter.UserName, player.PlayerCharacter.NickName, ItemRemoveType.FireError, player.CurrentGame.Data.Players[player].X.ToString() + " to " + x.ToString() + ",MapID:" + player.CurrentGame.Data.MapIndex); player.Client.Disconnect(); return false; ; } int force = packet.ReadInt(); int angle = packet.ReadInt(); TankData data = player.CurrentGame.Data; Tile shape = Managers.BallMgr.FindTile(data.CurrentBall.ID); GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD, player.PlayerCharacter.ID); pkg.WriteByte((byte)TankCmdType.FIRE); pkg.WriteInt(data.AddBall); for (int i = 0; i < data.AddBall; i++) { if (player.CurrentGame.Data.ReduceFireBombs) { if (data.IsFastSpeed()) { StatMgr.LogErrorPlayer(player.PlayerCharacter.ID, player.PlayerCharacter.UserName, player.PlayerCharacter.NickName, ItemRemoveType.FastError, "MapID:" + player.CurrentGame.Data.MapIndex); player.Client.Disconnect(); return false; ; } data.FireLogin = true; double reforce = 1; int reangle = 0; if (i == 1) { reforce = 0.9; reangle = -5; } else if (i == 2) { reforce = 1.1; reangle = 5; } int vx = (int)(force * reforce * Math.Cos((double)(angle + reangle) / 180 * Math.PI)); int vy = (int)(force * reforce * Math.Sin((double)(angle + reangle) / 180 * Math.PI)); data.PhyID++; BombObject bomb = new BombObject(data.PhyID, BallMgr.GetBallType(data.CurrentBall.ID), data.Players[player], shape, data.CurrentBall.Radii, data.AddMultiple < 1, data.CurrentBall.Mass, data.CurrentBall.Weight, data.CurrentBall.Wind, data.CurrentBall.DragIndex, data.BallPower); bomb.SetXY(x, y); bomb.setSpeedXY(vx, vy); data.CurrentMap.AddPhysical(bomb); pkg.WriteBoolean(bomb.IsHole); pkg.WriteInt(bomb.Id); pkg.WriteInt(x); pkg.WriteInt(y); pkg.WriteInt(vx); pkg.WriteInt(vy); pkg.WriteInt(bomb.Actions.Count); foreach (BombAction action in bomb.Actions) { pkg.WriteInt(action.TimeInt); pkg.WriteInt(action.Type); pkg.WriteInt(action.Param1); pkg.WriteInt(action.Param2); pkg.WriteInt(action.Param3); pkg.WriteInt(action.Param4); } data.SetRunTime((int)bomb.RunTime); } } player.CurrentGame.SendToAll(pkg); data.FireLogin = false; if (data.Bombs || data.Players[player].State == TankGameState.DEAD) { data.TotalDelay += data.CurrentBall.Delay; process.SendArk(player.CurrentGame, player); player.PropInventory.AddItemTemplate(PropItemMgr.GetRandomFightProp(data.MapIndex)); data.Players[player].SetDander(20); process.SendPlayFinish(player.CurrentGame, player); //GSPacketIn pkgMsg = new GSPacketIn((byte)ePackageType.GAME_CMD); //pkgMsg.WriteByte((byte)TankCmdType.PLAYFINISH); //pkgMsg.WriteInt(player.CurrentGame.Data.TurnNum); //player.CurrentGame.SendToAll(pkgMsg); } return true; } return false; }
public void SendChangeGameType(BaseRoom room) { GSPacketIn pkg = new GSPacketIn((byte)eFightPackageType.CHANGE_GAME_TYPE) { Parameter1 = room.RoomId }; pkg.WriteInt((int)room.GameType); SendTCP(pkg); }
/* internal void SendAttackEffect(Living player, int type) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD); pkg.Parameter1 = player.Id; pkg.WriteByte((byte)eTankCmdType.ATTACKEFFECT); pkg.WriteBoolean(true); pkg.WriteInt(type); SendToAll(pkg); } */ internal void SendSyncLifeTime() { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD); //pkg.Parameter2 = -1; pkg.WriteByte((byte)eTankCmdType.SYNC_LIFETIME); pkg.WriteInt(m_lifeTime); SendToAll(pkg); }
internal void SendStartLoading(int maxTime) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD); pkg.WriteByte((byte)eTankCmdType.GAME_LOAD); pkg.WriteInt(maxTime); pkg.WriteInt(m_map.Info.ID); pkg.WriteInt(m_loadingFiles.Count); foreach (LoadingFileInfo file in m_loadingFiles) { pkg.WriteInt(file.Type); pkg.WriteString(file.Path); pkg.WriteString(file.ClassName); } pkg.WriteInt(1);//petSkill Count for (int i = 0; i < 1; i++) { pkg.WriteString("1");//_loc_7.pic = event.pkg.readUTF(); pkg.WriteString("");//_loc_7.effect = event.pkg.readUTF(); } SendToAll(pkg); }
internal void SendRemovePhysicalObj(PhysicalObj obj) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD); pkg.WriteByte((byte)eTankCmdType.DISAPPEAR); pkg.WriteInt(obj.Id); SendToAll(pkg); //TODO 完成删除物品 }
internal void SendRemoveLiving(int id) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD); pkg.WriteByte((byte)eTankCmdType.DISAPPEAR); pkg.WriteInt(id); SendToAll(pkg); //TODO 完成删除物品 }
public override void OnStopping(BaseSceneGame game, Game.Base.Packets.GSPacketIn pkg) { base.OnStopping(game, pkg); game.BeginTimer(TIMEOUT / 2); TankData data = game.Data; pkg.WriteByte((byte)data.Players.Count); int winTeam = -1; int lastTeam = -1; data.killFlag = false; foreach (KeyValuePair <GamePlayer, Player> p in data.Players) { //if(p.Value.TotalHurt > 0) //{ // data.killFlag = true; //} if (winTeam == -1 && p.Value.Blood > 0) { if (game.GameMode == eGameMode.FLAG) { if (p.Value.IsCaptain) { winTeam = p.Key.CurrentTeamIndex; break; } else { lastTeam = p.Key.CurrentTeamIndex; } } else { winTeam = p.Key.CurrentTeamIndex; break; } } } //if (!data.killFlag) //{ // game.BeginTimer(3000); //} if (winTeam == -1 && game.Data.CurrentIndex == null) { winTeam = lastTeam; } if (winTeam == -1) { if (game.Data.CurrentFire != null) { winTeam = game.Data.CurrentFire.CurrentTeamIndex; } else { winTeam = data.LastDead; } } int GP; //E等级差=(对方平均等级+5)-玩家等级;取值区间(1~9); // P赢=4*[(对方平均等级+5)-玩家等级]+伤害的血量*0.2%+击杀数*2+(命中次数/玩家总的回合次数)*8; //P输=1*[(对方平均等级+5)-玩家等级]+伤害的血量*0.2%+击杀数*2+(命中次数/玩家总的回合次数)*8 // P赢=[2+伤害的血量*0.1%+击杀数*0.5+(命中次数/玩家总的回合次数)*2]*[(对方平均等级+10)-玩家等级] //P输=[伤害的血量*0.1%+击杀数*0.5+(命中次数/玩家总的回合次数)*2]*[(对方平均等级+10)-玩家等级]; // P赢=[2+伤害的血量*0.1%+击杀数*0.5+(命中次数/玩家总的回合次数)*2]*对方平均等级*[1+(总击杀数-1)*33%] //P输=[伤害的血量*0.1%+击杀数*0.5+(命中次数/玩家总的回合次数)*2]*对方平均等级*[1+(总击杀数-1)*33%] //P赢=[2+伤害的血量*0.1%+击杀数*0.5+(命中次数/玩家总的回合次数)*2]*对方平均等级*[0.9+(游戏开始时对方玩家人数-1)*30%] //P输=[伤害的血量*0.1%+击杀数*0.5+(命中次数/玩家总的回合次数)*2]*对方平均等级*[0.9+(游戏开始时对方玩家人数-1)*30%] //bool flag = data.GameStart.AddMinutes(1).CompareTo(DateTime.Now) > 0; string winStr = LanguageMgr.GetTranslation("Game.Server.SceneGames.OnStopping.Msg5"); GamePlayer winPlayer = null; string loseStr = LanguageMgr.GetTranslation("Game.Server.SceneGames.OnStopping.Msg5"); GamePlayer losePlayer = null; foreach (KeyValuePair <GamePlayer, Player> p in data.Players) { if (game.RoomType == 0) { p.Key.PlayerCharacter.CheckCount++; } else { p.Key.PlayerCharacter.CheckCount += 2; } p.Key.Out.SendCheckCode(); if (p.Value.TotalHurt > 0) { data.killFlag = true; } if (game.GameClass == eGameClass.CONSORTIA) { if (p.Key.CurrentTeamIndex == winTeam) { winStr += " [" + p.Key.PlayerCharacter.NickName + "] "; winPlayer = p.Key; } else { loseStr += " [" + p.Key.PlayerCharacter.NickName + "] "; losePlayer = p.Key; } } } int riches = 0; if (game.GameClass == eGameClass.CONSORTIA) { winStr += LanguageMgr.GetTranslation("Game.Server.SceneGames.OnStopping.Msg1") + losePlayer.PlayerCharacter.ConsortiaName + LanguageMgr.GetTranslation("Game.Server.SceneGames.OnStopping.Msg2"); loseStr += LanguageMgr.GetTranslation("Game.Server.SceneGames.OnStopping.Msg3") + winPlayer.PlayerCharacter.ConsortiaName + LanguageMgr.GetTranslation("Game.Server.SceneGames.OnStopping.Msg4"); riches = ConsortiaMgr.ConsortiaFight(winPlayer.CurrentTeamIndex == 1 ? data.ConsortiaID1 : data.ConsortiaID2, winPlayer.CurrentTeamIndex == 1 ? data.ConsortiaID2 : data.ConsortiaID1, game.Data.Players, game.RoomType, game.GameClass, data.persons[winPlayer.CurrentTeamIndex].TotalKillHealth); GameServer.Instance.LoginServer.SendConsortiaFight(winPlayer.PlayerCharacter.ConsortiaID, riches, winStr); //GameServer.Instance.LoginServer.SendConsortiaFight(losePlayer.PlayerCharacter.ConsortiaID, -riches, loseStr); } foreach (KeyValuePair <GamePlayer, Player> p in data.Players) { GP = 1; if (p.Value.State != TankGameState.LOSE) { if (game.RoomType == eRoomType.PAIRUP) { p.Key.PlayerCharacter.Total++; } double level = (data.TotalLevel - data.persons[p.Key.CurrentTeamIndex].TotalLevel) / (data.TotalPerson - data.persons[p.Key.CurrentTeamIndex].TeamPerson); double disLevel = level + 10 - p.Key.PlayerCharacter.Grade; if (p.Key.CurrentTeamIndex == winTeam) { if (game.RoomType == eRoomType.PAIRUP) { p.Key.PlayerCharacter.Win++; } //GP = (int)Math.Ceiling((((data.killFlag ? 2 : 0) + (double)p.Value.TotalHurt * 0.001 + p.Value.TotalKill * 0.5 + (p.Value.HitNum / (p.Value.BoutNum == 0 ? 1 : p.Value.BoutNum)) * 2) * level * (1 + (data.persons[p.Key.CurrentTeamIndex].TatolKill - 1) * 0.33))); GP = (int)Math.Ceiling((((data.killFlag ? 2 : 0) + (double)p.Value.TotalHurt * 0.001 + p.Value.TotalKill * 0.5 + (p.Value.HitNum / (p.Value.BoutNum == 0 ? 1 : p.Value.BoutNum)) * 2) * level * (0.9 + (data.persons[p.Key.CurrentTeamIndex].TeamPerson - 1) * 0.3))); } else { GP = (int)Math.Ceiling(((double)p.Value.TotalHurt * 0.001 + p.Value.TotalKill * 0.5 + (p.Value.HitNum / (p.Value.BoutNum == 0 ? 1 : p.Value.BoutNum)) * 2) * level * (0.9 + (data.persons[p.Key.CurrentTeamIndex].TeamPerson - 1) * 0.3)); } bool isMarried = false; if (p.Key.PlayerCharacter.IsMarried) { foreach (GamePlayer q in data.Players.Keys) { if (q.PlayerCharacter.ID != p.Key.PlayerCharacter.ID) { if (q.CurrentTeamIndex == p.Key.CurrentTeamIndex && p.Key.PlayerCharacter.SpouseID == q.PlayerCharacter.ID) { GP = (int)(GP * 1.2); isMarried = true; } } } } p.Key.QuestInventory.CheckWin(data.MapIndex, (int)game.GameMode, game.ScanTime, p.Value.IsCaptain, data.persons[p.Key.CurrentTeamIndex].TeamPerson, data.TotalPerson - data.persons[p.Key.CurrentTeamIndex].TeamPerson, p.Key.CurrentTeamIndex == winTeam, game.GameClass == eGameClass.CONSORTIA, (int)game.RoomType, isMarried); double AAS = AntiAddictionMgr.GetAntiAddictionCoefficient(p.Key.PlayerCharacter.AntiAddiction); GP = (int)(GP * AAS); GP = (int)(GP * RateMgr.GetRate(eRateType.Experience_Rate)); GP *= p.Key.BuffInventory.GPMultiple(); if (game.RoomType != eRoomType.PAIRUP && (disLevel <= 0 || disLevel >= 20)) { GP = 1; } if (AAS < 10E-6) { GP = 0; } else { if (GP < 1) { GP = 1; } } p.Key.SetGP(GP); Dictionary <int, int> requestItems = p.Key.QuestInventory.GetRequestItems(); List <MapGoodsInfo> questItems = Managers.MapMgr.GetQuestGoodsAll(data.MapIndex); foreach (MapGoodsInfo questID in questItems) { if (requestItems.ContainsKey(questID.GoodsID) && requestItems[questID.GoodsID] > 0) { int total = random.Next(questID.Value + 1); if (p.Key.CurrentTeamIndex != winTeam) { total = total / 2; } else if (total < 1) { total = 1; } if (total < 1) { continue; } int count = requestItems[questID.GoodsID] > total ? total : requestItems[questID.GoodsID]; ItemTemplateInfo temp = Bussiness.Managers.ItemMgr.GetSingleGoods(questID.GoodsID); p.Key.TempInventory.AddItemTemplate(temp, questID, count); requestItems[questID.GoodsID] -= count; } } } //p.Value.IsTakeOut = true; pkg.WriteInt(p.Key.PlayerCharacter.ID); pkg.WriteBoolean(winTeam == p.Key.CurrentTeamIndex); pkg.WriteInt(p.Key.PlayerCharacter.Grade); pkg.WriteInt(p.Key.PlayerCharacter.GP); pkg.WriteInt((int)p.Value.TotalKill); pkg.WriteInt(p.Value.TotalHurt); pkg.WriteInt(GP); pkg.WriteInt((int)p.Value.HitNum); pkg.WriteInt((int)p.Value.BoutNum); pkg.WriteInt(p.Value.Offer); if (data.persons[p.Key.CurrentTeamIndex].TotalKillHealth > 0) { p.Value.IsTakeOut = true; if (p.Key.CurrentGame != null) { p.Key.CurrentGame.IsTakeOut = true; } } pkg.WriteBoolean(p.Value.IsTakeOut); } pkg.WriteInt(riches); //pkg.WriteBoolean(data.killFlag); pkg.WriteInt(data.TotalPerson / 2); data.InsertGameInfo(game, winTeam); GamePlayer[] list = data.Players.Keys.ToArray(); foreach (GamePlayer p in list) { if (data.Players[p].State == TankGameState.LOSE) { data.Players.Remove(p); } else { //data.Players[p].Reset(); //p.PropInventory.Clear(); //if (!killFlag) //{ // if (p.CurrentGame.GameState != eGameState.FREE) // { // p.CurrentGame.ShowArk(p.CurrentGame, p); // } //} } } }