public void SendFindConsortiaAlly(int state, int gameid) { GSPacketIn gSPacketIn = new GSPacketIn(69, gameid); gSPacketIn.WriteInt(state); gSPacketIn.WriteInt((int)RateMgr.GetRate(eRateType.Riches_Rate)); this.SendTCP(gSPacketIn); }
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 void SendAddRoom(BaseRoom room) { GSPacketIn gSPacketIn = new GSPacketIn(64); gSPacketIn.WriteInt(room.RoomId); gSPacketIn.WriteInt((int)room.GameType); gSPacketIn.WriteInt(room.GuildId); List <GamePlayer> players = room.GetPlayers(); gSPacketIn.WriteInt(players.Count); foreach (GamePlayer current in players) { gSPacketIn.WriteInt(current.PlayerCharacter.ID); gSPacketIn.WriteString(current.PlayerCharacter.NickName); gSPacketIn.WriteBoolean(current.PlayerCharacter.Sex); gSPacketIn.WriteByte(current.PlayerCharacter.typeVIP); gSPacketIn.WriteInt(current.PlayerCharacter.VIPLevel); gSPacketIn.WriteInt(current.PlayerCharacter.Hide); gSPacketIn.WriteString(current.PlayerCharacter.Style); gSPacketIn.WriteString(current.PlayerCharacter.Colors); gSPacketIn.WriteString(current.PlayerCharacter.Skin); gSPacketIn.WriteInt(current.PlayerCharacter.Offer); gSPacketIn.WriteInt(current.PlayerCharacter.GP); gSPacketIn.WriteInt(current.PlayerCharacter.Grade); gSPacketIn.WriteInt(current.PlayerCharacter.Repute); gSPacketIn.WriteInt(current.PlayerCharacter.ConsortiaID); gSPacketIn.WriteString(current.PlayerCharacter.ConsortiaName); gSPacketIn.WriteInt(current.PlayerCharacter.ConsortiaLevel); gSPacketIn.WriteInt(current.PlayerCharacter.ConsortiaRepute); gSPacketIn.WriteInt(current.PlayerCharacter.badgeID); gSPacketIn.WriteString(current.PlayerCharacter.WeaklessGuildProgressStr); gSPacketIn.WriteInt(current.PlayerCharacter.Attack); gSPacketIn.WriteInt(current.PlayerCharacter.Defence); gSPacketIn.WriteInt(current.PlayerCharacter.Agility); gSPacketIn.WriteInt(current.PlayerCharacter.Luck); gSPacketIn.WriteInt(current.PlayerCharacter.hp); gSPacketIn.WriteInt(current.PlayerCharacter.FightPower); gSPacketIn.WriteBoolean(current.PlayerCharacter.IsMarried); if (current.PlayerCharacter.IsMarried) { gSPacketIn.WriteInt(current.PlayerCharacter.SpouseID); gSPacketIn.WriteString(current.PlayerCharacter.SpouseName); } gSPacketIn.WriteDouble(current.GetBaseAttack()); gSPacketIn.WriteDouble(current.GetBaseDefence()); gSPacketIn.WriteDouble(current.GetBaseAgility()); gSPacketIn.WriteDouble(current.GetBaseBlood()); gSPacketIn.WriteInt(current.MainWeapon.TemplateID); gSPacketIn.WriteBoolean(current.CanUseProp); if (current.SecondWeapon != null) { gSPacketIn.WriteInt(current.SecondWeapon.TemplateID); gSPacketIn.WriteInt(current.SecondWeapon.StrengthenLevel); } else { gSPacketIn.WriteInt(0); gSPacketIn.WriteInt(0); } gSPacketIn.WriteDouble((double)RateMgr.GetRate(eRateType.Experience_Rate) * AntiAddictionMgr.GetAntiAddictionCoefficient(current.PlayerCharacter.AntiAddiction) * ((current.GPAddPlus == 0.0) ? 1.0 : current.GPAddPlus)); gSPacketIn.WriteDouble(AntiAddictionMgr.GetAntiAddictionCoefficient(current.PlayerCharacter.AntiAddiction) * ((current.OfferAddPlus == 0.0) ? 1.0 : current.OfferAddPlus)); gSPacketIn.WriteDouble((double)RateMgr.GetRate(eRateType.Experience_Rate)); gSPacketIn.WriteInt(GameServer.Instance.Configuration.ServerID); if (current.Pet == null) { gSPacketIn.WriteInt(0); } else { gSPacketIn.WriteInt(1); gSPacketIn.WriteInt(current.Pet.Place); gSPacketIn.WriteInt(current.Pet.TemplateID); gSPacketIn.WriteInt(current.Pet.ID); gSPacketIn.WriteString(current.Pet.Name); gSPacketIn.WriteInt(current.Pet.UserID); gSPacketIn.WriteInt(current.Pet.Level); gSPacketIn.WriteString(current.Pet.Skill); gSPacketIn.WriteString(current.Pet.SkillEquip); } List <AbstractBuffer> allBuffer = current.BufferList.GetAllBuffer(); gSPacketIn.WriteInt(allBuffer.Count); foreach (AbstractBuffer current2 in allBuffer) { BufferInfo info = current2.Info; gSPacketIn.WriteInt(info.Type); gSPacketIn.WriteBoolean(info.IsExist); gSPacketIn.WriteDateTime(info.BeginDate); gSPacketIn.WriteInt(info.ValidDate); gSPacketIn.WriteInt(info.Value); gSPacketIn.WriteInt(info.ValidCount); } gSPacketIn.WriteInt(current.EquipEffect.Count); foreach (ItemInfo current3 in current.EquipEffect) { gSPacketIn.WriteInt(current3.TemplateID); gSPacketIn.WriteInt(current3.Hole1); } } this.SendTCP(gSPacketIn); }
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); // } //} } } }
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); }