コード例 #1
0
        public void SaveShop()
        {
            SortedDictionary <String, String> saveData = new SortedDictionary <string, string>();

            saveData.Add("count", shopInventory.Count.ToString());
            Game.saveFile.Save(Game1.SaveFilePath, "save.ini", "shop" + identifyer, saveData);

            for (int i = 0; i < shopInventory.Count; i++)
            {
                saveData.Clear();
                saveData.Add("name", shopInventory[i].ToString());
                saveData.Add("kind", shopInventory[i].Kind);
                if (shopInventory[i] is ShipPart)
                {
                    ShipPart tmp = (ShipPart)shopInventory[i];
                    saveData.Add("variety", tmp.GetShipPartVariety().ToString());
                }
                if (shopInventory[i] is QuantityItem)
                {
                    QuantityItem foo = (QuantityItem)shopInventory[i];
                    saveData.Add("quantity", foo.Quantity.ToString());
                }
                Game.saveFile.Save(Game1.SaveFilePath, "save.ini", "shop" + identifyer + i, saveData);
            }
        }
コード例 #2
0
        public override void Initialize()
        {
            base.Initialize();

            RestartAfterFail();

            rebelBribe = new FlameShotWeapon(Game, ItemVariety.Low);

            fortrunStation = Game.stateManager.overworldState.GetStation("Fortrun Station");

            dummyCoordinateObject = new DummyCoordinateObject(Game, Game.spriteSheetOverworld);
            dummyCoordinateObject.Initialize();
            dummyCoordinateObject.position = DummyCoordinatePosition;

            rebelOutpost = new RebelOutpostAsteroid(Game, Game.stateManager.overworldState.GetSectorX.GetSpriteSheet());
            rebelOutpost.Initialize();

            SetDestinations();
            SetupObjectives();
        }
コード例 #3
0
        private void RandomShipPartAddition()
        {
            int     iterations  = 0;
            Boolean foundTarget = false;

            while (!foundTarget)
            {
                int pos = Game.random.Next(shopInventory.Count);
                if (shopInventory[pos] is EmptyItem)
                {
                    ShipPart part = ExtractShipPartFromItemFrequencies();
                    InsertPartAt(part, pos);
                    foundTarget = true;
                }

                iterations++;
                if (iterations > 1000)
                {
                    throw new ArgumentOutOfRangeException("You are attempting to add an item to a full shop inventory");
                }
            }
        }
コード例 #4
0
        protected void InventoryItemSetup(ShopFilling filling)
        {
            FillShopInventoryWithEmptyItem();

            int items = Game.random.Next(GetLowerFillLimit(filling), GetUpperFillLimit(filling));

            for (int n = 0; n < items; n++)
            {
                if (n < mandatoryShipItems.Count)
                {
                    ShopInventoryEntry entry = mandatoryShipItems[n];

                    ShipPart part = RetrievePartFromEnum(entry.ShipPartType, Game);
                    part.SetShipPartVariety(entry.ItemVariety);
                    InsertPartAt(part, n);
                }
                else if (!inventoryIsFixed)
                {
                    ShipPart part = ExtractShipPartFromItemFrequencies();
                    InsertPartAt(part, n);
                }
            }
        }
コード例 #5
0
        private ShipPart ExtractShipPartFromItemFrequencies()
        {
            ShipPart part = null;

            int summedItemFrequency = 0;

            // Stores an accumulated value for each ship part
            // The size of the ship parts range to previous value determines its probability for creation
            SortedDictionary <String, int> probabilityTable = new SortedDictionary <String, int>();

            foreach (ShopInventoryEntry entry in shopInventoryEntries)
            {
                switch (entry.Availability)
                {
                case ShipPartAvailability.rare:
                {
                    summedItemFrequency += 1;
                    probabilityTable.Add(entry.GetId(), summedItemFrequency);
                    break;
                }

                case ShipPartAvailability.uncommon:
                {
                    summedItemFrequency += 2;
                    probabilityTable.Add(entry.GetId(), summedItemFrequency);
                    break;
                }

                case ShipPartAvailability.common:
                {
                    summedItemFrequency += 3;
                    probabilityTable.Add(entry.GetId(), summedItemFrequency);
                    break;
                }

                case ShipPartAvailability.ubiquitous:
                {
                    summedItemFrequency += 4;
                    probabilityTable.Add(entry.GetId(), summedItemFrequency);
                    break;
                }

                default:
                {
                    throw new ArgumentException("Not implemented!");
                }
                }
            }

            int randItemValue = Game.random.Next(summedItemFrequency);

            foreach (KeyValuePair <String, int> pair in probabilityTable.OrderBy(key => key.Value))
            {
                if (pair.Value > randItemValue)
                {
                    ShopInventoryEntry entry = new ShopInventoryEntry(pair.Key);

                    part = RetrievePartFromEnum(entry.ShipPartType, Game);
                    part.SetShipPartVariety(entry.ItemVariety);
                    break;
                }
            }

            return(part);
        }
コード例 #6
0
 private void InsertPartAt(ShipPart part, int index)
 {
     shopInventory.RemoveAt(index);
     shopInventory.Insert(index, part);
     CompressShopInventory();
 }
コード例 #7
0
        public void Save()
        {
            SortedDictionary <String, String> saveData = new SortedDictionary <string, string>();

            saveData.Add("count", shipItems.Count.ToString());
            Game.saveFile.Save(Game1.SaveFilePath, "save.ini", "shipitems", saveData);

            for (int i = 0; i < shipItems.Count; i++)
            {
                saveData.Clear();
                saveData.Add("name", shipItems[i].ToString());
                saveData.Add("kind", shipItems[i].Kind);
                if (shipItems[i] is ShipPart)
                {
                    ShipPart tmp = (ShipPart)shipItems[i];
                    saveData.Add("variety", tmp.GetShipPartVariety().ToString());
                }
                if (shipItems[i] is QuantityItem)
                {
                    QuantityItem foo = (QuantityItem)shipItems[i];
                    saveData.Add("quantity", foo.Quantity.ToString());
                }
                if (shipItems[i] is PlayerPlating)
                {
                    PlayerPlating plating = (PlayerPlating)shipItems[i];
                    saveData.Add("currenthealth", plating.CurrentOverworldHealth.ToString());
                }
                Game.saveFile.Save(Game1.SaveFilePath, "save.ini", "shipinv" + i, saveData);
            }

            saveData.Clear();
            for (int i = 0; i < ownedPrimaryWeapons.Count; i++)
            {
                for (int n = 0; n < equippedPrimaryWeapons.Count; n++)
                {
                    if (ownedPrimaryWeapons[i] == equippedPrimaryWeapons[n])
                    {
                        saveData.Add("primaryinvpos" + n, i.ToString());
                    }
                }
            }
            for (int i = 0; i < ownedSecondary.Count; i++)
            {
                if (equippedSecondary == ownedSecondary[i])
                {
                    saveData.Add("secondaryinvpos", i.ToString());
                }
            }
            for (int i = 0; i < ownedEnergyCells.Count; i++)
            {
                if (equippedEnergyCell == ownedEnergyCells[i])
                {
                    saveData.Add("energyinvpos", i.ToString());
                }
            }
            for (int i = 0; i < ownedShields.Count; i++)
            {
                if (equippedShield == ownedShields[i])
                {
                    saveData.Add("shieldinvpos", i.ToString());
                }
            }
            for (int i = 0; i < ownedPlatings.Count; i++)
            {
                if (equippedPlating == ownedPlatings[i])
                {
                    saveData.Add("platinginvpos", i.ToString());
                }
            }
            Game.saveFile.Save(Game1.SaveFilePath, "save.ini", "shipequipped", saveData);
        }