Exemplo n.º 1
0
        protected override void OnDisconnect(PhotonHostRuntimeInterfaces.DisconnectReason reasonCode, string reasonDetail)
        {
            // 断开连接时候需要从队伍中剔除该用户
            MyGameApplication.MyInstance.RemovePeer(m_strRoomID, this);

            // 断开连接时候需要从已经创建了怪物列表中剔除该用户
            if (MyGameApplication.MyInstance.m_pInitMonsterPeer.Contains(this))
            {
                MyGameApplication.MyInstance.m_pInitMonsterPeer.Remove(this);
            }

            // 清除MonsterManager
            if (m_monsterManager != null)
            {
                m_monsterManager.Clear();
            }

            // 玩家掉线,通知队伍玩家删除自己
            HandlerBase curHandler = null;

            // 获取对应的Handler
            MyGameApplication.MyInstance.m_DicHandler.TryGetValue((byte)OperationCode.RemoveTeamRole, out curHandler);
            if (curHandler != null)
            {
                BattleHandler h = (BattleHandler)curHandler;
                h.RemoveTeamRole(this);
            }
            m_curRole = null;
            m_curUser = null;
            log.Debug("A Peer Is Disconnect");
        }