Quick Move feature improved
This commit is contained in:
parent
42eab26a67
commit
88f8ede129
@ -684,8 +684,8 @@ MonoBehaviour:
|
||||
m_TargetGraphic: {fileID: 1165938063523323413}
|
||||
m_HandleRect: {fileID: 2233503621217788993}
|
||||
m_Direction: 0
|
||||
m_Value: 0.0000007665326
|
||||
m_Size: 0.47786885
|
||||
m_Value: 0.000001053982
|
||||
m_Size: 0.4778688
|
||||
m_NumberOfSteps: 0
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
@ -856,7 +856,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2108268662488080482}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
@ -2115,7 +2115,7 @@ GameObject:
|
||||
- component: {fileID: 2770326604769037616}
|
||||
- component: {fileID: 2770326604769037583}
|
||||
m_Layer: 5
|
||||
m_Name: Slot
|
||||
m_Name: Pocket Slot A
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -2825,7 +2825,7 @@ GameObject:
|
||||
- component: {fileID: 2770326604921404284}
|
||||
- component: {fileID: 2770326604921404283}
|
||||
m_Layer: 5
|
||||
m_Name: Slot
|
||||
m_Name: Pocket Slot D
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -3407,7 +3407,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0.00024414062, y: 0}
|
||||
m_AnchoredPosition: {x: 0.00012207031, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 2250}
|
||||
m_Pivot: {x: 0, y: 1}
|
||||
--- !u!114 &2770326604978625766
|
||||
@ -3450,7 +3450,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2770326604978625764}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
@ -9018,7 +9018,7 @@ GameObject:
|
||||
- component: {fileID: 2770326605689845840}
|
||||
- component: {fileID: 2770326605689845841}
|
||||
m_Layer: 5
|
||||
m_Name: Grid (1)
|
||||
m_Name: Pockets Grid
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -9933,42 +9933,88 @@ MonoBehaviour:
|
||||
TagSlotPairings:
|
||||
- itemTag: 12
|
||||
slot: {fileID: 8600850533622123873}
|
||||
prioritizeItemStoreFirst: 0
|
||||
- itemTag: 1
|
||||
slot: {fileID: 2770326606581535715}
|
||||
prioritizeItemStoreFirst: 0
|
||||
- itemTag: 2
|
||||
slot: {fileID: 2770326606075084494}
|
||||
prioritizeItemStoreFirst: 0
|
||||
- itemTag: 5
|
||||
slot: {fileID: 2770326606094932650}
|
||||
prioritizeItemStoreFirst: 0
|
||||
- itemTag: 5
|
||||
slot: {fileID: 2770326605248660894}
|
||||
prioritizeItemStoreFirst: 0
|
||||
- itemTag: 6
|
||||
slot: {fileID: 2770326606217848658}
|
||||
prioritizeItemStoreFirst: 0
|
||||
- itemTag: 6
|
||||
slot: {fileID: 2770326605161289228}
|
||||
prioritizeItemStoreFirst: 0
|
||||
- itemTag: 7
|
||||
slot: {fileID: 2770326605798828943}
|
||||
prioritizeItemStoreFirst: 0
|
||||
- itemTag: 8
|
||||
slot: {fileID: 2770326604706167503}
|
||||
prioritizeItemStoreFirst: 0
|
||||
- itemTag: 9
|
||||
slot: {fileID: 2770326606194450705}
|
||||
prioritizeItemStoreFirst: 0
|
||||
- itemTag: 13
|
||||
slot: {fileID: 2770326605039798017}
|
||||
prioritizeItemStoreFirst: 0
|
||||
- itemTag: 14
|
||||
slot: {fileID: 2770326605069652580}
|
||||
prioritizeItemStoreFirst: 0
|
||||
- itemTag: 15
|
||||
slot: {fileID: 2770326605604029972}
|
||||
prioritizeItemStoreFirst: 0
|
||||
- itemTag: 16
|
||||
slot: {fileID: 2770326606725301634}
|
||||
- itemTag: 9
|
||||
slot: {fileID: 2770326606194450705}
|
||||
prioritizeItemStoreFirst: 0
|
||||
- itemTag: 18
|
||||
slot: {fileID: 2770326606194450705}
|
||||
prioritizeItemStoreFirst: 0
|
||||
- itemTag: 17
|
||||
slot: {fileID: 2770326606302022802}
|
||||
prioritizeItemStoreFirst: 0
|
||||
TagSlotGridPairings:
|
||||
- itemTag: 0
|
||||
referenceType: 2
|
||||
ReferencedGrid: {fileID: 2770326605902186952}
|
||||
slot: {fileID: 8600850533622123873}
|
||||
grid: {fileID: 0}
|
||||
- itemTag: 0
|
||||
referenceType: 3
|
||||
ReferencedGrid: {fileID: 0}
|
||||
slot: {fileID: 0}
|
||||
grid: {fileID: 2770326605807543574}
|
||||
- itemTag: 0
|
||||
referenceType: 0
|
||||
ReferencedGrid: {fileID: 2770326604769037581}
|
||||
slot: {fileID: 0}
|
||||
grid: {fileID: 2770326605807543574}
|
||||
- itemTag: 0
|
||||
referenceType: 0
|
||||
ReferencedGrid: {fileID: 2770326606686766473}
|
||||
slot: {fileID: 0}
|
||||
grid: {fileID: 2770326605807543574}
|
||||
- itemTag: 0
|
||||
referenceType: 0
|
||||
ReferencedGrid: {fileID: 2770326605995264619}
|
||||
slot: {fileID: 0}
|
||||
grid: {fileID: 2770326605807543574}
|
||||
- itemTag: 0
|
||||
referenceType: 0
|
||||
ReferencedGrid: {fileID: 2770326604921404281}
|
||||
slot: {fileID: 0}
|
||||
grid: {fileID: 2770326605807543574}
|
||||
- itemTag: 0
|
||||
referenceType: 1
|
||||
ReferencedGrid: {fileID: 2770326605807543572}
|
||||
slot: {fileID: 0}
|
||||
grid: {fileID: 2770326605807543574}
|
||||
raritiesList:
|
||||
- rarityType: 0
|
||||
color: {r: 0.6, g: 0.6, b: 0.6, a: 0}
|
||||
@ -10355,6 +10401,7 @@ MonoBehaviour:
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
itemsOnGrid: []
|
||||
--- !u!222 &2770326605807543577
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -11599,7 +11646,7 @@ GameObject:
|
||||
- component: {fileID: 2770326605995264622}
|
||||
- component: {fileID: 2770326605995264621}
|
||||
m_Layer: 5
|
||||
m_Name: Slot
|
||||
m_Name: Pocket Slot C
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -12942,7 +12989,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: -0.0004272461, y: -0.0009530247}
|
||||
m_AnchoredPosition: {x: -0.0005689588, y: -0.00016524519}
|
||||
m_SizeDelta: {x: 1220, y: 1200}
|
||||
m_Pivot: {x: 0, y: 1}
|
||||
--- !u!114 &2770326606141421693
|
||||
@ -18184,7 +18231,7 @@ GameObject:
|
||||
- component: {fileID: 2770326606686766476}
|
||||
- component: {fileID: 2770326606686766475}
|
||||
m_Layer: 5
|
||||
m_Name: Slot
|
||||
m_Name: Pocket Slot B
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -20201,7 +20248,7 @@ MonoBehaviour:
|
||||
m_TargetGraphic: {fileID: 8873855520739210168}
|
||||
m_HandleRect: {fileID: 52681282418728116}
|
||||
m_Direction: 2
|
||||
m_Value: 1.0000024
|
||||
m_Value: 1.0000002
|
||||
m_Size: 0.6525
|
||||
m_NumberOfSteps: 0
|
||||
m_OnValueChanged:
|
||||
|
@ -11,6 +11,7 @@ GameObject:
|
||||
- component: {fileID: 4440658733661691366}
|
||||
- component: {fileID: 2813530617427812674}
|
||||
- component: {fileID: 2772551615480428293}
|
||||
- component: {fileID: 4972946875524611880}
|
||||
m_Layer: 5
|
||||
m_Name: Pouch_Cells_1x1
|
||||
m_TagString: Untagged
|
||||
@ -78,11 +79,26 @@ MonoBehaviour:
|
||||
type: 3}
|
||||
generateCells: 0
|
||||
slots: []
|
||||
associatedItemUI: {fileID: 0}
|
||||
gridSize:
|
||||
Width: 1
|
||||
Height: 1
|
||||
testItem: {fileID: 0}
|
||||
testItems: []
|
||||
--- !u!114 &4972946875524611880
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4961555904879958529}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1ed269bdb4294dc429d767fed43a92aa, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
AllowedItemTags:
|
||||
DisallowedItemTags: 0d0000000e0000000f00000010000000
|
||||
--- !u!1001 &2797168179609513955
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -11,6 +11,7 @@ GameObject:
|
||||
- component: {fileID: 4440658733661691366}
|
||||
- component: {fileID: 2813530617427812674}
|
||||
- component: {fileID: 2772551615480428293}
|
||||
- component: {fileID: 5669249702482988909}
|
||||
m_Layer: 5
|
||||
m_Name: Pouch_Cells_2x1
|
||||
m_TagString: Untagged
|
||||
@ -79,11 +80,26 @@ MonoBehaviour:
|
||||
type: 3}
|
||||
generateCells: 0
|
||||
slots: []
|
||||
associatedItemUI: {fileID: 0}
|
||||
gridSize:
|
||||
Width: 1
|
||||
Height: 2
|
||||
testItem: {fileID: 0}
|
||||
testItems: []
|
||||
--- !u!114 &5669249702482988909
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4961555904879958529}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1ed269bdb4294dc429d767fed43a92aa, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
AllowedItemTags:
|
||||
DisallowedItemTags: 0d0000000e0000000f00000010000000
|
||||
--- !u!1001 &2654960344705592353
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -11,6 +11,7 @@ GameObject:
|
||||
- component: {fileID: 4440658733661691366}
|
||||
- component: {fileID: 2813530617427812674}
|
||||
- component: {fileID: 2772551615480428293}
|
||||
- component: {fileID: 1471210313782040237}
|
||||
m_Layer: 5
|
||||
m_Name: Pouch_Cells_2x2
|
||||
m_TagString: Untagged
|
||||
@ -81,11 +82,26 @@ MonoBehaviour:
|
||||
type: 3}
|
||||
generateCells: 0
|
||||
slots: []
|
||||
associatedItemUI: {fileID: 0}
|
||||
gridSize:
|
||||
Width: 2
|
||||
Height: 2
|
||||
testItem: {fileID: 0}
|
||||
testItems: []
|
||||
--- !u!114 &1471210313782040237
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4961555904879958529}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1ed269bdb4294dc429d767fed43a92aa, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
AllowedItemTags:
|
||||
DisallowedItemTags: 0d0000000e0000000f00000010000000
|
||||
--- !u!1001 &2654960344705592353
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -11,8 +11,9 @@ GameObject:
|
||||
- component: {fileID: 4440658733661691366}
|
||||
- component: {fileID: 2813530617427812674}
|
||||
- component: {fileID: 2772551615480428293}
|
||||
- component: {fileID: 5726478664858734726}
|
||||
m_Layer: 5
|
||||
m_Name: Pouch_Cells_1x3
|
||||
m_Name: Pouch_Cells_3x1
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -80,11 +81,26 @@ MonoBehaviour:
|
||||
type: 3}
|
||||
generateCells: 0
|
||||
slots: []
|
||||
associatedItemUI: {fileID: 0}
|
||||
gridSize:
|
||||
Width: 1
|
||||
Height: 3
|
||||
testItem: {fileID: 0}
|
||||
testItems: []
|
||||
--- !u!114 &5726478664858734726
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4961555904879958529}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1ed269bdb4294dc429d767fed43a92aa, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
AllowedItemTags:
|
||||
DisallowedItemTags: 0d0000000e0000000f00000010000000
|
||||
--- !u!1001 &1541749983105574545
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -72,6 +72,7 @@ namespace SimpleInventorySystem
|
||||
{
|
||||
public ItemTags itemTag;
|
||||
public SlotUI slot;
|
||||
public bool prioritizeItemStoreFirst;
|
||||
|
||||
public bool HasSlotOccupied()
|
||||
{
|
||||
@ -93,32 +94,156 @@ namespace SimpleInventorySystem
|
||||
public class TagSlotGridPairing
|
||||
{
|
||||
public ItemTags itemTag;
|
||||
public SlotUI slot;
|
||||
public enum ReferenceTypes { SlotUI, GridUI, GridUIFromSlot, TagSlotGridPairUI }
|
||||
public ReferenceTypes referenceType = ReferenceTypes.SlotUI;
|
||||
public GameObject ReferencedGrid;
|
||||
[HideInInspector] public SlotUI slot;
|
||||
[HideInInspector] public GridUI grid;
|
||||
|
||||
public TagSlotGridPairing()
|
||||
{
|
||||
Debug.Log("this should be called");
|
||||
SetSlotsOrGrid();
|
||||
/*if (tagSlotGridPairUI == null && slot == null && tagSlotGridPairUI == null)
|
||||
{
|
||||
Debug.LogWarning($"TagSlotGridPairing: This TagSlotGridPairing will not work for {itemTag} on type {referenceType}.");
|
||||
}*/
|
||||
}
|
||||
|
||||
public void SetSlotsOrGrid()
|
||||
{
|
||||
switch (referenceType)
|
||||
{
|
||||
case ReferenceTypes.SlotUI:
|
||||
{
|
||||
if (ReferencedGrid != null)
|
||||
slot = ReferencedGrid.GetComponent<SlotUI>();
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"TagSlotGridPairing: ReferencedGrid missing.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ReferenceTypes.GridUI:
|
||||
{
|
||||
if (ReferencedGrid != null)
|
||||
grid = ReferencedGrid.GetComponent<GridUI>();
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"TagSlotGridPairing: ReferencedGrid missing.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ReferenceTypes.GridUIFromSlot:
|
||||
{
|
||||
if (ReferencedGrid != null)
|
||||
{
|
||||
slot = ReferencedGrid.GetComponent<SlotUI>();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"TagSlotGridPairing: ReferencedGrid missing.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ReferenceTypes.TagSlotGridPairUI:
|
||||
{
|
||||
if (ReferencedGrid != null)
|
||||
{
|
||||
Debug.LogWarning($"TagSlotGridPairing: This TagSlotGridPairing may not use {ReferencedGrid.name} as a Referenced Grid because reference type {referenceType} will search for most available slot based on Heiarchy order.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSlotOccupied()
|
||||
{
|
||||
return slot.GetItemUI() != null;
|
||||
}
|
||||
|
||||
public bool DropOntoGrid(ItemUI item)
|
||||
protected bool DropOntoGrid(ItemUI item)
|
||||
{
|
||||
//List<GridUI.Cell> cells = new List<GridUI.Cell>();
|
||||
//bool canMoveInCells = grid.CanMoveInCells(item, slot, cells);
|
||||
bool dropped = CanStore(item) && grid.DropItemOnGrid(item.gameObject);
|
||||
//Debug.Log("IS:" + dropped);
|
||||
Debug.Log("IS:Dropped:" + dropped);
|
||||
return dropped;
|
||||
}
|
||||
protected bool DropOntoSlot(ItemUI item)
|
||||
{
|
||||
bool dropped = CanStore(item) && slot.DropOntoSlot(item.gameObject);
|
||||
Debug.Log("IS:Dropped:" + dropped);
|
||||
return dropped;
|
||||
}
|
||||
|
||||
public bool Drop(ItemUI item)
|
||||
{
|
||||
bool dropped = (referenceType == ReferenceTypes.SlotUI) ? DropOntoSlot(item) : DropOntoGrid(item);
|
||||
return dropped;
|
||||
}
|
||||
|
||||
public bool CanStore(ItemUI item)
|
||||
{
|
||||
bool preliminaryCheck = item != null && (item.ItemTag == itemTag || itemTag == ItemTags.Any) && slot != null && IsSlotOccupied() && slot.GetItemUI().container != null;
|
||||
bool slotCheck = preliminaryCheck && slot != null && slot.GetItemUI() != null && slot.GetItemUI().container != null;
|
||||
if (!slotCheck)
|
||||
return slotCheck;
|
||||
SetSlotsOrGrid();
|
||||
|
||||
bool preliminaryCheck = item != null && (item.ItemTag == itemTag || itemTag == ItemTags.Any) && slot != null;
|
||||
//Debug.Log("IS:CanStore" + (preliminaryCheck));
|
||||
//Debug.Log("IS:CanStore" + (slot != null));
|
||||
bool slotCheck = false;
|
||||
bool gridCheck = false;
|
||||
|
||||
if (slot != null && (referenceType == ReferenceTypes.GridUIFromSlot || referenceType == ReferenceTypes.SlotUI))
|
||||
{
|
||||
if(referenceType == ReferenceTypes.GridUIFromSlot)
|
||||
{
|
||||
slotCheck = preliminaryCheck && IsSlotOccupied() && slot.GetItemUI().container != null && slot != null && slot.GetItemUI() != null && slot.GetItemUI().container != null;
|
||||
if (slotCheck)
|
||||
{
|
||||
grid = slot.GetItemUI().container.GetComponent<GridUI>();
|
||||
bool gridCheck = grid != null;
|
||||
//Debug.Log("IS:" + gridCheck);
|
||||
}
|
||||
gridCheck = grid != null && !grid.IsAssociatedItem(item) && !grid.ContainsItemFromGrid(item); // TODO: improve on this for stacking
|
||||
//Debug.Log($"Contains Item From Grid: {gridCheck}");
|
||||
//TODO: create function to check if item is inside grid.
|
||||
}
|
||||
else
|
||||
{
|
||||
slotCheck = preliminaryCheck && (!IsSlotOccupied() || slot.GetItemUI().Stackable) && slot != item.GetSlotUI();
|
||||
//Debug.Log(slotCheck);
|
||||
gridCheck = true;
|
||||
}
|
||||
}
|
||||
else if (referenceType == ReferenceTypes.GridUI)
|
||||
{
|
||||
slotCheck = true;
|
||||
gridCheck = grid != null && !grid.ContainsItemFromGrid(item);
|
||||
}
|
||||
else if (referenceType == ReferenceTypes.TagSlotGridPairUI)
|
||||
{
|
||||
slotCheck = true;
|
||||
TagSlotGridPairUI[] gridPairs = InventorySystem.instance.inventoryUI.GetComponentsInChildren<TagSlotGridPairUI>();
|
||||
foreach (TagSlotGridPairUI gp in gridPairs)
|
||||
{
|
||||
if (gp.IsAllowed(item.ItemTag))
|
||||
{
|
||||
grid = gp.GetComponent<GridUI>();
|
||||
if (grid != null)
|
||||
{
|
||||
//Debug.Log($"TagSlotGridPairing: {grid.gameObject.name}");
|
||||
if (grid.slots != null && grid.slots.Length > 0 && grid.slots[0] != null)
|
||||
gridCheck = grid.CanMoveInCells(item, grid.slots[0]) && !grid.ContainsItemFromGrid(item);// && grid.associatedItemUI.ContainedItems != null && !grid.associatedItemUI.ContainedItems.Contains(item);
|
||||
// TODO: improve on this for stacking
|
||||
|
||||
if (gridCheck)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Debug.Log("IS:CanStore" + (slotCheck && gridCheck));
|
||||
return slotCheck && gridCheck;
|
||||
}
|
||||
}
|
||||
|
@ -49,9 +49,16 @@ namespace SimpleInventorySystem
|
||||
public void DetachItemGameObject(GameObject go)
|
||||
{
|
||||
if (hideGameObject)
|
||||
{
|
||||
if (itemGameObject == null)
|
||||
{
|
||||
Debug.LogError($"TargetAttachment: Item Game Object is null, please correctly set up your Item with a PickUp. Game Object name: {itemGameObject.name}");
|
||||
}
|
||||
else
|
||||
{
|
||||
itemGameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
itemGameObject = null;
|
||||
// TODO: Most likely, implement drop here.
|
||||
go.transform.SetParent(null, true);
|
||||
|
@ -6,16 +6,5 @@ namespace SimpleInventorySystem
|
||||
{
|
||||
public class AttachTo : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@ namespace SimpleInventorySystem
|
||||
private Cell[,] cells;
|
||||
[HideInInspector] public GameObject testItem;
|
||||
[HideInInspector] public GameObject[] testItems;
|
||||
[HideInInspector] public List<ItemUI> itemsOnGrid;
|
||||
private Size cellSize;
|
||||
public Size CellSize { get { return cellSize; } }
|
||||
private Vector2 nextAvailableCellCoords;
|
||||
@ -277,11 +278,32 @@ namespace SimpleInventorySystem
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("GridUI: Could not add item to grid.");
|
||||
//Debug.LogWarning("GridUI: Could not add item to grid.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddItemToGrid(ItemUI item)
|
||||
{
|
||||
if (!itemsOnGrid.Contains(item))
|
||||
{
|
||||
itemsOnGrid.Add(item.GetComponent<ItemUI>());
|
||||
}
|
||||
}
|
||||
|
||||
public bool ContainsItemFromGrid(ItemUI item)
|
||||
{
|
||||
return itemsOnGrid.Contains(item);
|
||||
}
|
||||
|
||||
public void RemoveItemFromGrid(ItemUI item)
|
||||
{
|
||||
if (itemsOnGrid.Contains(item))
|
||||
{
|
||||
itemsOnGrid.Remove(item.GetComponent<ItemUI>());
|
||||
}
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
@ -228,38 +228,68 @@ namespace SimpleInventorySystem
|
||||
//rectTransform.localPosition = new Vector3(0, 0);
|
||||
}
|
||||
|
||||
public bool QuickMove()
|
||||
{
|
||||
bool moved = false;
|
||||
if (Equip())
|
||||
{
|
||||
//Debug.Log("Equipped");
|
||||
moved = true;
|
||||
}
|
||||
else if (Store())
|
||||
{
|
||||
//Debug.Log("Stored");
|
||||
moved = true;
|
||||
}
|
||||
return moved;
|
||||
}
|
||||
|
||||
public bool Equip()
|
||||
{
|
||||
bool equipped = false;
|
||||
foreach (TagSlotPairing tsp in InventorySystem.instance.TagSlotPairings)
|
||||
{
|
||||
//Debug.Log($"Equip: {tsp.itemTag}, {tsp.slot.gameObject.name}");
|
||||
if (tsp.slot == slot)
|
||||
{
|
||||
//Debug.Log("Could not equip, storing");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tsp.CanEquip(this))
|
||||
{
|
||||
UnsetSlot();
|
||||
|
||||
equipped = tsp.DropOntoSlot(this);
|
||||
|
||||
//Debug.Log(tsp.slot.gameObject.name);
|
||||
bool value = tsp.DropOntoSlot(this);
|
||||
if (!value)
|
||||
if (equipped)
|
||||
{
|
||||
ReturnToSlot();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
//Debug.Log("Returning to slot");
|
||||
ReturnToSlot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return equipped;
|
||||
}
|
||||
|
||||
public bool Store()
|
||||
{
|
||||
bool stored = false;
|
||||
foreach (TagSlotGridPairing tsgp in InventorySystem.instance.TagSlotGridPairings)
|
||||
{
|
||||
//Debug.Log($"Store: {tsgp.itemTag}, {tsgp.ReferencedGrid}");
|
||||
if (tsgp.CanStore(this))
|
||||
{
|
||||
UnsetSlot();
|
||||
bool value = tsgp.DropOntoGrid(this);
|
||||
if (!value)
|
||||
GrabAndDragItem(); // TODO: See if this conflicts with anything
|
||||
//UnsetSlot();
|
||||
stored = tsgp.Drop(this);
|
||||
if (!stored)
|
||||
{
|
||||
ReturnToSlot();
|
||||
}
|
||||
@ -268,12 +298,12 @@ namespace SimpleInventorySystem
|
||||
// TODO: see if this is needed
|
||||
if(container != null)
|
||||
container.SetActive(false);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return stored;
|
||||
}
|
||||
|
||||
public bool DropItemInStorageContainer(ItemUI droppedItem)
|
||||
@ -352,6 +382,17 @@ namespace SimpleInventorySystem
|
||||
//Debug.Log("OnPointerDown");
|
||||
|
||||
//Debug.Log("OnBeginDrag");
|
||||
|
||||
RemoveItemFromSlot();
|
||||
|
||||
isDragging = true;
|
||||
InventorySystem.instance.DraggedItem = this;
|
||||
PickedUpOnFrame = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveItemFromSlot()
|
||||
{
|
||||
canvasGroup.alpha = .7f;
|
||||
canvasGroup.blocksRaycasts = false;
|
||||
|
||||
@ -374,23 +415,23 @@ namespace SimpleInventorySystem
|
||||
|
||||
HideEmptyGrid();
|
||||
|
||||
isDragging = true;
|
||||
InventorySystem.instance.DraggedItem = this;
|
||||
PickedUpOnFrame = true;
|
||||
|
||||
// Destroy each associated window, since we won't rely on windows if we are moving this item
|
||||
for(int i = ContextWindows.Count - 1; i >= 0; i--)
|
||||
for (int i = ContextWindows.Count - 1; i >= 0; i--)
|
||||
{
|
||||
ContextWindows[i].SetActive(true);
|
||||
}
|
||||
ContextWindows.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void UnsetSlot()
|
||||
{
|
||||
if (slot != null)
|
||||
{
|
||||
if(slot.grid != null)
|
||||
{
|
||||
slot.grid.RemoveItemFromGrid(this);
|
||||
}
|
||||
|
||||
previousSlot = slot;
|
||||
slot.RemoveDragDropItem();
|
||||
slot = null;
|
||||
@ -649,7 +690,7 @@ namespace SimpleInventorySystem
|
||||
|
||||
if (PointerIsHoveredOver && InventorySystem.instance.PressedEquipItemKey(false))
|
||||
{
|
||||
Equip();
|
||||
QuickMove();
|
||||
// TODO: see if more needs to be implemented here.
|
||||
return;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace SimpleInventorySystem
|
||||
[HideInInspector] public LimitStackSlot limitStackSlot;
|
||||
[HideInInspector] public LimitStackSlotManager limitStackSlotManager;
|
||||
[HideInInspector] public bool DroppedOnFrame;
|
||||
[HideInInspector] public List<GroupSlotUI> groupSlots;
|
||||
public List<GroupSlotUI> groupSlots;
|
||||
[HideInInspector] public GridUI grid;
|
||||
[HideInInspector] public GridUI.Cell cell;
|
||||
[HideInInspector] public ChangeSlotTitle changeSlotTitle;
|
||||
@ -78,7 +78,7 @@ namespace SimpleInventorySystem
|
||||
ItemTags itemTag = itemDrop.ItemTag;
|
||||
|
||||
bool allowed = AllowedItemTags == null || AllowedItemTags.Count == 0 || AllowedItemTags.Contains(ItemTags.Any) || AllowedItemTags.Contains(itemTag);
|
||||
bool disallowed = DisallowedItemTags.Contains(itemTag);
|
||||
bool disallowed = DisallowedItemTags == null || DisallowedItemTags.Contains(itemTag);
|
||||
|
||||
if (!allowed || disallowed)
|
||||
{
|
||||
@ -149,7 +149,7 @@ namespace SimpleInventorySystem
|
||||
// Debug.Log(grid);
|
||||
|
||||
bool dropCheck = (grid != null && grid.CanMoveInCells(itemDrop, this, occupiedCells)) ||
|
||||
(grid == null && !cell.inUse && (IgnoreItemSize || (cell.slot.width >= itemDrop.SizeAfterOrientation().Width && !cell.inUse && cell.slot.height >= itemDrop.SizeAfterOrientation().Height)));
|
||||
(grid == null && cell != null && !cell.inUse && (IgnoreItemSize || (cell.slot.width >= itemDrop.SizeAfterOrientation().Width && !cell.inUse && cell.slot.height >= itemDrop.SizeAfterOrientation().Height)));
|
||||
|
||||
// Debug.Log("Drop Check: " + dropCheck);
|
||||
|
||||
@ -172,9 +172,11 @@ namespace SimpleInventorySystem
|
||||
CellInUse = cell.inUse;
|
||||
}
|
||||
|
||||
Debug.Log($"Using Image as Slot Holder: {useImageAsSlotHolder}");
|
||||
Transform parent = transform;
|
||||
if (useImageAsSlotHolder && image != null)
|
||||
{
|
||||
//Debug.Log("Using Image as Slot Holder");
|
||||
parent = image.gameObject.transform;
|
||||
}
|
||||
item.GetComponent<Transform>().SetParent(parent);
|
||||
@ -200,6 +202,8 @@ namespace SimpleInventorySystem
|
||||
if (grid != null)
|
||||
{
|
||||
grid.HideSlotsOfItem(itemDrop);
|
||||
//Debug.Log("Grid is not null");
|
||||
grid.AddItemToGrid(item.GetComponent<ItemUI>());
|
||||
}
|
||||
|
||||
if (!useImageAsSlotHolder)
|
||||
@ -272,7 +276,7 @@ namespace SimpleInventorySystem
|
||||
else
|
||||
{
|
||||
//Debug.LogWarning("SlotUI: Failed to drop. dropCheck: " + dropCheck + ", allowed: " + allowed);
|
||||
Debug.LogError("SlotUI: Something wrong has happened.");
|
||||
//Debug.LogError("SlotUI: Something wrong has happened.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -323,8 +327,17 @@ namespace SimpleInventorySystem
|
||||
limitStackSlot.Increment();
|
||||
}
|
||||
|
||||
//DropOntoSlot(item.gameObject);
|
||||
|
||||
stackedItems.Push(item);
|
||||
if(useImageAsSlotHolder && image != null)
|
||||
{
|
||||
item.transform.SetParent(image.transform, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.transform.SetParent(transform, false);
|
||||
}
|
||||
item.gameObject.SetActive(true);
|
||||
/*
|
||||
foreach(ItemUI item in )
|
||||
@ -426,7 +439,7 @@ namespace SimpleInventorySystem
|
||||
|
||||
public bool CanDropOntoSlot()
|
||||
{
|
||||
bool groupSlotsCheck = false;
|
||||
/*bool groupSlotsCheck = false;
|
||||
if (groupSlots.Count == 0)
|
||||
groupSlotsCheck = true;
|
||||
else
|
||||
@ -439,10 +452,10 @@ namespace SimpleInventorySystem
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
// TODO: add check for Limit Slot Stack here
|
||||
|
||||
return (GetItemUI() == null || IsStacking()) && groupSlotsCheck;
|
||||
return (GetItemUI() == null || IsStacking());// && groupSlotsCheck;
|
||||
}
|
||||
|
||||
public bool IsSingleCellSlot()
|
||||
|
20
Assets/Inventory System/Scripts/UI/TagSlotGridPairUI.cs
Normal file
20
Assets/Inventory System/Scripts/UI/TagSlotGridPairUI.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SimpleInventorySystem
|
||||
{
|
||||
public class TagSlotGridPairUI : MonoBehaviour
|
||||
{
|
||||
public List<ItemTags> AllowedItemTags;
|
||||
public List<ItemTags> DisallowedItemTags;
|
||||
|
||||
public bool IsAllowed(ItemTags itemTag)
|
||||
{
|
||||
bool allowed = AllowedItemTags == null || AllowedItemTags.Count == 0 || AllowedItemTags.Contains(ItemTags.Any) || AllowedItemTags.Contains(itemTag);
|
||||
bool disallowed = DisallowedItemTags == null || DisallowedItemTags.Contains(itemTag);
|
||||
|
||||
return allowed && !disallowed;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Inventory System/Scripts/UI/TagSlotGridPairUI.cs.meta
Normal file
11
Assets/Inventory System/Scripts/UI/TagSlotGridPairUI.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ed269bdb4294dc429d767fed43a92aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -49547,6 +49547,8 @@ MonoBehaviour:
|
||||
- {fileID: 1241596305986958, guid: 7f0652b80b458c74b9383ea6a02ea96e, type: 3}
|
||||
- {fileID: 8053794548077495502, guid: 3e5ad4148935cf44f8f502719c58ac30, type: 3}
|
||||
- {fileID: 1360962833793172, guid: e3c3fc737aaecec47998dbddc1dc85f6, type: 3}
|
||||
- {fileID: 1241596305986958, guid: 5ddf4d2d41dcd3c46893e4b8cd1fc142, type: 3}
|
||||
- {fileID: 1360962833793172, guid: e3c3fc737aaecec47998dbddc1dc85f6, type: 3}
|
||||
itemUIs: []
|
||||
--- !u!4 &1937331975 stripped
|
||||
Transform:
|
||||
|
Loading…
Reference in New Issue
Block a user