예제 #1
0
    public void SaveFurniture()
    {
        StreamWriter writer = new StreamWriter(saveName);

        BBuildManager a = this.transform.GetComponent <BBuildManager>();

        Debug.Log(a);

        List <Furniture_Recepteur> b = a.getFurnitureList();

        Debug.Log(b.Count);

        foreach (Furniture_Recepteur currentFurniture in b)
        {
            writer.WriteLine(JsonUtility.ToJson(currentFurniture.getFurniture()));
            Debug.Log(currentFurniture.getFurniture());
        }

        writer.Close();
    }
예제 #2
0
    public void LoadSaveFile(string savefileName)
    {
        // 1) Effacer tous les objets actuellement present dans la scene
        // 2) Lire 1 ligne, convertir en GameObject
        // 3) Creer un Furniture_Recepteur pour chaque gameObject avec la fonction AddFurniture de BBuildManager

        this.GetComponentInParent <BBuildManager>().RemoveAllFurniture();

        StreamReader reader = new StreamReader(savefileName);
        string       line   = reader.ReadLine();

        while (line != null)
        {
            GetComponentInParent <BBuildManager>().LoadFurniture(line);
            line = reader.ReadLine();
        }

        reader.Close();
        Transform firstObject = bBuildManager.getFurnitureList()[0].getGameObject().transform;

        cam.transform.localPosition = new Vector3(firstObject.position.x, cam.transform.position.y, firstObject.position.z);
        return;
    }