示例#1
0
    /// <summary>
    /// 复制(深拷贝)
    /// </summary>
    protected override void toCopy(BaseData data)
    {
        if (!(data is PlayerOfflineCacheExData))
        {
            return;
        }

        PlayerOfflineCacheExData mData = (PlayerOfflineCacheExData)data;

        this.serverOffTime = mData.serverOffTime;
    }
示例#2
0
    /// <summary>
    /// 是否数据一致
    /// </summary>
    protected override bool toDataEquals(BaseData data)
    {
        PlayerOfflineCacheExData mData = (PlayerOfflineCacheExData)data;

        if (this.serverOffTime != mData.serverOffTime)
        {
            return(false);
        }

        return(true);
    }
示例#3
0
    private void initNewPlayer()
    {
        _listData = null;

        _offlineWorkListData = GameC.factory.createClientOfflineWorkListData();
        _offlineWorkListData.initDefault();

        _offLineExData = GameC.factory.createPlayerOfflineCacheExData();
        _offLineExData.initDefault();

        _currentIndex = _offlineWorkListData.index;
    }
示例#4
0
    /** 读取某角色(离线用) */
    public void loadPlayer(long playerID)
    {
        int serverBornCode = GameC.save.getCacheServerBornCode();

        if (_currentBornCode == serverBornCode && _currentPlayerID == playerID)
        {
            return;
        }

        _currentBornCode = serverBornCode;
        _currentPlayerID = playerID;

        //兼容旧版
        if (_currentBornCode <= 0)
        {
            _playerSavePath = Application.persistentDataPath + "/player_" + playerID + "/offlinePlayer.bin";
        }
        else
        {
            _playerSavePath = Application.persistentDataPath + "/player_" + serverBornCode + "_" + playerID + "/offlinePlayer.bin";
        }

        _listData = null;

        if (FileUtils.fileExists(_playerSavePath))
        {
            BytesReadStream stream = FileUtils.readFileForBytesReadStream(_playerSavePath);

            int version = stream.readInt();

            //版本号不匹配
            if (version != BaseC.config.getDBDataVersion())
            {
                Ctrl.errorLog("本地存储结构版本不匹配,已清空persistant!,old:" + version + ",new:" + BaseC.config.getDBDataVersion());

                //不是正式版
                if (!ShineSetting.isOfficial)
                {
                    if (ShineSetting.isRelease)
                    {
                        FileUtils.deleteFile(_playerSavePath);
                    }
                    else
                    {
                        FileUtils.clearDir(Application.persistentDataPath);
                    }

                    initNewPlayer();
                    return;
                }

                //跳过list
                stream.startReadObj();
                stream.endReadObj();
                _listData = null;
            }
            else
            {
                _listData = GameC.player.createListData();
                _listData.readBytesFull(stream);
            }

            _offlineWorkListData = GameC.factory.createClientOfflineWorkListData();
            _offlineWorkListData.readBytesFull(stream);

            _offLineExData = GameC.factory.createPlayerOfflineCacheExData();
            _offLineExData.readBytesFull(stream);

            _currentIndex = _offlineWorkListData.index;
        }
        else
        {
            initNewPlayer();
        }

        if (!_playerLoaded)
        {
            _playerLoaded = true;

            //需要离线部分
            if (CommonSetting.useOfflineGame)
            {
                TimeDriver.instance.setInterval(onSave, CommonSetting.offlineSaveDelay);
            }
        }
    }