public AT.Battle.Equip BattleEquip(InventoryItem i, EquipmentSlotType t) { AT.Battle.Equip action = new AT.Battle.Equip(InventoryView.instance.CurrentActor); (action.ActionOptions [0] as ItemsOnPersonOption).chosenChoice = new InventoryItemChoice(i); (action.ActionOptions [1] as EquipmentSlotTypeOption).chosenChoice = new EquipmentSlotTypeChoice(t); return(action); }
/// <summary> /// Checks if the item slot dropped can be droppped, and acts accordingly. /// Look at ItemSlot subclass to find see what functionality this overrides, /// and if you are curious how the cursor is unset by the item dragged. /// </summary> /// <param name="self">Self.</param> public override void DroppedItem(OptButton self) { if (currentlyDraggingSlot != null) { bool updated = false; NoDropReason reason = DropRestrictReasonEquipSlot(currentlyDraggingSlot.CurrentItem, currentlyDraggingSlot); switch (reason) { case NoDropReason.NONE__CAN_ACTUALLY_DROP: //if battle mode... if (InventoryView.instance.IsBattleMode) { AT.Battle.Equip action = new AT.Battle.Equip(InventoryView.instance.CurrentActor); (action.ActionOptions [0] as ItemsOnPersonOption).chosenChoice = new InventoryItemChoice(currentlyDraggingSlot.CurrentItem); (action.ActionOptions [1] as EquipmentSlotTypeOption).chosenChoice = new EquipmentSlotTypeChoice(slotType); action.Perform(); if (CurrentItem != null) { InventoryItem swap = CurrentItem; SetInventoryItem(currentlyDraggingSlot.CurrentItem); currentlyDraggingSlot.SetInventoryItem(swap); } else { SetInventoryItem(currentlyDraggingSlot.CurrentItem); currentlyDraggingSlot.ClearItem(); } } else { if (CurrentItem != null) { if (currentlyDraggingSlot is EquipmentUISlot) { EquipmentUISlot sl = currentlyDraggingSlot as EquipmentUISlot; if (sl.EquipmentFits(CurrentItem as Equipment)) { InventoryItem swap = currentlyDraggingSlot.CurrentItem; currentlyDraggingSlot.SetInventoryItem(CurrentItem); SetInventoryItem(swap); } else { InventoryView.instance.inventoryDisplay.AddToInventory(CurrentItem); SetInventoryItem(currentlyDraggingSlot.CurrentItem); currentlyDraggingSlot.ClearItem(); } // //// // // SetInventoryItem (swap); } else { // InventoryItem swap = currentlyDraggingSlot.CurrentItem; // currentlyDraggingSlot.SetInventoryItem (CurrentItem); // InventoryView.instance.inventoryDisplay.AddToInventory (CurrentItem); InventoryItem swap = currentlyDraggingSlot.CurrentItem; currentlyDraggingSlot.SetInventoryItem(CurrentItem); SetInventoryItem(swap); } } else { //just set the state as needed directly SetInventoryItem(currentlyDraggingSlot.CurrentItem); currentlyDraggingSlot.ClearItem(); // InventoryView.instance.RefreshUi (); } } updated = true; break; case NoDropReason.NOT_EQUIPMENT: Debug.Log("you can't drop non-equipmnet on a equpment slot"); break; case NoDropReason.NO_FIT: Debug.Log((currentlyDraggingSlot.CurrentItem as Equipment).DefaultFitSlotType + " doesn't match " + slotType); break; case NoDropReason.NOT_YOUR_TURN: Debug.Log("Not your turn, my sone"); break; case NoDropReason.NO_ACTION_LEFT: Debug.Log("You can't act"); break; } if (updated && InventoryView.instance.IsBattleMode) { //in this case, the action takes care of syncing character stuff InventoryView.instance.RefreshUi(); } else { InventoryView.instance.RefreshCharacter(); } UIManager.instance.Tooltip.Hide(); } }
//This happens before the drag end happens. public virtual void DroppedItem(OptButton opt) { if (currentlyDraggingSlot != null) { bool updated = false; NoDropReason reason = DropRestrictReasonItemSlot(currentlyDraggingSlot.CurrentItem, currentlyDraggingSlot); switch (reason) { case NoDropReason.CANT_UNEQUIP_TO_HERE: Debug.Log("shit, can unequip here ni"); break; case NoDropReason.NO_ACTION_LEFT_FOR_UNEQUIP: Debug.Log("No action left my friend."); break; case NoDropReason.NONE__CAN_ACTUALLY_DROP: Debug.Log("You can drop!"); if (currentlyDraggingSlot is EquipmentUISlot) //slot is an equipment slot { EquipmentUISlot sl = currentlyDraggingSlot as EquipmentUISlot; if (InventoryView.instance.IsBattleMode) { //actions need to be performed... if (CurrentItem == null) { AT.Battle.Unequip action = BattleUnequip(sl.slotType); action.Perform(); } else { AT.Battle.Equip action = BattleEquip(CurrentItem, sl.slotType); action.Perform(); } InventoryView.instance.RefreshUi(); } else { //The state can just be set. if (CurrentItem == null) { // AT.Battle.Unequip action = BattleUnequip (sl.slotType); // Debug.Log("here, will unequp"); SetInventoryItem(currentlyDraggingSlot.CurrentItem); currentlyDraggingSlot.SetInventoryItem(null); } else { InventoryItem swap = CurrentItem; InventoryView.instance.currentCharacter.Unequip( (currentlyDraggingSlot as EquipmentUISlot).slotType, currentlyDraggingSlot.CurrentItem as Equipment); SetInventoryItem(currentlyDraggingSlot.CurrentItem); currentlyDraggingSlot.SetInventoryItem(swap); } InventoryView.instance.RefreshCharacter(); } } else ///TODO: add case for if the slot is a ground slot (only valid in battle) { InventoryItem swap = CurrentItem; SetInventoryItem(currentlyDraggingSlot.CurrentItem); currentlyDraggingSlot.SetInventoryItem(swap); InventoryView.instance.RefreshCharacter(); } break; } } }