示例#1
0
    public void load()
    {
        SceneLoader scene = GameObject.Find("SceneLoader").GetComponent <SceneLoader>();


        string fileName = "X" + secX.ToString() + "Z" + secZ.ToString() + ".dat";


        if (File.Exists(Application.persistentDataPath + "/" + sceneName + "/Sectors/" + fileName))
        {
            BinaryFormatter bf     = new BinaryFormatter();
            FileStream      input  = File.Open(Application.persistentDataPath + "/" + sceneName + "/Sectors/" + fileName, FileMode.OpenOrCreate);
            SaveSector      sector = (SaveSector)bf.Deserialize(input);
            if (secX != 0 || secZ != 0)
            {
                this.seed = sector.seed;
                this.molH = sector.molH;
                scene.loadScene(seed);
                expandMol();
            }
            else
            {
                this.molH = sector.molH;
                loadBase(scene);
            }
        }
        else
        {
            scene.generateWithoutSeed();
        }
    }
示例#2
0
    void saveSectorWithoutDestory()
    {
        condenseWODestroy();
        SceneLoader scene = GameObject.Find("SceneLoader").GetComponent <SceneLoader>();

        this.seed = scene.seed;
        string fileName = "X" + secX.ToString() + "Z" + secZ.ToString() + ".dat";

        BinaryFormatter bf = new BinaryFormatter();

        if (!Directory.Exists(Application.persistentDataPath + "/" + sceneName + "/Sectors/"))
        {
            Directory.CreateDirectory(Application.persistentDataPath + "/" + sceneName + "/Sectors/");
        }
        Debug.Log(Application.persistentDataPath + "/" + sceneName + "/Sectors/");
        FileStream output = File.Open(Application.persistentDataPath + "/" + sceneName + "/Sectors/" + fileName, FileMode.OpenOrCreate);
        SaveSector save   = new SaveSector(seed, molH);

        bf.Serialize(output, save);
        output.Close();
    }