예제 #1
0
파일: Save.cs 프로젝트: GreenCalx/LD47
    bool Load(String s)
    {
        if (!File.Exists(s))
        {
            return(false);
        }
        BinaryFormatter   BF = new BinaryFormatter();
        SurrogateSelector ss = new SurrogateSelector();

        ss.AddSurrogate(typeof(Vector3),
                        new StreamingContext(StreamingContextStates.All),
                        new Vector3SerializationSurrogate());
        ss.AddSurrogate(typeof(Quaternion),
                        new StreamingContext(StreamingContextStates.All),
                        new QuaternionSerializationSurrogate());
        ss.AddSurrogate(typeof(Color),
                        new StreamingContext(StreamingContextStates.All),
                        new ColorSerializationSurrogate());
        BF.SurrogateSelector = ss;
        using (FileStream stream = new FileStream(Application.persistentDataPath + "/" + FileName + ".save", FileMode.Open, FileAccess.Read))
        {
            IS = BF.Deserialize(stream) as InputSaver;
            IS.setParent(this.gameObject.transform.parent.transform.parent.gameObject);
            stream.Close();
        }
        return(true);
    }
예제 #2
0
파일: Save.cs 프로젝트: GreenCalx/LD47
    public void Start()
    {
        IS.setParent(this.gameObject.transform.parent.transform.parent.gameObject);

        String Path = Application.persistentDataPath + "/" + FileName + ".save";

        if (this.Load(Path))
        {
            IS.FirstFrame.Apply();
            IsReplaying = true;
        }
    }
예제 #3
0
파일: Save.cs 프로젝트: GreenCalx/LD47
    public void EndLevel()
    {
        if (IsRecording)
        {
            IS.EndFrame.Init();

            String Path = Application.persistentDataPath + "/" + FileName + ".save";
            if (!IsSerializing && !IsReplaying && IS.InputsFrame.Count != 0)
            {
                BinaryFormatter   BF = new BinaryFormatter();
                SurrogateSelector ss = new SurrogateSelector();
                ss.AddSurrogate(typeof(Vector3),
                                new StreamingContext(StreamingContextStates.All),
                                new Vector3SerializationSurrogate());
                ss.AddSurrogate(typeof(Quaternion),
                                new StreamingContext(StreamingContextStates.All),
                                new QuaternionSerializationSurrogate());
                ss.AddSurrogate(typeof(Color),
                                new StreamingContext(StreamingContextStates.All),
                                new ColorSerializationSurrogate());

                BF.SurrogateSelector = ss;

                FileStream file = File.Create(Path);
                IsSerializing = true;
                BF.Serialize(file, IS);
                IsSerializing = false;
                file.Close();

                IS = new InputSaver();
                IS.setParent(this.gameObject.transform.parent.transform.parent.gameObject);
            }
        }

#if false
        if (IsReplaying)
        {
            CompareEndFrames();
        }
#endif
    }