Beispiel #1
0
    /// <summary>
    /// 当前分数保存到存档
    /// </summary>
    private void SavaScore()
    {
        GlobalArchival archival = ArchivalUtils.Load <GlobalArchival>();

        var curScore = PlayerPrefs.GetInt("curScore");
        var score    = archival.maxScore < curScore ? curScore : archival.maxScore;

        archival.maxScore = score;

        var curCoin = contexts.game.gameCoin.value;

        archival.coinNum += curCoin;
        ArchivalUtils.Save(archival);
    }
Beispiel #2
0
    public static object GetData(string fileName, Type pType)
    {
        //如果没有存档就创建空存档
        if (!IsDirectoryExists(ConstantUtils.dirpath))
        {
            Directory.CreateDirectory(ConstantUtils.dirpath);
            GlobalArchival obj = pType.Assembly.CreateInstance(pType.Name) as GlobalArchival;
            SetData(fileName, obj);
        }

        StreamReader streamReader = File.OpenText(fileName);
        string       data         = streamReader.ReadToEnd();

        //对数据进行解密,32位解密密钥
        data = RijndaelDecrypt(data, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
        streamReader.Close();
        return(DeserializeObject(data, pType));
    }