protected override void Initialize(SeedOptions options) { var gameSettings = Level.GameSave.GetSettings(); var fillType = gameSettings.ShopFill.Value; if (fillType == "Vanilla") { return; } PlayerInventory inventory = Dynamic._level.GameSave.Inventory; // Only sell warp shards if Pyramid Key is aquired (and allowed in settings) if ((gameSettings.ShopWarpShards.Value || fillType == "Default") && inventory.RelicInventory.IsRelicActive(EInventoryRelicType.PyramidsKey)) { merchandiseInventory.AddItem(EInventoryUseItemType.WarpCard); } if (fillType == "Empty") { Dynamic._merchandiseInventory = merchandiseInventory; return; } if (fillType == "Random") { var random = new Random((int)Level.GameSave.GetSeed().Value.Id); for (var i = 0; i < 8; i++) { var item = Helper.GetAllLoot().SelectRandom(random); // Give half of the items to each era. Needs to be done after the random advances // to keep the inventory consistent for the seed if ((Dynamic._isInPresent && (i % 2 == 0) || !Dynamic._isInPresent && (i % 2 != 0))) { continue; } if (item.LootType == LootType.Equipment) { merchandiseInventory.AddItem((EInventoryEquipmentType)item.ItemId); } else { merchandiseInventory.AddItem((EInventoryUseItemType)item.ItemId); } } Dynamic._merchandiseInventory = merchandiseInventory; return; } // Default case, streamlined inventory for randomizer players if (Dynamic._isInPresent) { merchandiseInventory.AddItem(EInventoryUseItemType.FuturePotion); merchandiseInventory.AddItem(EInventoryUseItemType.FutureEther); } else { merchandiseInventory.AddItem(EInventoryUseItemType.Potion); merchandiseInventory.AddItem(EInventoryUseItemType.Ether); } merchandiseInventory.AddItem(EInventoryUseItemType.Biscuit); merchandiseInventory.AddItem(EInventoryUseItemType.Antidote); merchandiseInventory.AddItem(EInventoryUseItemType.SandBottle); merchandiseInventory.AddItem(EInventoryUseItemType.ChaosHeal); Dynamic._merchandiseInventory = merchandiseInventory; }
public override void Update(GameTime gameTime) { PlayerIndex index = PlayerIndex.One; int i = 0; switch (_mode) { case MerchantMode.Talk: _conversation.Update(gameTime); if (Xin.WasReleased(PlayerIndexInControl, Buttons.A, Keys.Space, out index) || Xin.WasReleased(PlayerIndexInControl, Buttons.A, Keys.Space, out index)) { if (_conversation.CurrentScene.OptionAction.Action == ActionType.Buy) { _mode = MerchantMode.Buy; } if (_conversation.CurrentScene.OptionAction.Action == ActionType.Sell) { _mode = MerchantMode.Sell; } if (_conversation.CurrentScene.OptionAction.Action == ActionType.End) { _manager.PopState(); } } else if (Xin.CheckMouseReleased(MouseButton.Left) && _conversation.CurrentScene.IsMouseOver) { if (_conversation.CurrentScene.OptionAction.Action == ActionType.Buy) { _mode = MerchantMode.Buy; } if (_conversation.CurrentScene.OptionAction.Action == ActionType.Sell) { _mode = MerchantMode.Sell; } if (_conversation.CurrentScene.OptionAction.Action == ActionType.End) { _manager.PopState(); } } break; case MerchantMode.Buy: if (Xin.WasReleased(PlayerIndexInControl, Buttons.A, Keys.Space, out index) || (Xin.CheckMouseReleased(MouseButton.Left) && mouseOver)) { if (_inventoryManager.ItemList[_selectedItem].Cost <= player.Gold) { player.AddItem(_selectedItem); player.UpdateGold(_inventoryManager.ItemList[_selectedItem].Cost * -1); player.Character.AddItem(_inventoryManager.ItemList[_selectedItem]); _inventory.RemoveItem(_selectedItem); foreach (string s in player.ActiveQuests.Keys) { if (player.ActiveQuests[s].CurrentStep.QuestStepType == QuestStepType.Buy && player.ActiveQuests[s].CurrentStep.Target == Enum.GetName(typeof(ItemCategory), _inventoryManager.ItemList[_selectedItem].ItemType)) { player.ActiveQuests[s].CurrentStep.Finish(); player.ActiveQuests[s].UpdateQuestStep(); } } } else { // show that the offer was refused } } else if (Xin.WasReleased(PlayerIndexInControl, Buttons.Back, Keys.Escape, out index) || Xin.CheckMouseReleased(MouseButton.Right)) { _mode = MerchantMode.Talk; } else if (!mouseOver) { if (Xin.WasReleased(PlayerIndexInControl, Buttons.LeftThumbstickUp, Keys.Up, out index)) { _selectedIndex--; if (_selectedIndex < 0) { _selectedIndex = _inventory.Inventory.Count - 1; } } else if (Xin.WasReleased(PlayerIndexInControl, Buttons.LeftThumbstickDown, Keys.Down, out index)) { _selectedIndex++; if (_selectedIndex >= _inventory.Inventory.Count) { _selectedIndex = 0; } } } foreach (string s in _inventory.Inventory.Keys) { if (_selectedIndex == i) { _selectedItem = s; break; } i++; } break; case MerchantMode.Sell: if (Xin.WasReleased(PlayerIndexInControl, Buttons.A, Keys.Space, out index) || (Xin.CheckMouseReleased(MouseButton.Left) && mouseOver)) { player.RemoveItem(_selectedItem); player.UpdateGold(_inventoryManager.ItemList[_selectedItem].Cost / 2); _inventory.AddItem(_selectedItem); foreach (string s in player.ActiveQuests.Keys) { if (player.ActiveQuests[s].CurrentStep.QuestStepType == QuestStepType.Sell && player.ActiveQuests[s].CurrentStep.Target == Enum.GetName(typeof(ItemCategory), _inventoryManager.ItemList[_selectedItem].ItemType)) { player.ActiveQuests[s].CurrentStep.Finish(); player.ActiveQuests[s].UpdateQuestStep(); } } } else if (Xin.WasReleased(PlayerIndexInControl, Buttons.Back, Keys.Escape, out index) || Xin.CheckMouseReleased(MouseButton.Right)) { _mode = MerchantMode.Talk; } else if (!mouseOver) { if (Xin.WasReleased(PlayerIndexInControl, Buttons.LeftThumbstickUp, Keys.Up, out index)) { _selectedIndex--; if (_selectedIndex < 0) { _selectedIndex = _inventory.Inventory.Count - 1; } } else if (Xin.WasReleased(PlayerIndexInControl, Buttons.LeftThumbstickDown, Keys.Down, out index)) { _selectedIndex++; if (_selectedIndex >= _inventory.Inventory.Count) { _selectedIndex = 0; } } } foreach (string s in player.Backpack.Keys) { if (_selectedIndex == i) { _selectedItem = s; break; } i++; } break; } base.Update(gameTime); }