public ItemInfo(ref GSPacketIn pkg, bool isNullable) { if (isNullable) { if (pkg.ReadBoolean() == false) { isNull = true; return; } } else { BagType = pkg.ReadByte(); //bagtype } UserID = pkg.ReadInt(); // uid ItemID = pkg.ReadInt(); // item id Count = pkg.ReadInt(); // count Place = pkg.ReadInt(); // place TemplateID = pkg.ReadInt(); //TemplateID AttackCompose = pkg.ReadInt(); //Attack DefendCompose = pkg.ReadInt(); //Defence AgilityCompose = pkg.ReadInt(); //agi LuckCompose = pkg.ReadInt(); //Luck StrengthenLevel = pkg.ReadInt(); //StrengthenLevel IsBinds = pkg.ReadBoolean(); //IsBinds IsJudge = pkg.ReadBoolean(); // IsJudge BeginDate = pkg.ReadDateTime(); //BeginDate ValidDate = pkg.ReadInt(); //ValidDate Color = pkg.ReadString(); //Color Skin = pkg.ReadString(); //Skin IsUsed = pkg.ReadBoolean(); //IsUsed Hole1 = pkg.ReadInt(); //Hole1 Hole2 = pkg.ReadInt(); //Hole2 Hole3 = pkg.ReadInt(); //Hole3 Hole4 = pkg.ReadInt(); //Hole4 Hole5 = pkg.ReadInt(); //Hole5 Hole6 = pkg.ReadInt(); //Hole6 Pic = pkg.ReadString(); //template.pic RefineryLevel = pkg.ReadInt(); //RefineryLevel pkg.ReadDateTime(); if (isNullable) { pkg.ReadInt(); } pkg.ReadByte(); pkg.ReadInt(); pkg.ReadByte(); pkg.ReadInt(); }
public void HandleConsortiaUserPass(GSPacketIn packet) { packet.ReadInt(); packet.ReadBoolean(); int num = packet.ReadInt(); string consortiaName = packet.ReadString(); int num2 = packet.ReadInt(); packet.ReadString(); packet.ReadInt(); packet.ReadString(); packet.ReadInt(); string dutyName = packet.ReadString(); packet.ReadInt(); packet.ReadInt(); packet.ReadInt(); packet.ReadDateTime(); packet.ReadInt(); int dutyLevel = packet.ReadInt(); packet.ReadInt(); packet.ReadBoolean(); int right = packet.ReadInt(); packet.ReadInt(); packet.ReadInt(); packet.ReadInt(); int consortiaRepute = packet.ReadInt(); GamePlayer[] allPlayers = WorldMgr.GetAllPlayers(); GamePlayer[] array = allPlayers; for (int i = 0; i < array.Length; i++) { GamePlayer gamePlayer = array[i]; if (gamePlayer.PlayerCharacter.ID == num2) { gamePlayer.BeginChanges(); gamePlayer.PlayerCharacter.ConsortiaID = num; gamePlayer.PlayerCharacter.ConsortiaName = consortiaName; gamePlayer.PlayerCharacter.DutyName = dutyName; gamePlayer.PlayerCharacter.DutyLevel = dutyLevel; gamePlayer.PlayerCharacter.Right = right; gamePlayer.PlayerCharacter.ConsortiaRepute = consortiaRepute; ConsortiaInfo consortiaInfo = ConsortiaMgr.FindConsortiaInfo(num); if (consortiaInfo != null) { gamePlayer.PlayerCharacter.ConsortiaLevel = consortiaInfo.Level; } gamePlayer.CommitChanges(); } if (gamePlayer.PlayerCharacter.ConsortiaID == num) { gamePlayer.Out.SendTCP(packet); } } }
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); } } }
public static void PlayerInfo_LOGIN(ref PlayerInfo localPlayerInfo, ref GSPacketIn pkg) { localPlayerInfo.attack = pkg.ReadInt(); //attack localPlayerInfo.defence = pkg.ReadInt(); //def localPlayerInfo.agility = pkg.ReadInt(); //agil localPlayerInfo.luck = pkg.ReadInt(); //luck pkg.ReadInt(); //gp pkg.ReadInt(); //repute pkg.ReadInt(); //gold pkg.ReadInt(); //money pkg.ReadInt(); //PropBag.GetItemCount pkg.ReadInt(); //PlayerCharacter.Hide localPlayerInfo.fightPower = pkg.ReadInt(); //PlayerCharacter.FightPower pkg.ReadInt(); pkg.ReadInt(); pkg.ReadString(); //Master pkg.ReadInt(); pkg.ReadString(); //HoNorMaster pkg.ReadDateTime(); pkg.ReadBoolean(); //true pkg.ReadInt(); pkg.ReadInt(); pkg.ReadDateTime(); pkg.ReadDateTime(); pkg.ReadInt(); pkg.ReadDateTime(); pkg.ReadBoolean(); // false pkg.ReadInt(); //1599 pkg.ReadInt(); //1599 pkg.ReadString(); //honor pkg.ReadInt(); // 0 localPlayerInfo.sex = pkg.ReadBoolean(); //sex string tmpStr = pkg.ReadString(); //style & color localPlayerInfo.style = tmpStr.Split('&')[0]; pkg.ReadString(); //skin }
public static List <PlayerInfo> GameCreate_PlayerList(ref PlayerInfo localPlayerInfo, ref GSPacketIn pkg) { int num2 = pkg.ReadInt(); // number of players List <PlayerInfo> playersList = new List <PlayerInfo>(); for (int i = 0; i < num2; i++) { playersList.Add(new PlayerInfo()); pkg.ReadInt(); pkg.ReadString(); playersList[i].id = pkg.ReadInt(); playersList[i].nickname = pkg.ReadString(); if (localPlayerInfo.nickname == playersList[i].nickname) { localPlayerInfo.id = playersList[i].id; } pkg.ReadBoolean(); // is vip pkg.ReadInt(); // vip level playersList[i].sex = pkg.ReadBoolean(); // sex pkg.ReadInt(); playersList[i].style = pkg.ReadString(); playersList[i].color = pkg.ReadString(); playersList[i].skin = pkg.ReadString(); pkg.ReadInt(); // grade pkg.ReadInt(); // repute playersList[i].mainWeapon = pkg.ReadInt(); pkg.ReadInt(); pkg.ReadString(); pkg.ReadDateTime(); pkg.ReadInt(); pkg.ReadInt(); // Nimbus pkg.ReadInt(); // Corsotia Id pkg.ReadString(); //Corsotia name pkg.ReadInt(); // Corsotia level pkg.ReadInt(); // Corsotia repute pkg.ReadInt(); // win pkg.ReadInt(); // total pkg.ReadInt(); // fightPower pkg.ReadInt(); pkg.ReadInt(); pkg.ReadString(); pkg.ReadInt(); pkg.ReadString(); bool isMarried = pkg.ReadBoolean(); if (isMarried) { pkg.ReadInt(); pkg.ReadString(); } pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); playersList[i].team = pkg.ReadInt(); playersList[i].id = pkg.ReadInt(); playersList[i].blood = pkg.ReadInt(); } return(playersList); }
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 override void OnRecvPacket(GSPacketIn pkg) { this.m_lastRecv = pkg.Code; this.m_recvCount++; // Debug.Log("player ["+this.m_account+"]:"+DateTime.Now+" receive: "+pkg.Code+" (ePackageType."+(ePackageType)pkg.Code+")"); /*if (this.m_log != null) * { * this.m_log.WriteLine(Marshal.ToHexDump(string.Format("player [{0}]:{1} recive:", this.m_account, DateTime.Now), pkg.Buffer, 0, pkg.Length)); * }*/ switch (pkg.Code) { case 1: { //LOGIN if (pkg.ReadByte() != 0) { string str = pkg.ReadString(); Debug.Log(this.m_account + " login socket failed: " + str); this.m_state = ePlayerState.Stopped; this.LastError = "SocketError:" + str; break; } this.UserId = pkg.ClientID; pkg.ReadInt(); //4 this.m_playerId = pkg.Parameter1; localPlayerInfo = new PlayerInfo(); pkg.ReadInt(); //attack pkg.ReadInt(); //def pkg.ReadInt(); //agil pkg.ReadInt(); //luck pkg.ReadInt(); //gp pkg.ReadInt(); //repute pkg.ReadInt(); //gold pkg.ReadInt(); //money pkg.ReadInt(); //PropBag.GetItemCount pkg.ReadInt(); //PlayerCharacter.Hide pkg.ReadInt(); //PlayerCharacter.FightPower pkg.ReadInt(); pkg.ReadInt(); pkg.ReadString(); //Master pkg.ReadInt(); pkg.ReadString(); //HoNorMaster pkg.ReadDateTime(); pkg.ReadBoolean(); //true pkg.ReadInt(); pkg.ReadInt(); pkg.ReadDateTime(); pkg.ReadDateTime(); pkg.ReadInt(); pkg.ReadDateTime(); pkg.ReadBoolean(); // false pkg.ReadInt(); //1599 pkg.ReadInt(); //1599 pkg.ReadString(); //honor pkg.ReadInt(); // 0 localPlayerInfo.sex = pkg.ReadBoolean(); //sex string tmpStr = pkg.ReadString(); //style & color localPlayerInfo.style = tmpStr.Split('&')[0]; pkg.ReadString(); //skin Debug.Log("login socket success! pid " + this.m_playerId + " uid: " + this.UserId); Debug.Log("localPlayerInfo style: " + localPlayerInfo.style); UnityThread.executeInUpdate(() => { //Call StartGameHandler in ConnectorManager connectorManager.UpdateLocalPlayerPreview(); }); break; } case 2: { //KIT_USER Debug.Log("CMDType 2 KIT_USER"); this.m_state = ePlayerState.Stopped; this.LastError = "KickReason:" + pkg.ReadString(); Debug.Log(this.LastError); break; } case 3: { //SYS_MESS Debug.Log("CMDType 3 - SYS MESS"); int val = pkg.ReadInt(); Debug.Log("CMDType 3 val: " + val.ToString()); this.LastMsg = pkg.ReadString(); Debug.Log(this.LastMsg); break; } case 0x5b: { //GAME_CMD //Debug.Log("GAME_CMD"); eTankCmdType type = (eTankCmdType)pkg.ReadByte(); int pId = pkg.Parameter1; int LifeTime = pkg.Parameter2; Debug.Log("[CMD] " + ((eTankCmdType)type).ToString() + " - lifeTime: " + LifeTime.ToString()); switch (type) { case eTankCmdType.TAKE_CARD: // Debug.Log("TAKE_CARD "); // return; case eTankCmdType.GAME_OVER: // this.Act(new PlayerExecutable(this.EnterWaitingRoom)); // this.Act(new PlayerExecutable(this.CreateRoom)); // this.Act(new PlayerExecutable(this.StartGame)); UnityThread.executeInUpdate(() => { //Call StartGameHandler in ConnectorManager connectorManager.GameOverHandler(); }); return; case eTankCmdType.GAME_TIME: this.m_lifeTime = pkg.ReadInt(); Debug.Log("GAME_TIME sync: " + this.m_lifeTime.ToString()); return; case eTankCmdType.START_GAME: // Game.Logic/PVPGame.cs int size = pkg.ReadInt(); //number of players // List<PlayerInfo> Players = new List<PlayerInfo>(); for (int i = 0; i < size; i++) { // Players.Add(new PlayerInfo()); int tmpId = pkg.ReadInt(); // Players[i].id = pkg.ReadInt(); for (int j = 0; j < size; j++) { if (tmpId != playersList[j].id) { continue; } playersList[j].x = pkg.ReadInt(); playersList[j].y = pkg.ReadInt(); playersList[j].direction = pkg.ReadInt(); playersList[j].blood = pkg.ReadInt(); pkg.ReadInt(); //2 pkg.ReadInt(); //34 playersList[j].isMainPlayer = false; //check if player is this user //Debug.Log("thisPid: "+ this.m_playerId.ToString() + " - Pid: " + Players[i].id.ToString()); // if (playersList[j].id == this.m_playerId){ if (playersList[j].nickname == this.m_account) { playersList[j].isMainPlayer = true; this.m_posX = playersList[j].x; this.m_posY = playersList[j].y; } playersList[j].dander = pkg.ReadInt(); playersList[j].effectCount = pkg.ReadInt(); playersList[j].property3 = new List <int>(); playersList[j].property4 = new List <int>(); for (int k = 0; k < playersList[j].effectCount; k++) { playersList[j].property3.Add(pkg.ReadInt()); playersList[j].property4.Add(pkg.ReadInt()); } break; } } UnityThread.executeInUpdate(() => { //Call StartGameHandler in ConnectorManager connectorManager.StartGameHandler(playersList); }); this.m_state = ePlayerState.StartGame; return; case eTankCmdType.GAME_CREATE: this.m_gameCount++; pkg.ReadInt(); //Roomtype pkg.ReadInt(); //gametype pkg.ReadInt(); //Timetype int num2 = pkg.ReadInt(); // number of players this.playersList = new List <PlayerInfo>(); for (int i = 0; i < num2; i++) { this.playersList.Add(new PlayerInfo()); pkg.ReadInt(); pkg.ReadString(); this.playersList[i].id = pkg.ReadInt(); this.playersList[i].nickname = pkg.ReadString(); pkg.ReadBoolean(); // is vip pkg.ReadInt(); // vip level this.playersList[i].sex = pkg.ReadBoolean(); // sex pkg.ReadInt(); this.playersList[i].style = pkg.ReadString(); this.playersList[i].color = pkg.ReadString(); this.playersList[i].skin = pkg.ReadString(); pkg.ReadInt(); // grade pkg.ReadInt(); // repute this.playersList[i].mainWeapon = pkg.ReadInt(); pkg.ReadInt(); pkg.ReadString(); pkg.ReadDateTime(); pkg.ReadInt(); pkg.ReadInt(); // Nimbus pkg.ReadInt(); // Corsotia Id pkg.ReadString(); //Corsotia name pkg.ReadInt(); // Corsotia level pkg.ReadInt(); // Corsotia repute pkg.ReadInt(); // win pkg.ReadInt(); // total pkg.ReadInt(); // fightPower pkg.ReadInt(); pkg.ReadInt(); pkg.ReadString(); pkg.ReadInt(); pkg.ReadString(); bool isMarried = pkg.ReadBoolean(); if (isMarried) { pkg.ReadInt(); pkg.ReadString(); } pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); this.playersList[i].team = pkg.ReadInt(); this.playersList[i].id = pkg.ReadInt(); this.playersList[i].blood = pkg.ReadInt(); if (this.playersList[i].id == this.m_playerId) { this.m_team = this.playersList[i].team; this.m_blood = this.playersList[i].blood; } } this.m_state = ePlayerState.CreateGame; UnityThread.executeInUpdate(() => { //Call GameCreateHandler in ConnectorManager connectorManager.GameCreateHandler(this.playersList); }); return; case eTankCmdType.GAME_LOAD: pkg.ReadInt(); //maxTime int mapId = pkg.ReadInt(); UnityThread.executeInUpdate(() => { //Call LoadMapHandler in ConnectorManager connectorManager.GameLoadHandler(mapId); }); return; case eTankCmdType.LOAD: this.m_state = ePlayerState.Loading; // this.Act(new PlayerExecutable(this.SendLoadingComplete)); return; case eTankCmdType.TURN: Debug.Log("pId turn: " + pkg.Parameter1.ToString()); int wind = pkg.ReadInt(); pkg.ReadBoolean(); pkg.ReadByte(); pkg.ReadByte(); pkg.ReadByte(); bool isHiding = pkg.ReadBoolean(); //turnTime // TimeType int timeType = pkg.ReadInt(); List <BoxInfo> newBoxesList = new List <BoxInfo>(); int newBoxesCount = pkg.ReadInt(); for (int j = 0; j < newBoxesCount; j++) { newBoxesList.Add(new BoxInfo()); newBoxesList[j].id = pkg.ReadInt(); newBoxesList[j].x = pkg.ReadInt(); newBoxesList[j].y = pkg.ReadInt(); pkg.ReadInt(); // pkg.ReadBoolean(); } List <PlayerInfo> updatedPlayerList = new List <PlayerInfo>(); int listSize = pkg.ReadInt(); for (int j = 0; j < listSize; j++) { updatedPlayerList.Add(new PlayerInfo()); updatedPlayerList[j].id = pkg.ReadInt(); updatedPlayerList[j].isLiving = pkg.ReadBoolean(); updatedPlayerList[j].x = pkg.ReadInt(); updatedPlayerList[j].y = pkg.ReadInt(); updatedPlayerList[j].blood = pkg.ReadInt(); updatedPlayerList[j].isNoHole = pkg.ReadBoolean(); updatedPlayerList[j].energy = pkg.ReadInt(); updatedPlayerList[j].dander = pkg.ReadInt(); updatedPlayerList[j].shootCount = pkg.ReadInt(); } int turnIndex = pkg.ReadInt(); UnityThread.executeInUpdate(() => { //Call TurnHandler in ConnectorManager connectorManager.TurnHandler(pkg.Parameter1, newBoxesList, updatedPlayerList); }); // this.m_state = ePlayerState.Shoot; // this.m_shootCount++; //this.Act(new PlayerExecutable(this.Shoot)); return; case eTankCmdType.CURRENTBALL: bool special = pkg.ReadBoolean(); int currentBallId = pkg.ReadInt(); UnityThread.executeInUpdate(() => { //Call CurrentBallHandler in ConnectorManager connectorManager.CurrentBallHandler(pId, special, currentBallId); }); //pkg.WriteByte((byte)player.BallCount); return; case eTankCmdType.FIRE: int bombCount = pkg.ReadInt(); float lifeTime = 0; List <FireInfo> fireInfos = new List <FireInfo>(); for (int i = 0; i < bombCount; i++) { fireInfos.Add(new FireInfo()); // 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)); //Console.ReadLine(string.Format("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< vx:{0} vy:{1}", vx, vy)); // m_map.AddPhysical(bomb); // bomb.StartMoving(); pkg.ReadInt(); pkg.ReadInt(); fireInfos[i].isDigMap = pkg.ReadBoolean(); fireInfos[i].bomId = pkg.ReadInt(); fireInfos[i].x = pkg.ReadInt(); fireInfos[i].y = pkg.ReadInt(); fireInfos[i].vx = pkg.ReadInt(); fireInfos[i].vy = pkg.ReadInt(); fireInfos[i].bomInfoId = pkg.ReadInt(); //FlyingPartical //pkg.ReadString(bomb.BallInfo.FlyingPartical); pkg.ReadString(); pkg.ReadInt(); pkg.ReadInt(); //pkg.ReadInt(0); fireInfos[i].bomActionCount = pkg.ReadInt(); //Debug.Log("Bom Action count: "+ fireInfos[i].bomActionCount.ToString()); for (int j = 0; j < fireInfos[i].bomActionCount; j++) { fireInfos[i].timeInt.Add(pkg.ReadInt()); //0 ->null fireInfos[i].actionType.Add(pkg.ReadInt()); //0 ->null fireInfos[i].actionParam1.Add(pkg.ReadInt()); //0 ->null fireInfos[i].actionParam2.Add(pkg.ReadInt()); //0 ->null fireInfos[i].actionParam3.Add(pkg.ReadInt()); //0 ->null fireInfos[i].actionParam4.Add(pkg.ReadInt()); //0 ->null } //Debug.Log(fireInfos[i].ToString()); } UnityThread.executeInUpdate(() => { //Call FireHandler in ConnectorManager connectorManager.FireHandler(pId, fireInfos); }); return; case eTankCmdType.FIRE_TAG: bool tag = pkg.ReadBoolean(); byte speedTime = pkg.ReadByte(); UnityThread.executeInUpdate(() => { //Call FireTagHandler in ConnectorManager connectorManager.FireTagHandler(pId, tag, speedTime); }); return; case eTankCmdType.USING_PROP: byte propType = pkg.ReadByte(); int place = pkg.ReadInt(); int templateId = pkg.ReadInt(); UnityThread.executeInUpdate(() => { //Call UsingPropHandler in ConnectorManager connectorManager.UsingPropHandler(pId, propType, place, templateId); }); return; case eTankCmdType.MOVESTART: byte moveType = pkg.ReadByte(); int tx = pkg.ReadInt(); int ty = pkg.ReadInt(); byte dir = pkg.ReadByte(); bool isLiving = pkg.ReadBoolean(); string action = pkg.ReadString(); // is null or empty or "move" Debug.Log("MOVE type: " + moveType.ToString() + " tX: " + tx.ToString() + " tY:" + ty.ToString() + " dir: " + dir.ToString()); UnityThread.executeInUpdate(() => { //Call MoveStartHandler in ConnectorManager connectorManager.MoveStartHandler(pId, moveType, tx, ty, dir, isLiving); }); return; case eTankCmdType.DIRECTION: int direction = pkg.ReadInt(); UnityThread.executeInUpdate(() => { //Call CurrentBallHandler in ConnectorManager connectorManager.DirectionHandler(pId, direction); }); return; case eTankCmdType.DANDER: int playerId = pkg.Parameter1; int dander = pkg.ReadInt(); UnityThread.executeInUpdate(() => { //Call CurrentBallHandler in ConnectorManager connectorManager.DanderHandler(pId, dander); }); return; default: Debug.Log("Unhandled type: " + type.ToString()); return; } break; } case 0x5e: { //GAME_CREATE_ROOM Debug.Log("GET GAME_CREATE_ROOM PACKAGE"); if (pkg.ReadInt() != 0) //if (m_isHost == false) { this.m_state = ePlayerState.Room; this.m_isHost = true; this.m_roomCount++; //this.Act(new PlayerExecutable(this.StartGame)); } break; } case 5: { //SYS_DATE Debug.Log("GET SYS_DATE PACKAGE"); // this.Act(new PlayerExecutable(this.EnterWaitingRoom)); // System.Threading.Thread.Sleep(100); // this.Act(new PlayerExecutable(this.CreateRoom)); // //Debug.Log(this.m_State == ePlayerState.Room); // //Debug.Log(this.m_isHost); // //Debug.Log(this.m_roomCount); // System.Threading.Thread.Sleep(100); // this.Act(new PlayerExecutable(this.StartGame)); break; } } }
public void HandleGameRoomCreate(GSPacketIn pkg) { int totalLevel = 0; int totalFightPower = 0; int roomId = pkg.ReadInt(); int gameType = pkg.ReadInt(); int guildId = pkg.ReadInt(); int areaId = pkg.ReadInt(); bool IsArea = pkg.ReadBoolean(); int count = pkg.ReadInt(); IGamePlayer[] players = new IGamePlayer[count]; for (int i = 0; i < count; i++) { PlayerInfo info = new PlayerInfo(); ProxyPlayerInfo proxyPlayerInfo = new ProxyPlayerInfo(); proxyPlayerInfo.m_AreaID = pkg.ReadInt(); proxyPlayerInfo.m_AreaName = pkg.ReadString(); 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.Nimbus = pkg.ReadInt(); info.ConsortiaID = pkg.ReadInt(); info.ConsortiaName = pkg.ReadString(); info.ConsortiaLevel = pkg.ReadInt(); info.ConsortiaRepute = pkg.ReadInt(); info.Win = pkg.ReadInt(); info.Total = pkg.ReadInt(); info.Attack = pkg.ReadInt(); info.Defence = pkg.ReadInt(); info.Agility = pkg.ReadInt(); info.Luck = pkg.ReadInt(); info.FightPower = pkg.ReadInt(); info.IsMarried = pkg.ReadBoolean(); if (info.IsMarried) { info.SpouseID = pkg.ReadInt(); info.SpouseName = pkg.ReadString(); } totalFightPower += info.FightPower; proxyPlayerInfo.BaseAttack = pkg.ReadDouble(); proxyPlayerInfo.BaseDefence = pkg.ReadDouble(); proxyPlayerInfo.BaseAgility = pkg.ReadDouble(); proxyPlayerInfo.BaseBlood = pkg.ReadDouble(); proxyPlayerInfo.TemplateId = pkg.ReadInt(); proxyPlayerInfo.CanUserProp = pkg.ReadBoolean(); proxyPlayerInfo.SecondWeapon = pkg.ReadInt(); proxyPlayerInfo.StrengthLevel = pkg.ReadInt(); proxyPlayerInfo.GPAddPlus = pkg.ReadDouble(); proxyPlayerInfo.GMExperienceRate = pkg.ReadFloat(); proxyPlayerInfo.AuncherExperienceRate = pkg.ReadFloat(); proxyPlayerInfo.OfferAddPlus = pkg.ReadDouble(); proxyPlayerInfo.GMOfferRate = pkg.ReadFloat(); proxyPlayerInfo.AuncherOfferRate = pkg.ReadFloat(); proxyPlayerInfo.GMRichesRate = pkg.ReadFloat(); proxyPlayerInfo.AuncherRichesRate = pkg.ReadFloat(); proxyPlayerInfo.AntiAddictionRate = pkg.ReadDouble(); 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, proxyPlayerInfo, infos); players[i].CanUseProp = proxyPlayerInfo.CanUserProp; int ec = pkg.ReadInt(); for (int j = 0; j < ec; j++) { players[i].EquipEffect.Add(pkg.ReadInt()); } totalLevel += info.Grade; } if (players.Length != 0) { ProxyRoom room = new ProxyRoom(ProxyRoomMgr.NextRoomId(), roomId, players, this, totalLevel, totalFightPower, IsArea); room.GuildId = guildId; room.AreaID = areaId; room.GameType = (eGameType)gameType; ProxyRoom oldroom = null; Dictionary <int, ProxyRoom> rooms; Monitor.Enter(rooms = this.m_rooms); try { if (this.m_rooms.ContainsKey(roomId)) { oldroom = this.m_rooms[roomId]; this.m_rooms.Remove(roomId); } } finally { Monitor.Exit(rooms); } if (oldroom != null) { ProxyRoomMgr.RemoveRoom(oldroom); } Monitor.Enter(rooms = this.m_rooms); try { if (!this.m_rooms.ContainsKey(roomId)) { this.m_rooms.Add(roomId, room); this.SendFightRoomID(roomId, room.RoomId); } else { room = null; } } finally { Monitor.Exit(rooms); } if (room != null) { ProxyRoomMgr.AddRoom(room); } else { ServerClient.log.ErrorFormat("Room already exists:{0}", roomId); } } }
public void HandleGameRoomCreate(GSPacketIn pkg) { int num = pkg.ReadInt(); int gameType = pkg.ReadInt(); int guildId = pkg.ReadInt(); int num2 = pkg.ReadInt(); int num3 = 0; IGamePlayer[] array = new IGamePlayer[num2]; for (int i = 0; i < num2; i++) { PlayerInfo playerInfo = new PlayerInfo(); playerInfo.ID = pkg.ReadInt(); playerInfo.NickName = pkg.ReadString(); playerInfo.Sex = pkg.ReadBoolean(); playerInfo.typeVIP = pkg.ReadByte(); playerInfo.VIPLevel = pkg.ReadInt(); playerInfo.Hide = pkg.ReadInt(); playerInfo.Style = pkg.ReadString(); playerInfo.Colors = pkg.ReadString(); playerInfo.Skin = pkg.ReadString(); playerInfo.Offer = pkg.ReadInt(); playerInfo.GP = pkg.ReadInt(); playerInfo.Grade = pkg.ReadInt(); playerInfo.Repute = pkg.ReadInt(); playerInfo.ConsortiaID = pkg.ReadInt(); playerInfo.ConsortiaName = pkg.ReadString(); playerInfo.ConsortiaLevel = pkg.ReadInt(); playerInfo.ConsortiaRepute = pkg.ReadInt(); playerInfo.badgeID = pkg.ReadInt(); playerInfo.weaklessGuildProgress = Base64.decodeToByteArray(pkg.ReadString()); playerInfo.Attack = pkg.ReadInt(); playerInfo.Defence = pkg.ReadInt(); playerInfo.Agility = pkg.ReadInt(); playerInfo.Luck = pkg.ReadInt(); playerInfo.hp = pkg.ReadInt(); playerInfo.FightPower = pkg.ReadInt(); playerInfo.IsMarried = pkg.ReadBoolean(); if (playerInfo.IsMarried) { playerInfo.SpouseID = pkg.ReadInt(); playerInfo.SpouseName = pkg.ReadString(); } ProxyPlayerInfo proxyPlayerInfo = new ProxyPlayerInfo(); proxyPlayerInfo.BaseAttack = pkg.ReadDouble(); proxyPlayerInfo.BaseDefence = pkg.ReadDouble(); proxyPlayerInfo.BaseAgility = pkg.ReadDouble(); proxyPlayerInfo.BaseBlood = pkg.ReadDouble(); proxyPlayerInfo.TemplateId = pkg.ReadInt(); proxyPlayerInfo.CanUserProp = pkg.ReadBoolean(); proxyPlayerInfo.SecondWeapon = pkg.ReadInt(); proxyPlayerInfo.StrengthLevel = pkg.ReadInt(); proxyPlayerInfo.GPAddPlus = pkg.ReadDouble(); proxyPlayerInfo.OfferAddPlus = pkg.ReadDouble(); proxyPlayerInfo.AntiAddictionRate = pkg.ReadDouble(); proxyPlayerInfo.ServerId = pkg.ReadInt(); UsersPetinfo usersPetinfo = new UsersPetinfo(); int num4 = pkg.ReadInt(); if (num4 == 1) { usersPetinfo.Place = pkg.ReadInt(); usersPetinfo.TemplateID = pkg.ReadInt(); usersPetinfo.ID = pkg.ReadInt(); usersPetinfo.Name = pkg.ReadString(); usersPetinfo.UserID = pkg.ReadInt(); usersPetinfo.Level = pkg.ReadInt(); usersPetinfo.Skill = pkg.ReadString(); usersPetinfo.SkillEquip = pkg.ReadString(); } else { usersPetinfo = null; } List <BufferInfo> list = new List <BufferInfo>(); int num5 = pkg.ReadInt(); for (int j = 0; j < num5; j++) { BufferInfo bufferInfo = new BufferInfo(); bufferInfo.Type = pkg.ReadInt(); bufferInfo.IsExist = pkg.ReadBoolean(); bufferInfo.BeginDate = pkg.ReadDateTime(); bufferInfo.ValidDate = pkg.ReadInt(); bufferInfo.Value = pkg.ReadInt(); bufferInfo.ValidCount = pkg.ReadInt(); if (playerInfo != null) { list.Add(bufferInfo); } } List <ItemInfo> list2 = new List <ItemInfo>(); int num6 = pkg.ReadInt(); for (int k = 0; k < num6; k++) { int templateId = pkg.ReadInt(); int hole = pkg.ReadInt(); ItemInfo itemInfo = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(templateId), 1, 1); itemInfo.Hole1 = hole; list2.Add(itemInfo); } array[i] = new ProxyPlayer(this, playerInfo, proxyPlayerInfo, usersPetinfo, list, list2); array[i].CanUseProp = proxyPlayerInfo.CanUserProp; num3 += playerInfo.Grade; } ProxyRoom proxyRoom = new ProxyRoom(ProxyRoomMgr.NextRoomId(), num, array, this); proxyRoom.GuildId = guildId; proxyRoom.GameType = (eGameType)gameType; Dictionary <int, ProxyRoom> rooms; Monitor.Enter(rooms = this.m_rooms); try { if (!this.m_rooms.ContainsKey(num)) { this.m_rooms.Add(num, proxyRoom); } else { proxyRoom = null; } } finally { Monitor.Exit(rooms); } if (proxyRoom != null) { ProxyRoomMgr.AddRoom(proxyRoom); return; } ServerClient.log.ErrorFormat("Room already exists:{0}", num); }
public override void OnRecvPacket(GSPacketIn pkg) { this.m_lastRecv = pkg.Code; this.m_recvCount++; // Debug.Log("player ["+this.m_account+"]:"+DateTime.Now+" receive: "+pkg.Code+" (ePackageType."+(ePackageType)pkg.Code+")"); /*if (this.m_log != null) * { * this.m_log.WriteLine(Marshal.ToHexDump(string.Format("player [{0}]:{1} recive:", this.m_account, DateTime.Now), pkg.Buffer, 0, pkg.Length)); * }*/ Debug.Log("OnRecvPacket: " + (ePackageType)pkg.Code); switch (pkg.Code) { case (byte)ePlayerPackageType.LOGIN: { //LOGIN if (pkg.ReadByte() != 0) { string str = pkg.ReadString(); Debug.Log(this.m_account + " login socket failed: " + str); this.m_state = ePlayerState.Stopped; this.LastError = "SocketError:" + str; break; } this.UserId = pkg.ClientID; pkg.ReadInt(); //4 this.m_playerId = pkg.Parameter1; localPlayerInfo = new PlayerInfo(); localPlayerInfo.id = this.m_playerId; localPlayerInfo.nickname = this.NickName; ClientRecvPreparer.PlayerInfo_LOGIN(ref localPlayerInfo, ref pkg); Debug.Log("login socket success! pid " + this.m_playerId + " uid: " + this.UserId); // Debug.Log("login info: "+ localPlayerInfo.ToString()); // Debug.Log("localPlayerInfo style: " + localPlayerInfo.style); UnityThread.executeInUpdate(() => { //Call UpdateLocalPlayerPreview in ConnectorManager connectorManager.UpdateLocalPlayerPreview(); }); break; } case 2: { //KIT_USER Debug.Log("CMDType 2 KIT_USER"); this.m_state = ePlayerState.Stopped; this.LastError = "KickReason:" + pkg.ReadString(); Debug.Log(this.LastError); break; } case 3: { //SYS_MESS Debug.Log("CMDType 3 - SYS MESS"); int val = pkg.ReadInt(); Debug.Log("CMDType 3 val: " + val.ToString()); this.LastMsg = pkg.ReadString(); Debug.Log(this.LastMsg); break; } case (byte)ePlayerPackageType.GRID_GOODS: { // MainBag = 0, PropBag = 1, TaskBag = 2, //TempBag = 4, CaddyBag = 5, Bank = 11, Store =12, Card=15 int bagType = pkg.ReadInt(); int slotLength = pkg.ReadInt(); List <ItemInfo> bagBag = new List <ItemInfo>(); Debug.Log("bagtype: " + bagType + " - " + (eBagType)bagType + " slotLEngth: " + slotLength); for (int ind = 0; ind < slotLength; ind++) { pkg.ReadInt(); bagBag.Add(new ItemInfo(ref pkg, true)); // Debug.Log(bagBag[ind].ToString()); } UnityThread.executeInUpdate(() => { //Call StartGameHandler in ConnectorManager connectorManager.GridGoodsHandler(bagType, bagBag); }); break; } case (byte)ePackageType.GAME_ROOM_CREATE: { RoomInfo ri = new RoomInfo(); ri.id = pkg.ReadInt(); ri.roomType = (eRoomType)pkg.ReadByte(); ri.hardLevel = (eHardLevel)pkg.ReadByte(); ri.timeMode = pkg.ReadByte(); ri.playerCount = pkg.ReadByte(); ri.placescount = pkg.ReadByte(); ri.isPasswd = pkg.ReadBoolean(); ri.mapid = pkg.ReadInt(); ri.isplaying = pkg.ReadBoolean(); ri.roomname = pkg.ReadString(); ri.gametype = (eGameType)pkg.ReadByte(); ri.levelLimits = pkg.ReadInt(); pkg.ReadBoolean(); //pkg.WriteBoolean(false); Debug.Log(ri.ToString()); this.m_state = ePlayerState.Room; this.m_isHost = true; this.m_roomCount++; this.Act(new PlayerExecutable(this.StartGame)); break; } case (byte)ePlayerPackageType.ITEM_EQUIP: { { pkg.ReadInt(); //id pkg.ReadInt(); //agi pkg.ReadInt(); //Attack pkg.ReadString(); //Colors pkg.ReadString(); //Skin pkg.ReadInt(); //Defence pkg.ReadInt(); // GP pkg.ReadInt(); //Grade pkg.ReadInt(); //Luck pkg.ReadInt(); //Hide pkg.ReadInt(); //Repute pkg.ReadBoolean(); // Sex pkg.ReadString(); // Style pkg.ReadInt(); //Offer pkg.ReadString(); //NickName pkg.ReadBoolean(); pkg.ReadInt(); pkg.ReadInt(); //Win pkg.ReadInt(); //Total pkg.ReadInt(); //Escape pkg.ReadInt(); pkg.ReadString(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadBoolean(); pkg.ReadInt(); pkg.ReadString(); pkg.ReadString(); pkg.ReadInt(); pkg.ReadInt(); //FightPower pkg.ReadInt(); pkg.ReadInt(); pkg.ReadString(); pkg.ReadInt(); pkg.ReadString(); //AchievementPoint pkg.ReadInt(); pkg.ReadString(); pkg.ReadDateTime(); } int iCount = pkg.ReadInt(); //itemCount List <ItemInfo> items = new List <ItemInfo>(); for (int ind = 0; ind < iCount; ind++) { items.Add(new ItemInfo(ref pkg, false)); Debug.Log(items[ind].ToString()); } break; } case (byte)ePlayerPackageType.UPDATE_PRIVATE_INFO: { localPlayerInfo.money = pkg.ReadInt(); localPlayerInfo.medal = pkg.ReadInt(); localPlayerInfo.gold = pkg.ReadInt(); localPlayerInfo.giftToken = pkg.ReadInt(); break; } case (byte)ePlayerPackageType.UPDATE_PlAYER_INFO: { localPlayerInfo.nickname = this.m_account; localPlayerInfo.id = this.m_playerId; localPlayerInfo.grade = this.m_grade; localPlayerInfo.gp = pkg.ReadInt(); //info.GP); pkg.ReadInt(); //info.Offer); pkg.ReadInt(); //info.RichesOffer); pkg.ReadInt(); //info.RichesRob); localPlayerInfo.win = pkg.ReadInt(); //info.Win); localPlayerInfo.totalMatch = pkg.ReadInt(); //info.Total); pkg.ReadInt(); //info.Escape); localPlayerInfo.attack = pkg.ReadInt(); //info.Attack); localPlayerInfo.defence = pkg.ReadInt(); //info.Defence); localPlayerInfo.agility = pkg.ReadInt(); //info.Agility); localPlayerInfo.luck = pkg.ReadInt(); //info.Luck); pkg.ReadInt(); //info.Hide); localPlayerInfo.style = pkg.ReadString(); //info.Style); localPlayerInfo.color = pkg.ReadString(); //info.Colors); localPlayerInfo.skin = pkg.ReadString(); //info.Skin); pkg.ReadInt(); //info.ConsortiaID); pkg.ReadString(); //info.ConsortiaName); pkg.ReadInt(); //info.ConsortiaLevel); pkg.ReadInt(); //info.ConsortiaRepute); pkg.ReadInt(); //info.Nimbus); pkg.ReadString(); //info.PvePermission); pkg.ReadString(); //"1"); localPlayerInfo.fightPower = pkg.ReadInt(); //info.FightPower); // pkg.ReadInt();//1); // pkg.ReadInt();//-1); // pkg.ReadString();//"ss"); // pkg.ReadInt();//1); // pkg.ReadString();//"ss"); // ////AchievementPoint // pkg.ReadInt();//0); // ////honor // pkg.ReadString();//"honor"); // // //LastSpaDate // // if ();//info.ExpendDate != null) // // pkg.ReadDateTime();//();//DateTime)info.ExpendDate); // // else { pkg.ReadDateTime();//DateTime.MinValue); } // //charmgp // pkg.ReadInt();//100); // //consortiaCharmGP // pkg.ReadInt();//100); // pkg.ReadDateTime();//DateTime.MinValue); // ////DeputyWeaponID // pkg.ReadInt();//10001); // pkg.ReadInt();//0); // // box gi ko biet // pkg.ReadInt();//info.AnswerSite); // // pkg.ReadInt();//0); Debug.Log(localPlayerInfo.ToString()); UnityThread.executeInUpdate(() => { //Call Update mainplayer info in ConnectorManager connectorManager.UpdateLocalPlayerPreview(); connectorManager.UpdateStatsDisplay(); }); break; } case (byte)ePlayerPackageType.GAME_CMD: { //GAME_CMD //Debug.Log("GAME_CMD"); eTankCmdType type = (eTankCmdType)pkg.ReadByte(); int pId = pkg.Parameter1; int LifeTime = pkg.Parameter2; Debug.Log("[CMD] " + ((eTankCmdType)type).ToString() + " - lifeTime: " + LifeTime.ToString()); switch (type) { case eTankCmdType.TAKE_CARD: // Debug.Log("TAKE_CARD "); // return; case eTankCmdType.GAME_OVER: // this.Act(new PlayerExecutable(this.EnterWaitingRoom)); // this.Act(new PlayerExecutable(this.CreateRoom)); // this.Act(new PlayerExecutable(this.StartGame)); MatchSummary ms = ClientRecvPreparer.GameOver_MatchSummary(ref pkg, this.m_playerId); UnityThread.executeInUpdate(() => { //Call StartGameHandler in ConnectorManager connectorManager.GameOverHandler(ms); }); return; case eTankCmdType.GAME_TIME: this.m_lifeTime = pkg.ReadInt(); Debug.Log("GAME_TIME sync: " + this.m_lifeTime.ToString()); return; case eTankCmdType.START_GAME: // Game.Logic/PVPGame.cs int size = pkg.ReadInt(); //number of players // List<PlayerInfo> Players = new List<PlayerInfo>(); for (int i = 0; i < size; i++) { int tmpId = pkg.ReadInt(); for (int j = 0; j < size; j++) { if (tmpId != playersList[j].id) { continue; } playersList[j].x = pkg.ReadInt(); playersList[j].y = pkg.ReadInt(); playersList[j].direction = pkg.ReadInt(); playersList[j].blood = pkg.ReadInt(); pkg.ReadInt(); //2 pkg.ReadInt(); //34 playersList[j].isMainPlayer = false; //check if player is this user //Debug.Log("thisPid: "+ this.m_playerId.ToString() + " - Pid: " + Players[i].id.ToString()); // if (playersList[j].id == this.m_playerId){ if (playersList[j].nickname == this.m_account || playersList[j].nickname == this.NickName) { playersList[j].isMainPlayer = true; this.m_playerId = playersList[j].id; this.m_posX = playersList[j].x; this.m_posY = playersList[j].y; } playersList[j].dander = pkg.ReadInt(); playersList[j].effectCount = pkg.ReadInt(); playersList[j].property3 = new List <int>(); playersList[j].property4 = new List <int>(); for (int k = 0; k < playersList[j].effectCount; k++) { playersList[j].property3.Add(pkg.ReadInt()); playersList[j].property4.Add(pkg.ReadInt()); } break; } } UnityThread.executeInUpdate(() => { //Call StartGameHandler in ConnectorManager connectorManager.StartGameHandler(playersList); }); this.m_state = ePlayerState.StartGame; return; case eTankCmdType.GAME_CREATE: this.m_gameCount++; pkg.ReadInt(); //Roomtype pkg.ReadInt(); //gametype pkg.ReadInt(); //Timetype localPlayerInfo.nickname = this.m_account; this.playersList = ClientRecvPreparer.GameCreate_PlayerList(ref localPlayerInfo, ref pkg); this.m_playerId = localPlayerInfo.id; this.m_state = ePlayerState.CreateGame; UnityThread.executeInUpdate(() => { //Call GameCreateHandler in ConnectorManager connectorManager.GameCreateHandler(this.playersList); }); return; case eTankCmdType.GAME_LOAD: pkg.ReadInt(); //maxTime int mapId = pkg.ReadInt(); UnityThread.executeInUpdate(() => { //Call LoadMapHandler in ConnectorManager connectorManager.GameLoadHandler(mapId); }); return; case eTankCmdType.LOAD: this.m_state = ePlayerState.Loading; // this.Act(new PlayerExecutable(this.SendLoadingComplete)); return; case eTankCmdType.GAME_MISSION_INFO: MissionInfo mi = ClientRecvPreparer.GetPVEMissionInfo(ref pkg); UnityThread.executeInUpdate(() => { connectorManager.PVEMissionPrepare(mi); }); return; case eTankCmdType.GAME_UI_DATA: // update turn index and kill count; int TurnIndex = pkg.ReadInt(); int count = pkg.ReadInt(); int param3 = pkg.ReadInt(), param4 = pkg.ReadInt(); UnityThread.executeInUpdate(() => { Debug.Log(string.Format("GAME_UI_DATA : TurnIndex:{0} - count:{1} - param3,4:{2},{3}", TurnIndex, count, param3, param4)); }); return; case eTankCmdType.ADD_LIVING: // update turn index and kill count; LivingInfo li = ClientRecvPreparer.AddLivingInfo(ref pkg); UnityThread.executeInUpdate(() => { Debug.Log("ADD_LIVING : " + li.ToString()); }); return; case eTankCmdType.TURN: Debug.Log("pId turn: " + pkg.Parameter1.ToString()); int wind = pkg.ReadInt(); pkg.ReadBoolean(); pkg.ReadByte(); pkg.ReadByte(); pkg.ReadByte(); bool isHiding = pkg.ReadBoolean(); //turnTime // TimeType int timeType = pkg.ReadInt(); List <BoxInfo> newBoxesList = new List <BoxInfo>(); int newBoxesCount = pkg.ReadInt(); for (int j = 0; j < newBoxesCount; j++) { newBoxesList.Add(new BoxInfo()); newBoxesList[j].id = pkg.ReadInt(); newBoxesList[j].x = pkg.ReadInt(); newBoxesList[j].y = pkg.ReadInt(); pkg.ReadInt(); // pkg.ReadBoolean(); } List <PlayerInfo> updatedPlayerList = new List <PlayerInfo>(); int listSize = pkg.ReadInt(); for (int j = 0; j < listSize; j++) { updatedPlayerList.Add(new PlayerInfo()); updatedPlayerList[j].id = pkg.ReadInt(); updatedPlayerList[j].isLiving = pkg.ReadBoolean(); updatedPlayerList[j].x = pkg.ReadInt(); updatedPlayerList[j].y = pkg.ReadInt(); updatedPlayerList[j].blood = pkg.ReadInt(); updatedPlayerList[j].isNoHole = pkg.ReadBoolean(); updatedPlayerList[j].energy = pkg.ReadInt(); updatedPlayerList[j].dander = pkg.ReadInt(); updatedPlayerList[j].shootCount = pkg.ReadInt(); } int turnIndex = pkg.ReadInt(); UnityThread.executeInUpdate(() => { //Call TurnHandler in ConnectorManager connectorManager.TurnHandler(pkg.Parameter1, newBoxesList, updatedPlayerList); }); // this.m_state = ePlayerState.Shoot; // this.m_shootCount++; //this.Act(new PlayerExecutable(this.Shoot)); return; case eTankCmdType.CURRENTBALL: bool special = pkg.ReadBoolean(); int currentBallId = pkg.ReadInt(); UnityThread.executeInUpdate(() => { //Call CurrentBallHandler in ConnectorManager connectorManager.CurrentBallHandler(pId, special, currentBallId); }); //pkg.WriteByte((byte)player.BallCount); return; case eTankCmdType.FIRE: List <FireInfo> fireInfos = ClientRecvPreparer.MakeFireInfo(ref pkg); UnityThread.executeInUpdate(() => { //Call FireHandler in ConnectorManager connectorManager.FireHandler(pId, fireInfos); }); return; case eTankCmdType.FIRE_TAG: bool tag = pkg.ReadBoolean(); byte speedTime = pkg.ReadByte(); UnityThread.executeInUpdate(() => { //Call FireTagHandler in ConnectorManager connectorManager.FireTagHandler(pId, tag, speedTime); }); return; case eTankCmdType.USING_PROP: byte propType = pkg.ReadByte(); int place = pkg.ReadInt(); int templateId = pkg.ReadInt(); UnityThread.executeInUpdate(() => { //Call UsingPropHandler in ConnectorManager connectorManager.UsingPropHandler(pId, propType, place, templateId); }); return; case eTankCmdType.MOVESTART: byte moveType = pkg.ReadByte(); int tx = pkg.ReadInt(); int ty = pkg.ReadInt(); byte dir = pkg.ReadByte(); bool isLiving = pkg.ReadBoolean(); string action = pkg.ReadString(); // is null or empty or "move" // Debug.Log("MOVE type: "+moveType.ToString()+" tX: " + tx.ToString()+ // " tY:"+ ty.ToString()+ " dir: "+dir.ToString()); UnityThread.executeInUpdate(() => { //Call MoveStartHandler in ConnectorManager connectorManager.MoveStartHandler(pId, moveType, tx, ty, dir, isLiving); }); return; case eTankCmdType.DIRECTION: int direction = pkg.ReadInt(); UnityThread.executeInUpdate(() => { //Call CurrentBallHandler in ConnectorManager connectorManager.DirectionHandler(pId, direction); }); return; case eTankCmdType.DANDER: int playerId = pkg.Parameter1; int dander = pkg.ReadInt(); localPlayerInfo.dander = dander; UnityThread.executeInUpdate(() => { //Call CurrentBallHandler in ConnectorManager connectorManager.DanderHandler(pId, dander); }); return; default: Debug.Log("Unhandled GAME_CMD type: " + type.ToString()); return; } break; } // case 0x5e:{ // //GAME_CREATE_ROOM // Debug.Log("GET GAME_CREATE_ROOM PACKAGE"); // if (pkg.ReadInt() != 0)//if (m_isHost == false) // { // this.m_state = ePlayerState.Room; // this.m_isHost = true; // this.m_roomCount++; // this.Act(new PlayerExecutable(this.StartGame)); // } // break; // } case 5: { //SYS_DATE Debug.Log("GET SYS_DATE PACKAGE"); // this.Act(new PlayerExecutable(this.EnterWaitingRoom)); // System.Threading.Thread.Sleep(100); // this.Act(new PlayerExecutable(this.CreateRoom)); // //Debug.Log(this.m_State == ePlayerState.Room); // //Debug.Log(this.m_isHost); // //Debug.Log(this.m_roomCount); // System.Threading.Thread.Sleep(100); // this.Act(new PlayerExecutable(this.StartGame)); break; } case (int)ePackageType.GAME_PAIRUP_START: UnityThread.executeInUpdate(() => { connectorManager.ConfirmMatching(); }); break; default: Debug.Log("Unhandled Package type: " + ((ePackageType)pkg.Code).ToString()); break; } }
public override void OnRecvPacket(GSPacketIn pkg) { UnityEngine.Debug.Log("ONRecvPacket"); this.m_lastRecv = pkg.Code; this.m_recvCount++; Console.WriteLine("player [{0}]:{1} receive: 0x{2:X2} (ePackageType.{3})", this.Account, DateTime.Now, pkg.Code, (ePackageType)pkg.Code); /*if (this.m_log != null) * { * this.m_log.WriteLine(Marshal.ToHexDump(string.Format("player [{0}]:{1} recive:", this.Account, DateTime.Now), pkg.Buffer, 0, pkg.Length)); * }*/ switch (pkg.Code) { case 1: if (pkg.ReadByte() != 0) { string str = pkg.ReadString(); Console.WriteLine("{0} login socket failed:{1}", this.Account, str); this.m_state = ePlayerState.Stopped; this.LastError = "SocketError:" + str; break; } Console.WriteLine("{0} login socket success!", this.Account); this.UserId = pkg.ClientID; break; case 2: this.m_state = ePlayerState.Stopped; this.LastError = "KickReason:" + pkg.ReadString(); break; case 3: pkg.ReadInt(); this.LastMsg = pkg.ReadString(); break; case 0x5b: { UnityEngine.Debug.Log("0x5b"); eTankCmdType type = (eTankCmdType)pkg.ReadByte(); switch (type) { case eTankCmdType.TAKE_CARD: case eTankCmdType.GAME_OVER: this.Act(new PlayerExecutable(this.EnterWaitingRoom)); this.Act(new PlayerExecutable(this.CreateRoom)); return; case eTankCmdType.START_GAME: this.m_state = ePlayerState.StartGame; return; case eTankCmdType.GAME_CREATE: { UnityEngine.Debug.Log("GAME_CREATE"); this.m_gameCount++; pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); int num2 = pkg.ReadInt(); UnityEngine.Debug.Log(num2); for (int i = 0; i < num2; i++) { pkg.ReadInt(); pkg.ReadString(); int num4 = pkg.ReadInt(); string nn = pkg.ReadString(); UnityEngine.Debug.Log(nn); pkg.ReadBoolean(); pkg.ReadByte(); pkg.ReadInt(); pkg.ReadBoolean(); pkg.ReadInt(); pkg.ReadString(); pkg.ReadString(); pkg.ReadString(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadString(); pkg.ReadDateTime(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadBoolean(); pkg.ReadInt(); pkg.ReadString(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadString(); pkg.ReadInt(); pkg.ReadString(); pkg.ReadInt(); pkg.ReadBoolean(); pkg.ReadInt(); if (pkg.ReadBoolean()) { pkg.ReadInt(); pkg.ReadString(); } pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); int num5 = pkg.ReadInt(); int num6 = pkg.ReadInt(); int num7 = pkg.ReadInt(); if (num4 == this.UserId) { this.m_team = num5; this.m_playerId = num6; this.m_blood = num7; } if (pkg.ReadInt() != 0) { pkg.ReadInt(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadString(); pkg.ReadInt(); pkg.ReadInt(); int num9 = pkg.ReadInt(); for (int j = 0; j < num9; j++) { pkg.ReadInt(); pkg.ReadInt(); } } } this.m_state = ePlayerState.CreateGame; return; } case eTankCmdType.GAME_LOAD: pkg.ReadInt(); //maxTime int mapId = pkg.ReadInt(); //mapID UnityEngine.Debug.Log("mapId: " + mapId.ToString()); return; case eTankCmdType.LOAD: this.m_state = ePlayerState.Loading; this.Act(new PlayerExecutable(this.SendLoadingComplete)); return; case eTankCmdType.TURN: if (pkg.Parameter1 == this.m_playerId) { this.m_state = ePlayerState.Shoot; this.m_shootCount++; this.Act(new PlayerExecutable(this.Shoot)); } return; } break; } case 0x5e: if (pkg.ReadInt() != 0)//if (m_isHost == false) { this.m_state = ePlayerState.Room; this.m_isHost = true; this.m_roomCount++; //this.Act(new PlayerExecutable(this.StartGame)); } break; case 5: this.Act(new PlayerExecutable(this.EnterWaitingRoom)); System.Threading.Thread.Sleep(3000); this.Act(new PlayerExecutable(this.CreateRoom)); //Debug.Log(this.m_State == ePlayerState.Room); //Debug.Log(this.m_isHost); //Debug.Log(this.m_roomCount); System.Threading.Thread.Sleep(3000); this.Act(new PlayerExecutable(this.StartGame)); break; } }