public ItemUnderfootMenu(int mapItemSlot) { this.mapItemSlot = mapItemSlot; MapItem mapItem = ZoneManager.Instance.CurrentMap.Items[mapItemSlot]; string itemName = mapItem.GetDungeonName(); List <MenuTextChoice> choices = new List <MenuTextChoice>(); bool invFull = (DungeonScene.Instance.ActiveTeam.GetInvCount() >= DungeonScene.Instance.ActiveTeam.GetMaxInvSlots(ZoneManager.Instance.CurrentZone)); bool hasItem = (DungeonScene.Instance.FocusedCharacter.EquippedItem.ID > -1); if (mapItem.IsMoney) { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_GROUND_GET"), PickupAction)); } else { Data.ItemData entry = Data.DataManager.Instance.GetItem(mapItem.Value); //disable pick up for full inv //disable swap for empty inv bool canGet = (DungeonScene.Instance.ActiveTeam.GetInvCount() < DungeonScene.Instance.ActiveTeam.GetMaxInvSlots(ZoneManager.Instance.CurrentZone)); if (!canGet && entry.MaxStack > 1) { //find an inventory slot that isn't full stack foreach (InvItem item in DungeonScene.Instance.ActiveTeam.EnumerateInv()) { if (item.ID == mapItem.Value && item.Cursed == mapItem.Cursed && item.HiddenValue < entry.MaxStack) { canGet = true; break; } } } bool hasItems = (DungeonScene.Instance.ActiveTeam.GetInvCount() > 0); choices.Add(new MenuTextChoice(Text.FormatKey("MENU_GROUND_GET"), PickupAction, canGet, canGet ? Color.White : Color.Red)); choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_REPLACE"), ReplaceAction, hasItems, hasItems ? Color.White : Color.Red)); switch (entry.UsageType) { case Data.ItemData.UseType.Eat: { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_EAT"), UseSelfAction, !mapItem.Cursed, mapItem.Cursed ? Color.Red : Color.White)); break; } case Data.ItemData.UseType.Drink: { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_DRINK"), UseSelfAction, !mapItem.Cursed, mapItem.Cursed ? Color.Red : Color.White)); break; } case Data.ItemData.UseType.Use: case Data.ItemData.UseType.UseOther: { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_USE"), UseSelfAction, !mapItem.Cursed, mapItem.Cursed ? Color.Red : Color.White)); break; } case Data.ItemData.UseType.Learn: { //if the character is teaching to himself, need to disable this choice if not compatible bool canLearn = TeachMenu.CanLearnSkill(DungeonScene.Instance.FocusedCharacter, DungeonScene.Instance.FocusedCharacter, BattleContext.FLOOR_ITEM_SLOT); choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_LEARN"), UseSelfAction, canLearn && !mapItem.Cursed, (canLearn && !mapItem.Cursed) ? Color.White : Color.Red)); break; } } //hold item bool allowHold = (!invFull || hasItem); if (hasItem) { ItemData equipEntry = DataManager.Instance.GetItem(DungeonScene.Instance.FocusedCharacter.EquippedItem.ID); if (equipEntry.CannotDrop) { allowHold = false; } } choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_HOLD"), HoldAction, allowHold, allowHold ? Color.White : Color.Red)); if (entry.UsageType == Data.ItemData.UseType.Throw) { int choiceIndex = choices.Count - 1; choices.Insert(choiceIndex, new MenuTextChoice(Text.FormatKey("MENU_ITEM_THROW"), ThrowAction)); } else { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_THROW"), ThrowAction)); } if (entry.UsageType == Data.ItemData.UseType.Learn) { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_INFO"), InfoAction)); } } choices.Add(new MenuTextChoice(Text.FormatKey("MENU_EXIT"), ExitAction)); if (!mapItem.IsMoney) { summaryMenu = new ItemSummary(Rect.FromPoints(new Loc(16, GraphicsManager.ScreenHeight - 8 - 4 * VERT_SPACE - GraphicsManager.MenuBG.TileHeight * 2), new Loc(GraphicsManager.ScreenWidth - 16, GraphicsManager.ScreenHeight - 8))); summaryMenu.SetItem(new InvItem(mapItem.Value, mapItem.Cursed, mapItem.HiddenValue)); } int menuwidth = CalculateChoiceLength(choices, 72); Initialize(new Loc(GraphicsManager.ScreenWidth - 16 - menuwidth, 16), menuwidth, choices.ToArray(), 0, itemName); }
public ItemChosenMenu(int slot, bool held) { this.slot = slot; this.held = held; bool leader = (GameManager.Instance.CurrentScene != DungeonScene.Instance) || (DungeonScene.Instance.ActiveTeam.Leader == DungeonScene.Instance.FocusedCharacter); bool focus = (GameManager.Instance.CurrentScene != DungeonScene.Instance) || (held && DungeonScene.Instance.ActiveTeam.Players[slot] == DungeonScene.Instance.FocusedCharacter); InvItem invItem = null; if (held) { invItem = DataManager.Instance.Save.ActiveTeam.Players[slot].EquippedItem; } else { invItem = DataManager.Instance.Save.ActiveTeam.GetInv(slot); } ItemData entry = DataManager.Instance.GetItem(invItem.ID); List <MenuTextChoice> choices = new List <MenuTextChoice>(); //able to use if an item is not held, or if an item is held, but the focused character is the holder if (GameManager.Instance.CurrentScene != DungeonScene.Instance) { } else if (!held || focus) { switch (entry.UsageType) { case Data.ItemData.UseType.Eat: { if (leader && !held) { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_EAT"), UseOtherAction, !invItem.Cursed, invItem.Cursed ? Color.Red : Color.White)); } else { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_EAT"), UseSelfAction, !invItem.Cursed, invItem.Cursed ? Color.Red : Color.White)); } break; } case Data.ItemData.UseType.Drink: { if (leader && !held) { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_DRINK"), UseOtherAction, !invItem.Cursed, invItem.Cursed ? Color.Red : Color.White)); } else { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_DRINK"), UseSelfAction, !invItem.Cursed, invItem.Cursed ? Color.Red : Color.White)); } break; } case Data.ItemData.UseType.Use: { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_USE"), UseSelfAction, !invItem.Cursed, invItem.Cursed ? Color.Red : Color.White)); break; } case Data.ItemData.UseType.UseOther: { if (leader && !held) { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_USE"), UseOtherAction, !invItem.Cursed, invItem.Cursed ? Color.Red : Color.White)); } else { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_USE"), UseSelfAction, !invItem.Cursed, invItem.Cursed ? Color.Red : Color.White)); } break; } case Data.ItemData.UseType.Learn: { bool canLearn = true; if (!(leader && !held)) { //if the character is teaching the skill itself, need to disable this choice if not compatible if (!TeachMenu.CanLearnSkill(DungeonScene.Instance.FocusedCharacter, DungeonScene.Instance.FocusedCharacter, held ? BattleContext.EQUIP_ITEM_SLOT : slot)) { canLearn = false; } } if (leader && !held) { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_TEACH"), TeachOtherAction, !invItem.Cursed, invItem.Cursed ? Color.Red : Color.White)); } else { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_LEARN"), UseSelfAction, canLearn && !invItem.Cursed, (canLearn && !invItem.Cursed) ? Color.White : Color.Red)); } break; } } } if (!held) { //item is not held, can give or hold if (leader) { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_GIVE"), GiveAction)); } else { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_HOLD"), HoldAction)); } } else { bool invEmpty = (DataManager.Instance.Save.ActiveTeam.GetInvCount() == 0); //item is held if (focus || leader) { //if the focused character is the holder, it can put it back (disable if inv is full) choices.Add(new MenuTextChoice(leader ? Text.FormatKey("MENU_ITEM_TAKE") : Text.FormatKey("MENU_ITEM_PUT"), PutBackAction)); //or swap it with an item in inventory choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_SWAP"), SwapAction, !invEmpty, invEmpty ? Color.Red : Color.White)); } } if (GameManager.Instance.CurrentScene != DungeonScene.Instance) { } else if (!held || focus) { //actions can be done only if the focused character is the holder, or if it isn't held at all if (!entry.CannotDrop) { int itemSlot = ZoneManager.Instance.CurrentMap.GetItem(DungeonScene.Instance.FocusedCharacter.CharLoc); string dropString = Text.FormatKey("MENU_ITEM_PLACE"); bool disableDrop = false; if (itemSlot > -1) { MapItem mapItem = ZoneManager.Instance.CurrentMap.Items[itemSlot]; if (mapItem.IsMoney) { disableDrop = true; } else { dropString = Text.FormatKey("MENU_ITEM_REPLACE"); } } choices.Add(new MenuTextChoice(dropString, PlaceAction, !disableDrop, disableDrop ? Color.Red : Color.White)); if (entry.UsageType == Data.ItemData.UseType.Throw) { choices.Insert(0, new MenuTextChoice(Text.FormatKey("MENU_ITEM_THROW"), ThrowAction)); } else { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_THROW"), ThrowAction)); } } } if (entry.UsageType == Data.ItemData.UseType.Learn) { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_INFO"), InfoAction)); } if (GameManager.Instance.CurrentScene != DungeonScene.Instance) { choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_TRASH"), TrashAction)); } choices.Add(new MenuTextChoice(Text.FormatKey("MENU_EXIT"), ExitAction)); Initialize(new Loc(ItemMenu.ITEM_MENU_WIDTH + 16, 16), CalculateChoiceLength(choices, 72), choices.ToArray(), 0); }