Exemple #1
0
 public void SaveGame(Stream writer)
 {
     Console.Out.WriteLine("Game saved!");
     PlayerInventory.SaveToFile(writer);                                                                 //PlayerInventory
     HatchInv.SaveToFile(writer);                                                                        //HatchInv
     writer.WriteByte((byte)(CurrentCast != null ? 1 : 0));                                              //Is CurrentCast not null?
     if (CurrentCast != null)
     {
         StreamIO.SaveItem(CurrentCast, writer);                                         //CurrentCast if it's not null.
     }
     writer.WriteByte((byte)CastMetal);                                                  //CastMetal
     writer.Write(BitConverter.GetBytes(CastMetalPurity), 0, sizeof(float));             //CastMetalPurity
     writer.Write(BitConverter.GetBytes(CastFilling), 0, sizeof(float));                 //CastFilling
     writer.Write(BitConverter.GetBytes(CastingTemprature), 0, sizeof(float));           //CastingTemerature
     writer.Write(BitConverter.GetBytes(OldFoundryAmount), 0, sizeof(float));            //OldFoundryAmount
     for (int i = 0; i < FoundryIngots.Capacity; i++)
     {
         writer.WriteByte((byte)(FoundryIngots[i] != null?1 : 0));                                       //Is The Ingot at i not null?
         if (FoundryIngots [i] != null)
         {
             StreamIO.SaveItem(FoundryIngots [i], writer);
         }
     }
     StreamIO.SaveAlloy(FoundryAlloy, writer);                                           //FoundryAlloy
     writer.Write(BitConverter.GetBytes(AirQuality), 0, sizeof(float));                  //AirQualtiy
     writer.Write(BitConverter.GetBytes(CoalPercent), 0, sizeof(float));                 //CoalPercent
     writer.Write(BitConverter.GetBytes(FoundryTemprature), 0, sizeof(float));           //FoundryTemperature
     Console.Out.WriteLine(writer.Position);
 }
        public void SaveToFile(Stream writer)
        {
            writer.WriteByte((byte)items.Count);

            foreach (Item i in items)
            {
                StreamIO.SaveItem(i, writer);
            }
        }