Exemple #1
0
        public static void SaveShip(ShipProperties properties)
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(SHIPS_PROPERTIES_PATH, FileMode.Create);

            formatter.Serialize(stream, properties);
            stream.Close();
        }
Exemple #2
0
        public static ShipProperties LoadShip(ShipType type)
        {
            string file = SHIPS_PROPERTIES_PATH;

            if (!File.Exists(file))
            {
                ShipProperties newShip = new ShipProperties();
                SaveShip(newShip);
            }

            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(file, FileMode.Open);
            ShipProperties  ship      = (ShipProperties)formatter.Deserialize(stream);

            stream.Close();
            return(ship);
        }