public void Read(TCPBinaryReader br) { if (br == null) { return; } Exp = br.ReadUInt32(); AccountExp = br.ReadUInt32(); Coin = br.ReadUInt32(); Cash = br.ReadUInt32(); Metal = br.ReadUInt32(); Nutrient = br.ReadUInt32(); Power = br.ReadUInt32(); RewardCharList = br.ReadList <RewardCharInfo>(); RewardItemList = br.ReadList <ItemInfo>(); }
private void ParsePayload(byte[] memory, int size) { using (MemoryStream ms = new MemoryStream(memory, 0, size)) using (TCPBinaryReader br = new TCPBinaryReader(ms)) { TcpHeader header = br.ReadObj <TcpHeader>(); HParam type = (HParam)header.PacketNumber; if (type == HParam.CharacterCreate)//캐릭터 생성 구간. { CharInfo info = br.ReadObj <CharInfo>(); string name = Translate.GetTranslate(info.Name.Split('_')[2]); byte grade = info.Grade; ConsoleColor color = ConsoleColor.White; if (grade >= 4) { color = ConsoleColor.Yellow; CLI.ShowToast("PCAP", "캐릭터 획득", $"{(Grade)grade} 등급 {name} 획득했다!", ""); } CLI.PrintQueueLog(Channel.One, $"{(Grade)grade} 등급 {name} 획득했다!", color); if (RewardChar.ContainsKey(name) == true) { RewardChar[name]++; } else { RewardChar[name] = 1; } } else if (type == HParam.CheckNetwork || type == HParam.Ping || type == HParam.SetAuto || type == HParam.Packet || type == HParam.BattleLoginSuccess || type == HParam.BattleLogout || type == HParam.QUESTUPDATENTF || type == HParam.EnterStageSuccess) { //무시해도 되는 부분. } else if (type == HParam.ChangeWave)//웨이브 클리어 했을때. { BuffList.Clear(); byte NextWaveStep = br.ReadByte(); CurrentWave = NextWaveStep; RewardInfo ClearRewardInfo = br.ReadObj <RewardInfo>(); List <CharEXPLevel> pcExpAndLevelupList = br.ReadList <CharEXPLevel>(); List <CharSkillExpLevelInfo> SkillExpAndLevelupList = br.ReadList <CharSkillExpLevelInfo>(); byte IsApplyOpenUI = br.ReadByte(); ulong OpenUI_ActorID = br.ReadUInt64(); byte WaveClearRank = br.ReadByte(); CLI.PrintQueueLog(Channel.One, $"다음 웨이브 : {NextWaveStep + 1} ", ConsoleColor.White); ClearRewardInfo.RewardCharList.ForEach(element => { CLI.PrintQueueLog(Channel.One, element.CharString, ConsoleColor.Cyan); }); ClearRewardInfo.RewardItemList.ForEach(element => { CLI.PrintQueueLog(Channel.One, element.ItemString + " : " + element.StackCount, ConsoleColor.Cyan); }); pcExpAndLevelupList.ForEach(element => { CLI.PrintQueueLog(Channel.One, PIDMap[element.CharID] + " Level UP " + element.BeforeLevel + " =>" + element.AfterLevel, ConsoleColor.Cyan); }); SkillExpAndLevelupList.ForEach(element => { element.SkillInfo.ForEach(skill => { if (skill.IsLevelUp == 1) { CLI.PrintQueueLog(Channel.One, PIDMap[element.CharID] + " : " + skill.SkillString + " SkillLevel UP " + skill.BeforeLevel + " =>" + skill.AfterLevel, ConsoleColor.Cyan); } }); }); CLI.PrintQueueLog(Channel.One, new string('─', CLI.channelGap), ConsoleColor.White, ConsoleColor.Black, false); } //else if (type == HParam.CharInfo){} else if (type == HParam.Exp) { var PID = br.ReadUInt64(); var Exp = br.ReadUInt32(); var Offset = br.ReadUInt32(); CLI.PrintQueueLog(Channel.One, $"{PIDMap[PID].Name} {Exp}경험치 ({Offset}상승)"); } else if (type == HParam.LevelUp) { var PID = br.ReadUInt64(); var Level = br.ReadByte(); var NextExp = br.ReadInt32(); var MaxEnchant = br.ReadUInt16(); CLI.PrintQueueLog(Channel.One, $"{PIDMap[PID].Name} {Level}으로 레벨업! 다음 경험치 : {NextExp}"); } else if (type == HParam.FavorPoint) { var ActorID = br.ReadUInt64(); var CurrentFavorPoint = br.ReadUInt32(); var OffSet = br.ReadInt32(); CLI.PrintQueueLog(Channel.One, $"{LoadedMap[ActorID].Name} 호감도 {CurrentFavorPoint/100.0} {OffSet/100.0} 상승"); } else if (type == HParam.StageClear) { foreach (var kv in RewardChar) { CLI.PrintQueueLog(Channel.Zero, $"{kv.Key} {kv.Value} 개 얻음."); } } else if (type == HParam.StageClearUpdate) { var UID = br.ReadUInt64(); var StageKeyString = br.ReadString(); var ClearCount = br.ReadInt32(); var MissionInfoList = br.ReadList <MissionInfo>(); CLI.CleanQueue(Channel.Zero); CLI.PrintQueueLog(Channel.Zero, $"{StageKeyString}클리어! ({ClearCount}회 클리어됨.)"); } else if (type == HParam.GiveBuffList) { List <GiveBuffInfo> infoList = br.ReadList <GiveBuffInfo>(); // GUI.PrintQueueLog(Channel.Zero, new string('─', GUI.channelGap), ConsoleColor.White, false); BuffList.AddRange(infoList); /*infoList.ForEach(element => * { * if ((BuffType)element.AttrType != BuffType.MAX) * { * GUI.PrintQueueLog(Channel.Zero, LoadedMap[element.FromID].Name + " Buffed " + LoadedMap[element.ToID].Name + " " + * (BuffType)element.AttrType + " : " + element.AttrValue * 100 + $"% ({element.LeftRoundCount})Left ", ConsoleColor.Yellow); * } * });*/ ParseBuffList(); } else if (type == HParam.GiveBuff) { GiveBuffInfo info = br.ReadObj <GiveBuffInfo>(); BuffList.Add(info); //GUI.PrintQueueLog(Channel.Zero, new string('─', GUI.channelGap), ConsoleColor.White, false); /*if ((BuffType)info.AttrType != BuffType.MAX) * { * GUI.PrintQueueLog(Channel.Zero, LoadedMap[info.FromID].Name + " Buffed " + LoadedMap[info.ToID].Name + " " + * (BuffType)info.AttrType + " : " + info.AttrValue * 100 + $"% ({info.LeftRoundCount})Left ", ConsoleColor.Yellow); * }*/ ParseBuffList(); } else if (type == HParam.RemoveBuffList) { List <RemoveBuffInfo> infoList = br.ReadList <RemoveBuffInfo>(); //GUI.PrintQueueLog(Channel.Zero, new string('─', GUI.channelGap), ConsoleColor.White, false); infoList.ForEach(element => { BuffList.Remove(BuffList.Find(buff => buff.BuffID == element.BuffID)); //GUI.PrintQueueLog(Channel.Zero, LoadedMap[element.FromID].Name + " Buff Removed " + LoadedMap[element.ToID].Name, ConsoleColor.Red); }); ParseBuffList(); } else if (type == HParam.RemoveBuff) { RemoveBuffInfo info = br.ReadObj <RemoveBuffInfo>(); BuffList.Remove(BuffList.Find(buff => buff.BuffID == info.BuffID)); } else if (type == HParam.Hp) { ulong Trid = br.ReadUInt64(); ulong Aid = br.ReadUInt64(); int HP = br.ReadInt32(); int MaxHP = br.ReadInt32(); int Damage = br.ReadInt32(); ulong Aid_From = br.ReadUInt64(); byte DamageType = br.ReadByte(); byte BuffEffectType = br.ReadByte(); byte IsCri = br.ReadByte(); CLI.PrintQueueLog(Channel.One, $"{LoadedMap[Aid_From].Name} 피해 입힘 => {LoadedMap[Aid].Name} Dmg : {Damage}{(IsCri == 1 ? "치명타!" : "")}", IsCri == 1 ? ConsoleColor.Red : ConsoleColor.White); if (HP <= 0) { Console.ForegroundColor = ConsoleColor.Red; } else if (((double)HP / MaxHP) <= 0.25 && LoadedMap[Aid].TeamId == 0) { Console.ForegroundColor = ConsoleColor.Yellow; } else { Console.ForegroundColor = ConsoleColor.White; } if (LoadedMap[Aid].TeamId == 1)//적군 { MonsterEnterInfo mob = LoadedMap[Aid] as MonsterEnterInfo; byte wave = mob.WaveStep; var xPos = CLI.tableWidth * (wave + 1) + CLI.alt + CLI.gap * wave; CLI.RemoveCharacter(xPos, 0, mob.GridPosIndex, 0, 1); CLI.PrintCharacter(xPos, 0, mob.GridPosIndex, HP + " / " + MaxHP, 0, 1); } else { CharEnterInfo pc = LoadedMap[Aid] as CharEnterInfo; CLI.RemoveCharacter(0, 0, pc.GridPosIndex, 0, 1); CLI.PrintCharacter(0, 0, pc.GridPosIndex, HP + " / " + MaxHP, 0, 1); } Console.ForegroundColor = ConsoleColor.White; } else if (type == HParam.AttackTarget) { List <AttackTargetInfo> AttackTargetList = br.ReadList <AttackTargetInfo>(); byte IsNotRemove = br.ReadByte(); byte TargetGridPos = br.ReadByte(); } else if (type == HParam.StartTurn) { byte CurrentRound = br.ReadByte(); int CurrentGlobalTurn = br.ReadInt32(); List <TurnInfo> TurnList = br.ReadList <TurnInfo>(); List <TurnInfo> DisplayTurnList = br.ReadList <TurnInfo>();//실제로 보이는 행동력 리스트 byte IsSkillSelectTurn = br.ReadByte(); byte isReconnect = br.ReadByte(); DisplayTurnList.ForEach(element => { EnterInfo info = LoadedMap[element.Aid]; double prev = element.PreTurnPos; double turn = element.TurnPos; int x = 0; int grid = 0; //GUI.PrintQueueLog($"{prev} {turn}", ConsoleColor.Blue); Console.ForegroundColor = ConsoleColor.White; if (turn < 10) { Console.ForegroundColor = ConsoleColor.Red; } else if (turn >= 20) { Console.ForegroundColor = ConsoleColor.Blue; } if (info.TeamId == 1)//적군 { MonsterEnterInfo mob = info as MonsterEnterInfo; byte wave = mob.WaveStep; x = CLI.tableWidth * (wave + 1) + CLI.alt + CLI.gap * wave; grid = mob.GridPosIndex; } else if (info.TeamId == 0) { grid = info.GridPosIndex; } CLI.RemoveCharacter(x, 0, grid, 0, -1); CLI.PrintCharacter(x, 0, grid, turn.ToString("0.0AP"), 0, -1); Console.ForegroundColor = ConsoleColor.White; }); } else if (type == HParam.ItemCreate) { byte UpdateType = br.ReadByte(); ItemInfo Info = br.ReadObj <ItemInfo>(); CLI.PrintQueueLog(Channel.One, $"{Info.ItemString} 획득했다! 현재 {Info.StackCount}개 있음.", ConsoleColor.White); } else if (type == HParam.LoadResource) { string StageKeyString = br.ReadString(); CurrentWave = 0; List <CharEnterInfo> PCEnterInfoList = br.ReadList <CharEnterInfo>(); List <MonsterEnterInfo> MonsterEnterInfoList = br.ReadList <MonsterEnterInfo>(); LoadedMap.Clear(); PIDMap.Clear(); CLI.RemoveRange(0, 0, CLI.tableWidth / 2); Console.ForegroundColor = ConsoleColor.White; CLI.PrintGrid(0, 0); CLI.PrintQueueLog(Channel.One, $"스테이지 : {StageKeyString} 입장.", ConsoleColor.White); CLI.PrintQueueLog(Channel.One, new string('─', CLI.channelGap), ConsoleColor.White, ConsoleColor.Black, false); PCEnterInfoList.ForEach(element => { string name = Translate.GetTranslate(element.Name.Split('_')[2]); element.Name = name; PIDMap[element.CharacterID] = element; LoadedMap[element.InstanceID] = element; //GUI.PrintQueueLog(Channel.Zero, $"Char ID : {element.InstanceID} Name: {name} Added { element.GridPosIndex} Grid", ConsoleColor.Cyan); Console.ForegroundColor = ConsoleColor.White; CLI.PrintCharacter(0, 0, element.GridPosIndex, name); if (((double)element.HP / element.MaxHP) <= 0.25) { Console.ForegroundColor = ConsoleColor.Yellow; } CLI.PrintCharacter(0, 0, element.GridPosIndex, element.HP + " / " + element.MaxHP, 0, 1); Console.ForegroundColor = ConsoleColor.White; CLI.PrintCharacter(0, 0, element.GridPosIndex, element.MaxAP.ToString(), 0, -1); CLI.PrintCharacter(0, 0, element.GridPosIndex, (Grade)element.Grade + " " + element.Level, 0, -2); }); int lastWave = -1; List <(string, int)> SameName = new List <(string, int)>(); Dictionary <(string, int), int> SameIndex = new Dictionary <(string, int), int>(); MonsterEnterInfoList.ForEach(element => { SameName.Add((element.Name, element.WaveStep)); SameIndex[(element.Name, element.WaveStep)] = 0; }