void OnFreeScence(byte[] data, int dataSize) { var typeValue = typeof(CMD_S_StatusFree); int localDataSize = Marshal.SizeOf(typeValue); if (dataSize != localDataSize) { Debug.LogError("OnFreeScence:localDataSize=" + localDataSize + ", serverDataSize=" + dataSize); return; } CMD_S_StatusFree pNetInfo = (CMD_S_StatusFree)StructConverterByteArray.BytesToStruct(data, typeValue); GlobalUserInfo pGlobalUserInfo = GlobalUserInfo.GetInstance(); tagGlobalUserData pGlobalUserData = pGlobalUserInfo.GetGlobalUserData(); pGlobalUserData.cbMapIndexRand = pNetInfo.cbMapIndex; pGlobalUserData.wRandseed = pNetInfo.wRandseed; pGlobalUserData.wRandseedForRandomGameObject = pNetInfo.wRandseedForRandomGameObject; pGlobalUserData.wRandseedForInventory = pNetInfo.wRandseedForInventory; //道具同步 Array.Copy(pNetInfo.sInventoryList, pGlobalUserData.sInventoryList, pNetInfo.sInventoryList.Length); //Buffer.BlockCopy(pNetInfo.sInventoryList, 0, pGlobalUserData.sInventoryList, 0, pNetInfo.sInventoryList.Length); Loom.QueueOnMainThread(() => { hnManager.LoadHideSeekSceneOfWangHu(); }); }
private bool onSubQueryInfoResult(byte[] data, int size) { if (size != Marshal.SizeOf(typeof(CMD_GP_CheckInInfo))) ///if (size != sizeof(CMD_GP_CheckInInfo)) { ///ASSERT(false); return(false); } CMD_GP_CheckInInfo pNetInfo = (CMD_GP_CheckInInfo)StructConverterByteArray.BytesToStruct(data, typeof(CMD_GP_CheckInInfo)); ///CMD_GP_CheckInInfo* pNetInfo = (CMD_GP_CheckInInfo*)data; GlobalUserInfo pGlobalUserInfo = GlobalUserInfo.GetInstance(); tagGlobalUserData pGlobalUserData = pGlobalUserInfo.GetGlobalUserData(); pGlobalUserData.wSeriesDate = pNetInfo.wSeriesDate; pGlobalUserData.bTodayChecked = (pNetInfo.bTodayChecked != 0); //pGlobalUserData.wSeriesDate++;//hack if (mIGPSignInMissionSink != null) { mIGPSignInMissionSink.onSignInQueryInfoResult(pNetInfo); } stop(); return(true); }
//列表配置 bool onSocketListConfig(byte[] data, int size) { CMD_GP_ListConfig pListConfig = (CMD_GP_ListConfig)StructConverterByteArray.BytesToStruct(data, typeof(CMD_GP_ListConfig)); return(true); }
//登陆成功 public void OnGRLogonSuccess(byte[] data, int dataSize) { var typeValue = typeof(CMD_GR_LogonSuccess); if (dataSize != Marshal.SizeOf(typeValue)) { return; } //消息处理 CMD_GR_LogonSuccess pLogonSuccess = (CMD_GR_LogonSuccess)StructConverterByteArray.BytesToStruct(data, typeValue); //玩家属性 m_dwUserRight = pLogonSuccess.dwUserRight; m_dwMasterRight = pLogonSuccess.dwMasterRight; #if UNITY_IPHONE bool bIsForAppleReview = (pLogonSuccess.cbIsForAppleReview != 0); if (hnManager != null) { hnManager.ShowHideRedForeground(bIsForAppleReview); } #endif RestTick(); }
//插入类型 public bool InsertGameKind(tagGameKind pGameKind) { //效验参数 //ASSERT(pGameKind!=0); //if (pGameKind == null) return false; //变量定义 CGameKindItem pGameKindItem = null; bool bInsert = false; if (m_GameKindItemMap.ContainsKey(pGameKind.wKindID)) { pGameKindItem = m_GameKindItemMap[pGameKind.wKindID]; } else { pGameKindItem = new CGameKindItem(); bInsert = true; } if (pGameKindItem == null) { return(false); } //设置数据 var buf = StructConverterByteArray.StructToBytes(pGameKind); pGameKindItem.m_GameKind = (tagGameKind)StructConverterByteArray.BytesToStruct(buf, typeof(tagGameKind)); //memcpy(&pGameKindItem.m_GameKind, pGameKind, sizeof(tagGameKind)); //插入处理 if (bInsert == true) { //设置索引 m_GameKindItemMap[pGameKind.wKindID] = pGameKindItem; //插入子项 if (m_pIServerListDataSink != null) { m_pIServerListDataSink.OnGameItemInsert(pGameKindItem); } } else { //更新子项 if (m_pIServerListDataSink != null) { m_pIServerListDataSink.OnGameItemUpdate(pGameKindItem); } } return(true); }
//插入函数 //插入种类 public bool InsertGameType(tagGameType pGameType) { //if (pGameType == null) return false; //变量定义 CGameTypeItem pGameTypeItem = null; bool bInsert = false; if (m_GameTypeItemMap.ContainsKey(pGameType.wTypeID)) { pGameTypeItem = m_GameTypeItemMap[pGameType.wTypeID]; } else { pGameTypeItem = new CGameTypeItem(); bInsert = true; } if (pGameTypeItem == null) { return(false); } //设置数据 var buf = StructConverterByteArray.StructToBytes(pGameType); pGameTypeItem.m_GameType = (tagGameType)StructConverterByteArray.BytesToStruct(buf, typeof(tagGameType)); //memcpy(&pGameTypeItem.m_GameType, pGameType, sizeof(tagGameType)); //插入处理 if (bInsert == true) { //设置索引 m_GameTypeItemMap[pGameType.wTypeID] = pGameTypeItem; //界面更新 if (m_pIServerListDataSink != null) { m_pIServerListDataSink.OnGameItemInsert(pGameTypeItem); } } else { //界面更新 if (m_pIServerListDataSink != null) { m_pIServerListDataSink.OnGameItemUpdate(pGameTypeItem); } } return(true); }
//登录失败 bool onSocketSubLogonFailure(byte[] data, int size) { DBR_GP_LogonError pNetInfo = (DBR_GP_LogonError)StructConverterByteArray.BytesToStruct(data, typeof(DBR_GP_LogonError)); //显示消息 if (mIGPLoginMissionSink != null) { mIGPLoginMissionSink.onGPLoginFailure(pNetInfo.lErrorCode, (pNetInfo.szErrorDescribe)); } return(true); }
private bool onSubGPLobbyChat(byte[] data, int size) { CMD_GP_CHAT pNetInfo = (CMD_GP_CHAT)StructConverterByteArray.BytesToStruct(data, typeof(CMD_GP_CHAT)); if (mLobbyChatSystem != null) { mLobbyChatSystem.onSubGPLobbyChat(pNetInfo); } ///stop(); return(true); }
public void OnSubOperateNotify(byte[] pBuffer, ushort wDataSize) { var typeValue = typeof(CMD_S_OperateNotify); if (wDataSize != Marshal.SizeOf(typeValue)) { return; } CMD_S_OperateNotify pOperateNotify = (CMD_S_OperateNotify)StructConverterByteArray.BytesToStruct(pBuffer, typeValue); handle_OnSubOperateNotify(pOperateNotify); ///m_pLocal.AddCommand( new HNMJPlayer.PlayerUICommand(HNMJPlayer.PlayerAnimType.OnSubOperateNotify, new[] { (byte)pOperateNotify.wResumeUser, pOperateNotify.cbActionMask, pOperateNotify.cbActionCard }) ); }
public void OnSubGameStart(byte[] pBuffer, ushort wDataSize) { var typeValue = typeof(CMD_S_GameStart); Debug.Log("建德游戏开始" + Marshal.SizeOf(typeValue)); if (wDataSize != Marshal.SizeOf(typeValue)) { return; } //变量定义 CMD_S_GameStart pGameStart = (CMD_S_GameStart)StructConverterByteArray.BytesToStruct(pBuffer, typeValue); defaultState(); m_iBankerUser = pGameStart.wBankerUser; m_iCurrentUser = pGameStart.wCurrentUser; m_iUserAction = pGameStart.cbUserAction; //WidgetFun::setText(this, "LastCardCout", (int)pGameStart.cbLeftCardCount); //WidgetFun::setVisible(this, "XZDDButton_WeiXinFriend", false);//mChen hack for (int i = 0; i < MAX_PLAYER; i++) { var player = getPlayerByChairID(i); player.setHandCard(pGameStart.cbCardData, i * HNMJ_Defines.MAX_COUNT, HNMJ_Defines.MAX_COUNT - 1); player.startGame(); } Loom.QueueOnMainThread(() => { //Lin: pGameStart.lSiceCount 服务端未设置,暂时rand一个 hnManager.SetLeftCard(pGameStart.cbLeftCardCount); Random.state = new Random.State(); var buf = new byte[(HNMJ_Defines.MAX_COUNT) * HNMJ_Defines.GAME_PLAYER]; Buffer.BlockCopy(pGameStart.cbCardData, 0, buf, 0, buf.Length); hnManager.GameStartProcedure(Random.Range(2, 13), m_iBankerUser, buf); //hnManager.GameStartProcedure(pGameStart.lSiceCount, m_iBankerUser); }); //HNMJButtonAction_ShowCard(); getPlayerByChairID(m_iBankerUser).setZhuang(); if (pGameStart.cbXiaoHuTag == 1) { setGameState(MJState.HNMJ_STATE_XIAO_HU); } else { setGameState(MJState.HNMJ_STATE_PLAYING); } }
//游戏结束 public void OnSubGameEnd(byte[] pBuffer, ushort wDataSize) { var typeValue = typeof(CMD_S_GameEnd); //if (wDataSize != Marshal.SizeOf(typeValue)) // return; //消息处理 CMD_S_GameEnd pGameEnd = (CMD_S_GameEnd)StructConverterByteArray.BytesToStruct(pBuffer, typeValue); ////mChen add, for HideSeek WangHu //Loom.QueueOnMainThread(() => //{ // hnManager.ReturnFromBigFinalToHallScene(); //}); }
public void Net_InGameServerID(byte[] data, int dataSize) { if (dataSize != Marshal.SizeOf(typeof(CMD_GP_InGameSeverID))) { return; } CMD_GP_InGameSeverID pNetInfo = (CMD_GP_InGameSeverID)StructConverterByteArray.BytesToStruct(data, typeof(CMD_GP_InGameSeverID)); if (m_pInGameServerInfoSink != null) { m_pInGameServerInfoSink.onUserInGameServerID(pNetInfo); } stop(); }
//接收聊天数据 public void OnSubChatData(byte[] pBuffer, ushort wDataSize) { var typeValue = typeof(CMD_C_CHAT); if (wDataSize != Marshal.SizeOf(typeValue)) { Debug.Log("数据长度不符合"); return; } CMD_C_CHAT ChatData = (CMD_C_CHAT)StructConverterByteArray.BytesToStruct(pBuffer, typeValue); string data = Encoding.GetEncoding(936).GetString(ChatData.ChatData); //Debug.Log("接收到的数据:" + data); int chairid = ChatData.ChairId; byte userstatus = ChatData.UserStatus; hnManager.ShowChatPanel(chairid, userstatus, data); }
//WQ add. for HideSeek //大厅列表 bool onSocketListLobby(byte[] data, int size) { ////更新数据 tagGameLobby tempStruct = new tagGameLobby(); int itemSize = Marshal.SizeOf(tempStruct); if (size % itemSize != 0) { return(false); } byte[] pNetInfo = new byte[itemSize]; int iItemCount = size / itemSize; for (int i = 0; i < iItemCount; i++) { Buffer.BlockCopy(data, i * itemSize, pNetInfo, 0, itemSize); tagGameLobby sGameLobby = (tagGameLobby)StructConverterByteArray.BytesToStruct(pNetInfo, typeof(tagGameLobby)); CServerListData.shared().InsertGameLobby(sGameLobby); } //Create CGPLobbyMission Loom.QueueOnMainThread(() => { if (CServerListData.shared().GetGameLobbyCount() > 0) { tagGameLobby gameLobby = CServerListData.shared().getARandGameLobby(); if (gameLobby.wLobbyPort != 0) { CGPLobbyMission kGPLobbyMission = CGPLobbyMission.CreateInstance(gameLobby.szServerAddr, gameLobby.wLobbyPort); if (kGPLobbyMission != null && !kGPLobbyMission.isAlive()) { kGPLobbyMission.SendChatData("StartChatConnect!");//只是为了连接上 } } else { Debug.LogError("onSocketListLobby: incorrect wLobbyPort=0"); } } }); return(true); }
public override bool OnSubUserChatIndex(byte[] data, int dataSize) { var typeValue = typeof(CMD_GF_C_UserChatIdx); if (dataSize != Marshal.SizeOf(typeValue)) { return(false); } //消息处理 CMD_GF_C_UserChatIdx pUserChatIdx = (CMD_GF_C_UserChatIdx)StructConverterByteArray.BytesToStruct(data, typeValue); ushort localChairId = m_pLocal.GetChairID(); if (pUserChatIdx.wSendUserID != localChairId) { showPlane(TYPE_LANS, pUserChatIdx.wItemIndex, pUserChatIdx.wSendUserID); } return(true); }
//构造函数 //功能函数 public byte[] GetData(ref tagDataDescribe DataDescribe) { //效验数据 if (m_wDataPos >= m_wDataSize) { DataDescribe.wDataSize = 0; DataDescribe.wDataDescribe = DTP_NULL;//无效数据 return(null); } //获取数据 var structSize = Marshal.SizeOf(m_ttagDataDescribe); byte[] buf = new byte[structSize]; Buffer.BlockCopy(m_pcbBuffer, m_wDataPos, buf, 0, structSize); DataDescribe = (tagDataDescribe)StructConverterByteArray.BytesToStruct(buf, m_ttagDataDescribe); //memcpy(&DataDescribe, m_pcbBuffer + m_wDataPos, sizeof(tagDataDescribe)); //ASSERT((m_wDataPos + sizeof(tagDataDescribe) + DataDescribe.wDataSize) <= m_wDataSize); //效验数据 if ((m_wDataPos + structSize + DataDescribe.wDataSize) > m_wDataSize) { DataDescribe.wDataSize = 0; DataDescribe.wDataDescribe = DTP_NULL; return(null); } //设置数据 byte[] pData = null; if (DataDescribe.wDataSize > 0) { pData = new byte[DataDescribe.wDataSize]; Buffer.BlockCopy(m_pcbBuffer, m_wDataPos + structSize, pData, 0, DataDescribe.wDataSize); //pData = m_pcbBuffer + m_wDataPos + structSize; } m_wDataPos += (ushort)(structSize + DataDescribe.wDataSize); return(pData); }
//用户托管 public void OnSubTrustee(byte[] pBuffer, ushort wDataSize) { var typeValue = typeof(CMD_S_Trustee); if (wDataSize != Marshal.SizeOf(typeValue)) { return; } //消息处理 CMD_S_Trustee pTrustee = (CMD_S_Trustee)StructConverterByteArray.BytesToStruct(pBuffer, typeValue); // UI Log HNMJPlayer pPlyer = getPlayerByChairID(pTrustee.wChairID); if (pPlyer == null) { return; } String strNickName = pPlyer.GetNickName(); String[] strName = strNickName.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries); if (strName.Length > 0) { Loom.QueueOnMainThread(() => { ChatSystem.GetInstance.ShowChatText("通知", strName[0] + " 离开了房间!"); }); } Loom.QueueOnMainThread(() => { PlayerBase player = GameObjectsManager.GetInstance().GetPlayerByChairID(pTrustee.wChairID); if (player != null) { Debug.LogWarning("------------- " + player.ChairID); GameObjectsManager.GetInstance().RemovePlayerByChairID(player.TeamType, (byte)player.ChairID); //离开房间移除玩家 } }); }
public void OnSubAwardData(byte[] pBuffer, ushort wDataSize) { Debug.LogWarning("------------OnSubAwardData"); var typeValue = typeof(CMD_S_AwardResult); if (wDataSize != Marshal.SizeOf(typeValue)) { Debug.LogError("数据长度不符合"); return; } CMD_S_AwardResult pNetInfo = (CMD_S_AwardResult)StructConverterByteArray.BytesToStruct(pBuffer, typeValue); string strLog = GlobalUserInfo.GBToUtf8(pNetInfo.szNotifyContent); Debug.Log("OnSubAwardData: " + strLog); GlobalUserInfo pGlobalUserInfo = GlobalUserInfo.GetInstance(); tagGlobalUserData pGlobalUserData = pGlobalUserInfo.GetGlobalUserData(); if (pNetInfo.bSuccessed == 0) //成功 { //Success if (pNetInfo.cbCostType == 0) //奖励金币 { GlobalUserInfo.setUserScore(pNetInfo.lScore); GameSceneUIHandler.ShowLog("奖励10枚金币"); } else //奖励钻石 { GlobalUserInfo.setUserInsure(pNetInfo.lScore); GameSceneUIHandler.ShowLog("奖励10颗钻石"); } Loom.QueueOnMainThread(() => { if (UIManager.GetInstance() != null) { UIManager.GetInstance().UpdateUIInfo(); //更新钻石金币 } }); } }
//类型信息 bool onSocketListKind(byte[] data, int size) { ////更新数据 tagGameKind tempStruct = new tagGameKind(); int itemSize = Marshal.SizeOf(tempStruct); if (size % itemSize != 0) { return(false); } byte[] pNetInfo = new byte[itemSize]; int iItemCount = size / itemSize; CServerListData pServerListData = CServerListData.shared(); for (int i = 0; i < iItemCount; i++) { Buffer.BlockCopy(data, i * itemSize, pNetInfo, 0, itemSize); tagGameKind pGameKind = (tagGameKind)StructConverterByteArray.BytesToStruct(pNetInfo, typeof(tagGameKind)); pServerListData.InsertGameKind(pGameKind); } return(true); }
public virtual bool RevTalkFile(byte[] data, int dataSize) { var typeValue = typeof(CMD_GR_C_TableTalk); Debug.Log("talk data size: " + dataSize); CMD_GR_C_TableTalk kTalkNet = (CMD_GR_C_TableTalk)StructConverterByteArray.BytesToStruct(data, typeValue); if (kTalkNet.cbChairID == m_pSelfPlayer.GetChairID()) { return(true); } int structSize = Marshal.SizeOf(typeValue); var lenbuf = new byte[4]; Buffer.BlockCopy(data, structSize, lenbuf, 0, 4); int soundLen = dataSize - structSize - 4; Debug.Log("received sound data " + soundLen + "in " + BitConverter.ToInt32(lenbuf, 0)); Debug.Assert(BitConverter.ToInt32(lenbuf, 0) == soundLen, "RevTalkFile failed"); var soundData = new byte[soundLen]; Buffer.BlockCopy(data, structSize + 4, soundData, 0, soundLen); Debug.Log("talk data size: " + dataSize + "structSize " + structSize); Loom.QueueOnMainThread(() => { hnManager.UserTalk(kTalkNet.cbChairID, soundData); }); #if false datastream kDataStream(data, dataSize); CMD_GR_C_TableTalk kTalkNet; kTalkNet.StreamValue(kDataStream, false); if (kTalkNet.kDataStream.size() == 0) { return(true); }
//登录完成 bool onSocketSubMacthSignupInfo(byte[] data, int size) { //校验数据 if (size % sizeof(ushort) != 0) { return(false); } //提取数据 tagSignupMatchInfo tempInfo = new tagSignupMatchInfo(); int structSize = Marshal.SizeOf(tempInfo); var buf = new byte[structSize]; ushort wSignupCount = (ushort)(size / structSize); tagSignupMatchInfo[] pSignupMatchInfo = new tagSignupMatchInfo[wSignupCount]; //获取对象 //ASSERT(CServerListData::shared() != NULL); CServerListData pServerListData = CServerListData.shared(); //查找房间 CGameServerItem pGameServerItem = null; for (int i = 0; i < wSignupCount; i++) { Buffer.BlockCopy(data, i * structSize, buf, 0, structSize); pSignupMatchInfo[i] = (tagSignupMatchInfo)StructConverterByteArray.BytesToStruct(buf, typeof(tagSignupMatchInfo)); //设置报名 pGameServerItem = pServerListData.SearchGameServer(pSignupMatchInfo[i].wServerID); if (pGameServerItem != null && pGameServerItem.m_GameMatch.dwMatchID == pSignupMatchInfo[i].dwMatchID) { pGameServerItem.m_bSignuped = true; } } return(true); }
//比赛列表 bool onSocketListMatch(byte[] data, int size) { tagGameMatch tempStruct = new tagGameMatch(); int itemSize = Marshal.SizeOf(tempStruct); if (size % itemSize != 0) { return(false); } //变量定义 ushort wItemCount = (ushort)(size / itemSize); var buf = new byte[itemSize]; tagGameMatch[] pGameMatch = new tagGameMatch[wItemCount]; //获取对象 CGameServerItem pGameServerItem = null; for (int i = 0; i < wItemCount; i++) { Buffer.BlockCopy(data, i * itemSize, buf, 0, itemSize); pGameMatch[i] = (tagGameMatch)StructConverterByteArray.BytesToStruct(buf, typeof(tagGameMatch)); //更新数据 pGameServerItem = CServerListData.shared().SearchGameServer(pGameMatch[i].wServerID); if (pGameServerItem != null) { pGameServerItem.m_GameMatch = (tagGameMatch)StructConverterByteArray.BytesToStruct(buf, typeof(tagGameMatch)); //memcpy(&pGameServerItem.m_GameMatch, pGameMatch++, sizeof(pGameServerItem.m_GameMatch)); } } return(true); }
private bool onSubRaffleResult(byte[] data, int size) { CMD_GP_RaffleResult pNetInfo = (CMD_GP_RaffleResult)StructConverterByteArray.BytesToStruct(data, typeof(CMD_GP_RaffleResult)); ///CMD_GP_RaffleResult* pNetInfo = (CMD_GP_RaffleResult*)data; string strLog = GlobalUserInfo.GBToUtf8(pNetInfo.szNotifyContent); //string strLog2 = Encoding.Default.GetString(pNetInfo.szNotifyContent); //string strLog3 = Encoding.GetEncoding(936).GetString(pNetInfo.szNotifyContent); //string strLog4 = Encoding.UTF8.GetString(pNetInfo.szNotifyContent); Debug.Log("CGPRaffleMission::onSubRaffleResult:" + strLog); GameSceneUIHandler.ShowLog(strLog); GlobalUserInfo pGlobalUserInfo = GlobalUserInfo.GetInstance(); tagGlobalUserData pGlobalUserData = pGlobalUserInfo.GetGlobalUserData(); if (pNetInfo.bSuccessed != 0) { //Success pGlobalUserData.lUserInsure = pNetInfo.lScore; pGlobalUserData.dwPlayCount = pNetInfo.dwPlayCount; pGlobalUserData.dwRaffleCount = pNetInfo.dwRaffleCount; pGlobalUserInfo.upPlayerInfo(); } stop(); //if (mIGPSignInMissionSink != null) //{ // mIGPSignInMissionSink.onSignInDoneResult(pNetInfo); //} return(true); }
public void OnSubInventoryConsumption(byte[] pBuffer, ushort wDataSize) { Debug.LogWarning("------------OnSubInventoryConsumption"); var typeValue = typeof(CMD_S_InventoryConsumptionInfoResult); if (wDataSize != Marshal.SizeOf(typeValue)) { Debug.LogError("数据长度不符合"); return; } CMD_S_InventoryConsumptionInfoResult InfoResult = (CMD_S_InventoryConsumptionInfoResult)StructConverterByteArray.BytesToStruct(pBuffer, typeValue); string str = GlobalUserInfo.GBToUtf8(InfoResult.szDescribeString); Debug.Log("onSubInventoryConsumptionResult: " + str); if (InfoResult.cbSuccess == 0) //成功 { long ScoreNow = 0; if (InfoResult.cbCostType == 0) //金币 { ScoreNow = GlobalUserInfo.getUserScore(); GlobalUserInfo.setUserScore(InfoResult.dwFinalScore); } else //钻石 { ScoreNow = GlobalUserInfo.getUserInsure(); GlobalUserInfo.setUserInsure(InfoResult.dwFinalScore); } Loom.QueueOnMainThread(() => { if (InfoResult.cbItemID == (byte)ControlManager.InventoryItemID.Stealth) //开启隐身冷却时间 { if (UIManager.GetInstance() != null) { UIManager.GetInstance().StartColdTime(ControlManager.GetInstance().StealthButton, 60); } } if (UIManager.GetInstance() != null) { UIManager.GetInstance().UpdateUIInfo(); //更新钻石金币 if (InfoResult.cbCostType == 0) //金币 { if (ScoreNow != GlobalUserInfo.getUserScore()) { UIManager.GetInstance().ShowMiddleTips(str); } } else //钻石 { if (ScoreNow != GlobalUserInfo.getUserInsure()) { UIManager.GetInstance().ShowMiddleTips(str); } } } }); } else { GameSceneUIHandler.ShowLog(str); } }
//插入房间 public bool InsertGameServer(tagGameServer pGameServer) { //效验参数 //ASSERT(pGameServer!=0); //if (pGameServer == null) return false; //变量定义 CGameServerItem pGameServerItem = null; bool bInsert = false; if (m_GameServerItemMap.ContainsKey(pGameServer.wServerID)) { pGameServerItem = m_GameServerItemMap[pGameServer.wServerID]; } else { pGameServerItem = new CGameServerItem(); bInsert = true; } if (pGameServerItem == null) { return(false); } //设置数据 var buf = StructConverterByteArray.StructToBytes(pGameServer); pGameServerItem.m_GameServer = (tagGameServer)StructConverterByteArray.BytesToStruct(buf, typeof(tagGameServer)); //memcpy(&pGameServerItem.m_GameServer, pGameServer, sizeof(tagGameServer)); m_dwAllOnLineCount += pGameServer.dwOnLineCount; pGameServerItem.m_pGameKindItem = SearchGameKind(pGameServer.wKindID); //查找类型 if (bInsert == true && pGameServerItem.m_pGameKindItem != null) { //变量定义 uint dwGameKindOnline = 0; foreach (var cGameServerItem in m_GameServerItemMap) { //获取房间 CGameServerItem pGameServerItem2 = cGameServerItem.Value; //设置房间 if ((pGameServerItem2 != null) && (pGameServerItem2.m_GameServer.wKindID == pGameServerItem.m_GameServer.wKindID)) { dwGameKindOnline += pGameServerItem2.m_GameServer.dwOnLineCount; } } //设置变量 pGameServerItem.m_pGameKindItem.m_GameKind.dwOnLineCount = dwGameKindOnline; //事件通知 //ASSERT(m_pIServerListDataSink!=0); if (m_pIServerListDataSink != null) { m_pIServerListDataSink.OnGameItemUpdate(pGameServerItem.m_pGameKindItem); } } //插入处理 if (bInsert == true) { //设置索引 m_GameServerItemMap[pGameServer.wServerID] = pGameServerItem; //插入子项 if (m_pIServerListDataSink != null) { m_pIServerListDataSink.OnGameItemInsert(pGameServerItem); } } else { //更新子项 if (m_pIServerListDataSink != null) { m_pIServerListDataSink.OnGameItemUpdate(pGameServerItem); } } return(true); }
//登录成功 bool onSocketSubLogonSuccess(byte[] data, int size) { //登陆成功 CMD_GP_LogonSuccess pData = (CMD_GP_LogonSuccess)StructConverterByteArray.BytesToStruct(data, typeof(CMD_GP_LogonSuccess)); // for Match Time Loom.QueueOnMainThread(() => { if (hnManager == null) { hnManager = GameObject.FindObjectOfType <HNGameManager>(); } hnManager.m_matchStartTime = pData.MatchStartTime; hnManager.m_matchEndTime = pData.MatchEndTime; }); //变量定义 GlobalUserInfo pGlobalUserInfo = GameNet.GlobalUserInfo.GetInstance(); tagGlobalUserData pGlobalUserData = pGlobalUserInfo.GetGlobalUserData(); pGlobalUserData.lUserScore = pData.lUserScore; pGlobalUserData.lUserInsure = pData.lUserInsure; // for签到 pGlobalUserData.wSeriesDate = pData.wSeriesDate; // 已打场次,for抽奖 pGlobalUserData.dwPlayCount = pData.dwPlayCount; //WQ add,抽奖记录 pGlobalUserData.dwRaffleCount = pData.dwRaffleCount; pGlobalUserData.dwPlayCountPerRaffle = pData.dwPlayCountPerRaffle; // 代理 pGlobalUserData.iSpreaderLevel = pData.iSpreaderLevel; // -1:不是代理人 // for HideSeek:查询警察模型库 pGlobalUserData.lModelIndex0 = pData.lModelIndex0; pGlobalUserData.bGPIsForAppleReview = (pData.cbGPIsForAppleReview != 0); //WQ 头像Http string szHeadHttp = GlobalUserInfo.GBToUtf8(pData.szHeadHttp); Buffer.BlockCopy(pData.szHeadHttp, 0, pGlobalUserData.szHeadHttp, 0, pData.szHeadHttp.Length); //WQ add,公告信息 string szPublicNotice = GlobalUserInfo.GBToUtf8(pData.szPublicNotice); Buffer.BlockCopy(pData.szPublicNotice, 0, pGlobalUserData.szPublicNotice, 0, pData.szPublicNotice.Length); //保存信息 pGlobalUserData.wFaceID = pData.wFaceID; pGlobalUserData.cbGender = pData.cbGender; pGlobalUserData.dwUserID = pData.dwUserID; pGlobalUserData.dwGameID = pData.dwGameID; pGlobalUserData.dwSpreaderID = pData.dwSpreaderID; pGlobalUserData.dwExperience = pData.dwExperience; pGlobalUserData.cbInsureEnabled = pData.cbInsureEnabled; Debug.Log("onSocketSubLogonSuccess " + Encoding.Default.GetString(pData.szNickName)); Buffer.BlockCopy(pData.szNickName, 0, pGlobalUserData.szNickName, 0, pData.szNickName.Length); // strcpy(pGlobalUserData.szNickName, utility::a_u8((char*)pData.szNickName).c_str()); Buffer.BlockCopy(pData.szAccounts, 0, pGlobalUserData.szAccounts, 0, pData.szAccounts.Length); // strncpy(pGlobalUserData.szAccounts, ((char*)pData.szAccounts), countarray(pGlobalUserData.szAccounts)); //金币信息 pGlobalUserInfo.upPlayerInfo(); if (mIGPLoginMissionSink != null) { mIGPLoginMissionSink.onGPLoginSuccess(); } return(true); }
public void OnSubInventoryConsumptionEvent(byte[] pBuffer, ushort wDataSize) { Debug.LogWarning("------------OnSubInventoryConsumptionEvent"); var typeValue = typeof(CMD_S_InventoryConsumptionEvent); if (wDataSize != Marshal.SizeOf(typeValue)) { Debug.LogError("数据长度不符合"); return; } CMD_S_InventoryConsumptionEvent InfoResult = (CMD_S_InventoryConsumptionEvent)StructConverterByteArray.BytesToStruct(pBuffer, typeValue); if (InfoResult.cbChairID != HNGameManager.m_iLocalChairID) //接收其他人的道具使用信息 { PlayerBase player = GameObjectsManager.GetInstance().GetPlayerByChairID(InfoResult.cbChairID); if (player != null) { switch ((ControlManager.InventoryItemID)InfoResult.cbItemID) { case ControlManager.InventoryItemID.ChangeModel: //变身 Loom.QueueOnMainThread(() => { ControlManager.GetInstance().ChangeModel(player.gameObject, InfoResult.dwModelIndex); }); break; case ControlManager.InventoryItemID.Stealth: //隐身 { if (InfoResult.cbStealthStatus == 0) { Loom.QueueOnMainThread(() => { ControlManager.GetInstance().Stealth(player.gameObject, true); }); } else if (InfoResult.cbStealthStatus == 1) { Loom.QueueOnMainThread(() => { ControlManager.GetInstance().Stealth(player.gameObject, false); }); } } break; case ControlManager.InventoryItemID.Resurrection: //复活 Loom.QueueOnMainThread(() => { ControlManager.GetInstance().Resurrection(player.gameObject); }); break; } } } else //接收自己的道具使用信息 { //使用道具 switch ((ControlManager.InventoryItemID)InfoResult.cbItemID) { case ControlManager.InventoryItemID.ChangeModel: //变身 Loom.QueueOnMainThread(() => { ControlManager.GetInstance().ChangeModel(InfoResult.dwModelIndex); }); break; case ControlManager.InventoryItemID.Stealth: //隐身 { if (InfoResult.cbStealthStatus == 0) { Loom.QueueOnMainThread(() => { ControlManager.GetInstance().Stealth(true); ControlManager.GetInstance().StealthTime(255); }); } else if (InfoResult.cbStealthStatus == 1) { Loom.QueueOnMainThread(() => { ControlManager.GetInstance().Stealth(false); ControlManager.GetInstance().StealthTime(InfoResult.cbStealthTimeLeft); }); } } break; case ControlManager.InventoryItemID.Resurrection: //复活 Loom.QueueOnMainThread(() => { ControlManager.GetInstance().Resurrection(); }); break; } } }
//解密数据 public uint CrevasseBuffer(byte[] pcbDataBuffer, uint wDataSize)//修改了参数类型 { //if (wDataSize == 16 ) //{ // Debug.Log("CrevasseBuffer wDataSize==16"); //} //ASSERT(m_dwSendPacketCount > 0); System.Diagnostics.Debug.Assert(wDataSize >= Packet.SizeOfTCP_Head); //调整长度 uint wSnapCount = 0; if ((wDataSize % sizeof(uint)) != 0) { wSnapCount = (uint)(sizeof(uint) - wDataSize % sizeof(uint)); Array.Clear(pcbDataBuffer, (int)wDataSize, (int)wSnapCount); //memset(pcbDataBuffer + wDataSize, 0, wSnapCount); } if (m_dwRecvPacketCount == 0) { //数据包长度错误 if (wDataSize < (Packet.SizeOfTCP_Head + sizeof(uint))) { return(0); } //m_dwRecvXorKey = *(uint*)(pcbDataBuffer + Packet.SizeOfTCP_Head); m_dwRecvXorKey = BitConverter.ToUInt32(pcbDataBuffer, Packet.SizeOfTCP_Head); //Debug.Log("2new recv key: " + m_dwRecvXorKey); m_dwSendXorKey = m_dwRecvXorKey; //memmove(pcbDataBuffer + sizeof(TCP_Head), pcbDataBuffer + sizeof(TCP_Head) + sizeof(unsigned int),wDataSize - sizeof(TCP_Head) - sizeof(unsigned int)); byte[] tempBuf = (byte[])pcbDataBuffer.Clone(); Buffer.BlockCopy(tempBuf, Packet.SizeOfTCP_Head + sizeof(uint), pcbDataBuffer, Packet.SizeOfIPC_Head, (int)(wDataSize - Packet.SizeOfTCP_Head - sizeof(uint))); wDataSize -= sizeof(uint); //((TCP_Head*)pcbDataBuffer)->TCPInfo.wPacketSize -= sizeof(unsigned int); var packetSize = BitConverter.ToUInt32(pcbDataBuffer, sizeof(byte) * 2) - sizeof(uint); var sizeBuf = BitConverter.GetBytes(packetSize); Buffer.BlockCopy(sizeBuf, 0, pcbDataBuffer, sizeof(byte) * 2, sizeBuf.Length); } //解密数据 uint dwXorKey = m_dwRecvXorKey; //uint* pdwXor = (uint*)(pcbDataBuffer + sizeof(TCP_Info)); //ushort* pwSeed = (ushort*)(pcbDataBuffer + sizeof(TCP_Info)); ushort pwSeed; uint pdwXor; uint wEncrypCount = (uint)((wDataSize + wSnapCount - Packet.SizeOfTCP_Info) / 4); for (uint i = 0; i < wEncrypCount; i++) { if ((i == (wEncrypCount - 1)) && (wSnapCount > 0)) { //byte[] pcbKeys = new byte[wSnapCount]; var pcbKeys = BitConverter.GetBytes(m_dwRecvXorKey); Buffer.BlockCopy(pcbKeys, (int)(sizeof(uint) - wSnapCount), pcbDataBuffer, (int)wDataSize, (int)wSnapCount); //unsigned char* pcbKey = ((unsigned char*)&m_dwRecvXorKey) +sizeof(unsigned int)-wSnapCount; //memcpy(pcbDataBuffer + wDataSize, pcbKey, wSnapCount); } pwSeed = BitConverter.ToUInt16(pcbDataBuffer, (int)(Packet.SizeOfTCP_Info + i * 4)); dwXorKey = SeedRandMap(pwSeed); pwSeed = BitConverter.ToUInt16(pcbDataBuffer, (int)(Packet.SizeOfTCP_Info + i * 4 + 2)); dwXorKey |= ((uint)SeedRandMap(pwSeed)) << 16; dwXorKey ^= Packet.g_dwPacketKey; pdwXor = BitConverter.ToUInt32(pcbDataBuffer, (int)(Packet.SizeOfTCP_Info + 4 * i)); pdwXor ^= m_dwRecvXorKey; var newValue = BitConverter.GetBytes(pdwXor); Buffer.BlockCopy(newValue, 0, pcbDataBuffer, (int)(Packet.SizeOfTCP_Info + 4 * i), 4); m_dwRecvXorKey = dwXorKey; //Debug.Log("3new recv key: " + m_dwRecvXorKey); } // Debug.Log("----------!!!------------"); //效验码与字节映射 Packet.TCP_Info pHeadTCPInfo = (Packet.TCP_Info)StructConverterByteArray.BytesToStruct(pcbDataBuffer, typeof(Packet.TCP_Info)); byte cbCheckCode = pHeadTCPInfo.cbCheckCode; for (int i = Packet.SizeOfTCP_Info; i < wDataSize; i++) { pcbDataBuffer[i] = MapRecvByte(pcbDataBuffer[i]); cbCheckCode += pcbDataBuffer[i]; } if (cbCheckCode != 0) { return(0); } return(wDataSize); }
void OnPlayScence(byte[] data, int dataSize) { //旁观者或者重连 var typeValue = typeof(CMD_S_StatusPlay); int localDataSize = Marshal.SizeOf(typeValue); if (dataSize != localDataSize) { Debug.LogError("OnPlayScence:localDataSize=" + localDataSize + ", serverDataSize=" + dataSize); return; } CMD_S_StatusPlay pNetInfo = (CMD_S_StatusPlay)StructConverterByteArray.BytesToStruct(data, typeValue); GlobalUserInfo pGlobalUserInfo = GlobalUserInfo.GetInstance(); tagGlobalUserData pGlobalUserData = pGlobalUserInfo.GetGlobalUserData(); pGlobalUserData.cbMapIndexRand = pNetInfo.cbMapIndex; pGlobalUserData.wRandseed = pNetInfo.wRandseed; pGlobalUserData.wRandseedForRandomGameObject = pNetInfo.wRandseedForRandomGameObject; pGlobalUserData.wRandseedForInventory = pNetInfo.wRandseedForInventory; //道具同步 Array.Copy(pNetInfo.sInventoryList, pGlobalUserData.sInventoryList, pNetInfo.sInventoryList.Length); //Buffer.BlockCopy(pNetInfo.sInventoryList, 0, pGlobalUserData.sInventoryList, 0, pNetInfo.sInventoryList.Length); //旁观者 int nStatus = SocketDefines.US_NULL; IClientUserItem pMeItem = CServerItem.get().GetMeUserItem(); if (pMeItem != null) { nStatus = pMeItem.GetUserStatus(); } if (nStatus == SocketDefines.US_LOOKON) { Loom.QueueOnMainThread(() => { hnManager.LoadHideSeekSceneOfWangHu(); }); } else { //mChen add, temp Loom.QueueOnMainThread(() => { hnManager.LoadHideSeekSceneOfWangHu(); }); if (false)//if (!hnManager.bEnteredGameScene) { //没进入游戏场景 //强杀进程后进来 Debug.LogError("OnPlayScence : 在大厅重连?强杀进程后回来? cbGameStatus=" + pNetInfo.cbGameStatus + " UserStatus=" + nStatus + " bEnteredGameScene=" + hnManager.bEnteredGameScene); //在大厅重连? Loom.QueueOnMainThread(() => { //hnManager.LoadHideSeekSceneOfWangHu(); //hnManager.SetLoading(false); hnManager.StartOrStopGameSceneHeartBeat(false); hnManager.LeaveRoom(); hnManager.LeaveGameToHall(); //CServerItem.get().IntermitConnect(true); }); } } //重连 byte cbGameStatus = pNetInfo.cbGameStatus; Debug.Log("OnPlayScence : cbGameStatus=" + cbGameStatus + " UserStatus=" + nStatus + " bEnteredGameScene=" + hnManager.bEnteredGameScene); //mChen add, for HideSeek: //if (nStatus != SocketDefines.US_LOOKON && !hnManager.bEnteredGameScene) //{ // //在大厅重连? // StartOrStopGameSceneHeartBeat(false); // CServerItem.get().IntermitConnect(true); // hnManager.LeaveRoom(); //} defaultState(); }
private bool onSubDoneResult(byte[] data, int size) { CMD_GP_CheckInResult pNetInfo = (CMD_GP_CheckInResult)StructConverterByteArray.BytesToStruct(data, typeof(CMD_GP_CheckInResult)); ///CMD_GP_CheckInResult* pNetInfo = (CMD_GP_CheckInResult*)data; string strLog = GlobalUserInfo.GBToUtf8(pNetInfo.szNotifyContent); Debug.Log("CGPSignInMission::onSubDoneResult:" + strLog); GameSceneUIHandler.ShowLog(strLog); GlobalUserInfo pGlobalUserInfo = GlobalUserInfo.GetInstance(); tagGlobalUserData pGlobalUserData = pGlobalUserInfo.GetGlobalUserData(); if (pNetInfo.bSuccessed != 0) { //Success if (pNetInfo.bType == 0) { //签到结果返回 pGlobalUserData.wSeriesDate = pNetInfo.wSeriesDate; award(); } else { Loom.QueueOnMainThread(() => { HNGameManager.GetInstance.PlaySoundEffect(-1, (int)AudioManager.Sound_Effect_Defines.SOUND_SIGNGIN_AWARED); }); } pGlobalUserData.lUserInsure = pNetInfo.lScore; pGlobalUserInfo.upPlayerInfo(); //刷新UI Loom.QueueOnMainThread(() => { if (CreateOrJoinRoom.GetInstance != null) { CreateOrJoinRoom.GetInstance.UpdateInfo(); } }); } else { stop(); } if (pNetInfo.bType == 0) { //签到结果返回 } else { //签到奖励返回 stop(); } if (mIGPSignInMissionSink != null) { mIGPSignInMissionSink.onSignInDoneResult(pNetInfo); } return(true); }