コード例 #1
0
    public static void SaveWorld(MasterWorldSave masterWorldSave)
    {
        PersistentData.Instance.CurrentWorld = masterWorldSave;
        string worldPath = Application.persistentDataPath + "/Worlds/" + masterWorldSave.guid + ".data";

        File.WriteAllBytes(worldPath, Encoding.Default.GetBytes(JsonConvert.SerializeObject(masterWorldSave)));
        Debug.Log(File.ReadAllText(worldPath));
        PersistentData.Instance.CurrentWorld = masterWorldSave;
    }
コード例 #2
0
 void LoadDDL()
 {
     string[] saves = LoadHelper.GetWorldSaves();
     for (int i = 0; i < saves.Length; i++)
     {
         masterWorldSave = LoadHelper.GetMasterWorldSave(saves[i]);
         Debug.Log(saves[i]);
         GenerateWorldSlot(masterWorldSave.name, 0f, i + 1);
     }
     Instantiate(Resources.Load <GameObject>("Prefabs/NewWorldSlot"), content.transform);
 }
コード例 #3
0
    void checkToggle(bool o)
    {
        if (toggle.isOn)
        {
            int             slotNum = Int32.Parse(this.gameObject.transform.Find("SlotNumBackground").transform.Find("SlotNum").GetComponent <Text>().text) - 1;
            MasterWorldSave s       = LoadHelper.GetMasterWorldSave(Directory.GetFiles(Application.persistentDataPath + "/Worlds/")[slotNum]);
            PersistentData.Instance.CurrentWorld = s;

            Debug.Log(PersistentData.Instance.CurrentWorld.name);
        }
    }
コード例 #4
0
 // Start is called before the first frame update
 void Start()
 {
     saveObject         = new SaveObject();
     masterSave         = new MasterSave();
     masterWorldSave    = new MasterWorldSave();
     characterInventory = new CharacterInventory();
     characterPath      = Application.persistentDataPath + "/Characters/";
     if (!Directory.Exists(Application.persistentDataPath + "/Characters/"))
     {
         Directory.CreateDirectory(Application.persistentDataPath + "/Characters/");
     }
     if (!Directory.Exists(Application.persistentDataPath + "/Worlds/"))
     {
         Directory.CreateDirectory(Application.persistentDataPath + "/Worlds/");
     }
 }