예제 #1
0
    public BaseConfig getSplitConfigSync(int type, string configName, int key)
    {
        int configResourceID = LoadControl.getResourceIDByNameAbs(getSplitConfigPath(configName, key));

        byte[] bytes = (byte[])LoadControl.getResource(configResourceID);

        if (bytes == null)
        {
            return(null);
        }

        BytesReadStream stream = _tempStream;

        stream.setBuf(bytes);

        if (CommonSetting.configNeedCompress)
        {
            stream.unCompress();
        }

        if (!stream.checkVersion(ShineGlobal.configVersion))
        {
            Ctrl.errorLog("config结构版本不对");
            return(null);
        }

        if (!checkSplitStream(stream))
        {
            return(null);
        }

        BaseConfig bConfig = _useData.readBytesOneSplit(type, stream);

        return(bConfig);
    }
예제 #2
0
    /** 读取角色数据 */
    public void loadPlayer(long playerID)
    {
        int serverBornCode = GameC.save.getCacheServerBornCode();

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

        _data = GameC.factory.createClientPlayerLocalCacheData();

        BytesReadStream stream = FileUtils.readFileForBytesReadStream(_savePath);

        if (stream != null && stream.checkVersion(ShineGlobal.playerSaveVersion))
        {
            _data.readBytesFull(stream);
        }
        else
        {
            _data.initDefault();
        }
    }
예제 #3
0
    public void loadSplit(int type, string configName, int key, Action <BaseConfig> overFunc)
    {
        int configResourceID = LoadControl.getResourceIDByNameAbs(getSplitConfigPath(configName, key));

        LoadControl.loadOne(configResourceID, () =>
        {
            byte[] bytes = (byte[])LoadControl.getResource(configResourceID);

            BytesReadStream stream = _tempStream;

            stream.setBuf(bytes);

            if (CommonSetting.configNeedCompress)
            {
                stream.unCompress();
            }

            if (!stream.checkVersion(ShineGlobal.configVersion))
            {
                Ctrl.errorLog("config结构版本不对");
                return;
            }

            if (!checkSplitStream(stream))
            {
                return;
            }

            BaseConfig bConfig = _useData.readBytesOneSplit(type, stream);

            overFunc(bConfig);
        });
    }
예제 #4
0
    /// <summary>
    /// 读取本地文件
    /// </summary>
    private void load()
    {
        _data = new KeepSaveData();

        BytesReadStream stream = FileUtils.readFileForBytesReadStream(_localSavePath);

        if (stream != null && stream.checkVersion(ShineGlobal.localSaveVersion))
        {
            _data.readBytesFull(stream);
        }
        else
        {
            _data.initDefault();
        }
    }
예제 #5
0
    /** 读取登录数据缓存 */
    public ClientLoginCacheData loadLoginCache()
    {
        if (_loginData != null)
        {
            return(_loginData);
        }

        BytesReadStream stream = FileUtils.readFileForBytesReadStream(_loginDataPath);

        if (stream != null && stream.checkVersion(ShineGlobal.loginDataVersion))
        {
            _loginData = new ClientLoginCacheData();
            _loginData.readBytesFull(stream);
            return(_loginData);
        }

        return(null);
    }
예제 #6
0
        /** 读取bundleInfo */
        private void readLastBundleInfo()
        {
            string bundlePath = getTargetSourcePath() + "/" + ShineGlobal.bundleInfoPath;

            //存在
            if (!File.Exists(bundlePath))
            {
                Ctrl.throwError("请先执行打包!");
            }
            else
            {
                BytesReadStream stream = FileUtils.readFileForBytesReadStream(bundlePath);

                if (!stream.checkVersion(ShineGlobal.bundleInfoVersion))
                {
                    Ctrl.throwError("请先执行打包!");
                    return;
                }

                ResourceInfoControl.readBundleInfo(stream);
            }
        }
예제 #7
0
        /** 读取上次发布信息 */
        private void readLastReleaseInfo()
        {
            string targetVersionPath = getTargetSavePath() + "/" + ShineGlobal.versionInfoPath;

            _lastTargetVersion = new VersionSaveExData();

            BytesReadStream stream = FileUtils.readFileForBytesReadStream(targetVersionPath);

            //存在
            if (stream != null && stream.checkVersion(ShineGlobal.versionInfoVersion))
            {
                _lastTargetVersion.readBytes(stream);
            }
            else
            {
                _isNewApp                               = true;
                _isAppNeedUpdate                        = true;
                _lastTargetVersion.version              = "";
                _lastTargetVersion.appVersion           = 0;
                _lastTargetVersion.resourceVersion      = 0;
                _lastTargetVersion.leastResourceVersion = 1;              //最小1版
            }
        }
예제 #8
0
    private ConfigReadData doRead(BytesReadStream stream)
    {
        if (CommonSetting.configNeedCompress)
        {
            stream.unCompress();
        }

        if (!stream.checkVersion(ShineGlobal.configVersion))
        {
            Ctrl.errorLog("config结构版本不对");
            return(null);
        }

        if (!checkStream(stream))
        {
            return(null);
        }

        ConfigReadData data = GameC.factory.createConfigReadData();

        data.readBytes(stream);
        return(data);
    }
예제 #9
0
        /// <summary>
        /// 生成UI预制
        /// </summary>
        /// <param name="force">是否强制全部生成(如果否,则增量生成,只生成改变量)</param>
        public static void make(bool force = false)
        {
            EditorUtility.DisplayProgressBar("请耐心等待", "正在抽离UI预制体...", 0.0f);

            /** 需要处理的预制体列表 */
            SMap <string, long> generateList = new SMap <string, long>();
            /** 全部预处理列表(包含当前所有的预制体修改记录,用于生成记录文件) */
            SMap <string, long> allGenerateList = new SMap <string, long>();

            if (!Directory.Exists(ShineToolGlobal.uiModelsPath))
            {
                Directory.CreateDirectory(ShineToolGlobal.uiModelsPath);
            }

            if (!Directory.Exists(ShineToolGlobal.uiGenerateModelsPath))
            {
                Directory.CreateDirectory(ShineToolGlobal.uiGenerateModelsPath);
                force = true;
            }

            //生成新预处理列表
            string[] files   = FileUtils.getDeepFileList(ShineToolGlobal.uiModelsPath, "prefab");
            int      pathLen = ShineToolGlobal.gamePath.Length + 1;

            for (int i = 0; i < files.Length; i++)
            {
                string file = files[i];
                long   time = File.GetLastWriteTime(file).Ticks;
                file = file.Substring(pathLen);
                generateList.put(file, time);
                allGenerateList.put(file, time);
            }

            //读取旧预处理列表
            BytesReadStream stream = FileUtils.readFileForBytesReadStream(ShineToolGlobal.uiRecordPath);

            //读取旧预处理列表
            if (force || stream == null || !stream.checkVersion(ShineToolGlobal.uiRecordVersion))
            {
                FileUtils.clearDir(ShineToolGlobal.uiGenerateModelsPath);
            }
            else
            {
                /** 旧预处理列表 */
                SMap <string, long> oldGenerateList = new SMap <string, long>();

                int len = stream.readInt();
                for (int i = 0; i < len; ++i)
                {
                    oldGenerateList[stream.readUTF()] = stream.readLong();
                }

                //比较新旧预制列表,并删除无效预制
                oldGenerateList.forEach((k, v) =>
                {
                    long newTime;
                    string genPath = ShineToolGlobal.uiGenerateModelsPath + "/";
                    if (generateList.tryGetValue(k, out newTime))                //如果新列表里有
                    {
                        if (newTime == oldGenerateList[k])                       //如果未修改,则不用抽离
                        {
                            generateList.remove(k);
                        }
                        else                          //如果已修改
                        {
                            File.Delete(genPath + Path.GetFileName(k));
                        }
                    }
                    else                      //新列表里没有,说明已删除
                    {
                        File.Delete(genPath + Path.GetFileName(k));
                    }
                });
            }

            //生成UI预制
            int progressNum = generateList.length() + 1;
            int curNum      = 0;

            generateList.forEach((k, v) =>
            {
                generateUIPrefab(k);
                ++curNum;
                EditorUtility.DisplayProgressBar("请耐心等待", "正在抽离UI预制体...", (float)curNum / progressNum);
            });

            //写入记录
            BytesWriteStream buffer = new BytesWriteStream();

            buffer.writeVersion(ShineToolGlobal.uiRecordVersion);

            buffer.writeInt(allGenerateList.Count);

            allGenerateList.forEach((k, v) =>
            {
                buffer.writeUTF(k);
                buffer.writeLong(allGenerateList[k]);
            });

            FileUtils.writeFileForBytes(ShineToolGlobal.uiRecordPath, buffer);

            EditorUtility.ClearProgressBar();
        }