Panel refactoring - player inventory
This commit is contained in:
parent
db575614ec
commit
792bcb8466
@ -9,18 +9,18 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 943bb4b7c1123c44fb1cbc048a56a954, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: a0c176e87b3c91641897c23dc27e92a0, type: 3}
|
||||
m_Name: Axe
|
||||
m_EditorClassIdentifier:
|
||||
id: 0
|
||||
name: Axe_one
|
||||
description: Lumberjack's Axe
|
||||
id: 2
|
||||
name: Axe
|
||||
description: Lumberjack axe
|
||||
level: 1
|
||||
image: {fileID: 21300000, guid: d7a7292796eda0941a6a863b7d66bbcb, type: 3}
|
||||
itemModel: {fileID: 1826809974269949497, guid: 83fa1f81238efb541bd77405dcf33dd1, type: 3}
|
||||
StrengthBonus: 0
|
||||
StrengthBonus: 1
|
||||
AgilityBonus: 0
|
||||
InteligenceBonus: 0
|
||||
InteligenceBonus: 5
|
||||
VitalityBonus: 0
|
||||
isStackable: 0
|
||||
EquipmentType: 4
|
||||
|
@ -9,18 +9,12 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 943bb4b7c1123c44fb1cbc048a56a954, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 1c6df47a2440e8a49bef89083164fdc1, type: 3}
|
||||
m_Name: Gold Ore
|
||||
m_EditorClassIdentifier:
|
||||
id: 0
|
||||
id: 1
|
||||
name: Gold Ore
|
||||
description:
|
||||
level: 0
|
||||
level: 1
|
||||
image: {fileID: 21300000, guid: 83bbd515e788cbd4090c1c6649b76a29, type: 3}
|
||||
itemModel: {fileID: 6960265943931164901, guid: 7aaf1038c5485164ea90044b40c5baa1, type: 3}
|
||||
StrengthBonus: 0
|
||||
AgilityBonus: 0
|
||||
InteligenceBonus: 0
|
||||
VitalityBonus: 0
|
||||
isStackable: 0
|
||||
EquipmentType: 9
|
||||
|
@ -9,12 +9,12 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 943bb4b7c1123c44fb1cbc048a56a954, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: a0c176e87b3c91641897c23dc27e92a0, type: 3}
|
||||
m_Name: Pickaxe
|
||||
m_EditorClassIdentifier:
|
||||
id: 0
|
||||
name: pickaxe_test
|
||||
description: Example pickaxe
|
||||
name: Pickaxe
|
||||
description:
|
||||
level: 1
|
||||
image: {fileID: 8959118705387878318, guid: 25e473b59d2d7534e803be0a2825e0f7, type: 3}
|
||||
itemModel: {fileID: 9081071845930167562, guid: 0bccd32818043074d9785f6d90ebdcb3, type: 3}
|
||||
@ -23,4 +23,4 @@ MonoBehaviour:
|
||||
InteligenceBonus: 0
|
||||
VitalityBonus: 0
|
||||
isStackable: 0
|
||||
EquipmentType: 0
|
||||
EquipmentType: 4
|
||||
|
@ -225,7 +225,7 @@ GameObject:
|
||||
- component: {fileID: 7550267750876868091}
|
||||
- component: {fileID: 6531490600091353741}
|
||||
m_Layer: 5
|
||||
m_Name: inventory_slot
|
||||
m_Name: InventoryBox
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
@ -28,6 +28,7 @@ RectTransform:
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 9124304228607424520}
|
||||
m_RootOrder: 0
|
||||
@ -134,126 +135,6 @@ MonoBehaviour:
|
||||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!1 &9124304227312933332
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 9124304227312933335}
|
||||
- component: {fileID: 9124304227312933320}
|
||||
- component: {fileID: 9124304227312933321}
|
||||
- component: {fileID: 9124304227312933334}
|
||||
m_Layer: 5
|
||||
m_Name: Button
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &9124304227312933335
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9124304227312933332}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 9124304227729624650}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 232.6, y: 404.2}
|
||||
m_SizeDelta: {x: 50, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &9124304227312933320
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9124304227312933332}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &9124304227312933321
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9124304227312933332}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: 11277a3f23988ec47908362d708edaa8, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &9124304227312933334
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9124304227312933332}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 9124304227312933321}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!1 &9124304227602340161
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -283,6 +164,7 @@ RectTransform:
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 9124304227903849263}
|
||||
m_Father: {fileID: 9124304227744546881}
|
||||
@ -355,9 +237,9 @@ GameObject:
|
||||
- component: {fileID: 9124304227729624650}
|
||||
- component: {fileID: 9124304227729624652}
|
||||
- component: {fileID: 9124304227729624653}
|
||||
- component: {fileID: 4753590907807807515}
|
||||
- component: {fileID: 7107743575243314760}
|
||||
m_Layer: 5
|
||||
m_Name: inventory_panel
|
||||
m_Name: InventoryPanel
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -373,10 +255,10 @@ RectTransform:
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0.4, y: 0.4, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 9124304228607424520}
|
||||
- {fileID: 9124304227744546881}
|
||||
- {fileID: 9124304227312933335}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@ -423,7 +305,7 @@ MonoBehaviour:
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &4753590907807807515
|
||||
--- !u!114 &7107743575243314760
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@ -432,16 +314,12 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 9124304227729624651}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0bff20d6fb721a449df16891030739a, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: b3ae9277a19e5dc49aa607d1d2ec2dc9, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_panel: {fileID: 9124304227903849260}
|
||||
_blankSlot: {fileID: 4202482119828722599, guid: 843626bb28e804c4384ea070e0fead67, type: 3}
|
||||
_panelCloseButton: {fileID: 9124304227312933334}
|
||||
_instance: {fileID: 0}
|
||||
_itemTemplate: {fileID: 6570396142606985298, guid: 1304511dd1dfefc449e87c3d904ab15f, type: 3}
|
||||
_tmp: {fileID: 0}
|
||||
MAX_SLOT_CUNT: 48
|
||||
_panelContent: {fileID: 9124304227903849260}
|
||||
ChildBoxTemplate: {fileID: 4202482119828722599, guid: 843626bb28e804c4384ea070e0fead67, type: 3}
|
||||
ChildBoxList: []
|
||||
--- !u!1 &9124304227744546894
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -471,6 +349,7 @@ RectTransform:
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 9124304227602340160}
|
||||
m_Father: {fileID: 9124304227729624650}
|
||||
@ -577,6 +456,7 @@ RectTransform:
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 9124304227602340160}
|
||||
m_RootOrder: 0
|
||||
@ -652,6 +532,7 @@ RectTransform:
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 9124304227092242855}
|
||||
m_Father: {fileID: 9124304227729624650}
|
@ -119,7 +119,7 @@ GameObject:
|
||||
- component: {fileID: 4136979550784496705}
|
||||
- component: {fileID: 4136979550784496711}
|
||||
- component: {fileID: 4136979550784496710}
|
||||
- component: {fileID: 23121313890645495}
|
||||
- component: {fileID: 169130841095946002}
|
||||
m_Layer: 5
|
||||
m_Name: TaskPanel
|
||||
m_TagString: Untagged
|
||||
@ -187,7 +187,7 @@ MonoBehaviour:
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &23121313890645495
|
||||
--- !u!114 &169130841095946002
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@ -200,8 +200,8 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_panelContent: {fileID: 4136979552221407527}
|
||||
TaskBoxTemplate: {fileID: 3337243677719157076, guid: 1cd878accdd121744a3a4829d9bc910f, type: 3}
|
||||
TaskBoxList: []
|
||||
ChildBoxTemplate: {fileID: 3337243677719157076, guid: 1cd878accdd121744a3a4829d9bc910f, type: 3}
|
||||
ChildBoxList: []
|
||||
--- !u!1 &4136979550912312138
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -94,42 +94,42 @@ public class EquipmentManager : BaseWarehouseController
|
||||
|
||||
switch(_item.EquipmentType)
|
||||
{
|
||||
case EquipmentType.Helmet:
|
||||
case EquipmentTypeEnum.Helmet:
|
||||
{
|
||||
key = 0;
|
||||
break;
|
||||
}
|
||||
case EquipmentType.Chest:
|
||||
case EquipmentTypeEnum.Chest:
|
||||
{
|
||||
key = 1;
|
||||
break;
|
||||
}
|
||||
case EquipmentType.Boots:
|
||||
case EquipmentTypeEnum.Boots:
|
||||
{
|
||||
key = 2;
|
||||
break;
|
||||
}
|
||||
case EquipmentType.Weapon:
|
||||
case EquipmentTypeEnum.Weapon:
|
||||
{
|
||||
key = 3;
|
||||
break;
|
||||
}
|
||||
case EquipmentType.Potion:
|
||||
case EquipmentTypeEnum.Potion:
|
||||
{
|
||||
key = 4;
|
||||
break;
|
||||
}
|
||||
case EquipmentType.Bracelet:
|
||||
case EquipmentTypeEnum.Bracelet:
|
||||
{
|
||||
key = 5;
|
||||
break;
|
||||
}
|
||||
case EquipmentType.Necklet:
|
||||
case EquipmentTypeEnum.Necklet:
|
||||
{
|
||||
key = 6;
|
||||
break;
|
||||
}
|
||||
case EquipmentType.Ring:
|
||||
case EquipmentTypeEnum.Ring:
|
||||
{
|
||||
if(!equipment.ContainsKey(7) || equipment[7] == null)
|
||||
{
|
||||
@ -159,42 +159,42 @@ public class EquipmentManager : BaseWarehouseController
|
||||
{
|
||||
switch(_item.EquipmentType)
|
||||
{
|
||||
case EquipmentType.Helmet:
|
||||
case EquipmentTypeEnum.Helmet:
|
||||
{
|
||||
_helmet = put ? _item : null;
|
||||
break;
|
||||
}
|
||||
case EquipmentType.Chest:
|
||||
case EquipmentTypeEnum.Chest:
|
||||
{
|
||||
_chest = put ? _item : null;
|
||||
break;
|
||||
}
|
||||
case EquipmentType.Boots:
|
||||
case EquipmentTypeEnum.Boots:
|
||||
{
|
||||
_boots = put ? _item : null;
|
||||
break;
|
||||
}
|
||||
case EquipmentType.Weapon:
|
||||
case EquipmentTypeEnum.Weapon:
|
||||
{
|
||||
_weapon = put ? _item : null;
|
||||
break;
|
||||
}
|
||||
case EquipmentType.Potion:
|
||||
case EquipmentTypeEnum.Potion:
|
||||
{
|
||||
_potion_one = put ? _item : null;
|
||||
break;
|
||||
}
|
||||
case EquipmentType.Bracelet:
|
||||
case EquipmentTypeEnum.Bracelet:
|
||||
{
|
||||
_potion_two = put ? _item : null;
|
||||
break;
|
||||
}
|
||||
case EquipmentType.Necklet:
|
||||
case EquipmentTypeEnum.Necklet:
|
||||
{
|
||||
_potion_three = put ? _item : null;
|
||||
break;
|
||||
}
|
||||
case EquipmentType.Ring:
|
||||
case EquipmentTypeEnum.Ring:
|
||||
{
|
||||
if(!equipment.ContainsKey(7) || equipment[7] == null)
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ using UnityEngine;
|
||||
|
||||
public class EquipmentSlot : ItemSlot
|
||||
{
|
||||
public EquipmentType EquipmentType;
|
||||
public EquipmentTypeEnum EquipmentType;
|
||||
|
||||
public override bool CanReceiveItem(Item item)
|
||||
{
|
||||
|
@ -1,76 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class InventoryManager : BaseWarehouseController
|
||||
{
|
||||
public static int MAX_ITEMS = 5;
|
||||
|
||||
public static InventoryManager Instance;
|
||||
|
||||
// temporary delegate dragged item to outside static object instance to remember it
|
||||
[Space]
|
||||
[SerializeField]
|
||||
protected ISlot _draggedSlot;
|
||||
public ISlot DraggedSlot
|
||||
{
|
||||
get { return _draggedSlot; }
|
||||
set
|
||||
{
|
||||
_draggedSlot = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if(Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
}else if (Instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public int AddToInventory(EquippableItem pickable)
|
||||
{
|
||||
if(this._items.Count <= MAX_ITEMS)
|
||||
{
|
||||
for(int slotNumber=0; slotNumber<MAX_ITEMS; slotNumber++)
|
||||
{
|
||||
if(!this._items.ContainsKey(slotNumber))
|
||||
{
|
||||
this._items[slotNumber] = pickable;
|
||||
return slotNumber;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Function for placed item in inventory on SPECYFIC position
|
||||
/// Used by SceneInventoryManager for load saved items on their positions
|
||||
///</summary>
|
||||
public void SetupItemInInventory(int key, EquippableItem pickable)
|
||||
{
|
||||
this._items[key] = pickable;
|
||||
}
|
||||
|
||||
protected override void SetupPanel()
|
||||
{
|
||||
if(this.dynamicPanel)
|
||||
{
|
||||
this.dynamicPanel.GetComponent<InventoryPanelController>().Setup(gameObject, _items);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public void DropItem()
|
||||
// {
|
||||
|
||||
// }
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using System;
|
||||
|
||||
public class InventoryPanelController : BasePanelController
|
||||
{
|
||||
|
||||
public override void CloseOnClick()
|
||||
{
|
||||
Destroy(gameObject); // destroy panel
|
||||
|
||||
InventoryManager.Instance.GetComponent<InventoryManager>().ClosePanel();
|
||||
}
|
||||
|
||||
public void Setup(GameObject _inventory, Dictionary<int, Item> _items)
|
||||
{
|
||||
_instance = _inventory;
|
||||
|
||||
base.Setup(_items);
|
||||
}
|
||||
|
||||
protected override ISlot SetupSlot(int key, GameObject _parent)
|
||||
{
|
||||
InventorySlot _tmpSlot = Instantiate(_blankSlot, _parent.transform.position, Quaternion.identity).GetComponent<InventorySlot>();
|
||||
_tmpSlot.transform.SetParent(_parent.transform);
|
||||
|
||||
_tmpSlot.SetupSlot(key, null, this);
|
||||
|
||||
return _tmpSlot;
|
||||
}
|
||||
|
||||
// public void Drop(ItemSlot<InventoryPanelController> dropItemSlot)
|
||||
// {
|
||||
// if(dropItemSlot.CanReceiveItem(draggedSlot.Item) && draggedSlot.CanReceiveItem(dropItemSlot.Item))
|
||||
// {
|
||||
// EquippableItem dragItem = draggedSlot.Item as EquippableItem;
|
||||
// EquippableItem dropItem = dropItemSlot.Item as EquippableItem;
|
||||
|
||||
// // for changing chest to evuuipment or onventory panel !!!!
|
||||
|
||||
// if(draggedSlot is EquipmentSlot)
|
||||
// {
|
||||
// if(dragItem != null) dragItem.Unequip(this);
|
||||
// if(dropItem != null) dropItem.Equip(this);
|
||||
// }
|
||||
|
||||
// if(dropItemSlot is EquipmentSlot)
|
||||
// {
|
||||
// if(dragItem != null) dragItem.Equip(this);
|
||||
// if(dropItem != null) dropItem.Unequip(this);
|
||||
// }
|
||||
|
||||
// Item draggedItem = draggedSlot.Item; // remember temporary currently dragged item
|
||||
|
||||
// draggedSlot.Item = dropItemSlot.Item;
|
||||
// dropItemSlot.Item = draggedItem;
|
||||
|
||||
// // update items position in chest slots
|
||||
// // - after close paned - items dont reset its positions
|
||||
// _inventory.GetComponent<InventoryManager>().SetItemOnPosition(draggedSlot.Number, draggedSlot.Item);
|
||||
// _inventory.GetComponent<InventoryManager>().SetItemOnPosition(dropItemSlot.Number, dropItemSlot.Item);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
@ -39,8 +39,9 @@ public class PickableController : MonoBehaviour
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.E))
|
||||
{
|
||||
if(InventoryManager.Instance.AddToInventory(this.item) >= 0)
|
||||
if(InventoryUIManager.Instance.IsFull())
|
||||
{
|
||||
InventoryUIManager.Instance.Add(this.item);
|
||||
isPicked = 1;
|
||||
//PlayerPrefs.SetInt(name, isPicked);
|
||||
//gameObject.SetActive(false);
|
||||
@ -52,12 +53,11 @@ public class PickableController : MonoBehaviour
|
||||
{
|
||||
Debug.LogError("Can't pick item - Your inventory is full");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D collision)
|
||||
private void OnTrigerEnter2D(Collider2D collision)
|
||||
{
|
||||
if (collision.tag == "Player")
|
||||
{
|
||||
|
3
Assets/Scripts/REFACTORING/Application.meta
Normal file
3
Assets/Scripts/REFACTORING/Application.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7b6c099a5334c44b977899871b4a61a
|
||||
timeCreated: 1660483312
|
3
Assets/Scripts/REFACTORING/Application/Panel.meta
Normal file
3
Assets/Scripts/REFACTORING/Application/Panel.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 925cd94b992c46259a205c12a9a3b969
|
||||
timeCreated: 1660171743
|
3
Assets/Scripts/REFACTORING/Application/Panel/Chest.meta
Normal file
3
Assets/Scripts/REFACTORING/Application/Panel/Chest.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 546db8cdadd345c6a364ed0e1a58c4b7
|
||||
timeCreated: 1660488534
|
@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ChestDataListManager : SceneDataListManager<ChestPrefarbAsset>
|
||||
{
|
||||
public ChestDataListManager(string gameObjectLocalization, string assetLocalization) : base(gameObjectLocalization, assetLocalization)
|
||||
{
|
||||
}
|
||||
|
||||
public override void AddElementToList(ChestPrefarbAsset newElement)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public override void RemoveElementFromList(ChestPrefarbAsset element)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void doBuild(GameObject _object)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b07ed99c7ae4d07bb7201c51459dce0
|
||||
timeCreated: 1660488551
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe46dc8c381d43eb971d9e24236d16f0
|
||||
timeCreated: 1660405143
|
@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class InventoryDataListManager : DataListManager<KeyValuePair<int, Item>> // or maybe EquippableItem - but its get conflicts...
|
||||
{
|
||||
public DataListManager<KeyValuePair<int, Item>> SetUiManager(ref UIWarehouseManager _uiManager)
|
||||
{
|
||||
uiManager = _uiManager;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public override void AddElementToList(KeyValuePair<int, Item> newElement)
|
||||
{
|
||||
Elements.Add(newElement);
|
||||
}
|
||||
|
||||
public override void RemoveElementFromList(KeyValuePair<int, Item> element)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
// public override void Build()
|
||||
// {
|
||||
// // pass to InventoryManager singleton
|
||||
// foreach(KeyValuePair<int, EquippableItemPrefabAsset> itemEntry in Elements)
|
||||
// InventoryManager.Instance.SetupItemInInventory(itemEntry.Key, itemEntry.Value.equippableItem);
|
||||
//
|
||||
// }
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7610fa3cdda79614e94110dd314fbfed
|
||||
guid: 6c7ff03e3ec547d39ea36456237d74e5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@ -0,0 +1,99 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using UnityEngine;
|
||||
|
||||
public class SaveInventoryManager : SaveModelSystem<KeyValuePair<int, EquippableItemPrefabAsset>>
|
||||
{
|
||||
public override bool SaveModelItem(KeyValuePair<int, EquippableItemPrefabAsset> model)
|
||||
{
|
||||
return base.SaveModelItem(model);
|
||||
}
|
||||
|
||||
public override bool SaveModelList(List<KeyValuePair<int, EquippableItemPrefabAsset>> list)
|
||||
{
|
||||
BinaryFormatter formatter = new BinaryFormatter();
|
||||
|
||||
Debug.Log("Saved Inventory at " + Path);
|
||||
|
||||
if (!Directory.Exists(Path)) Directory.CreateDirectory(Path);
|
||||
|
||||
/* Main logic of conversion data format */
|
||||
var data = ConvertObjectsListToListOfDataModels(list);
|
||||
|
||||
FileStream stream = new FileStream(
|
||||
Path + GetFileName(ObjectListName),
|
||||
FileMode.Create
|
||||
);
|
||||
|
||||
formatter.Serialize(stream, data);
|
||||
stream.Close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override KeyValuePair<int, EquippableItemPrefabAsset> LoadModelItem()
|
||||
{
|
||||
return base.LoadModelItem();
|
||||
}
|
||||
|
||||
public override List<KeyValuePair<int, EquippableItemPrefabAsset>> LoadModelList()
|
||||
{
|
||||
string path = Path + GetFileName(ObjectListName);
|
||||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
BinaryFormatter formatter = new BinaryFormatter();
|
||||
FileStream stream = new FileStream(path, FileMode.Open);
|
||||
|
||||
List<KeyValuePair<int, EquippableItemPrefabAssetData>> questsList = formatter.Deserialize(stream) as List<KeyValuePair<int, EquippableItemPrefabAssetData>>;
|
||||
stream.Close();
|
||||
|
||||
return ConvertListOfDataModelsToListOfObject(questsList);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Save file not found in " + path);
|
||||
}
|
||||
|
||||
return new List<KeyValuePair<int, EquippableItemPrefabAsset>>();
|
||||
}
|
||||
|
||||
// Support function
|
||||
|
||||
// 1. From model to data format
|
||||
private KeyValuePair<int, EquippableItemPrefabAssetData> ConvertObjectToDataModel(KeyValuePair<int, EquippableItemPrefabAsset> model)
|
||||
{
|
||||
return new KeyValuePair<int, EquippableItemPrefabAssetData>(model.Key, new EquippableItemPrefabAssetData(model.Value));
|
||||
}
|
||||
|
||||
private List<KeyValuePair<int, EquippableItemPrefabAssetData>> ConvertObjectsListToListOfDataModels(List<KeyValuePair<int, EquippableItemPrefabAsset>> modelsList)
|
||||
{
|
||||
List<KeyValuePair<int, EquippableItemPrefabAssetData>> convertedList = new List<KeyValuePair<int, EquippableItemPrefabAssetData>>();
|
||||
|
||||
foreach(KeyValuePair <int, EquippableItemPrefabAsset> model in modelsList)
|
||||
{
|
||||
convertedList.Add(ConvertObjectToDataModel(model));
|
||||
}
|
||||
|
||||
return convertedList;
|
||||
}
|
||||
|
||||
// 2. From data to model format
|
||||
private KeyValuePair<int, EquippableItemPrefabAsset> ConvertDataModelToObject(KeyValuePair<int, EquippableItemPrefabAssetData> dataModel)
|
||||
{
|
||||
return new KeyValuePair<int, EquippableItemPrefabAsset>(dataModel.Key, (EquippableItemPrefabAsset)dataModel.Value.MapDataToPrefabAssetModel());
|
||||
}
|
||||
|
||||
private List<KeyValuePair<int, EquippableItemPrefabAsset>> ConvertListOfDataModelsToListOfObject(List<KeyValuePair<int, EquippableItemPrefabAssetData>> dataModelsList)
|
||||
{
|
||||
List<KeyValuePair<int, EquippableItemPrefabAsset>> convertedList = new List<KeyValuePair<int, EquippableItemPrefabAsset>>();
|
||||
|
||||
foreach (KeyValuePair<int, EquippableItemPrefabAssetData> dataModel in dataModelsList)
|
||||
{
|
||||
convertedList.Add(ConvertDataModelToObject(dataModel));
|
||||
}
|
||||
|
||||
return convertedList;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae3fbd7c37d1aa140a398a84afd9adb4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class SceneInventoryDataLoader : SceneBaseDataLoader<KeyValuePair<int, EquippableItemPrefabAsset>>
|
||||
{
|
||||
public SceneInventoryDataLoader(string _objectListName, string _objectFolderName)
|
||||
{
|
||||
SaveModelSystem = new SaveInventoryManager();
|
||||
SaveModelSystem.ObjectFolderName = _objectFolderName;
|
||||
SaveModelSystem.ObjectListName = _objectListName;
|
||||
}
|
||||
|
||||
/*
|
||||
public void LoadInventoryItemsList()
|
||||
{
|
||||
string path = SaveSystem.GetSavePath();
|
||||
|
||||
if (!Directory.Exists(path)) // if not exists thats mean there was nothing saved yet - nothing to load
|
||||
return;
|
||||
|
||||
FileInfo[] fileInfo = new DirectoryInfo(path).GetFiles();
|
||||
|
||||
foreach(FileInfo file in fileInfo)
|
||||
{
|
||||
if(file.Name != this.ItemsListName + ".fun")
|
||||
continue;
|
||||
|
||||
Dictionary<int, EquippableItemPrefabAssetData> equippableItemsList = SaveInventorySystem.LoadInventoryItemsList(this.ItemsListName);
|
||||
|
||||
// itemEntry.Value.MapDataToEquippableItem() - map data format to object
|
||||
|
||||
// save object
|
||||
foreach(KeyValuePair<int, EquippableItemPrefabAssetData> itemEntry in equippableItemsList)
|
||||
{
|
||||
InventoryManager.Instance.SetupItemInInventory(itemEntry.Key, itemEntry.Value.MapDataToEquippableItemPrefarbAsset().equippableItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveInventoryItems()
|
||||
{
|
||||
// Case I - if we remember all list
|
||||
// 1) if after removed item form DynamicList is empty - remove all file
|
||||
// 2) if after removed item form DynamciList there are another one - save updated list again
|
||||
if(InventoryManager.Instance._items.Count > 0) {
|
||||
|
||||
// 1. Map From Dictionary<int, Item>' to 'Dictionary<int, EquippableItemPrefabAsset>'
|
||||
Dictionary<int, EquippableItemPrefabAsset> mappedList = new Dictionary<int, EquippableItemPrefabAsset>();
|
||||
|
||||
foreach(KeyValuePair<int, Item> itemElement in InventoryManager.Instance._items)
|
||||
{
|
||||
mappedList[itemElement.Key] = new EquippableItemPrefabAsset(
|
||||
itemElement.Value.Name,
|
||||
itemElement.Value.ItemModel.name,
|
||||
new Vector3(0,0,0),
|
||||
(EquippableItem) itemElement.Value
|
||||
);
|
||||
}
|
||||
|
||||
// 2. Save Items
|
||||
SaveInventorySystem.SaveInventoryItemsList(mappedList, this.ItemsListName);
|
||||
} else {
|
||||
string _path = SaveSystem.GetSavePath() + "/" + this.ItemsListName + ".fun";
|
||||
|
||||
try
|
||||
{
|
||||
Debug.Log("File to remove: " + _path);
|
||||
|
||||
if(File.Exists(_path))
|
||||
{
|
||||
File.Delete(_path);
|
||||
}
|
||||
}
|
||||
catch (IOException ioExp)
|
||||
{
|
||||
Debug.LogError(ioExp.Message);
|
||||
}
|
||||
}
|
||||
|
||||
// Case II - if we rememenber object per file
|
||||
// 1) remove specyfic file
|
||||
//
|
||||
// Unfortunatelly we don't use this way of saving items yet :D
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
protected override List<KeyValuePair<int, EquippableItemPrefabAsset>> LoadGenericData()
|
||||
{
|
||||
SaveModelSystem.Path = PathBuilder.BuildSavePath().GetString();
|
||||
|
||||
return SaveModelSystem.LoadModelList();
|
||||
}
|
||||
|
||||
protected override bool SaveGenericData(List<KeyValuePair<int, EquippableItemPrefabAsset>> _elements)
|
||||
{
|
||||
SaveModelSystem.Path = PathBuilder.BuildSavePath().GetString();
|
||||
|
||||
try
|
||||
{
|
||||
SaveModelSystem.SaveModelList(_elements);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) { Debug.LogError(e.Message); }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override List<KeyValuePair<int, EquippableItemPrefabAsset>> LoadStaticData() { throw new System.NotImplementedException(); }
|
||||
|
||||
protected override List<KeyValuePair<int, EquippableItemPrefabAsset>> LoadDynamicData() { throw new System.NotImplementedException(); }
|
||||
|
||||
protected override bool SaveStaticData(List<KeyValuePair<int, EquippableItemPrefabAsset>> _elements) { throw new System.NotImplementedException(); }
|
||||
|
||||
protected override bool SaveDynamicData(List<KeyValuePair<int, EquippableItemPrefabAsset>> _elements) { throw new System.NotImplementedException(); }
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: baf283801c6e7974fa09be212719ea78
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class SceneInventoryDataManager : SceneBaseDataManager<KeyValuePair<int, Item>>
|
||||
{
|
||||
protected override string OBJECT_FOLDER_NAME { get { return "Inventory"; } }
|
||||
protected override string OBJECT_LIST_NAME { get { return "InventoryList"; } }
|
||||
|
||||
protected new SceneBaseDataLoader<KeyValuePair<int, EquippableItemPrefabAsset>> DataLoader { get; set; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Debug.Log("Start SceneInventoryData manager");
|
||||
|
||||
//TaskUIManager.FindOrCreateInstance();
|
||||
var inventoryManager = InventoryUIManager.Instance;
|
||||
|
||||
if (inventoryManager == null)
|
||||
throw new NullReferenceException("InventoryUIManager not found!!!");
|
||||
|
||||
StaticDataList = (new InventoryDataListManager()).SetUiManager(ref inventoryManager);
|
||||
// DynamicDataList = (new TaskDataListManager()).SetUiManager(ref taskManager);
|
||||
|
||||
DataLoader = new SceneInventoryDataLoader(OBJECT_LIST_NAME, OBJECT_FOLDER_NAME);
|
||||
|
||||
|
||||
//SaveData(StaticDataList.GetList(), SceneElementTypeEnum.None);
|
||||
|
||||
LoadData(SceneElementTypeEnum.None, ref StaticDataList);
|
||||
// LoadDynamicData();
|
||||
|
||||
inventoryManager.SetList(StaticDataList.GetList());
|
||||
|
||||
inventoryManager.OpenPanel();
|
||||
}
|
||||
|
||||
#region override load & save
|
||||
protected override bool LoadData(SceneElementTypeEnum type, ref DataListManager<KeyValuePair<int, Item>> dataListManager)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 1. Convert EquippableItemPrefabAsset to EquippableItem list
|
||||
List<KeyValuePair<int, Item>> convertedList = new List<KeyValuePair<int, Item>>();
|
||||
|
||||
foreach(KeyValuePair<int, EquippableItemPrefabAsset> loadedEquippableItemPrefarbAssetElement in (List<KeyValuePair<int, EquippableItemPrefabAsset>>)DataLoader.LoadData(SceneElementTypeEnum.None))
|
||||
{
|
||||
convertedList.Add(new KeyValuePair<int, Item>(loadedEquippableItemPrefarbAssetElement.Key, (EquippableItem)loadedEquippableItemPrefarbAssetElement.Value.EquippableItem));
|
||||
}
|
||||
|
||||
// 2. Pass loaded list to InventoryDataManager
|
||||
dataListManager.SetList(convertedList);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogWarning(e.Message);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override bool SaveData(List<KeyValuePair<int, Item>> _elements, SceneElementTypeEnum type)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 1. Convert EquippableItem to EquippableItemPrefabAsset list
|
||||
List<KeyValuePair<int, EquippableItemPrefabAsset>> convertedList = new List<KeyValuePair<int, EquippableItemPrefabAsset>>();
|
||||
|
||||
foreach (KeyValuePair<int, Item> itemElement in _elements)
|
||||
{
|
||||
convertedList.Add(new KeyValuePair<int, EquippableItemPrefabAsset>(
|
||||
itemElement.Key,
|
||||
new EquippableItemPrefabAsset(
|
||||
itemElement.Value.Name,
|
||||
itemElement.Value.ItemModel.name,
|
||||
new Vector3(0, 0, 0),
|
||||
(EquippableItem)itemElement.Value
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
// 2. Pass loaded list to InventoryDataManager
|
||||
DataLoader.SaveData(convertedList, type);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogWarning(e.Message);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected SceneBaseDataManager<KeyValuePair<int, Item>> GetObjectType()
|
||||
{
|
||||
return GameObject.FindObjectOfType<SceneInventoryDataManager>();
|
||||
}
|
||||
|
||||
protected SceneBaseDataManager<KeyValuePair<int, Item>> CreateInstance(ref GameObject managerGameObject)
|
||||
{
|
||||
return managerGameObject.AddComponent<SceneInventoryDataManager>();
|
||||
}
|
||||
|
||||
|
||||
// TODO whats with that
|
||||
/* public int AddToInventory(EquippableItem pickable)
|
||||
{
|
||||
if (this._items.Count <= MAX_ITEMS)
|
||||
{
|
||||
for (int slotNumber = 0; slotNumber < MAX_ITEMS; slotNumber++)
|
||||
{
|
||||
if (!this._items.ContainsKey(slotNumber))
|
||||
{
|
||||
this._items[slotNumber] = pickable;
|
||||
return slotNumber;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}*/
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2abcc8484cbc4084baa69da81c59fc3d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,80 @@
|
||||
// using Shared.Manager.Scene;
|
||||
// using System.Collections.Generic;
|
||||
// using UnityEngine;
|
||||
// using UnityEditor;
|
||||
// using UnityEngine.SceneManagement;
|
||||
// using System.IO;
|
||||
// using System.Linq;
|
||||
// using REFACTORING.Shared.Manager.Scene;
|
||||
//
|
||||
// namespace REFACTORING.Scene
|
||||
// {
|
||||
// public class SceneChestManager : SceneBaseDataManager<ChestPrefarbAsset>
|
||||
// {
|
||||
// private new const string STATIC_ELEMENT_LOCATION = "/StaticElements/";
|
||||
// private new const string ELEMENT_FOLDER_NAME = "Chest";
|
||||
// private new const string ITEM_LIST_NAME = "ChestList";
|
||||
//
|
||||
// // [SerializeField]
|
||||
// // public List<ChestPrefarbAsset> StaticElements;
|
||||
// //
|
||||
// // [SerializeField]
|
||||
// // public List<ChestPrefarbAsset> DynamicElements;
|
||||
//
|
||||
// public override void AddElementToList()
|
||||
// {
|
||||
// throw new System.NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public override void RemoveElementFromList()
|
||||
// {
|
||||
// throw new System.NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public override void Build()
|
||||
// {
|
||||
// throw new System.NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public override void LoadData()
|
||||
// {
|
||||
// this.StaticElements = LoadStaticChestsList();
|
||||
// }
|
||||
//
|
||||
// #region Static list of Chest Loader
|
||||
// private List<ChestPrefarbAsset> LoadStaticChestsList()
|
||||
// {
|
||||
// var path = SaveSystem.GetSavePath(this.MapName + STATIC_ELEMENT_LOCATION);
|
||||
//
|
||||
// if (!Directory.Exists(path))
|
||||
// return new List<ChestPrefarbAsset>();
|
||||
//
|
||||
// List<ChestPrefarbAsset> chestPrefabAssetList = new List<ChestPrefarbAsset>();
|
||||
//
|
||||
// foreach(var file in new DirectoryInfo(path).GetFiles())
|
||||
// {
|
||||
// Debug.Log(file.FullName);
|
||||
//
|
||||
// List<ChestPrefarbAssetData> chestPrefabAssetDataList = SaveChestSystem.LoadChestsList(this.MapName + STATIC_ELEMENT_LOCATION, ITEM_LIST_NAME);
|
||||
//
|
||||
// chestPrefabAssetList = chestPrefabAssetDataList.Select(chestPrefabAssetData => chestPrefabAssetData.MapDataToChestPrefarbAsset()).ToList();
|
||||
//
|
||||
// // Debug.Log("---- Load Chest");
|
||||
// //
|
||||
// // foreach(ChestPrefarbAsset chest in chestPrefarbAssetList)
|
||||
// // {
|
||||
// // Debug.Log(chest.name);
|
||||
// // foreach(KeyValuePair<int, EquippableItemPrefabAsset> equippableItemPrefarbAsset in chest.content)
|
||||
// // {
|
||||
// // // Debug.Log("item on position " + equippableItemPrefarbAsset.Key +
|
||||
// // // " " + equippableItemPrefarbAsset.Value.equippableItem.name);
|
||||
// // }
|
||||
// // }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// return chestPrefabAssetList;
|
||||
// }
|
||||
// #endregion
|
||||
// }
|
||||
// }
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03ae14a03c0d4cfb83ddf5c7eb84c528
|
||||
timeCreated: 1660171923
|
@ -26,9 +26,6 @@ public class SceneTaskDataManager : SceneBaseDataManager<Task>
|
||||
// LoadDynamicData();
|
||||
|
||||
taskManager.SetList(StaticDataList.GetList());
|
||||
|
||||
taskManager.OpenPanel();
|
||||
|
||||
}
|
||||
|
||||
protected SceneBaseDataManager<Task> GetObjectType()
|
3
Assets/Scripts/REFACTORING/Application/Shared.meta
Normal file
3
Assets/Scripts/REFACTORING/Application/Shared.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c947e46e1d604351adf547f0d75360e4
|
||||
timeCreated: 1660164696
|
@ -3,7 +3,7 @@ using UnityEngine;
|
||||
|
||||
public abstract class DataListManager<T> : SceneDataListManagerInterface<T>
|
||||
{
|
||||
[SerializeField] protected List<T> Elements;
|
||||
[SerializeField] protected List<T> Elements = new List<T>();
|
||||
[SerializeField] protected UIBaseManager<T> uiManager;
|
||||
|
||||
/// <summary>
|
||||
@ -26,16 +26,10 @@ public abstract class DataListManager<T> : SceneDataListManagerInterface<T>
|
||||
{
|
||||
Elements = _elements;
|
||||
}
|
||||
|
||||
public void AddElementToList(T newElement)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public void RemoveElementFromList(T element)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public abstract void AddElementToList(T newElement);
|
||||
|
||||
public abstract void RemoveElementFromList(T element);
|
||||
|
||||
//public abstract void Build();
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a593b8f8685477295db56223cebd3eb
|
||||
timeCreated: 1660487127
|
||||
guid: 77ed1a571d1643f1993ccef6284861fd
|
||||
timeCreated: 1660166978
|
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class SceneBaseDataManager<T> : MonoBehaviour where T : Task
|
||||
/*where T : Task*/
|
||||
public abstract class SceneBaseDataManager<T> : MonoBehaviour
|
||||
{
|
||||
protected virtual string OBJECT_FOLDER_NAME => "";
|
||||
protected virtual string OBJECT_LIST_NAME => "";
|
||||
@ -12,7 +12,7 @@ public abstract class SceneBaseDataManager<T> : MonoBehaviour where T : Task
|
||||
protected DataListManager<T> StaticDataList;
|
||||
protected DataListManager<T> DynamicDataList;
|
||||
|
||||
protected SceneDataLoaderInterface<T> DataLoader { get; set; }
|
||||
protected SceneBaseDataLoader<T> DataLoader { get; set; }
|
||||
|
||||
public static SceneBaseDataManager<T> Instance; // { get; private set; }
|
||||
|
||||
@ -64,12 +64,12 @@ public abstract class SceneBaseDataManager<T> : MonoBehaviour where T : Task
|
||||
// // DynamicDataList.Build();
|
||||
// }
|
||||
|
||||
private bool LoadData(SceneElementTypeEnum type, ref DataListManager<T> dataListManager)
|
||||
protected virtual bool LoadData(SceneElementTypeEnum type, ref DataListManager<T> dataListManager)
|
||||
{
|
||||
try
|
||||
{
|
||||
dataListManager.SetList(
|
||||
DataLoader.LoadData(SceneElementTypeEnum.None)
|
||||
DataLoader.LoadData(SceneElementTypeEnum.None) as List<T>
|
||||
);
|
||||
|
||||
return true;
|
||||
@ -80,8 +80,8 @@ public abstract class SceneBaseDataManager<T> : MonoBehaviour where T : Task
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool SaveData(List<T> _elements, SceneElementTypeEnum type)
|
||||
|
||||
protected virtual bool SaveData(List<T> _elements, SceneElementTypeEnum type)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -119,11 +119,12 @@ public abstract class SceneBaseDataManager<T> : MonoBehaviour where T : Task
|
||||
// TODO
|
||||
// how to get list
|
||||
// 1. List in UI manager should be synchronized with list in this manager
|
||||
|
||||
|
||||
// approach:
|
||||
// 1. get from outside, update local list && us it
|
||||
// 2. Handle list synchronized all the time & pass local list
|
||||
|
||||
|
||||
Debug.Log("SaveStaticData");
|
||||
return SaveData(StaticDataList.GetList(), SceneElementTypeEnum.Static);
|
||||
}
|
||||
|
@ -49,11 +49,11 @@ public abstract class SceneDataListManager<T> : DataListManager<T>
|
||||
//
|
||||
// doBuild(_object);
|
||||
// // // 3. SetUp EqippableItems list
|
||||
// // Dictionary<int, EquippableItemPrefarbAsset> itemsOfChestList = prefabAsset.content;
|
||||
// // Dictionary<int, EquippableItemPrefabAsset> itemsOfChestList = prefabAsset.content;
|
||||
// //
|
||||
// // string[] assetNames = AssetDatabase.FindAssets("t:EquippableItem", new[] { assetLocalization });
|
||||
// //
|
||||
// // foreach(KeyValuePair<int, EquippableItemPrefarbAsset> itemsOfChestEntry in itemsOfChestList)
|
||||
// // foreach(KeyValuePair<int, EquippableItemPrefabAsset> itemsOfChestEntry in itemsOfChestList)
|
||||
// // {
|
||||
// // // 3.1 find object
|
||||
// // foreach (string SOName in assetNames)
|
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77ed1a571d1643f1993ccef6284861fd
|
||||
timeCreated: 1660166978
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fdd6687dd658574da87271e9677e290
|
||||
guid: 26415552df60a48448e65ca186d33e97
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@ -0,0 +1,106 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public abstract class DraggablePanelController : PanelController<KeyValuePair<int, Item>>, DraggablePanelInterface
|
||||
{
|
||||
[SerializeField] protected new List<ISlot> ChildBoxList = new List<ISlot>();
|
||||
|
||||
protected static UIWarehouseManager _uiManager;
|
||||
|
||||
protected new UIWarehouseManager UiManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_uiManager == null) { return FetchUiManager() as UIWarehouseManager; }
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ISlot SetupDragAndDropToSlot(ISlot slot)
|
||||
{
|
||||
slot.OnBeginDragEvent += BeginDrag;
|
||||
slot.OnEndDragEvent += EndDrag;
|
||||
slot.OnDragEvent += Drag;
|
||||
slot.OnDropEvent += Drop;
|
||||
|
||||
return slot;
|
||||
}
|
||||
|
||||
public void BeginDrag(ItemSlot itemSlot)
|
||||
{
|
||||
if (itemSlot.Item != null)
|
||||
{
|
||||
DraggedSlotController.Instance.CreateDraggedSlot(itemSlot, _panelContent.transform.position);
|
||||
}
|
||||
}
|
||||
|
||||
public void Drag(ItemSlot itemSlot)
|
||||
{
|
||||
DraggedSlotController.Instance.UpdatePosition(Input.mousePosition);
|
||||
}
|
||||
|
||||
public void EndDrag(ItemSlot itemSlot)
|
||||
{
|
||||
if (!DraggedSlotController.Instance.IsDragged()) // if there was nothing dragged - ignore event
|
||||
return;
|
||||
|
||||
DraggedSlotController.Instance.RemoveDraggedSlot();
|
||||
|
||||
// Apply list of items
|
||||
for (int i = 0; i < ChildBoxList.Count; i++)
|
||||
{
|
||||
if (ChildBoxList[i].Item != null)
|
||||
{
|
||||
UiManager.Add(new KeyValuePair<int, Item>(i, (EquippableItem)ChildBoxList[i].Item));
|
||||
}
|
||||
else
|
||||
{
|
||||
UiManager.RemoveByPosition(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Drop(ItemSlot dropItemSlot)
|
||||
{
|
||||
if (!DraggedSlotController.Instance.IsDragged()) // if there was nothing dragged - ignore event
|
||||
return;
|
||||
|
||||
var draggedSlot = GetDraggedSlot();
|
||||
|
||||
if (dropItemSlot.CanReceiveItem(draggedSlot.Item) && draggedSlot.CanReceiveItem(dropItemSlot.Item))
|
||||
{
|
||||
EquippableItem dragItem = draggedSlot.Item as EquippableItem;
|
||||
EquippableItem dropItem = dropItemSlot.Item as EquippableItem;
|
||||
|
||||
// TODO insert child criterials
|
||||
|
||||
Item _tmpDraggedItem = draggedSlot.Item; // InventoryUIManager.Instance.DraggedSlot.Item; // remember temporary currently dragged item
|
||||
|
||||
|
||||
/*
|
||||
* not sure why but if you change order of assign, something will ovberride dropItemSlot.Item vale accordint to draggedSlot.Item = dropItemSlot.Item; value
|
||||
* BUG - not sure where
|
||||
*/
|
||||
draggedSlot.Item = dropItemSlot.Item;
|
||||
UiManager.Add(new KeyValuePair<int, Item>(draggedSlot.Number, (EquippableItem)draggedSlot.Item));
|
||||
|
||||
dropItemSlot.Item = _tmpDraggedItem;
|
||||
UiManager.Add(new KeyValuePair<int, Item>(dropItemSlot.Number, (EquippableItem)dropItemSlot.Item));
|
||||
}
|
||||
}
|
||||
|
||||
//public ISlot GetDraggedSlotFromManager() => InventoryUIManager.Instance.DraggedSlot;
|
||||
public ISlot GetDraggedSlot()
|
||||
{
|
||||
return DraggedSlotController.Instance.DraggedSlot;
|
||||
}
|
||||
|
||||
public void SetItemOnPosition()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68a2f165c11561a438c59d76adceff30
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,25 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public interface DraggablePanelInterface
|
||||
{
|
||||
/// <summary>
|
||||
/// Function to associate defined Drag&Drop behaviour to passed slot
|
||||
/// </summary>
|
||||
/// <param name="slot"></param>
|
||||
public ISlot SetupDragAndDropToSlot(ISlot slot);
|
||||
|
||||
|
||||
public void BeginDrag(ItemSlot itemSlot);
|
||||
|
||||
public void EndDrag(ItemSlot itemSlot);
|
||||
|
||||
public void Drag(ItemSlot itemSlot);
|
||||
|
||||
public void Drop(ItemSlot dropItemSlot);
|
||||
|
||||
// supports function to use in Drop
|
||||
public void SetItemOnPosition();
|
||||
|
||||
public ISlot GetDraggedSlot();
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0472eb5aa2400874b98ffa373b72c07e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class DraggedSlotController : MonoBehaviour
|
||||
{
|
||||
public static DraggedSlotController Instance { get; private set; }
|
||||
|
||||
[Header("Dragged Image")]
|
||||
[SerializeField] protected Image DraggedSlotImageTemplate;
|
||||
[SerializeField] protected Image DraggedSlotImage;
|
||||
|
||||
[Space]
|
||||
[Header("Dragged Slot")]
|
||||
[SerializeField] protected ISlot _draggedSlot;
|
||||
public ISlot DraggedSlot // in Drag & Drop functionality for Warehouse set of panels I will temporary delegate dragged item to outside static object instance in order to remember it during dragging object from one slot to anothe one
|
||||
{
|
||||
get { return _draggedSlot; }
|
||||
set
|
||||
{
|
||||
_draggedSlot = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsDragged()
|
||||
{
|
||||
return DraggedSlot != null;
|
||||
}
|
||||
|
||||
public void CreateDraggedSlot(ItemSlot itemSlot, Vector3 beginingPosition)
|
||||
{
|
||||
DraggedSlot = itemSlot;
|
||||
|
||||
MakeDraggableItem(beginingPosition);
|
||||
}
|
||||
private void MakeDraggableItem( Vector3 beginingPosition)
|
||||
{
|
||||
if (DraggedSlotImage)
|
||||
{
|
||||
DraggedSlotImage.enabled = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject globalGUI = GameObject.FindGameObjectWithTag("GUI");
|
||||
|
||||
if (globalGUI)
|
||||
{
|
||||
DraggedSlotImage = MonoBehaviour.Instantiate(DraggedSlotImageTemplate, DraggedSlotImageTemplate.transform.position, Quaternion.identity, globalGUI.transform);
|
||||
DraggedSlotImage.transform.localPosition = beginingPosition;
|
||||
DraggedSlotImage.sprite = DraggedSlot.Item.Image;
|
||||
DraggedSlotImage.transform.position = Input.mousePosition;
|
||||
DraggedSlotImage.enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Can't find global GUI object!!!");
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdatePosition(Vector3 newSlotPosition)
|
||||
{
|
||||
if(DraggedSlotImage != null)
|
||||
DraggedSlotImage.transform.position = newSlotPosition;
|
||||
}
|
||||
|
||||
public bool RemoveDraggedSlot()
|
||||
{
|
||||
try
|
||||
{
|
||||
DestroyImmediate(DraggedSlotImage.gameObject, true);
|
||||
DraggedSlotImage = null;
|
||||
|
||||
DraggedSlot = null;
|
||||
}catch(Exception e)
|
||||
{
|
||||
Debug.LogError(e.Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8081574e3f851e4d9335be93900a94e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e39995ada1a75cf4bb0857afc6d14d67
|
||||
guid: e3e28c38b9237d74eb9ac2555dea625e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class WarehousePanelController : DraggablePanelController
|
||||
{
|
||||
public override void BuildPanelContent(List<KeyValuePair<int, Item>> elements)
|
||||
{
|
||||
base.BuildPanelContent(elements);
|
||||
|
||||
ClearSlots();
|
||||
}
|
||||
|
||||
public override void ClearSlots()
|
||||
{
|
||||
foreach (ItemSlot ChestSlot in ChildBoxList)
|
||||
{
|
||||
ChestSlot.ResetSlot();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract override void BuildPanelSlots();
|
||||
public abstract override GameObject BuildSlot(int key, GameObject _parent);
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cba22a871f952fc4ea06e8cfc81628ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,136 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class UIWarehouseManager : UIBaseManager<KeyValuePair<int, Item>>
|
||||
{
|
||||
public virtual int SLOTS_NUMBER => 0;
|
||||
|
||||
public static new UIWarehouseManager Instance { get; private set; }
|
||||
/*
|
||||
* not sure why but childrens of this class dont interfere on parents Awake
|
||||
*/
|
||||
public void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function to find item in warehouser by its id, returns list of all slots where item occured
|
||||
/// </summary>
|
||||
/// <param name="itemId"></param>
|
||||
/// <returns></returns>
|
||||
public List<KeyValuePair<int, Item>> FindItemInWarehouse(int itemId)
|
||||
{
|
||||
return Elements.Where(item => item.Value.Id == itemId).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function to find item in warehouser by its name, returns list of all slots where item occured
|
||||
/// </summary>
|
||||
/// <param name="itemId"></param>
|
||||
/// <returns></returns>
|
||||
public List<KeyValuePair<int, Item>> FindItemInWarehouseByName(string itemName)
|
||||
{
|
||||
return Elements.Where(item => item.Value.name == itemName).ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function (SetItemOnPosition) to add slot with its number and item to list (which will be mapped with panel content)
|
||||
/// </summary>
|
||||
/// <param name="itemOnSlot"></param>
|
||||
public void Add(KeyValuePair<int, Item> itemOnSlot)
|
||||
{
|
||||
if (!CheckIfSlotIsInRange(itemOnSlot.Key))
|
||||
throw new System.Exception($"Slot number: {itemOnSlot.Key} is out of range, avaiable: {SLOTS_NUMBER} slots");
|
||||
|
||||
if (CheckIfSlotExists(itemOnSlot.Key) && !CheckIfPositionIsEmpty(itemOnSlot.Key))
|
||||
RemoveByPosition(itemOnSlot.Key);
|
||||
|
||||
if(itemOnSlot.Value != null)
|
||||
{
|
||||
Debug.Log($" Added {itemOnSlot.Value} on position {itemOnSlot.Key}");
|
||||
base.Add(itemOnSlot);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function to add item on first empty slot to list (which will be mapped with panel content)
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(Item item)
|
||||
{
|
||||
if(IsFull())
|
||||
throw new System.Exception($"Warehouse is full!!!");
|
||||
|
||||
// find first empty position / slot
|
||||
var max = Elements.Max(itemSlot => itemSlot.Key);
|
||||
|
||||
base.Add(new KeyValuePair<int, Item>(max, item));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void RemoveByPosition(int keyPosition)
|
||||
{
|
||||
if (!CheckIfSlotExists(keyPosition))
|
||||
return; // throw new System.Exception($"Slot with number: {keyPosition} don't exist");
|
||||
|
||||
Debug.Log($"Remove from position: {keyPosition}");
|
||||
|
||||
Elements.RemoveAll(itemSlot => itemSlot.Key == keyPosition);
|
||||
}
|
||||
|
||||
public int RemoveByItemId(int itemId)
|
||||
{
|
||||
return Elements.RemoveAll(itemSlot => itemSlot.Value.Id == itemId);
|
||||
}
|
||||
|
||||
public int RemoveByItemName(string itemName)
|
||||
{
|
||||
return Elements.RemoveAll(itemSlot => itemSlot.Value.Name == itemName);
|
||||
}
|
||||
|
||||
|
||||
public bool IsFull()
|
||||
{
|
||||
return Elements.Count() == SLOTS_NUMBER;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private bool CheckIfSlotIsInRange(int slotNumber)
|
||||
{
|
||||
return slotNumber < SLOTS_NUMBER;
|
||||
}
|
||||
|
||||
private bool CheckIfSlotExists(int slotNumber)
|
||||
{
|
||||
return Elements.Any(itemSlot => itemSlot.Key == slotNumber);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if slot is empty in local list
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool CheckIfPositionIsEmpty(int slotNumber)
|
||||
{
|
||||
if(CheckIfSlotExists(slotNumber)) {
|
||||
return Elements.Where(itemSlot => itemSlot.Key == slotNumber).First().Value == null;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64ff67a5470895e4d9f186fe4e4ad353
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public abstract class SaveModelSystem<T>
|
||||
{
|
||||
@ -19,4 +20,5 @@ public abstract class SaveModelSystem<T>
|
||||
public virtual T LoadModelItem() { return (T)Activator.CreateInstance(typeof(T), new object[] { }); }
|
||||
|
||||
public virtual List<T> LoadModelList() { return new List<T>(); }
|
||||
|
||||
}
|
3
Assets/Scripts/REFACTORING/Application/UI.meta
Normal file
3
Assets/Scripts/REFACTORING/Application/UI.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e72a7403874a4dd3b9987b033d009bb8
|
||||
timeCreated: 1660171754
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ce31190a4475124d929da9d4612aaef
|
||||
guid: 1042da730845c974598aec17c507491d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class InventoryUIManager : UIWarehouseManager
|
||||
{
|
||||
public override int SLOTS_NUMBER { get { return 48; } }
|
||||
|
||||
public const string ITEM_LOCALIZATION = "UiPanels/";
|
||||
public const string PANEL_NAME = "InventoryPanel";
|
||||
|
||||
/* public override void UpdateList()
|
||||
{
|
||||
// TODO something like rebuild associated panel content
|
||||
// depending on which class we use it mayu be Inventory / Chest / Shop Panel Controller
|
||||
DynamicPanel.GetComponent<InventoryPanelController>(); //.Refresh() -- rebuild content
|
||||
}*/
|
||||
|
||||
public override void SetupPanel()
|
||||
{
|
||||
base.SetupPanel();
|
||||
|
||||
// setup models list
|
||||
DynamicPanel.GetComponent<InventoryPanelController>().SetUp(Elements);
|
||||
}
|
||||
|
||||
public override void UpdateList()
|
||||
{
|
||||
DynamicPanel.GetComponent<InventoryPanelController>().BuildPanelContent(Elements);
|
||||
}
|
||||
|
||||
protected override GameObject GetTemplatePanel()
|
||||
{
|
||||
// Resources = default path - Asset/Resources ... .obj
|
||||
return Resources.Load(ITEM_LOCALIZATION + PANEL_NAME) as GameObject;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 79e7954722c69764e9be36961af94d1e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,91 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using System;
|
||||
|
||||
|
||||
public class InventoryPanelController : WarehousePanelController
|
||||
{
|
||||
protected override UIBaseManager<KeyValuePair<int, Item>> FetchUiManager()
|
||||
{
|
||||
var uiManager = GameObject.FindObjectOfType<InventoryUIManager>();
|
||||
|
||||
// uiManager.SetPanelController(gameObject); - unnecessary
|
||||
|
||||
return uiManager;
|
||||
}
|
||||
|
||||
|
||||
// build panel sunction
|
||||
// - setup - main function to build panel on screen
|
||||
// - setPanelISlots - build slots on panel dependiong on declared amount
|
||||
// - setPanelItems - invoking building items on slots
|
||||
|
||||
// api for drag and drop
|
||||
// - set item on position
|
||||
// - remove item from position
|
||||
// - find item in warehouse
|
||||
|
||||
|
||||
// 1. Prepare empty panel
|
||||
public override void BuildPanelSlots()
|
||||
{
|
||||
if (_panelContent == null)
|
||||
throw new Exception("Panel content is not attaches");
|
||||
|
||||
|
||||
for (int _position = 0; _position < UiManager.SLOTS_NUMBER; _position++)
|
||||
{
|
||||
//ISlot newSlot = SetupSlot(_position, _panel);
|
||||
GameObject newSlot = BuildSlot(_position, _panelContent);
|
||||
|
||||
// Set new Slot instance
|
||||
ChildBoxList.Add(newSlot.GetComponent<InventorySlot>());
|
||||
|
||||
// Assign events
|
||||
ChildBoxList[_position] = SetupDragAndDropToSlot(ChildBoxList[_position]);
|
||||
}
|
||||
}
|
||||
|
||||
public override GameObject BuildSlot(int key, GameObject _parent)
|
||||
{
|
||||
if (ChildBoxTemplate == null)
|
||||
throw new Exception("itemslotbox_template is empty");
|
||||
|
||||
GameObject _newItemSlot = MonoBehaviour.Instantiate(ChildBoxTemplate, _parent.transform.position, Quaternion.identity); //.GetComponent<InventorySlot>();
|
||||
|
||||
_newItemSlot.transform.SetParent(_parent.transform);
|
||||
_newItemSlot.transform.localScale = new Vector3(1.15f, 1.15f, 1.15f);
|
||||
|
||||
_newItemSlot.GetComponent<InventorySlot>().SetupSlot(key, null, this);
|
||||
|
||||
return _newItemSlot;
|
||||
}
|
||||
|
||||
|
||||
// 2. Set up panel additn items to it
|
||||
public override void SetUp(List<KeyValuePair<int, Item>> elements)
|
||||
{
|
||||
// Build panel content template
|
||||
BuildPanelSlots();
|
||||
|
||||
// Fill with items
|
||||
BuildPanelContent(elements);
|
||||
}
|
||||
|
||||
|
||||
public override void BuildPanelContent(List<KeyValuePair<int, Item>> elements)
|
||||
{
|
||||
|
||||
base.BuildPanelContent(elements);
|
||||
|
||||
Debug.Log("Build content");
|
||||
foreach (KeyValuePair<int, Item> element in elements)
|
||||
{
|
||||
Debug.Log($"key: {element.Key} - value: {element.Value}");
|
||||
ChildBoxList[element.Key].SetItem(element.Value);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0bff20d6fb721a449df16891030739a
|
||||
guid: b3ae9277a19e5dc49aa607d1d2ec2dc9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@ -5,32 +5,9 @@ using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using System;
|
||||
|
||||
public class TaskPanelController : MonoBehaviour
|
||||
public class TaskPanelController : PanelController<Task>
|
||||
{
|
||||
[Header("Panel Information")]
|
||||
[SerializeField] protected GameObject _panelContent;
|
||||
//[SerializeField] private TaskBox TaskBoxTemplate;
|
||||
[SerializeField] private GameObject TaskBoxTemplate;
|
||||
[SerializeField] private List<GameObject> TaskBoxList;
|
||||
|
||||
/// <summary>
|
||||
/// Fetch reference to static instance of UiManager script
|
||||
/// </summary>
|
||||
private static UIBaseManager<Task> _uiManager;
|
||||
|
||||
private UIBaseManager<Task> UiManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_uiManager == null) { _uiManager = FetchUiManager(); }
|
||||
|
||||
return _uiManager;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO decide whick method use and where bind object with itself
|
||||
// public abstract void Bind(ManagerInterfac<T>e manager);
|
||||
private UIBaseManager<Task> FetchUiManager() // check if need return by ref
|
||||
protected override UIBaseManager<Task> FetchUiManager() // check if need return by ref
|
||||
{
|
||||
var uiManager = GameObject.FindObjectOfType<TaskUIManager>();
|
||||
|
||||
@ -38,39 +15,18 @@ public class TaskPanelController : MonoBehaviour
|
||||
|
||||
return uiManager;
|
||||
}
|
||||
|
||||
public void InitPanelBoxes(List<Task> _tasks)
|
||||
{
|
||||
if (_panelContent == null)
|
||||
throw new Exception("Panel content is not attaches");
|
||||
|
||||
for(int i = 0; i < _tasks.Count; i++)
|
||||
|
||||
public override void BuildPanelContent(List<Task> elements)
|
||||
{
|
||||
base.BuildPanelContent(elements);
|
||||
|
||||
for (int i = 0; i < elements.Count; i++)
|
||||
{
|
||||
this.AddTask(_tasks[i]);
|
||||
this.AddTask(elements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
protected GameObject SetupTaskBox(Task _task)
|
||||
{
|
||||
if (TaskBoxTemplate == null)
|
||||
throw new Exception("taskbox_template is empty");
|
||||
|
||||
GameObject _newTaskBox = Instantiate(TaskBoxTemplate, _panelContent.transform.position, Quaternion.identity); //.GetComponent<TaskBox>();
|
||||
|
||||
_newTaskBox.transform.SetParent(_panelContent.transform);
|
||||
|
||||
_newTaskBox.transform.localScale = new Vector3(2.5f, 2.5f, 1.0f);
|
||||
|
||||
_newTaskBox.GetComponent<TaskBox>().SetTask(_task);
|
||||
|
||||
return _newTaskBox;
|
||||
}
|
||||
|
||||
public void Setup(List<Task> _tasks)
|
||||
{
|
||||
this.InitPanelBoxes(_tasks);
|
||||
}
|
||||
|
||||
public void AddTask(Task _task)
|
||||
{
|
||||
// update TaskManager main list of task
|
||||
@ -80,6 +36,40 @@ public class TaskPanelController : MonoBehaviour
|
||||
GameObject newTaskBox = SetupTaskBox(_task);
|
||||
|
||||
// Set new Slot instance
|
||||
TaskBoxList.Add(newTaskBox);
|
||||
ChildBoxList.Add(newTaskBox);
|
||||
}
|
||||
|
||||
protected GameObject SetupTaskBox(Task _task)
|
||||
{
|
||||
if (ChildBoxTemplate == null)
|
||||
throw new Exception("taskbox_template is empty");
|
||||
|
||||
GameObject _newTaskBox = MonoBehaviour.Instantiate(ChildBoxTemplate, _panelContent.transform.position, Quaternion.identity); //.GetComponent<TaskBox>();
|
||||
|
||||
_newTaskBox.transform.SetParent(_panelContent.transform);
|
||||
|
||||
_newTaskBox.transform.localScale = new Vector3(2.5f, 2.5f, 1.0f);
|
||||
|
||||
_newTaskBox.GetComponent<TaskBox>().SetTask(_task);
|
||||
|
||||
return _newTaskBox;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Ignored methods
|
||||
public override void BuildPanelSlots()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public override GameObject BuildSlot(int key, GameObject _parent)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void ClearSlots()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
3
Assets/Scripts/REFACTORING/Domain.meta
Normal file
3
Assets/Scripts/REFACTORING/Domain.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb4d460084b74e059c3d762bc6e13050
|
||||
timeCreated: 1660483299
|
14
Assets/Scripts/REFACTORING/Domain/Enum/EquipmentTypeEnum.cs
Normal file
14
Assets/Scripts/REFACTORING/Domain/Enum/EquipmentTypeEnum.cs
Normal file
@ -0,0 +1,14 @@
|
||||
[System.Serializable]
|
||||
public enum EquipmentTypeEnum
|
||||
{
|
||||
Helmet,
|
||||
Chest,
|
||||
Gloves,
|
||||
Boots,
|
||||
Weapon,
|
||||
Potion,
|
||||
Bracelet,
|
||||
Necklet,
|
||||
Ring,
|
||||
Other
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 583901b64ccc6d3499f1e4f57390255d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
3
Assets/Scripts/REFACTORING/Models/Item.meta
Normal file
3
Assets/Scripts/REFACTORING/Models/Item.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f614b6829bdb4b289e4e097b4fd17a12
|
||||
timeCreated: 1662915893
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8f73a42f83f7964fa1578e1dd5b4d61
|
||||
guid: 1d9b2ee8ca4dff44e879cfe9ea14c175
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@ -2,20 +2,6 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public enum EquipmentType
|
||||
{
|
||||
Helmet,
|
||||
Chest,
|
||||
Gloves,
|
||||
Boots,
|
||||
Weapon,
|
||||
Potion,
|
||||
Bracelet,
|
||||
Necklet,
|
||||
Ring,
|
||||
Other
|
||||
}
|
||||
|
||||
[CreateAssetMenu]
|
||||
[System.Serializable]
|
||||
public class EquippableItem : Item
|
||||
@ -29,13 +15,12 @@ public class EquippableItem : Item
|
||||
public bool isStackable = false;
|
||||
|
||||
[Space]
|
||||
public EquipmentType EquipmentType;
|
||||
public EquipmentTypeEnum EquipmentType;
|
||||
|
||||
public EquippableItem(){}
|
||||
|
||||
public EquippableItem(Item _item) : base(_item){}
|
||||
|
||||
public EquippableItem(string _name, string _description, int _level, GameObject _itemModel, Sprite _image) : base(_name, _description, _level, _itemModel, _image)
|
||||
{
|
||||
}
|
||||
public EquippableItem(string _name, string _description, int _level, GameObject _itemModel, Sprite _image) : base(_name, _description, _level, _itemModel, _image) { }
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 943bb4b7c1123c44fb1cbc048a56a954
|
||||
guid: a0c176e87b3c91641897c23dc27e92a0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@ -16,7 +16,7 @@ public class EquippableItemData : ItemData
|
||||
|
||||
public bool isStackable;
|
||||
|
||||
public EquipmentType equipmentType;
|
||||
public EquipmentTypeEnum equipmentType;
|
||||
|
||||
private const string ITEM_LOCALIZATION = "Assets/Items/";
|
||||
|
||||
@ -47,7 +47,7 @@ public class EquippableItemData : ItemData
|
||||
// equippableItem.InteligenceBonus = inteligenceBonus;
|
||||
// equippableItem.VitalityBonus = vitalityBonus;
|
||||
// equippableItem.isStackable = isStackable;
|
||||
// equippableItem.EquipmentType = equipmentType;
|
||||
// equippableItem.EquipmentTypeEnum = equipmentType;
|
||||
|
||||
// Item item = base.MapDataToItem(prefarbAssetName);
|
||||
// equippableItem.Name = item.Name;
|
@ -0,0 +1,55 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class EquippableItemPrefabAsset : PrefabAssetModel
|
||||
{
|
||||
|
||||
[SerializeField]
|
||||
public EquippableItem EquippableItem = null;
|
||||
|
||||
public EquippableItemPrefabAsset() { }
|
||||
|
||||
public EquippableItemPrefabAsset(string _name, string _prefabAssetName, Vector3 _position, EquippableItem _equippableItem = null)
|
||||
: base(_name, _prefabAssetName, _position)
|
||||
{
|
||||
EquippableItem = _equippableItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="_name"></param>
|
||||
/// <param name="_prefabAssetName"></param>
|
||||
/// <param name="_position"></param>
|
||||
/// <param name="_equippableItemName">the name by which the system will search for the item</param>
|
||||
public EquippableItemPrefabAsset(string _name, string _prefabAssetName, Vector3 _position, string _equippableItemName)
|
||||
: base(_name, _prefabAssetName, _position)
|
||||
{
|
||||
|
||||
// TODO during build product process, objects are not found - refactor this
|
||||
string[] assetNames = AssetDatabase.FindAssets("t:EquippableItem", new[] { "Assets/Items/" });
|
||||
foreach (string SOName in assetNames)
|
||||
{
|
||||
var SoPath = AssetDatabase.GUIDToAssetPath(SOName);
|
||||
|
||||
if(SoPath.Contains(_equippableItemName + ".asset"))
|
||||
{
|
||||
// 3.2 set EquippableItem object
|
||||
EquippableItem = AssetDatabase.LoadAssetAtPath<EquippableItem>(SoPath);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function to convert Prefab Asset model to data object
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public EquippableItemPrefabAssetData MapPrefabAssetModelToData()
|
||||
{
|
||||
return new EquippableItemPrefabAssetData(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b7802014e11d9745a1fb90b31553624
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,45 @@
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class EquippableItemPrefabAssetData : PrefabAssetModelData
|
||||
{
|
||||
EquippableItemData EquippableItemData;
|
||||
|
||||
public EquippableItemPrefabAssetData(EquippableItemPrefabAsset assetModel) : base(assetModel)
|
||||
{
|
||||
EquippableItemData = MapEquippableItemToData(assetModel.EquippableItem);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function to convert equitable item (current object partial variable) object to data format
|
||||
/// </summary>
|
||||
/// <param name="equippableItem"></param>
|
||||
/// <returns></returns>
|
||||
public EquippableItemData MapEquippableItemToData(EquippableItem equippableItem)
|
||||
{
|
||||
return new EquippableItemData(equippableItem);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function to convert EquippableItem Asset format to data format
|
||||
/// </summary>
|
||||
/// <param name="assetModel"></param>
|
||||
/// <returns></returns>
|
||||
public override PrefabAssetModelData PrefabAssetModelToData(PrefabAssetModel assetModel)
|
||||
{
|
||||
return new EquippableItemPrefabAssetData((EquippableItemPrefabAsset)assetModel);
|
||||
}
|
||||
|
||||
public override PrefabAssetModel MapDataToPrefabAssetModel()
|
||||
{
|
||||
EquippableItemPrefabAsset equippableItemPrefabAsset = new EquippableItemPrefabAsset(
|
||||
Name,
|
||||
PrefabAssetName,
|
||||
new Vector3(Position[0], Position[1], Position[2])
|
||||
);
|
||||
|
||||
equippableItemPrefabAsset.EquippableItem = EquippableItemData.MapDataToEquippableItem(equippableItemPrefabAsset.PrefabAssetName);
|
||||
|
||||
return equippableItemPrefabAsset;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 637522de5e9c1604b9edb7a21f660d60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d5bd84ad69269f4e8a3c4ec655119d5
|
||||
guid: 1c6df47a2440e8a49bef89083164fdc1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
8
Assets/Scripts/REFACTORING/Models/Panel.meta
Normal file
8
Assets/Scripts/REFACTORING/Models/Panel.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f794d5910b056443822eaf53a798555
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/REFACTORING/Models/Panel/Slot.meta
Normal file
8
Assets/Scripts/REFACTORING/Models/Panel/Slot.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47f80f9e6ba3c524084bb8d8ad9f30be
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -19,7 +19,7 @@ public interface ISlot
|
||||
event Action<ItemSlot> OnDropEvent;
|
||||
//(B)Islot // as B
|
||||
|
||||
public void SetupSlot(int _number, Item _item, BasePanelController _PanelController);
|
||||
public void SetupSlot(int _number, Item _item, WarehousePanelController _PanelController);
|
||||
public void SetItem(Item _item);
|
||||
bool CanReceiveItem(Item item);
|
||||
}
|
@ -12,7 +12,7 @@ public class ItemSlot : MonoBehaviour, ISlot, IBeginDragHandler, IEndDragHandler
|
||||
[SerializeField] private TextMeshProUGUI slotItemNumberText;
|
||||
[SerializeField] private Image itemImage;
|
||||
|
||||
public BasePanelController _PanelController;
|
||||
public WarehousePanelController _PanelController;
|
||||
|
||||
private Color normalColor = Color.white;
|
||||
private Color disabledColor = new Color(1, 1, 1, 0); // transparency = 0
|
||||
@ -48,7 +48,7 @@ public class ItemSlot : MonoBehaviour, ISlot, IBeginDragHandler, IEndDragHandler
|
||||
public event Action<ItemSlot> OnDragEvent;
|
||||
public event Action<ItemSlot> OnDropEvent;
|
||||
|
||||
public void SetupSlot(int _number, Item _item, BasePanelController _PanelController)
|
||||
public void SetupSlot(int _number, Item _item, WarehousePanelController _PanelController)
|
||||
{
|
||||
this._PanelController = _PanelController;
|
||||
|
||||
@ -71,6 +71,16 @@ public class ItemSlot : MonoBehaviour, ISlot, IBeginDragHandler, IEndDragHandler
|
||||
UpdateItemNumberHolder();
|
||||
}
|
||||
|
||||
public void ResetSlot()
|
||||
{
|
||||
Item = null;
|
||||
|
||||
ChangeEnableImageView(false);
|
||||
|
||||
countStackableItems = 0;
|
||||
|
||||
UpdateItemNumberHolder();
|
||||
}
|
||||
|
||||
private void ChangeEnableImageView(bool _flag)
|
||||
{
|
||||
@ -102,7 +112,9 @@ public class ItemSlot : MonoBehaviour, ISlot, IBeginDragHandler, IEndDragHandler
|
||||
return true;
|
||||
}
|
||||
|
||||
// Events methods
|
||||
|
||||
|
||||
#region Events methods
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
if(OnBeginDragEvent != null)
|
||||
@ -126,4 +138,5 @@ public class ItemSlot : MonoBehaviour, ISlot, IBeginDragHandler, IEndDragHandler
|
||||
if(OnDropEvent != null)
|
||||
OnDropEvent(this);
|
||||
}
|
||||
#endregion
|
||||
}
|
3
Assets/Scripts/REFACTORING/Models/Scene.meta
Normal file
3
Assets/Scripts/REFACTORING/Models/Scene.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08674bb7d06248b8b6174ac07b325ee7
|
||||
timeCreated: 1662917411
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user