private void ItemSellSplitterCallback(PopupRequest.EResultType p_result, String p_inputString) { if (p_result == PopupRequest.EResultType.CONFIRMED) { PartyInventoryController partyInventoryController = LegacyLogic.Instance.WorldManager.Party.Inventory; if (partyInventoryController.GetItemAt(PopupRequest.Instance.ItemSplitter.ItemSlotIndex) != PopupRequest.Instance.ItemSplitter.Item) { partyInventoryController = LegacyLogic.Instance.WorldManager.Party.MuleInventory; } Int32 count = PopupRequest.Instance.ItemSplitter.Count; partyInventoryController.SellItem(PopupRequest.Instance.ItemSplitter.Item, PopupRequest.Instance.ItemSplitter.ItemSlotIndex, count); } PopupRequest.Instance.ItemSplitter.Finish(); }
public override void ItemRightClick(ItemSlot p_slot) { if (p_slot.Item == null) { return; } if (IngameController.Instance.BilateralScreen.LootScreen.IsOpen) { return; } PartyInventoryController partyInventoryController = (PartyInventoryController)m_inventory; ConversationManager conversationManager = LegacyLogic.Instance.ConversationManager; if (conversationManager.CurrentNpc != null && conversationManager.CurrentNpc.TradingInventory.IsTrading && conversationManager.CurrentNpc.StaticData.AllowItemSell) { BaseItem item = p_slot.Item; Consumable consumable = item as Consumable; Equipment equipment = item as Equipment; if (consumable != null && consumable.Counter > 1) { PopupRequest.Instance.OpenRequest(PopupRequest.ERequestType.SPLIT_ITEMS, String.Empty, LocaManager.GetText("POPUP_REQUEST_ITEMS_SELL_LABEL"), new PopupRequest.RequestCallback(ItemSellSplitterCallback)); PopupRequest.Instance.ItemSplitter.Open(PopupItemSplitter.Mode.SELL, consumable.Counter, consumable, p_slot.Index, null, -1); } else if (equipment != null && ((equipment.Prefixes.Count > 0 && equipment.Suffixes.Count > 0) || equipment.IsRelic() || !equipment.Identified)) { m_itemToSell = p_slot; PopupRequest.Instance.OpenRequest(PopupRequest.ERequestType.CONFIRM_CANCEL, String.Empty, LocaManager.GetText("POPUP_REQUEST_CONFIRM_SELL_ITEM", p_slot.Item.Name), new PopupRequest.RequestCallback(SellItemCallback)); } else { partyInventoryController.SellItem(p_slot.Item, p_slot.Index, 1); } } else if (p_slot.Item is Consumable) { partyInventoryController.ConsumeItem(p_slot.Index, LegacyLogic.Instance.WorldManager.Party.CurrentCharacter); } else if (p_slot.Item is Equipment) { DragDropManager.Instance.ShortcutRightClick(p_slot); } }
public override void DoAction(Command p_command) { ConsumeCommand consumeCommand = (ConsumeCommand)p_command; Consumable consumable = (Consumable)consumeCommand.Slot.GetItem(); Character member = LegacyLogic.Instance.WorldManager.Party.GetMember(consumeCommand.TargetCharacter); PartyInventoryController partyInventoryController = (PartyInventoryController)consumeCommand.Slot.Inventory; if (consumable is Potion) { Potion p_potion = (Potion)consumable; member.UsePotion(p_potion); partyInventoryController.ConsumeSuccess(consumeCommand.Slot.Slot); } else if (consumable is Scroll) { Scroll p_scroll = (Scroll)consumable; m_consumeType = EConsumeType.NONE; Character.UseScroll(p_scroll); } }
private void OnDrop() { if (UICamera.currentTouchID == -1) { if (DragDropManager.Instance.DraggedItem is ItemDragObject) { Character selectedCharacter = LegacyLogic.Instance.WorldManager.Party.SelectedCharacter; ItemDragObject itemDragObject = (ItemDragObject)DragDropManager.Instance.DraggedItem; if (itemDragObject.ItemSlot != null && !selectedCharacter.DoneTurn && !selectedCharacter.ConditionHandler.CantDoAnything()) { LegacyLogic.Instance.WorldManager.Party.SelectCharacter(selectedCharacter.Index); Int32 index = itemDragObject.ItemSlot.Index; Potion potion = itemDragObject.Item as Potion; Equipment equipment = itemDragObject.Item as Equipment; PartyInventoryController partyInventoryController = itemDragObject.ItemSlot.Parent.Inventory as PartyInventoryController; if (potion != null && partyInventoryController != null) { partyInventoryController.ConsumeItem(index, selectedCharacter.Index); } if (equipment != null) { Int32 autoSlot = (Int32)selectedCharacter.Equipment.GetAutoSlot(equipment); if (autoSlot >= 0 && selectedCharacter.Equipment.IsItemPlaceableAt(equipment, autoSlot)) { EquipCommand p_command = new EquipCommand(selectedCharacter.Equipment, partyInventoryController, selectedCharacter.Equipment.GetItemAt((EEquipSlots)autoSlot), equipment, autoSlot, index); if (LegacyLogic.Instance.UpdateManager.PartyTurnActor.CanDoCommand(p_command, LegacyLogic.Instance.WorldManager.Party.CurrentCharacter)) { LegacyLogic.Instance.CommandManager.AddCommand(p_command); } } } } } DragDropManager.Instance.CancelDragAction(); } }
internal void DropItem(BaseItem p_item) { Party party = LegacyLogic.Instance.WorldManager.Party; if (party != null && p_item != null) { PartyInventoryController partyInventoryController = party.Inventory; if (!partyInventoryController.CanAddItem(p_item)) { partyInventoryController = (PartyInventoryController)party.GetOtherInventory(partyInventoryController); } if (partyInventoryController.CanAddItem(p_item)) { if (p_item is Equipment) { LegacyLogic.Instance.WorldManager.HintManager.TriggerHint(EHintType.EQUIPMENT); } partyInventoryController.AddItem(p_item); if (p_item is Equipment && !((Equipment)p_item).Identified && !((Equipment)p_item).IsRelic()) { LegacyLogic.Instance.CharacterBarkHandler.RandomPartyMemberBark(EBarks.UNIDENTIFIED_ITEM); } if (p_item is Equipment && ((Equipment)p_item).IsRelic()) { LegacyLogic.Instance.CharacterBarkHandler.RandomPartyMemberBark(EBarks.RELIC); } if (m_monster != null) { MonsterLootEntryEventArgs monsterLootEntryEventArgs = new MonsterLootEntryEventArgs(m_monster); monsterLootEntryEventArgs.Item = p_item; m_monsterLootEntries.Add(monsterLootEntryEventArgs); LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.PARTY_GET_LOOT, monsterLootEntryEventArgs); } else if (m_quest != null) { QuestLootEntryEventArgs questLootEntryEventArgs = new QuestLootEntryEventArgs(m_quest); questLootEntryEventArgs.Item = p_item; LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.PARTY_GET_LOOT, questLootEntryEventArgs); } } else if (m_monster != null || m_quest != null) { if (!m_inventoryFullBarkTriggered) { m_inventoryFullBarkTriggered = true; LegacyLogic.Instance.CharacterBarkHandler.RandomPartyMemberBark(EBarks.INVENTORY_FULL); } GridSlot slot = LegacyLogic.Instance.MapLoader.Grid.GetSlot(party.Position); List <InteractiveObject> passiveInteractiveObjects = slot.GetPassiveInteractiveObjects(EDirection.CENTER, false, false, false); Container container = null; foreach (InteractiveObject interactiveObject in passiveInteractiveObjects) { Container container2 = interactiveObject as Container; if (container2 != null && container2.ContainerType == EContainerType.LOOT_BAG) { container = container2; break; } } if (container == null) { Int32 nextDynamicSpawnID = LegacyLogic.Instance.WorldManager.GetNextDynamicSpawnID(); SpawnCommand spawnCommand = new SpawnCommand(); spawnCommand.Type = EInteraction.OPEN_CONTAINER; spawnCommand.Precondition = "NONE"; spawnCommand.Timing = EInteractionTiming.ON_EXECUTE; spawnCommand.RequiredState = EInteractiveObjectState.NONE; spawnCommand.ActivateCount = -1; spawnCommand.TargetSpawnID = nextDynamicSpawnID; container = new Container(8, nextDynamicSpawnID); container.Location = EDirection.CENTER; container.Position = party.Position; container.Prefab = "Prefabs/InteractiveObjects/LootContainer/Lootbag/Lootbag"; container.Commands.Add(spawnCommand); container.ContainerType = EContainerType.LOOT_BAG; slot.AddInteractiveObject(container); LegacyLogic.Instance.WorldManager.SpawnObject(container, party.Position); } container.Content.AddItem(p_item); if (m_monster != null) { LegacyLogic.Instance.ActionLog.PushEntry(new MonsterLootEntryEventArgs(m_monster)); } else if (m_quest != null) { LegacyLogic.Instance.ActionLog.PushEntry(new QuestLootEntryEventArgs(m_quest)); } } } }
public void OnSingleItemButtonClicked(GameObject p_sender) { if (m_itemContainer.SelectedItem != null) { ((ItemSlotIdentify)m_itemContainer.SelectedItem).PlayFX(m_itemContainer.Mode); BaseItem item = m_itemContainer.SelectedItem.Item; PartyInventoryController partyInventoryController = LegacyLogic.Instance.WorldManager.Party.Inventory; Int32 slotIndexForItem = partyInventoryController.GetSlotIndexForItem(item); if (slotIndexForItem == -1) { partyInventoryController = (PartyInventoryController)LegacyLogic.Instance.WorldManager.Party.GetOtherInventory(partyInventoryController); slotIndexForItem = partyInventoryController.GetSlotIndexForItem(item); } Equipment equipment = (Equipment)item; if (m_identifyInventory != null) { if (equipment.Identified) { return; } equipment.Identified = true; LegacyLogic.Instance.EventManager.InvokeEvent(partyInventoryController, EEventType.INVENTORY_ITEM_CHANGED, new InventoryItemEventArgs(new InventorySlotRef(partyInventoryController.Inventory, slotIndexForItem))); if (m_identifyInventory.FromScroll) { m_identifyInventory.RemoveOneScroll(); } else if (!m_fromSpell) { LegacyLogic.Instance.WorldManager.Party.ChangeGold(-m_costs); } else if (m_costs > 0) { LegacyLogic.Instance.WorldManager.Party.SelectedCharacter.ChangeMP(-m_costs); } AudioManager.Instance.RequestPlayAudioID("IdentifyGUI", 0); } else { if (!equipment.Broken) { return; } equipment.Broken = false; InventoryItemEventArgs p_eventArgs = null; switch (m_itemContainer.RepairInventory.RepairType) { case ERepairType.ALL: p_eventArgs = new InventoryItemEventArgs(InventoryItemEventArgs.ERepairType.ALL); break; case ERepairType.WEAPONS: p_eventArgs = new InventoryItemEventArgs(InventoryItemEventArgs.ERepairType.WEAPONS); break; case ERepairType.ARMOR_AND_SHIELD: p_eventArgs = new InventoryItemEventArgs(InventoryItemEventArgs.ERepairType.ARMOR); break; } if (slotIndexForItem == -1) { CharacterInventoryController characterInventoryController = null; foreach (Character character in LegacyLogic.Instance.WorldManager.Party.Members) { slotIndexForItem = character.Equipment.GetSlotIndexForItem(item); if (slotIndexForItem > -1) { characterInventoryController = character.Equipment; break; } } if (characterInventoryController != null && slotIndexForItem > -1) { LegacyLogic.Instance.EventManager.InvokeEvent(characterInventoryController.Equipment, EEventType.INVENTORY_ITEM_REPAIR_STATUS_CHANGED, p_eventArgs); } } else { LegacyLogic.Instance.EventManager.InvokeEvent(partyInventoryController, EEventType.INVENTORY_ITEM_REPAIR_STATUS_CHANGED, p_eventArgs); } LegacyLogic.Instance.WorldManager.Party.ChangeGold(-m_costs); } m_didDoAnyAction = true; m_itemContainer.UpdateItems(); m_itemContainer.SelectItemSlot(null); UpdateScrollBar(); UpdateButtons(); } }