コード例 #1
0
    public string Read(int id)
    {
        try
        {
            Dictionary <int, string> textDic = new Dictionary <int, string>();

            string[] newtext = File.ReadAllLines(Application.dataPath + "/HotUpdateRes/Config/PlotTextConfig.txt");
            for (int i = 2; i < newtext.Length; i++)
            {
                if (string.IsNullOrEmpty(newtext[i]))
                {
                    continue;
                }
                string   s = newtext[i];
                string[] a = s.Split('\t');
                textDic.Add(int.Parse(a[0]), a[1]);
            }
            return(textDic[id]);
        }
        catch (Exception)
        {
            UDebug.Log(id);
        }
        return(null);
    }
コード例 #2
0
ファイル: SaveService.cs プロジェクト: OlegGelezcov/boscs
        public void ResetByWinGame()
        {
            int resettedCount = 0;

            foreach (var pair in registeredSaveables)
            {
                if (pair.Value != null)
                {
                    if (pair.Value.IsLoaded)
                    {
                        pair.Value.ResetByWinGame();
                        UDebug.Log($"service => {pair.Value.SaveKey} resetted by win game");
                        resettedCount++;
                    }
                    else
                    {
                        pair.Value.LoadDefaults();
                        UDebug.Log($"service => {pair.Value.SaveKey} NOT resetted by win game");
                    }
                }
            }
            UDebug.Log(
                $"resetted services count => {resettedCount}, total services count => {registeredSaveables.Count}");
            SaveAll();
        }
コード例 #3
0
ファイル: Lanch.cs プロジェクト: lsunky/RhFrameWork
    IEnumerator MyTest(string FileUrl)
    {
        float maxNum = 100;

        for (int i = 0; i < maxNum; i++)
        {
            int randomNum = Random.Range(1, 100000);
            FileUrl = FileUrl + "?v=" + randomNum;
            WWW www = new WWW(FileUrl);
            yield return(www);

            if (string.IsNullOrEmpty(www.error))
            {
                UDebug.Log("WriteFile:  loginwindow.ab ");
                string tempFilePath = PathHelper.PersistentPath + "loginwindow" + i + ".ab";
                Util.WriteFile(tempFilePath, www.bytes);
            }
            else
            {
                UDebug.LogError(string.Format("{0}down failed:{1}", FileUrl, www.error));
                yield break;
            }
            GameStateManager.Instance.DownProgressChangeEvent(i + 1, maxNum, (float)i / maxNum);
            yield return(new WaitForSeconds(0.2f));
        }
    }
コード例 #4
0
    IEnumerator CheckFileListMd5(VersionConfig serverVersionConfig, FileUpdateVo versionVo)
    {
        string        content = File.ReadAllText(versionVo.PersistentPath);
        VersionConfig persistentVersionConfig = JsonUtility.FromJson <VersionConfig>(content);
        int           persistentVersion       = persistentVersionConfig.resVersion;
        int           serverVersion           = serverVersionConfig.resVersion;

        if (serverVersion >= persistentVersion)
        {
            bool            versionConfigChange = false;
            FileUpdateVo    fileListVo          = new FileUpdateVo(AppConst.FileListName, versionVo.Url, versionVo.Random, string.Empty, 100);
            string          fileListMd5         = Util.Md5file(fileListVo.PersistentPath);
            FileCheckResult checkResult         = null;
            byte[]          fileListBytes       = null;
            if (!serverVersionConfig.fileListMd5.Equals(fileListMd5))
            {
                versionConfigChange = true;
                WWW www = new WWW(fileListVo.FileUrl);
                yield return(www);

                if (string.IsNullOrEmpty(www.error))
                {
                    string[]      fileList       = www.text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
                    List <string> serverFileList = new List <string>(fileList);
                    fileList = File.ReadAllLines(fileListVo.PersistentPath);
                    List <string> persistentFileList = new List <string>(fileList);
                    checkResult   = Util.GetChangList(persistentFileList, serverFileList);
                    fileListBytes = www.bytes;
                }
                else
                {
                    UDebug.LogError(string.Format("{0}down failed:{1}", fileListVo.FileUrl, www.error));
                    yield break;
                }
                www.Dispose();
                //下载云端list
            }
            else if (serverVersion > persistentVersion)//只是version改变了,实际资源没有变,或者上次资源下载好了,但是version写入没有成功
            {
                versionConfigChange = true;
            }

            VersionConfig toWriteVersionConfig = versionConfigChange ? serverVersionConfig : null;
            CheckResourceComplete(toWriteVersionConfig, checkResult, fileListBytes, versionVo);
        }
        else
        {
            if (GameStateManager.Instance.showGameStateLog)
            {
                UDebug.Log("本资源比较超前,不做资源版本更新: " + "persistentVersion" + persistentVersion.ToString() + "    serverVersion:" + serverVersion.ToString());
            }
            CheckResourceComplete(null, null, null, versionVo);
        }
        yield return(new WaitForEndOfFrame());
    }
コード例 #5
0
 public void GameStateChang(GameStates state)
 {
     if (GameStateManager.Instance.showGameStateLog)
     {
         UDebug.Log("GameState:   " + state);
     }
     if (GameStateChangEvent != null)
     {
         GameStateChangEvent(state);
     }
 }
コード例 #6
0
    private void UnzipStreamingComplete(VersionConfig persistentAssetsConfig)
    {
        if (GameStateManager.Instance.showGameStateLog)
        {
            UDebug.Log("UnzipStreamingComplete");
        }
        Hashtable hash = new Hashtable();

        hash["serverVersionConfig"] = serverVersionConfig;
        hash["versionVo"]           = versionVo;
        this.stateMachine.SetState <State_CheckResource>(hash);
    }
コード例 #7
0
    private void CheckAppVersionComplete(VersionConfig serverVersionConfig, VersionConfig streamVersionConfig, FileUpdateVo versionVo)
    {
        if (GameStateManager.Instance.showGameStateLog)
        {
            UDebug.Log("CheckAppVersionComplete");
        }
        Hashtable hash = new Hashtable();

        hash["serverVersionConfig"] = serverVersionConfig;
        hash["streamVersionConfig"] = streamVersionConfig;
        hash["versionVo"]           = versionVo;
        this.stateMachine.SetState <State_CopyToPersistent>(hash);
    }
コード例 #8
0
        private System.Collections.IEnumerator UpdateManagerProfitMult(ManagerInfo manager)
        {
            yield return(new WaitUntil(() => IsLoaded));

            if (manager.IsHired)
            {
                Generators.AddProfitBoost(
                    generatorId: manager.Id,
                    boost: BoostInfo.CreateTemp(manager.ManagerProfitMultId, manager.Efficiency(Services)));

                double boostValue = Generators.GetGeneratorInfo(manager.Id).GetProfitBoostValue(manager.ManagerProfitMultId);
                UDebug.Log($"Update generator {manager.Id} efficiency mult to => {boostValue}".Attrib(bold: true, italic: true, color: "y"));
            }
        }
コード例 #9
0
 private void OnPlanetStateChanged(PlanetState oldState, PlanetState newState, PlanetInfo planet)
 {
     if (IsLoaded)
     {
         if (newState == PlanetState.Opened)
         {
             if (GameMode.IsGame)
             {
                 int countRemoved = RemoveBoosts(BoostSourceType.CoinUpgrade);
                 UDebug.Log($"count of boosts removed: {countRemoved}");
             }
             MakeGeneratorsManual();
         }
     }
 }
コード例 #10
0
    public static void ShowWindow()
    {
        EditorWindow.GetWindow(typeof(AbnormalStatusScriptableObjectCreatorWindow));
        DirectoryInfo dir = new DirectoryInfo(sourcePath);

        FileInfo[] files = dir.GetFiles("*.cs");
        objects = new List <ScriptableObject>();
        foreach (var file in files)
        {
            var name = file.Name;
            name = name.Replace(".cs", "");
            UDebug.Log(name);
            ScriptableObject obj = ScriptableObject.CreateInstance(name);
            objects.Add(obj);
        }
    }
コード例 #11
0
    static void Reload()
    {
        var go        = Selection.activeGameObject;
        var hierarchy = String.Empty;

        if (go != null)
        {
            hierarchy = UnityUtils.GetHierarchyPath(go.transform);
        }
        UnityEditor.SceneManagement.EditorSceneManager.OpenScene(currentScene);
        if (!String.IsNullOrEmpty(hierarchy))
        {
            go = GameObject.Find(hierarchy);
            Selection.activeGameObject = go;
        }
        UDebug.Log("Scene {0} reloaded.", currentScene);
    }
コード例 #12
0
    IEnumerator LoadResVersion(FileUpdateVo vo, VersionConfig streamVersionConfig)
    {
        bool          isExists = File.Exists(vo.PersistentPath);
        bool          needCopy = !isExists;
        VersionConfig persistentAssetsConfig = null;

        if (isExists)
        {
            string persistentStr = File.ReadAllText(vo.PersistentPath);
            if (GameStateManager.Instance.showGameStateLog)
            {
                UDebug.Log("persistentStr " + persistentStr);
            }
            persistentAssetsConfig = JsonUtility.FromJson <VersionConfig>(persistentStr);
            if (persistentAssetsConfig.packageVersion != streamVersionConfig.packageVersion)
            {
                needCopy = true;
            }
        }

        if (needCopy)
        {
            string resRoot = PathHelper.PersistentPath + "/" + AppConst.ResRoot;

            if (Directory.Exists(resRoot))
            {
                Directory.Delete(resRoot, true);
            }
        }

        if (!needCopy)
        {
            if (GameStateManager.Instance.showGameStateLog)
            {
                UDebug.Log("不需要解压文件");
            }
            UnzipStreamingComplete(persistentAssetsConfig);
            yield break;;
        }
        else
        {
            TaskManager.Instance.StartCoroutine(OnExtractResource(vo.Url, vo.Random, streamVersionConfig));
        }
    }
コード例 #13
0
ファイル: SourceExtension.cs プロジェクト: erwinwu211/SYHX
    public static Dictionary <string, PropertyInfo> InitDescOption <Ts, Tc>(this Ts source)
        where Ts : Source
        where Tc : Content
    {
        // UDebug.Log("==============");
        // UDebug.Log("In Start");
        var dictionary = new Dictionary <string, PropertyInfo>();
        var properties = typeof(Tc).GetProperties();

        foreach (var property in properties)
        {
            var att = (CustomDescAttribute)Attribute.GetCustomAttribute(property, typeof(CustomDescAttribute));
            if (att != null)
            {
                dictionary.Add(att.descName, property);
                UDebug.Log(att.descName);
            }
        }
        // UDebug.Log("===============");
        return(dictionary);
    }
コード例 #14
0
ファイル: SaveService.cs プロジェクト: OlegGelezcov/boscs
        public void ResetAll(params string[] excludeKeys)
        {
            UDebug.Log($"SaveService Reset All exlude => {excludeKeys.AsString()}".Colored(ConsoleTextColor.yellow));
            foreach (var pair in registeredSaveables)
            {
                if (pair.Value != null)
                {
                    string excludedKey = Array.Find(excludeKeys, key => key == pair.Value.SaveKey);

                    if (string.IsNullOrEmpty(excludedKey))
                    {
                        pair.Value.ResetFull();
                    }
                    else
                    {
                        UDebug.Log($"Key => {pair.Value.SaveKey} was excluded from resetting".Colored(ConsoleTextColor.yellow));
                    }
                }
            }
            SaveAll();
        }
コード例 #15
0
 private void DownResourceComplete()
 {
     UDebug.Log("DownResourceComplete");
     SceneManager.LoadScene("Game");
     TaskManager.Instance.StartCoroutine(Enter());
 }
コード例 #16
0
        private System.Collections.IEnumerator UpdateOnResumeImpl()
        {
            Services.GetService <IConsoleService>()?.AddOnScreenText("UpdateOnResumeImpl() generation service...");

            yield return(new WaitUntil(() => IsLoaded && Services.ResourceService.IsLoaded));

            yield return(new WaitUntil(() => Services.TransportService.IsLoaded && Services.PlayerService.IsLoaded && Services.TimeChangeService.IsLoaded));

            yield return(new WaitUntil(() => Services.InvestorService.IsLoaded));

            yield return(new WaitUntil(() => Services.GetService <ISleepService>().IsRunning));

            yield return(new WaitUntil(() => Player.LegacyPlayerData != null));

            ITransportUnitsService unitService     = Services.TransportService;
            IInvestorService       investorService = Services.InvestorService;
            ISleepService          sleepService    = Services.GetService <ISleepService>();
            IPlayerService         playerService   = Services.PlayerService;


            int interval = sleepService.SleepInterval;

            TotalOfflineBalance = 0.0;

            //clear expired timed boosts
            Generators.ClearExpiredBoosts(TimeService.UnixTimeInt);

            foreach (GeneratorInfo generator in Generators.PlanetGenerators)
            {
                if (generator.State == GeneratorState.Active)
                {
                    ProfitResult profitResult = generator.ConstructProfitResult(Generators);

                    if (generator.IsAutomatic)
                    {
                        TotalOfflineBalance += generator.UpdateAutomaticAfterSleep(interval, Generators);
                    }
                    else if (generator.IsManual && generator.IsGenerationStarted)
                    {
                        generator.AddGenerateTimer(interval);
                        if (generator.GenerateTimer >= profitResult.GenerationInterval)
                        {
                            generator.SetGenerateTimer(0);
                            generator.SetGenerationStarted(false);
                            playerService.AddGenerationCompanyCash(profitResult.ValuePerRound);
                            // UDebug.Log($"added to planet manual generator => {generator.GeneratorId} after sleep => {interval} seconds, value => {profitResult.ValuePerRound}".Colored(ConsoleTextColor.orange).Bold());
                            TotalOfflineBalance += profitResult.ValuePerRound;
                        }
                    }
                }
            }

            foreach (GeneratorInfo generator in Generators.NormalGenerators)
            {
                if (generator.State == GeneratorState.Active)
                {
                    ProfitResult profitResult = generator.ConstructProfitResult(Generators);

                    if (generator.IsAutomatic)
                    {
                        TotalOfflineBalance += generator.UpdateAutomaticAfterSleep(interval, Generators);
                        //UDebug.Log($"added to normal automatic generator => {generator.GeneratorId} after sleep => {interval} seconds, value => {value}".Colored(ConsoleTextColor.orange).Bold());
                    }
                    else if (generator.IsManual && generator.IsGenerationStarted)
                    {
                        UDebug.Log($"manul gen =>{generator.GeneratorId} sleep update".Colored(ConsoleTextColor.green).Bold());
                        generator.AddGenerateTimer(interval);
                        if (generator.GenerateTimer >= profitResult.GenerationInterval)
                        {
                            generator.SetGenerateTimer(0);
                            generator.SetGenerationStarted(false);
                            generator.SetAccumulatedCash(0);
                            playerService.AddGenerationCompanyCash(profitResult.ValuePerRound);
                            TotalOfflineBalance += profitResult.ValuePerRound;
                            generator.FireProgressEvent();
                            UDebug.Log($"added to normal manual generator => {generator.GeneratorId} after sleep => {interval} seconds, value => {profitResult.ValuePerRound}".Colored(ConsoleTextColor.orange).Bold());
                        }
                        //
                        //generator.Update(interval, Generators);
                    }
                }
            }
            //Services?.GetService<IConsoleService>()?.AddOnScreenText($"Added to company cash => {TotalOfflineBalance}");
            IsResumed = true;
        }
コード例 #17
0
    private void Save()
    {
        SaveFileDlg pth = new SaveFileDlg();

        pth.structSize   = Marshal.SizeOf(pth);
        pth.filter       = "bytes (*.bytes)";
        pth.file         = new string(new char[256]);
        pth.maxFile      = pth.file.Length;
        pth.fileTitle    = new string(new char[64]);
        pth.maxFileTitle = pth.fileTitle.Length;
        pth.initialDir   = Application.dataPath + "/HotUpdateRes/Story";        // default path
        UDebug.Log(Application.dataPath + "/HotUpdateRes/Story");
        pth.title  = "保存story数据";
        pth.defExt = "bytes";
        pth.flags  = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;

        Dictionary <string, int> plottext = new Dictionary <string, int>();
        string path = Application.dataPath + "/HotUpdateRes/Config/PlotTextConfig.txt";

        if (!File.Exists(path))
        {
            UDebug.LogError("can not find file : " + path);
            return;
        }
        string[] text           = File.ReadAllLines(path);
        bool     isChangeConfig = false;

        for (int i = 2; i < text.Length; i++)
        {
            if (string.IsNullOrEmpty(text[i]))
            {
                continue;
            }
            string[] plot = text[i].Split('\t');
            try
            {
                plottext.Add(plot[1], int.Parse(plot[0]));
            }
            catch (Exception e)
            {
                UDebug.Log(e.Message);
                UDebug.LogError("第一段:" + plot[0]);
                UDebug.LogError("第二段:" + plot[1]);
                throw;
            }
        }
        for (int i = 0; i < nodeRootList.Count; i++)
        {
            if (string.IsNullOrEmpty(((StoryNode)nodeRootList[i]).text))
            {
                ((StoryNode)nodeRootList[i]).textId = 0;
            }
            else if (plottext.ContainsKey(((StoryNode)nodeRootList[i]).text))
            {
                ((StoryNode)nodeRootList[i]).textId = plottext[((StoryNode)nodeRootList[i]).text];
            }
            else
            {
                int pltid = plottext[plottext.Keys.Last <string>()] + 1;
                plottext.Add(((StoryNode)nodeRootList[i]).text, pltid);
                ((StoryNode)nodeRootList[i]).textId = pltid;
                isChangeConfig = true;
            }
        }
        if (isChangeConfig)
        {
            string[] newtext = new string[plottext.Count + 2];
            int      i       = 2;
            newtext[0] = "id" + "\t" + "text";
            newtext[1] = "int" + "\t" + "string";
            foreach (var item in plottext)
            {
                newtext[i] = item.Value + "\t" + item.Key;
                i++;
            }
            File.WriteAllLines(Application.dataPath + "/HotUpdateRes/Config/PlotTextConfig.txt", newtext);
        }

        if (SaveFileDialog.GetSaveFileName(pth))
        {
            string filepath = pth.file;            //选择的文件路径;
            if (!OnSaveCheck())
            {
                return;
            }
            bool isSuccess = BinaryUtil.ObjectToFile(filepath, nodeRootList[0]);
            if (isSuccess)
            {
                path = filepath;
                UDebug.Log("Save succeed!");
            }
            else
            {
                UDebug.LogError("Save failed!");
            }
        }
    }
コード例 #18
0
 protected override void OnOpenHandle(UiBaseData data)
 {
     UDebug.Log("LoginWindow open ");
     inputAccount.text = "tempCode" + tempNum;
     tempNum++;
 }
コード例 #19
0
    /// <summary>
    /// 解包逻辑,装完包第一次运行时候做
    /// 现在用的比较笨的方法,真实项目可以用多线程
    /// </summary>
    /// <returns></returns>
    IEnumerator OnExtractResource(string url, string random, VersionConfig streamVersionConfig)
    {
        string message = "正在解包文件:>files.txt";
        string tempStr;

        if (GameStateManager.Instance.showGameStateLog)
        {
            UDebug.Log(message);
        }

        List <FileUpdateVo> fileVoList = new List <FileUpdateVo>();
        //files.txt
        FileUpdateVo fileUpdateVo = new FileUpdateVo(AppConst.FileListName, url, random, string.Empty, 100);

        if (Application.isMobilePlatform) //读取files.txt
        {
            WWW www = new WWW(fileUpdateVo.StreamingPath);
            yield return(www);

            tempStr = www.text;
            www.Dispose();
        }
        else
        {
            tempStr = File.ReadAllText(fileUpdateVo.StreamingPath);
        }
        string[] fileList = tempStr.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
        string[] strArr;
        foreach (var file in fileList)
        {
            string fileStr = file.Trim();
            if (!string.IsNullOrEmpty(fileStr))
            {
                strArr       = fileStr.Split('|');
                fileUpdateVo = new FileUpdateVo(strArr[0], url, random, strArr[2], float.Parse(strArr[1]));
                fileVoList.Add(fileUpdateVo);
            }
        }
        fileUpdateVo = new FileUpdateVo(AppConst.FileListName, url, random, string.Empty, 100);
        fileVoList.Add(fileUpdateVo);

        fileUpdateVo = new FileUpdateVo(AppConst.ResVersionConfigFile, url, random, string.Empty, 100, false);
        fileVoList.Add(fileUpdateVo);

        float allSize = Util.SumSize(fileVoList, fileVoList.Count);

        for (int i = 0; i < fileVoList.Count; i++)
        {
            GameStateManager.Instance.DownProgressHandle(GameStates.CopyToPersistent, fileVoList, i, allSize);
            fileUpdateVo = fileVoList[i];
            String strPath = Path.GetDirectoryName(fileUpdateVo.PersistentPath);
            if (!Directory.Exists(strPath))
            {
                Directory.CreateDirectory(strPath);
            }

            if (Application.isMobilePlatform)
            {
                WWW www = new WWW(fileUpdateVo.StreamingPath);
                yield return(www);

                if (www.isDone)
                {
                    File.WriteAllBytes(fileUpdateVo.PersistentPath, www.bytes);
                    www.Dispose();
                }
                if (GameStateManager.Instance.showGameStateLog)
                {
                    UDebug.Log(fileUpdateVo.FileName + "  文件写入成功");
                }
            }
            else
            {
                File.Copy(fileUpdateVo.StreamingPath, fileUpdateVo.PersistentPath, true);
            }
        }

        GameStateManager.Instance.DownProgressHandle(GameStates.GameMain, fileVoList, fileVoList.Count, allSize);


        message = "解包完成!!!";
        if (GameStateManager.Instance.showGameStateLog)
        {
            UDebug.Log(message);
        }

        yield return(new WaitForEndOfFrame());

        message = string.Empty;

        UnzipStreamingComplete(streamVersionConfig);
    }
コード例 #20
0
ファイル: SaveService.cs プロジェクト: OlegGelezcov/boscs
 public void UpdateResume(bool pause)
 => UDebug.Log($"{nameof(SaveService)}.{nameof(UpdateResume)}() => {pause}");
コード例 #21
0
    IEnumerator LoadResVersion(string versionFile, string _webUrl)
    {
        string       random    = DateTime.Now.ToString("yyyymmddhhmmss");
        FileUpdateVo versionVo = new FileUpdateVo(versionFile, _webUrl, random, string.Empty, 10, false);

        string configStr;
        WWW    www;

        if (Application.isMobilePlatform)
        {
            www = new WWW(versionVo.StreamingPath);
            yield return(www);

            if (!string.IsNullOrEmpty(www.error))
            {
                GameStateManager.Instance.ShowDownError(versionVo.StreamingPath, www.error);
            }
            configStr = www.text;
            www.Dispose();
        }
        else
        {
            configStr = File.ReadAllText(versionVo.StreamingPath);
        }
        VersionConfig streamVersionConfig = JsonUtility.FromJson <VersionConfig>(configStr);

        if (GameStateManager.Instance.showGameStateLog)
        {
            UDebug.Log("开始加载:" + versionVo.FileUrl);
        }
        www = new WWW(versionVo.FileUrl);
        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            GameStateManager.Instance.ShowDownError(versionVo.FileUrl, www.error);
            yield break;
        }
        if (GameStateManager.Instance.showGameStateLog)
        {
            UDebug.Log("加载结束:" + versionVo.FileName + www.text);
        }
        configStr = www.text;
        www.Dispose();

        VersionConfig serverVersionConfig = JsonUtility.FromJson <VersionConfig>(configStr);

        UDebug.enableLog = serverVersionConfig.enableLog;
        //GameStateManager.Instance.showGameStateLog = serverVersionConfig.enableLog;
        Version myVersion    = new Version(streamVersionConfig.packageVersion);
        Version cloudVersion = new Version(serverVersionConfig.packageVersion);

        if (cloudVersion > myVersion)
        {
            GameStateManager.Instance.ShowPop(true, "请下载最新版本!", () => {
                string url = AppConst.PackageUrl + "/MyGame_v" + serverVersionConfig.packageVersion + ".rar";
                //www = new WWW(url);
                Application.OpenURL(url);
                GameStateManager.Instance.Quit();
            }, GameStateManager.Instance.Quit);
        }
        else
        {
            CheckAppVersionComplete(serverVersionConfig, streamVersionConfig, versionVo);
        }
    }