コード例 #1
0
 public GameSaveClass(ControllerScript controller, EmethScript e, GameObject I, GameObject Table)
 {
     activearea    = controller.activeArea.currentAreaIndex();
     deleteditems  = controller.deleteditems.ToArray();
     EmethPosition = new float[] { e.transform.position.x, e.transform.position.y, e.transform.position.z };
     Emethscalex   = e.transform.localScale.x;
     items         = new string[I.transform.GetChild(0).childCount];
     for (int i = 0; i < I.transform.GetChild(0).childCount; i++)
     {
         items[i] = I.transform.GetChild(0).GetChild(i).name;
     }
     bools = (bool[])BoolsInts.boolies.Clone();
     plugs = (int[])Table.GetComponent <TableCloseUpScript> ().plugModes.Clone();
 }
コード例 #2
0
ファイル: SaveTheGame.cs プロジェクト: agnuss7/csharp
    public static void Save(ControllerScript controller, EmethScript e, GameObject I, GameObject Table)
    {
        BinaryFormatter form    = new BinaryFormatter();
        string          folder  = Application.persistentDataPath + "/SavedGames";
        string          savelog = Application.persistentDataPath + "/SavedGames/savelog.xml";

        if (!Directory.Exists(folder))
        {
            Directory.CreateDirectory(folder);
        }
        if (!File.Exists(savelog))
        {
            //File.Create (savelog);
            using (var fs = new FileStream(savelog, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite))
            {
                var newText = Encoding.UTF8.GetBytes("<xml>\n</xml>");
                fs.Write(newText, 0, newText.Length);
                fs.Close();
            }
        }
        string     name   = System.DateTime.Now.Month.ToString() + System.DateTime.Now.Day.ToString() + System.DateTime.Now.Hour.ToString() + System.DateTime.Now.Minute.ToString() + System.DateTime.Now.Second.ToString();
        string     path   = Application.persistentDataPath + "/SavedGames/" + name + ".gm";
        FileStream stream = new FileStream(path, FileMode.Create);

        GameSaveClass c = new GameSaveClass(controller, e, I, Table);

        form.Serialize(stream, c);
        stream.Close();
        string xml = "<save><image>" + name + ".jpg</image><timestamp>" + System.DateTime.Now.ToString() + "</timestamp><file>" + name + ".gm</file></save>\n</xml>";

        using (var fs = new FileStream(savelog, FileMode.Open))
        {
            fs.Seek(-6, SeekOrigin.End);
            var newText = Encoding.UTF8.GetBytes(xml);
            fs.Write(newText, 0, newText.Length);
            fs.Close();
        }

        /*
         * string old = File.ReadAllText (savelog);
         * old=old.Remove(old.Length - 6) + xml;
         * File.WriteAllText(savelog, old);
         */
        screenshotscript.TakeScreenshot_stat(name);
    }