Ejemplo n.º 1
0
    public static MapLayoutData LoadMap(string name)
    {
        string path = "";

        if (name == "PlayLevel1" || name == "PlayLevel2" || name == "PlayLevel3")
        {
            path = Application.dataPath + "/StreamingAssets/" + name + ".layout";
        }
        else
        {
            path = Application.persistentDataPath + "/Levels/" + name + ".layout";
        }
        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            MapLayoutData data = formatter.Deserialize(stream) as MapLayoutData;
            stream.Close();

            return(data);
        }
        else
        {
            Debug.LogError("Save file not found in " + path);
            return(null);
        }
    }
Ejemplo n.º 2
0
    public static void SaveMap(MapGenerator mg, string name)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/Levels/" + name + ".layout";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        MapLayoutData data = new MapLayoutData(mg);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Ejemplo n.º 3
0
	public void LoadLayout() {
		mg.ClearMap();
		MapLayoutData data = SaveSystem.LoadMap(fileName.text);
		mg.height = data.height;
		mg.width = data.width;
		mg.size = data.size;
		mg.InitializeMap();
		mg.InitializeHills(data.hills);
		mg.InitializePortals(data.entrance, data.exit);
		mg.navSurface.BuildNavMesh();
	}
Ejemplo n.º 4
0
    private void LoadLayout()
    {
        mg.ClearMap();
        MapLayoutData data = SaveSystem.LoadMap(PersistentData.getLoadLevel());

        mg.height = data.height;
        mg.width  = data.width;
        mg.size   = data.size;
        mg.InitializeMap();
        mg.InitializeHills(data.hills);
        mg.InitializePortals(data.entrance, data.exit);
        mg.navSurface.BuildNavMesh();
    }