Esempio n. 1
0
    private static void SaveActors(string path, CharacterSaveContainer actors)
    {
        string       json = JsonUtility.ToJson(actors);
        StreamWriter sw   = File.CreateText(path + ".txt");

        sw.Close();
        File.WriteAllText(path + ".txt", json);
    }
Esempio n. 2
0
    private static void SaveActors(string path, CharacterSaveContainer actors)
    {
        string json = JsonUtility.ToJson(actors);
        //Debug.Log ("jsoN: " + json);
        //Debug.Log ("save to path: " + path+ ".txt");
        //Debug.Log("Saving: " + json.ToString() + " to path: " + path);
        StreamWriter sw = File.CreateText(path + ".txt");

        sw.Close();
        File.WriteAllText(path + ".txt", json);
    }
Esempio n. 3
0
    //public const string playerPath = "Prefabs/Player";

    //Loading---------------
    public static void LoadRoom(string path)
    {
        charContainer = LoadChars(path);
        //Debug.Log ("items to recreate: " + charContainer.actors.Count + " from: " + path);
        foreach (CharData data in charContainer.actors)
        {
            RecreatePersistentItem(data, data.prefabPath,
                                   data.pos, Quaternion.identity);
            //PersistentItem pi = RecreatePersistentItem
            //pi.registryCheck ();
        }
        //OnLoaded();
        //ClearActorList();
    }
Esempio n. 4
0
    void m_moveItem(GameObject go, string newRoom, Vector3 newPos)
    {
        PersistentItem item = go.GetComponent <PersistentItem> ();

        item.StoreData();
        refreshPersItems();
        DelCharData(item.data);
        CharacterSaveContainer cc = LoadChars(savePath + newRoom);

//		item.pos = newPos;
        JsonUtility.ToJson(new CharacterSaveContainer());
        cc.actors.Add(item.data);
        Save(savePath + newRoom, cc);
        ResaveRoom();
    }
Esempio n. 5
0
 private static CharacterSaveContainer LoadChars(string path)
 {
     if (File.Exists(path + ".txt"))
     {
         string json = File.ReadAllText(path + ".txt");
         //Debug.Log ("Chars from path: " + path + " : " + json);
         return(JsonUtility.FromJson <CharacterSaveContainer>(json));
     }
     else
     {
         //Debug.Log("no save data found, creating new file");
         CharacterSaveContainer cc = new CharacterSaveContainer();
         SaveActors(path, cc);
         return(cc);
     }
 }
Esempio n. 6
0
    void m_moveItem(GameObject go, string newRoom, string newID, RoomDirection newDir)
    {
        //Debug.Log ("Moving " + go.name + " to " + newRoom + " at position: " + newID + " direction: " + newDir);
        PersistentItem item = go.GetComponent <PersistentItem> ();

        //Remove the current data.
        item.StoreData();
        refreshPersItems();
        DelCharData(item.data);

        //load the list of things in the new room and add the current character to it
        CharacterSaveContainer cc = LoadChars(savePath + newRoom);

        item.data.targetID  = newID;
        item.data.targetDir = newDir;
        cc.actors.Add(item.data);
        //Debug.Log ("What is this anyways?: " + item.data.targetID + " : " + item.data.targetDir);
        Save(savePath + newRoom, cc);
        ResaveRoom();
        LoadChars(savePath + curRoom);
    }
Esempio n. 7
0
 //Saving --------------------
 public static void Save(string path, CharacterSaveContainer actors)
 {
     SaveActors(path, actors);
 }