-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSlotSectorScript.cs
89 lines (82 loc) · 2.82 KB
/
SlotSectorScript.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
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class SlotSectorScript : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler {
public GameObject slotParent;
public int QuadNum;
public static IntVector2 posOffset;
public static SlotSectorScript sectorScript;
private InvenGridManager invenGridManager;
private SlotScript parentSlotScript;
private void Start()
{
invenGridManager = this.gameObject.transform.parent.parent.GetComponent<InvenGridManager>();
parentSlotScript = slotParent.GetComponent<SlotScript>();
}
public void OnPointerEnter(PointerEventData eventData)
{
sectorScript = this;
PosOffset();
if (invenGridManager.highlightedSlot != slotParent)
{
invenGridManager.highlightedSlot = slotParent;
}
if (ItemScript.selectedItem != null)
{
invenGridManager.RefrechColor(true);
}
if (parentSlotScript.storedItem != null && ItemScript.selectedItem == null)
{
invenGridManager.ColorChangeLoop(ColorHighlights.Blue, parentSlotScript.storedItemSize, parentSlotScript.storedItemStartPos);
}
}
public void PosOffset()
{
if (ItemScript.selectedItemSize.x != 0 && ItemScript.selectedItemSize.x % 2 == 0)
{
switch (QuadNum)
{
case 1:
posOffset.x = 0; break;
case 2:
posOffset.x = -1; break;
case 3:
posOffset.x = 0; break;
case 4:
posOffset.x = -1; break;
default: break;
}
}
if (ItemScript.selectedItemSize.y != 0 && ItemScript.selectedItemSize.y % 2 == 0)
{
switch (QuadNum)
{
case 1:
posOffset.y = -1; break;
case 2:
posOffset.y = -1; break;
case 3:
posOffset.y = 0; break;
case 4:
posOffset.y = 0; break;
default: break;
}
}
}
public void OnPointerExit(PointerEventData eventData)
{
sectorScript = null;
invenGridManager.highlightedSlot = null;
if (ItemScript.selectedItem != null)
{
invenGridManager.RefrechColor(false);
}
posOffset = IntVector2.Zero;
if (parentSlotScript.storedItem != null && ItemScript.selectedItem == null)
{
invenGridManager.ColorChangeLoop(Color.white, parentSlotScript.storedItemSize, parentSlotScript.storedItemStartPos);
}
}
}