示例#1
0
    public static void SaveWorm()
    {
        BinaryFormatter bf = new BinaryFormatter();
        FileStream      fs = new FileStream(wormPath, FileMode.Create);

        Worm_Data data = new Worm_Data(GameManager.Instance.Worm);

        bf.Serialize(fs, data);
        fs.Close();
    }
示例#2
0
    public static Worm_Data LoadWorm()
    {
        if (File.Exists(wormPath))
        {
            BinaryFormatter bf = new BinaryFormatter();
            FileStream      fs = new FileStream(wormPath, FileMode.Open);

            Worm_Data data = (Worm_Data)bf.Deserialize(fs);

            fs.Close();

            return(data);
        }
        else
        {
            return(null);
        }
    }
示例#3
0
    public void LoadWorm()
    {
        Worm_Data data = SaveManager.LoadWorm();

        if (data != null)
        {
            Vector3 pos = new Vector3();
            pos.x = data.Position[0];
            pos.y = data.Position[1];
            pos.z = data.Position[2];
            transform.position = pos;

            Quaternion rot = new Quaternion();
            rot.x = data.Rotation[0];
            rot.y = data.Rotation[1];
            rot.z = data.Rotation[2];
            rot.w = data.Rotation[3];
            transform.rotation = rot;
        }
    }