public virtual void onGPAccountInfoHttpIP(uint dwUserID, string strIP, string strHttp) { GamePlayer pPlayer = getPlayerByUserID(dwUserID); if (pPlayer == null) { return; } IClientUserItem pIClientUserItem = pPlayer.getUserItem(false); if (pIClientUserItem == null) { return; } //获取用户 tagUserInfo pUserInfo = pIClientUserItem.GetUserInfo(); tagCustomFaceInfo pCustomFaceInfo = pIClientUserItem.GetCustomFaceInfo(); var cbLogonIP = Encoding.Default.GetBytes(strIP); pUserInfo.dwClientAddr = (uint)(cbLogonIP[0] | cbLogonIP[1] << 8 | cbLogonIP[2] << 16 | cbLogonIP[3] << 24); ///pUserInfo.szLogonIP = Encoding.Default.GetBytes(strIP); pUserInfo.szHeadHttp = Encoding.Default.GetBytes(strHttp); // strncpy(pUserInfo.szLogonIP, strIP.c_str(), countarray(pUserInfo.szLogonIP)); // strncpy(pUserInfo.szHeadHttp, strHttp.c_str(), countarray(pUserInfo.szHeadHttp)); pPlayer.upPlayerInfo(); }
//删除用户 public bool DeleteUserItem(IClientUserItem pIClientUserItem) { //查找用户 CClientUserItem pUserItemActive = null; for (int i = 0, l = (int)m_UserItemActive.Count; i < l; i++) { pUserItemActive = m_UserItemActive[i]; if (pIClientUserItem == pUserItemActive) { //删除用户 m_UserItemActive.RemoveAt(i); //m_UserItemActive.erase(m_UserItemActive.begin() + i); addPool(pUserItemActive); //删除通知 if (m_pIUserManagerSink != null) { m_pIUserManagerSink.OnUserItemDelete(pUserItemActive); } //设置数据 pUserItemActive.m_cbCompanion = SocketDefines.CP_NORMAL; pUserItemActive.m_UserInfo = new tagUserInfo(); pUserItemActive.m_UserInfo.Init(); //zeromemory(&pUserItemActive.m_UserInfo, sizeof(tagUserInfo)); return(true); } } //错误断言 Debug.Assert(false, "DeleteUserItem failed"); return(false); }
//更新状态 public bool UpdateUserItemStatus(IClientUserItem pIClientUserItem, tagUserStatus pUserStatus) { //效验参数 //ASSERT(pUserStatus != 0); Debug.Assert(pIClientUserItem != null); //获取用户 tagUserInfo pUserInfo = pIClientUserItem.GetUserInfo(); //以往数据 tagUserStatus tUserStatus = new tagUserStatus(); tUserStatus.wTableID = pUserInfo.wTableID; tUserStatus.wChairID = pUserInfo.wChairID; tUserStatus.cbUserStatus = pUserInfo.cbUserStatus; //设置数据 pUserInfo.wTableID = pUserStatus.wTableID; pUserInfo.wChairID = pUserStatus.wChairID; pUserInfo.cbUserStatus = pUserStatus.cbUserStatus; pIClientUserItem.SetUserInfo(pUserInfo); //通知更新 Debug.Assert(m_pIUserManagerSink != null); if (m_pIUserManagerSink != null) { m_pIUserManagerSink.OnUserItemUpdate(pIClientUserItem, ref tUserStatus); } return(true); }
protected override GamePlayer CreatePlayer(IClientUserItem pIClientUserItem) { lock (HNGameManager.LockObjOfLoadScene) { int nChairID = pIClientUserItem.GetChairID(); if (pIClientUserItem.GetUserID() == UserInfo.getInstance().getUserID()) { m_pLocal.setUserItem(pIClientUserItem); Debug.Log("---------------------CreatePlayer m_pLocal"); //mChen add, for HideSeek Loom.QueueOnMainThread(() => { GameObjectsManager.s_LocalHumanTeamType = PlayerTeam.PlayerTeamType.TaggerTeam; //GameObjectsManager.s_LocalHumanTeamType = PlayerTeam.PlayerTeamType.HideTeam; //测试 HNGameManager.m_iLocalChairID = nChairID; if (GameManager.s_gameSingleMultiType == GameSingleMultiType.MultiGame_WangHu) { PlayerTeam.PlayerTeamType teamType = pIClientUserItem.GetTeamType();// PlayerTeam.PlayerTeamType.TaggerTeam; //PlayerTeam.PlayerTeamType teamType = PlayerTeam.PlayerTeamType.HideTeam; //测试 GameObjectsManager.s_LocalHumanTeamType = teamType; byte cbModelIndex = pIClientUserItem.GetModelIndex(); PlayerTeam team = GameObjectsManager.GetInstance().GetPlayerTeam(teamType); team.AddAPlayer(false, nChairID, cbModelIndex); } }); return(m_pLocal); } else { GamePlayer pPlayer = getPlayerByChairID(pIClientUserItem.GetChairID()); pPlayer.setUserItem(pIClientUserItem); //mChen add, for HideSeek Loom.QueueOnMainThread(() => { if (GameManager.s_gameSingleMultiType == GameSingleMultiType.MultiGame_WangHu) { PlayerTeam.PlayerTeamType teamType = pIClientUserItem.GetTeamType();//PlayerTeam.PlayerTeamType.TaggerTeam; //PlayerTeam.PlayerTeamType teamType = PlayerTeam.PlayerTeamType.HideTeam; //测试 byte cbModelIndex = pIClientUserItem.GetModelIndex(); PlayerTeam team = GameObjectsManager.GetInstance().GetPlayerTeam(teamType); team.AddAPlayer(false, nChairID, cbModelIndex); } }); return(pPlayer); } } }
//用户头像 public virtual void OnEventCustomFace(IClientUserItem pIClientUserItem, bool bLookonUser) { GamePlayer pPlayer = getGamePlayerByUserItem(pIClientUserItem); if (pPlayer != null) { pPlayer.upPlayerInfo(); } }
//设置信息 public bool SetClientUserItem(ushort wTableID, ushort wChairID, IClientUserItem pIClientUserItem) { ITableView pITableView = GetTableViewItem(wTableID); if (pITableView != null) { pITableView.SetClientUserItem(wChairID, pIClientUserItem); } return(true); }
//用户属性 public virtual void OnEventUserAttrib(IClientUserItem pIClientUserItem, bool bLookonUser) { GamePlayer pPlayer = getGamePlayerByUserItem(pIClientUserItem); if (pPlayer != null) { pPlayer.upPlayerInfo(); } if (pPlayer == m_pSelfPlayer) { upSelfPlayerInfo(); } }
public void OnLeaveMatchButtonClick() { if (_leaveMatchButton != null) { _leaveMatchButton.SetActive(false); } if (_showRoomUsersBtn != null) { _showRoomUsersBtn.SetActive(false); } if (m_hnGameManager == null) { m_hnGameManager = GameObject.FindObjectOfType <HNGameManager>(); } if (GameManager.s_gameSingleMultiType == GameSingleMultiType.SingleGame) { m_hnGameManager.StopSingleGame(); m_hnGameManager.LeaveGameToHall(); return; } int nStatus = SocketDefines.US_NULL; IClientUserItem pMeItem = null; if (CServerItem.get() != null) { pMeItem = CServerItem.get().GetMeUserItem(); } if (pMeItem != null) { nStatus = pMeItem.GetUserStatus(); } if (true)//if (nStatus == SocketDefines.US_LOOKON) { m_hnGameManager.PopLeaveRoomWindow(); } else { //_joinMatchButton.active = true; m_hnGameManager.DismissBtnClicked(); if (GameManager.s_NetWorkClient != null) { GameManager.s_NetWorkClient.LeaveMatchToRoom(); } } HideMatchStartCountDown(); HideWaitToJoinNextMatchLabel(); }
//用户离开 public virtual void OnEventUserLeave(IClientUserItem pIClientUserItem, bool bLookonUser) { GamePlayer pPlayer = getGamePlayerByUserItem(pIClientUserItem); if (pPlayer != null) { //fix连续断线导致的多个LocalTagger和LocalHide if (pPlayer == m_pSelfPlayer) { //断线时删除Human GameObjectsManager.GetInstance().ClearPlayers(false); } removeGamePlayerToList(pPlayer); DeletePlayer(pPlayer); } }
//设置信息 public bool SetClientUserItem(ushort wChairID, IClientUserItem pIClientUserItem) { //效验参数 //ASSERT(wChairID < mChairCount); if (wChairID >= mChairCount) { return(false); } //设置用户 mIClientUserItem[wChairID] = pIClientUserItem; //更新界面 mITableViewFrame.UpdateTableView(mTableID); return(true); }
//用户状态 public virtual void OnEventUserStatus(IClientUserItem pIClientUserItem, bool bLookonUser) { GamePlayer pPlayer = getGamePlayerByUserItem(pIClientUserItem); if (pPlayer != null) { pPlayer.upPlayerState(); OnEventUserStatus(pPlayer); //设置离线状态UI Loom.QueueOnMainThread(() => { int nStatus = pPlayer.GetUserStatus(); bool bIsOffline = (nStatus == SocketDefines.US_OFFLINE || nStatus == SocketDefines.US_NULL); hnManager.ShowOfflineUI(pPlayer.GetChairID(), bIsOffline); }); } }
//系统消息(窗口输出) public bool InsertSystemString(byte[] pszString) { string strLog = Encoding.Default.GetString(pszString); Debug.Log(strLog); String[] str = strLog.Split(new string[] { "[", "]" }, StringSplitOptions.RemoveEmptyEntries); if (str.Length != 1) { int time = int.Parse(str[1]); if (time == 200) //Play-200s { Debug.Log("Play SOUND_TIPS_START_SEEK"); Loom.QueueOnMainThread(() => { hnManager.PlaySoundEffect(-1, (int)AudioManager.Sound_Effect_Defines.SOUND_TIPS_START_SEEK); }); } else if (time == 45 || time == 100) //Hide-45s,Play-100s,Play-45s { Debug.Log("Play SOUND_TIPS_STARTOREND"); Loom.QueueOnMainThread(() => { hnManager.PlaySoundEffect(-1, (int)AudioManager.Sound_Effect_Defines.SOUND_TIPS_STARTOREND); }); if (time == 45) { IClientUserItem pMeItem = CServerItem.get().GetMeUserItem(); byte Gamestate = CServerItem.get().GetGameStatus(); if (Gamestate == SocketDefines.GAME_STATUS_PLAY) { if (UIManager.GetInstance() != null) { UIManager.GetInstance().ShowMiddleTips("警察进入无敌状态"); } } } } else if (time == 5 || time == 4 || time == 3 || time == 2 || time == 1) { Debug.Log("Play SOUND_TIME_SEC"); Loom.QueueOnMainThread(() => { hnManager.PlaySoundEffect(-1, (int)AudioManager.Sound_Effect_Defines.SOUND_TIME_SEC); }); } } strLog = GlobalUserInfo.GBToUtf8(pszString); GameSceneUIHandler.ShowLog(strLog); return(true); }
//更新属性 public bool UpdateUserItemAttrib(IClientUserItem pIClientUserItem, tagUserAttrib pUserAttrib) { Debug.Assert(pIClientUserItem != null); //以往数据 tagUserAttrib UserAttrib = new tagUserAttrib(); UserAttrib.cbCompanion = pIClientUserItem.GetUserCompanion(); //设置数据 pIClientUserItem.SetUserCompanion(pUserAttrib.cbCompanion); //通知更新 Debug.Assert(m_pIUserManagerSink != null); if (m_pIUserManagerSink != null) { m_pIUserManagerSink.OnUserItemUpdate(pIClientUserItem, ref UserAttrib); } return(true); }
//更新接口 //更新积分 public bool UpdateUserItemScore(IClientUserItem pIClientUserItem, tagUserScore pUserScore) { Debug.Log("更新积分"); //效验参数 //Debug.Assert(pUserScore != null); Debug.Assert(pIClientUserItem != null); //获取用户 tagUserInfo pUserInfo = pIClientUserItem.GetUserInfo(); //以往数据 tagUserScore UserScore = new tagUserScore(); UserScore.lScore = pUserInfo.lScore; UserScore.lInsure = pUserInfo.lInsureScore; UserScore.dwWinCount = pUserInfo.lWinCount; UserScore.dwLostCount = pUserInfo.lLostCount; UserScore.dwDrawCount = pUserInfo.lDrawCount; UserScore.dwFleeCount = pUserInfo.lFleeCount; UserScore.dwExperience = pUserInfo.lExperience; //设置数据 pUserInfo.lScore = pUserScore.lScore; pUserInfo.lInsureScore = pUserScore.lInsure; pUserInfo.lWinCount = pUserScore.dwWinCount; pUserInfo.lLostCount = pUserScore.dwLostCount; pUserInfo.lDrawCount = pUserScore.dwDrawCount; pUserInfo.lFleeCount = pUserScore.dwFleeCount; pUserInfo.lExperience = pUserScore.dwExperience; pIClientUserItem.SetUserInfo(pUserInfo); //通知更新 Debug.Assert(m_pIUserManagerSink != null); if (m_pIUserManagerSink != null) { m_pIUserManagerSink.OnUserItemUpdate(pIClientUserItem, ref UserScore); } return(true); }
//更新头像 public bool UpdateUserCustomFace(IClientUserItem pIClientUserItem, uint dwCustomID, tagCustomFaceInfo CustomFaceInfo) { //获取用户 tagUserInfo pUserInfo = pIClientUserItem.GetUserInfo(); pIClientUserItem.SetCustomFaceInfo(CustomFaceInfo); //设置变量 pUserInfo.dwCustomID = dwCustomID; pIClientUserItem.SetUserInfo(pUserInfo); //pCustomFaceInfo = CustomFaceInfo; //通知更新 Debug.Assert(m_pIUserManagerSink != null); if (m_pIUserManagerSink != null) { m_pIUserManagerSink.OnUserFaceUpdate(pIClientUserItem); } return(true); }
//用户事件 //用户进入 public virtual void OnEventUserEnter(IClientUserItem pIClientUserItem, bool bLookonUser) { if (HNGameManager.LockObjOfLoadScene == null) { Debug.LogError("HNGameManager.LockObjOfLoadScene == null"); HNGameManager.LockObjOfLoadScene = new object(); } lock (HNGameManager.LockObjOfLoadScene) { GamePlayer pPlayer = getGamePlayerByUserItem(pIClientUserItem); if (pPlayer != null) { pPlayer.upPlayerInfo(); return; } } if (CServerItem.get() == null) { Debug.LogError("OnEventUserEnter:ServerItem.get() == null"); return; } IClientUserItem pMeItem = CServerItem.get().GetMeUserItem(); if (pMeItem == null) { return; } if (pMeItem.GetTableID() != pIClientUserItem.GetTableID()) { return; } if (pIClientUserItem.GetUserStatus() == SocketDefines.US_LOOKON) { return; } //UI Log string strNickName = GlobalUserInfo.GBToUtf8(pIClientUserItem.GetNickName()); Debug.Log("---------------------OnEventUserEnter:" + strNickName); String[] strName = strNickName.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries); if (strName.Length > 0) { Loom.QueueOnMainThread(() => { if (ChatSystem.GetInstance != null) { ChatSystem.GetInstance.ShowChatText("通知", strName[0] + " 加入了房间!"); } }); } if (CServerItem.get().GetMeUserItem() == pIClientUserItem) { Debug.Log("OnEventUserEnter:Local Player Enter"); if (m_pSelfPlayer == null) { Debug.Log("---------------------Disconnect back 2 ?: Try to Create Local Player"); //GameObject LocalTaggerObj = GameObject.Find("Player/TaggerTeam/LocalTagger"); //GameObject.Destroy(LocalTaggerObj); //删除Human //GameObjectsManager.GetInstance().ClearPlayers(false); m_pSelfPlayer = CreatePlayer(pIClientUserItem); Loom.QueueOnMainThread(() => { if (hnManager == null) { hnManager = GameObject.FindObjectOfType <HNGameManager>(); } if (hnManager != null) { if (m_pSelfPlayer != null) { int nChairId = m_pSelfPlayer.GetChairID();//m_pSelfPlayer hnManager.LocalUserEnter(nChairId); } } }); addGamePlayerToList(m_pSelfPlayer); } upSelfPlayerInfo(); int iIdex = 0; while (true) { IClientUserItem pTempUserItem = CServerItem.get().GetTableUserItem((ushort)iIdex); iIdex++; if (pTempUserItem == null) { break; } if (pTempUserItem.GetTableID() != pMeItem.GetTableID()) { continue; } if (pTempUserItem.GetUserStatus() == SocketDefines.US_LOOKON) { continue; } if (m_bEnterGetUserInfo) { m_kIndividualMission.query((int)pIClientUserItem.GetUserID(), false); } if (pTempUserItem == pIClientUserItem) { continue; } GamePlayer pTempPlayer = CreatePlayer(pTempUserItem); addGamePlayerToList(pTempPlayer); } } else { if (m_pSelfPlayer != null || pMeItem.GetUserStatus() == SocketDefines.US_LOOKON) { GamePlayer pTempPlayer = CreatePlayer(pIClientUserItem); addGamePlayerToList(pTempPlayer); } } if (m_bEnterGetUserInfo) { m_kIndividualMission.query((int)pIClientUserItem.GetUserID(), false); } }
//用户删除 public void OnGRUserDelete(IClientUserItem pIClientUserItem) { }
//用户更新 public void OnGRUserUpdate(IClientUserItem pIClientUserItem) { }
//用户信息 //用户进入 public void OnGRUserEnter(IClientUserItem pIClientUserItem) { Debug.Log("GameManager::OnGRUserEnter: " + GlobalUserInfo.GBToUtf8(pIClientUserItem.GetNickName())); }
//显示头顶信息 public void ShowPlayerTopHeadInfo(PlayerBase playerBase) { if (GameManager.s_gameSingleMultiType == GameSingleMultiType.SingleGame) { if (GameManager.s_singleGameStatus == SocketDefines.GAME_STATUS_HIDE || GameManager.s_singleGameStatus == SocketDefines.GAME_STATUS_PLAY) { Human localHuman = GameObjectsManager.GetInstance().GetLocalHuman(); if (localHuman != null) { //本地玩家为警察时不显示躲藏者信息 if (localHuman.TeamType == PlayerTeam.PlayerTeamType.TaggerTeam && playerBase.TeamType == PlayerTeam.PlayerTeamType.HideTeam) { playerBase.SetTopInfoVisible(false); return; } goto TopHeadInfo; } return; } else { return; } } else { if (CServerItem.get() == null) { return; } byte Gamestate = CServerItem.get().GetGameStatus(); if (Gamestate == SocketDefines.GAME_STATUS_HIDE || Gamestate == SocketDefines.GAME_STATUS_PLAY) { Human localHuman = GameObjectsManager.GetInstance().GetLocalHuman(); if (localHuman != null) { //本地玩家为警察时不显示躲藏者信息 if (localHuman.TeamType == PlayerTeam.PlayerTeamType.TaggerTeam && playerBase.TeamType == PlayerTeam.PlayerTeamType.HideTeam) { playerBase.SetTopInfoVisible(false); return; } goto TopHeadInfo; } else { IClientUserItem pMeItem = CServerItem.get().GetMeUserItem(); if (pMeItem == null) { return; } int nStatus = pMeItem.GetUserStatus(); if (nStatus == SocketDefines.US_LOOKON) { goto TopHeadInfo; } } } else { return; } } TopHeadInfo: { GameObject InfoPanelObj = playerBase.gameObject.transform.Find("InfoPanel").gameObject; if (InfoPanelObj != null) { TextMesh nameText = InfoPanelObj.transform.Find("Name").GetComponent <TextMesh>(); TextMesh levelText = InfoPanelObj.transform.Find("Level").GetComponent <TextMesh>(); if (playerBase.IsAI) { nameText.text = playerBase.gameObject.name; nameText.color = Color.white; if (levelText.text == "") { levelText.text = "等级:" + UnityEngine.Random.Range(0, 100); } levelText.color = Color.white; } else { var kernel = (GameScene)CServerItem.get().GetClientKernelSink(); string strNN = ""; if (GameManager.s_gameSingleMultiType == GameSingleMultiType.SingleGame) { strNN = GlobalUserInfo.getNickName(); } else if (GameManager.s_gameSingleMultiType == GameSingleMultiType.MultiGame_WangHu) { if (kernel != null) { strNN = kernel.getPlayerByChairID(playerBase.ChairID).GetNickName(); } } if (strNN != "") { String[] str = strNN.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries); nameText.text = str[0]; nameText.color = Color.white; if (kernel != null) { tagUserInfo userInfo = (tagUserInfo)kernel.getPlayerByChairID(playerBase.ChairID).GetUserInfo(); levelText.text = "等级:" + (userInfo.lExperience / 100).ToString(); } else { levelText.text = "等级:" + (GlobalUserInfo.getUserExp() / 100).ToString(); } levelText.color = Color.white; } } if (InfoPanelObj != null) { InfoPanelObj.transform.LookAt(Camera.main.transform); } } return; } }
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(); }