예제 #1
0
        public static void SavePlayer(bool isSingleplayer, PlayerSave player)
        {
            String directory;

            if (isSingleplayer)
            {
                String documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                directory = Path.Combine(documentsPath, "SpireVenture");
            }
            else
            {
                String currentPath = Directory.GetCurrentDirectory();
                directory = Path.Combine(currentPath, "Saves");

                if (!Directory.Exists(directory))
                    Directory.CreateDirectory(directory);
            }

            String savename = Path.Combine(directory, player.Username + ".sav");

            Stream streamWrite = File.Create(savename);
            BinaryFormatter binaryWrite = new BinaryFormatter();
            binaryWrite.Serialize(streamWrite, player);
            streamWrite.Close();
        }
예제 #2
0
        public static void createNewProfile(string name)
        {
            String documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            String directory = Path.Combine(documentsPath, "SpireVenture");
            String profileFilePath = Path.Combine(directory, name + ".sav");

            PlayerSave save = new PlayerSave(name, "local");

            Stream streamWrite = File.Create(profileFilePath);
            BinaryFormatter binaryWrite = new BinaryFormatter();
            binaryWrite.Serialize(streamWrite, save);
            streamWrite.Close();
        }
예제 #3
0
        public static PlayerSave getPlayerSave(bool isSingleplayer, string playerName, string keyword)
        {
            String directory;

            if (isSingleplayer)
            {
                String documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                directory = Path.Combine(documentsPath, "SpireVenture");
            }
            else
            {
                String currentPath = Directory.GetCurrentDirectory();
                directory = Path.Combine(currentPath, "Saves");

                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }
            }

            String savename = Path.Combine(directory, playerName + ".sav");

            if (File.Exists(savename))
            {
                Stream          streamRead = File.OpenRead(savename);
                BinaryFormatter binaryRead = new BinaryFormatter();
                PlayerSave      player     = (PlayerSave)binaryRead.Deserialize(streamRead);
                streamRead.Close();
                return(player);
            }
            else
            {
                PlayerSave      playerSave  = new PlayerSave(playerName, keyword);
                Stream          streamWrite = File.Create(savename);
                BinaryFormatter binaryWrite = new BinaryFormatter();
                binaryWrite.Serialize(streamWrite, playerSave);
                streamWrite.Close();
                return(playerSave);
            }
        }
예제 #4
0
        public static PlayerSave getPlayerSave(bool isSingleplayer, string playerName, string keyword)
        {
            String directory;

            if (isSingleplayer)
            {
                String documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                directory = Path.Combine(documentsPath, "SpireVenture");
            }
            else
            {
                String currentPath = Directory.GetCurrentDirectory();
                directory = Path.Combine(currentPath, "Saves");

                if (!Directory.Exists(directory))
                    Directory.CreateDirectory(directory);
            }

            String savename = Path.Combine(directory, playerName + ".sav");
            if (File.Exists(savename))
            {
                Stream streamRead = File.OpenRead(savename);
                BinaryFormatter binaryRead = new BinaryFormatter();
                PlayerSave player = (PlayerSave)binaryRead.Deserialize(streamRead);
                streamRead.Close();
                return player;
            }
            else
            {
                PlayerSave playerSave = new PlayerSave(playerName, keyword);
                Stream streamWrite = File.Create(savename);
                BinaryFormatter binaryWrite = new BinaryFormatter();
                binaryWrite.Serialize(streamWrite, playerSave);
                streamWrite.Close();
                return playerSave;
            }
        }
예제 #5
0
 // *** MAP ENTITY TO SAVE FILE HERE ***
 public static void DumpEntityIntoSaveFile(Entity ent, PlayerSave save)
 {
     save.Position = (ent.GetComponent("Position") as Position).Vector2Pos;
 }
예제 #6
0
 // *** MAP ENTITY TO SAVE FILE HERE ***
 public static void DumpEntityIntoSaveFile(Entity ent, PlayerSave save)
 {
     save.Position = (ent.GetComponent("Position") as Position).Vector2Pos;
 }