-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathInventoryExample.cs
110 lines (79 loc) · 3.3 KB
/
InventoryExample.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#region Header
/* ============================================
* Author : Strix
* Initial Creation Date : 2020-01-30
* Summary :
* Template : For Unity Editor V1
============================================ */
#endregion Header
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using UIFramework.InventorySlotLogic;
namespace UIFramework
{
/// <summary>
///
/// </summary>
[RequireComponent(typeof(Inventory))]
public class InventoryExample : MonoBehaviour
{
/* const & readonly declaration */
/* enum & struct declaration */
[System.Serializable]
public class SomthingData : IInventoryData
{
public string strName;
public Sprite pSpriteIcon;
public Color pColor;
public string IInventoryData_Key => strName;
public int IInventoryData_Count => 1;
public IInventoryData IInventoryData_AddOrMinusCount(int iCount)
{
return this;
}
}
/* public - Field declaration */
public List<SomthingData> listSomthingData = new List<SomthingData>();
/* protected & private - Field declaration */
Inventory _pInventory;
// ========================================================================== //
/* public - [Do~Something] Function */
// ========================================================================== //
/* protected - [Override & Unity API] */
private void Awake()
{
_pInventory = GetComponent<Inventory>();
}
private void OnEnable()
{
if(_pInventory.bIsExecute_Awake == false)
_pInventory.EventAwake();
_pInventory.DoClearData();
_pInventory.DoAddRangeData(listSomthingData.ToArray());
InventoryLogicFactory pLogicFactory = new InventoryLogicFactory();
var pLogic = pLogicFactory.DoCreate_LibraryLogic_Command(InventorySlot.EInventorySlot_CommandEvent.OnDragBegin, EInventory_CommandLogicName.Instantiate_CloneSlot, InventorySlot.EInventorySlot_CommandEvent.OnDragEnd);
Instantiate_CloneSlot pInstantiateLogic = pLogic as Instantiate_CloneSlot;
pInstantiateLogic.DoInit((p => p.GetComponent<Image>().enabled = false), null);
_pInventory.DoInit_SlotLogic(pLogicFactory);
_pInventory.OnSwap_Slot += _pInventory_OnSwap_Slot;
_pInventory.OnSwap_Slot_OtherInventory += Inventory_OnSwap_OtherInventory;
}
private void Inventory_OnSwap_OtherInventory(Inventory.OnSwapSlot_Msg obj)
{
if (obj.pSlot_OnDraging.pData == null)
return;
obj.pSlot_OnDraging.DoSwapSlot(obj.pSlot_Dest);
obj.pSlot_OnDraging.Event_SetSelected(false, false);
}
private void _pInventory_OnSwap_Slot(InventorySlot pStart, InventorySlot pDest)
{
pStart.DoSwapSlot(pDest);
}
/* protected - [abstract & virtual] */
// ========================================================================== //
#region Private
#endregion Private
}
}