Пример #1
0
 public void NewGame()
 {
     disposed        = false;
     PlayerInventory = new Inventory();
     HatchInv        = new HatchInventory();
     PlayerInventory.AddItem(new IngotItem(KnownMetal.Iron, 1));
     HatchInv.AddItem(new CastItem(CastItem.GreatsowordCast));
     HatchInv.AddItem(new CastItem(CastItem.BroadswordCast));
     HatchInv.AddItem(new CastItem(CastItem.IngotCast));
     HatchInv.AddItem(new IngotItem(KnownMetal.Gold, 0.8f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Iron, 0.7f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Gold, 0.9f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Copper, 1f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Copper, 0.8f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Copper, 1f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Copper, 0.65f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Bronze, 0.8f));
     HatchInv.AddItem(new IngotItem(KnownMetal.HiTinBronze, 0.9f));
     HatchInv.AddItem(new IngotItem(KnownMetal.LowTinBronze, 0.7f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Tin, 0.8f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Tin, 0.9f));
     FoundryIngots     = new SolidList <IngotItem> (FoundryMeshInfo.IngotAmount);
     FoundryAlloy      = new Alloy();
     AirQuality        = 25;
     CoalPercent       = 80;
     FoundryTemprature = 25;
     CastMetal         = -1;
 }
Пример #2
0
        public void LoadGame(Stream reader)
        {
            disposed = false;
            Console.WriteLine("Loading game!");
            PlayerInventory = new Inventory();
            PlayerInventory.LoadFromFile(reader);                                                                       //PlayerInventory
            HatchInv = new HatchInventory();
            HatchInv.LoadFromFile(reader);                                                                              //HatchInv
            if (reader.ReadByte() != 0)                                                                                 //Check if CurrentCast is not null
            {
                CurrentCast = (CastItem)StreamIO.LoadItem(reader);                                                      //CurrentCast
            }
            CastMetal = reader.ReadByte();                                                                              //CastMetal
            var buffer = new byte[sizeof(float) * 4];

            reader.Read(buffer, 0, sizeof(float) * 4);                                                                          //CastMetaPurity, CastFilling, CastingTemperature, OldFoundryAmount
            CastMetalPurity   = BitConverter.ToSingle(buffer, 0);
            CastFilling       = BitConverter.ToSingle(buffer, sizeof(float));
            CastingTemprature = BitConverter.ToSingle(buffer, 2 * sizeof(float));
            OldFoundryAmount  = BitConverter.ToSingle(buffer, 3 * sizeof(float));
            FoundryIngots     = new SolidList <IngotItem> (FoundryMeshInfo.IngotAmount);
            for (int i = 0; i < FoundryIngots.Capacity; i++)
            {
                if (reader.ReadByte() != 0)                                                             //Check if the item is not null
                {
                    FoundryIngots [i] = (IngotItem)StreamIO.LoadItem(reader);                           //Read IngotItems
                }
            }
            FoundryAlloy = StreamIO.LoadAlloy(reader);                                                                  //FoundryAlloy
            reader.Read(buffer, 0, sizeof(float) * 3);                                                                  //Read3
            AirQuality        = BitConverter.ToSingle(buffer, 0);                                                       //AirQuality
            CoalPercent       = BitConverter.ToSingle(buffer, sizeof(float));                                           //CoalPercent
            FoundryTemprature = BitConverter.ToSingle(buffer, sizeof(float) * 2);                                       //FoundryTemperature
            Console.Out.WriteLine(reader.Position);
        }