示例#1
0
    // Yes = 0; No = 1
    public void Choice(int answer)
    {
        string            response  = (answer == 0) ? "Yes" : "No";
        SaveDataContainer container = SaveDataContainer.Load(Path.Combine(Application.persistentDataPath, "responses.xml"));

        container.Responses.Add(new ResponseData(response, DateTime.Now));
        container.Save(Path.Combine(Application.persistentDataPath, "responses.xml"));
        // Call the event if there are methods subscribed to it.
        if (ChoiceMade != null)
        {
            ChoiceMade();
        }
    }
示例#2
0
        public void Test_LoadOrCreate()
        {
            var svd1 = new SaveDataContainer ();
            svd1.Path = "./savedata2/";    // 存在しない
            svd1.LoadOrCreate ("TestSaveDataContainer-004.txt");
            svd1.Add ("Item", 1);
            svd1.Save ("TestSaveDataContainer-004.txt");

            var svd2 = new SaveDataContainer ();
            svd2.Path = "./savedata2/";
            svd2.Load ("TestSaveDataContainer-004.txt");

            Assert.AreEqual (1, svd2.ItemCount);
        }
    public void Save()
    {
        FeelingInterface[] feelingsArray = GameObject.FindObjectOfType <GameControllerScript>().currentFeelings;
        for (int j = 0; j < feelingsArray.GetLength(0); j++)
        {
            if (feelingsArray[j] == null)
            {
                continue;
            }
            saveData.date    = System.DateTime.Now;
            saveData.feeling = feelingsArray[j] as TunneStruct;

            try
            {
                saveDataContainer = SaveDataContainer.Load(Application.persistentDataPath + "/SaveDataContainer.xml");
                FeelingSaveData[] temp = saveDataContainer.SaveDataArray;
                saveDataContainer.SaveDataArray = new FeelingSaveData[temp.Length + 1];
                for (int i = 0; i < temp.Length; i++)
                {
                    saveDataContainer.SaveDataArray[i] = temp[i];
                }
                saveDataContainer.SaveDataArray[temp.Length] = saveData;
            }
            catch (Exception e)
            {
                saveDataContainer.SaveDataArray    = new FeelingSaveData[1];
                saveDataContainer.SaveDataArray[0] = saveData;
            }
            try
            {
                saveDataContainer.Save(Application.persistentDataPath + "/SaveDataContainer.xml");
            }
            catch (Exception e)
            {
            }
        }
    }
示例#4
0
        public void Test_Save_and_Load_with_Encryption()
        {
            var svd1 = new SaveDataContainer ();
            svd1.Encryption = true;
            svd1.Add ("Item", new MyStruct (1, 2f, "3"));
            svd1.Save ("TestSaveDataContainer-002.txt");

            var svd2 = new SaveDataContainer ();
            svd2.Encryption = true;
            svd2.Load ("TestSaveDataContainer-002.txt");

            Assert.AreEqual (1, svd2.ItemCount);
            Assert.AreEqual (new MyStruct (1, 2f, "3"), svd2.Get ("Item"));
        }