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 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); } }