-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathInventoryLogic_GridSlot.cs
77 lines (55 loc) · 2.13 KB
/
InventoryLogic_GridSlot.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
#region Header
/* ============================================
* Author : Strix
* Initial Creation Date : 2020-03-31
* Summary :
* Template : For Unity Editor V1
============================================ */
#endregion Header
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
namespace UIFramework
{
/// <summary>
/// 일단 Inventory Slot만
/// 가로 기준으로 구현
/// </summary>
[RequireComponent(typeof(Inventory))]
public class InventoryLogic_GridSlot : UIWidgetObjectBase
{
/* const & readonly declaration */
/* enum & struct declaration */
/* public - Field declaration */
public int iGridSlotCount;
/* protected & private - Field declaration */
List<InventorySlot> _listSlotInstance = new List<InventorySlot>();
Inventory _pInventory;
// ========================================================================== //
/* public - [Do~Something] Function */
// ========================================================================== //
/* protected - [Override & Unity API] */
protected override void OnAwake()
{
base.OnAwake();
_pInventory = GetComponent<Inventory>();
_pInventory.OnEmptySlot += Inventory_OnEmptySlot;
}
/* protected - [abstract & virtual] */
// ========================================================================== //
#region Private
private InventorySlot Inventory_OnEmptySlot(InventorySlot pSlotOrigin)
{
_listSlotInstance.Clear();
Transform pTransform_SlotParents = pSlotOrigin.transform.parent;
for (int i = 0; i < iGridSlotCount; i++)
{
InventorySlot pSlotCopy = GameObject.Instantiate(pSlotOrigin, pTransform_SlotParents);
pSlotCopy.EventAwake();
_listSlotInstance.Add(pSlotCopy);
}
return _listSlotInstance.FirstOrDefault();
}
#endregion Private
}
}