//用户信息
 //用户进入
 public void OnGRUserEnter(IClientUserItem pIClientUserItem)
 {
     Debug.Log("GameManager::OnGRUserEnter: " + GlobalUserInfo.GBToUtf8(pIClientUserItem.GetNickName()));
 }
Esempio n. 2
0
        //用户事件
        //用户进入
        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);
            }
        }