public InventoryView(InventoryController pInventoryController, ShopController pShopController = null) : base(560, 340) { _keyCommands = new List <KeyCommand>(); _items = new List <Item>(); _shopController = pShopController; _controller = pInventoryController; _commandManager = ServiceLocator.Instance.GetService <CommandManager>(); //----------------------------- Create Commands --------------------------------// var moveSelectionLeft = new MoveInventorySelectionCommand(_controller, this, -1, 0); var moveSelectionRight = new MoveInventorySelectionCommand(_controller, this, 1, 0); var moveSelectionUp = new MoveInventorySelectionCommand(_controller, this, 0, -1); var moveSelectionDown = new MoveInventorySelectionCommand(_controller, this, 0, 1); var equipItem = new EquipItemCommand(MyGame.Player, _controller); var drinkItem = new DrinkItemCommand(MyGame.Player, _controller); var sellItem = new SellItemCommand(pInventoryController, pShopController); //-------------------------- Add Commands to list ------------------------------// _keyCommands = new List <KeyCommand>() { new KeyCommand((int)Key.LEFT, moveSelectionLeft), new KeyCommand((int)Key.RIGHT, moveSelectionRight), new KeyCommand((int)Key.UP, moveSelectionUp), new KeyCommand((int)Key.DOWN, moveSelectionDown), new KeyCommand((int)Key.E, equipItem), new KeyCommand((int)Key.Q, drinkItem), new KeyCommand((int)Key.SPACE, sellItem) }; RegisterCommands(); }
Task OnEquipItem(EquipItemCommand cmd) { var model = _items.CreateModel(_unit, cmd.ItemId, TakeOffItem); ReplaceFragment(model); TryHideEquipWindow(); Refresh(); return(Task.CompletedTask); }
public EventCommandEquipItems(EquipItemCommand refCommand, FrmEvent editor) { InitializeComponent(); mMyCommand = refCommand; mEventEditor = editor; InitLocalization(); cmbItem.Items.Clear(); cmbItem.Items.AddRange(ItemBase.Names); cmbItem.SelectedIndex = ItemBase.ListIndex(mMyCommand.ItemId); }
public async Task Equip(EquipItemCommand equipItemCommand) { var item = await this.db .Items .FirstOrDefaultAsync(x => x.Id == equipItemCommand.ItemId); item.IsEquip = EquipType.InGear; this.db.Entry(item).State = EntityState.Modified; await this.db.SaveChangesAsync(); }
private bool SelectItem(int index, Game game) { var activeLocation = RightHasFocus ? RightPane : LeftPane; var targetLocation = !RightHasFocus ? RightPane : LeftPane; var items = GetItems(activeLocation); if (index >= items.Count) { return(false); } switch (targetLocation) { case StorageLocation.Equipment: { var equipItemCommand = new EquipItemCommand(); if (!equipItemCommand.CanSelect(items[index])) { return(false); } else { var targetItem = items[index]; var unequipedItem = Game.Hero.Equipment.equip(targetItem); if (unequipedItem != null) { RemoveTransferedItem(index, activeLocation); TryToTransfer(unequipedItem, activeLocation, true); return(false); } else { RemoveTransferedItem(index, activeLocation); return(false); } } return(false); } case StorageLocation.Crucible: { Item targetItem = GetTargetItem(index, activeLocation); var canUse = CanUseItemInRecipe(targetItem); if (!canUse) { return(false); } if (TryToTransfer(targetItem, targetLocation, activeLocation == StorageLocation.Equipment)) { RemoveTransferedItem(index, activeLocation); return(false); } else { return(false); } } default: { Item targetItem = GetTargetItem(index, activeLocation); if (TryToTransfer(targetItem, targetLocation, activeLocation == StorageLocation.Equipment)) { RemoveTransferedItem(index, activeLocation); return(false); } else { return(false); } } } }
private void DrawItems(BufferContainer buffer, int x, int y, List <Item> items, StorageLocation current, StorageLocation target, bool isActive = false) { var i = 0; foreach (var item in items) { var alphabet = "abcdefghijklmnopqrstuvwxyz"; var itemY = i + y; var borderColor = ConsoleColor.DarkGray; var letterColor = ConsoleColor.DarkGray; var textColor = ConsoleColor.DarkGray; var priceColor = ConsoleColor.DarkGray; var glyphColor = ConsoleColor.DarkGray; var attackColor = ConsoleColor.DarkGray; var armourColor = ConsoleColor.DarkGray; var enabled = true; if (isActive) { switch (target) { case StorageLocation.Equipment: { var command = new EquipItemCommand(); var canUse = command.CanSelect(item); if (canUse) { borderColor = ConsoleColor.Gray; letterColor = ConsoleColor.Yellow; textColor = item == null ? ConsoleColor.Gray : ConsoleColor.White; priceColor = ConsoleColor.DarkYellow; glyphColor = item == null ? ConsoleColor.Gray : ColourUtilities.ConvertToConsoleColor(item.Appearance.ForeGroundColor); attackColor = ConsoleColor.Yellow; armourColor = ConsoleColor.Green; } break; } case StorageLocation.Crucible: { var canUse = false; if (item != null) { canUse = CanUseItemInRecipe(item); } if (canUse) { borderColor = ConsoleColor.Gray; letterColor = ConsoleColor.Yellow; textColor = item == null ? ConsoleColor.Gray : ConsoleColor.White; priceColor = ConsoleColor.DarkYellow; glyphColor = item == null ? ConsoleColor.Gray : ColourUtilities.ConvertToConsoleColor(item.Appearance.ForeGroundColor); attackColor = ConsoleColor.Yellow; armourColor = ConsoleColor.Green; } break; } default: { borderColor = ConsoleColor.Gray; letterColor = ConsoleColor.Yellow; textColor = item == null ? ConsoleColor.Gray : ConsoleColor.White; priceColor = ConsoleColor.DarkYellow; glyphColor = item == null ? ConsoleColor.Gray : ColourUtilities.ConvertToConsoleColor(item.Appearance.ForeGroundColor); attackColor = ConsoleColor.Yellow; armourColor = ConsoleColor.Green; break; } } } WriteAt(buffer, x, itemY, " ) ", borderColor); WriteAt(buffer, x, itemY, alphabet[i].ToString(), letterColor); if (item == null) { // what is the location? if (current == StorageLocation.Equipment) { var text = ((EquipementSlot)i) + " slot is empty"; WriteAt(buffer, x + 3, itemY, text, textColor); } } else { if (enabled) { WriteAt(buffer, x + 3, itemY, item.Appearance.Glyph, glyphColor); } var text = item.NounText; if (text.Length > 32) { text = text.Substring(0, 29) + "..."; } WriteAt(buffer, x + 5, itemY, text, textColor); // TODO: Eventually need to handle equipment that gives both an armor and attack bonus. if (item.attack != null) { DrawStat(buffer, x, itemY, "»", item.attack.AverageDamage, attackColor, attackColor, enabled); } else if (item.armor != 0) { DrawStat(buffer, x, itemY, "•", item.armor, armourColor, armourColor, enabled); } if (item.price != 0) { var price = PriceString(item.price); WriteAt(buffer, x + 49 - price.Length, itemY, price, priceColor); } } // Increment the item counter i++; } // If this is the crucible then maybe a recipe has been completed. if (current == StorageLocation.Crucible) { if (completeRecipe != null) { i++; i++; var textColour = ConsoleColor.Yellow; if (isActive) { textColour = ConsoleColor.DarkGray; } var csv = string.Join(", ", completeRecipe.Produces.ToArray()); WriteAt(buffer, 0, y + i++, $"This recipe {csv}!", textColour); WriteAt(buffer, 0, y + i++, "Press[Space] to forge item!", textColour); } } }
public async Task <IActionResult> HandleAsync(EquipItemCommand equipItemCommand) { await this.itemsRepository.Equip(equipItemCommand); return(this.Ok()); }
private static string GetCommandText(EquipItemCommand command, MapInstance map) { return(Strings.EventCommandList.equipitem.ToString(ItemBase.GetName(command.ItemId))); }