コード例 #1
0
ファイル: SaveLoad.cs プロジェクト: deonix37/CreateYourFrisk
 public static bool LoadAlMighty()
 {
     if (File.Exists(Application.persistentDataPath + "/AlMightySave.gd"))
     {
         Debug.Log("We found an almighty save at this location : " + Application.persistentDataPath + "/AlMightySave.gd");
         BinaryFormatter bf   = new BinaryFormatter();
         FileStream      file = File.Open(Application.persistentDataPath + "/AlMightySave.gd", FileMode.Open);
         almightycurrentGame = (AlMightyGameState)bf.Deserialize(file);
         almightycurrentGame.LoadVariables();
         file.Close();
         return(true);
     }
     Debug.Log("There's no almighty save to load.");
     return(false);
 }
コード例 #2
0
 public static bool LoadAlMighty()
 {
     if (File.Exists(Application.persistentDataPath + "/AlMightySave.gd"))
     {
         Debug.Log("We found an almighty save at this location : " + Application.persistentDataPath + "/AlMightySave.gd");
         BinaryFormatter bf   = new BinaryFormatter();
         FileStream      file = File.Open(Application.persistentDataPath + "/AlMightySave.gd", FileMode.Open);
         almightycurrentGame = (AlMightyGameState)bf.Deserialize(file);
         almightycurrentGame.LoadVariables();
         file.Close();
         return(true);
     }
     else
     {
         Debug.Log("There's no almighty save to load... creating new one");
         BinaryFormatter bf = new BinaryFormatter();
         string          locFile;
         if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer)
         {
             locFile = "C:/Users/" + System.Environment.UserName + "/AppData/LocalLow/Nobody's Getting Paid Here/Create Your Frisk/AlMightySave.gd";
         }
         else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer)
         {
             locFile = "~/Library/Application Support/Nobody's Getting Paid Here/Create Your Frisk/AlMightySave.gd";
         }
         else
         {
             locFile = "$XDG_CONFIG_HOME/unity3d/Nobody's Getting Paid Here/Create Your Frisk/AlMightySave.gd";
         }
         if (File.Exists(locFile))
         {
             FileStream file = File.Open(locFile, FileMode.Open);
             almightycurrentGame = (AlMightyGameState)bf.Deserialize(file);
             almightycurrentGame.LoadVariables();
             file.Close();
             SaveAlMighty();
             return(true);
         }
         return(false);
     }
 }