//Handles a given item being click public void Click(int index) { print($"Handling a click to {Conversions.IntToNumbering(index)}"); print($"UI state is {queuedAction}"); switch (queuedAction) { case ItemAction.DROP: case ItemAction.PICK_UP: selected[index] = !selected[index]; for (int i = 0; i < displayed.Count; i++) { ItemPanel current = displayed[i]; if (current.index == index) { current.Select(); break; } } break; case ItemAction.INSPECT: print("OPENEING UI!"); UIController.singleton.OpenItemInspect(examinedInventory, index); break; case ItemAction.EQUIP: //TODO: Do something something different if item is already equipped print($"Attaching item {index} to slot {queuedEquipmentIndex}"); Player.player.SetAction(new EquipAction(index, queuedEquipmentIndex)); ExitAllWindows(); //After equiping, just exit break; case ItemAction.APPLY: Player.player.inventory.Apply(index); ExitAllWindows(); break; } }
public override void HandleInput(PlayerAction action, string inputString) { switch (queuedAction) { case ItemAction.INSPECT: //Break down input into item types foreach (char c in inputString.Where(c => char.IsLetter(c))) { int index = Conversions.NumberingToInt(c); if (index < examinedInventory.capacity && examinedInventory[index] != null) { //Display an item! UIController.singleton.OpenItemInspect(examinedInventory, index); break; } } break; case ItemAction.EQUIP: //Break down input into item types foreach (char c in inputString.Where(c => char.IsLetter(c))) { int index = Conversions.NumberingToInt(c); if (index < examinedInventory.capacity && examinedInventory[index] != null && index >= 0) { //Equip an item! Player.player.SetAction(new EquipAction(index, queuedEquipmentIndex)); ExitAllWindows(); break; } } break; case ItemAction.PICK_UP: case ItemAction.DROP: if (action == PlayerAction.ACCEPT) { //Splitting this up because of the new action system. //TODO: Refactor this bit better List <int> indices = new List <int>(); for (int i = 0; i < selected.Length; i++) { if (selected[i]) { indices.Add(i); } } GameAction act; if (queuedAction == ItemAction.DROP) { act = new DropAction(indices); } else { act = new PickupAction(indices); } Player.player.SetAction(act); ExitAllWindows(); } else { //Flip bits for selected items foreach (char c in inputString.Where(c => char.IsLetter(c))) { //Attempt to flip the bit int index = Conversions.NumberingToInt(c); selected[index] = !selected[index]; for (int i = 0; i < displayed.Count; i++) { ItemPanel current = displayed[i]; if (current.index == index) { current.Select(); break; } } } } break; case ItemAction.APPLY: foreach (char c in inputString.Where(c => char.IsLetter(c))) { int index = Conversions.NumberingToInt(c); if (index < examinedInventory.capacity && examinedInventory[index] != null && index >= 0) { //Equip an item! Player.player.inventory.Apply(index); ExitAllWindows(); break; } } break; } }