Exemplo n.º 1
0
    private void AppendStandardInfo(List <string> jsonObjs)
    {
        GameWebAPI.RespDataWD_DungeonStart respDataWD_DungeonStart = ClassSingleton <QuestData> .Instance.RespDataWD_DungeonStart;
        string             str                = string.Concat(jsonObjs.ToArray());
        string             hashCode           = this.CalculateMD5(str);
        VersatileDataStore versatileDataStore = new VersatileDataStore
        {
            worldDungeonId = respDataWD_DungeonStart.worldDungeonId,
            startId        = respDataWD_DungeonStart.startId,
            hashCode       = hashCode,
            randomState    = JsonUtility.ToJson(UnityEngine.Random.state)
        };

        UnityEngine.Random.state = JsonUtility.FromJson <UnityEngine.Random.State>(versatileDataStore.randomState);
        string item = JsonWriter.Serialize(versatileDataStore);

        jsonObjs.Insert(0, item);
        jsonObjs.Insert(0, VersionManager.version);
    }
Exemplo n.º 2
0
    private bool ValidateAndCacheJson(string resJson)
    {
        bool flag = true;

        try
        {
            string[] array = JsonReader.Deserialize <string[]>(resJson);
            if (array.Length < 3)
            {
                global::Debug.LogError("jsonObj format error");
                flag = false;
            }
            if (flag && VersionManager.version == array[0])
            {
                GameWebAPI.RespDataWD_DungeonStart respDataWD_DungeonStart = ClassSingleton <QuestData> .Instance.RespDataWD_DungeonStart;
                string b  = string.Empty;
                string b2 = string.Empty;
                if (respDataWD_DungeonStart == null)
                {
                    global::Debug.LogWarning("dungeon data is null");
                    flag = false;
                }
                else
                {
                    b  = respDataWD_DungeonStart.startId;
                    b2 = respDataWD_DungeonStart.worldDungeonId;
                }
                VersatileDataStore versatileDataStore = JsonReader.Deserialize <VersatileDataStore>(array[1]);
                string             startId            = versatileDataStore.startId;
                string             worldDungeonId     = versatileDataStore.worldDungeonId;
                if (flag && startId == b && worldDungeonId == b2)
                {
                    string[] array2 = new string[array.Length - 1];
                    int      num    = 2;
                    Array.Copy(array, num, array2, 0, array.Length - num);
                    string str = string.Concat(array2);
                    string a   = this.CalculateMD5(str);
                    if (a == versatileDataStore.hashCode)
                    {
                        this.cachedJsonArr = array2;
                    }
                    else
                    {
                        global::Debug.LogError("MD5違う.");
                        flag = false;
                    }
                }
                else
                {
                    flag = false;
                }
            }
            else
            {
                flag = false;
            }
        }
        catch (Exception ex)
        {
            global::Debug.LogErrorFormat("Error:{0}", new object[]
            {
                ex.Message
            });
            flag = false;
        }
        return(flag);
    }
Exemplo n.º 3
0
    private IEnumerator CacheJsonBySaveDataForBattle(Action <bool> callback)
    {
        global::Debug.Log("CacheJsonBySaveDataForBattle.");
        bool   res  = true;
        string path = this.GetJsonFilePath(this.isSubTurn);

        if (string.IsNullOrEmpty(VersionManager.version))
        {
            global::Debug.LogError("VersionManager.version is null.");
            callback(false);
            yield break;
        }
        string      tmpJsonStr = string.Empty;
        IEnumerator wait       = this.LoadFromBinaryFile(path, delegate(string resJson)
        {
            global::Debug.Log("resJson.");
            tmpJsonStr = resJson;
        });

        while (wait.MoveNext())
        {
            object obj = wait.Current;
            yield return(obj);
        }
        if (string.IsNullOrEmpty(tmpJsonStr))
        {
            global::Debug.LogError("tmpJsonStr file is bad.");
            callback(false);
            yield break;
        }
        try
        {
            string[] array = JsonReader.Deserialize <string[]>(tmpJsonStr);
            if (array.Length < 3)
            {
                global::Debug.LogError("jsonObj format error");
                res = false;
            }
            if (res && VersionManager.version == array[0])
            {
                GameWebAPI.RespDataWD_DungeonStart respDataWD_DungeonStart = ClassSingleton <QuestData> .Instance.RespDataWD_DungeonStart;
                string b  = string.Empty;
                string b2 = string.Empty;
                if (respDataWD_DungeonStart == null)
                {
                    global::Debug.LogError("dungeon data is null");
                    res = false;
                }
                else
                {
                    b  = respDataWD_DungeonStart.startId;
                    b2 = respDataWD_DungeonStart.worldDungeonId;
                }
                VersatileDataStore versatileDataStore = JsonReader.Deserialize <VersatileDataStore>(array[1]);
                string             startId            = versatileDataStore.startId;
                string             worldDungeonId     = versatileDataStore.worldDungeonId;
                if (versatileDataStore.randomSeed != 0)
                {
                    UnityEngine.Random.InitState(versatileDataStore.randomSeed);
                }
                else
                {
                    UnityEngine.Random.state = JsonUtility.FromJson <UnityEngine.Random.State>(versatileDataStore.randomState);
                }
                if (res && startId == b && worldDungeonId == b2)
                {
                    this.cachedJsonArr = new string[array.Length - 1];
                    int num = 2;
                    Array.Copy(array, num, this.cachedJsonArr, 0, array.Length - num);
                    callback(res);
                    yield break;
                }
                callback(false);
                yield break;
            }
            else
            {
                res = false;
            }
        }
        catch (Exception ex)
        {
            global::Debug.LogErrorFormat("Error:{0}", new object[]
            {
                ex.Message
            });
            res = false;
        }
        global::Debug.LogFormat("最終的なres:{0}", new object[]
        {
            res
        });
        callback(res);
        yield break;
    }