blob: 9e0fffb79b5a7bc86a9f35e8c85b0349be4fe92b (
plain)
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
using UnityEngine;
public class CharacterCreatorButtonSpawner : MonoBehaviour
{
public GameObject sourceButton;
private CharacterCreatorItemLoader loader;
private CharacterCreator creator;
private void Start()
{
creator = GetComponent<CharacterCreator>();
loader = CharacterCreatorItemLoader.instance;
OpenMenu(CharacterItemType.Eyes, 0);
}
public void OpenMenu(int id)
{
if (id == 0)
{
OpenMenu(CharacterItemType.Eyes, 0);
}
if (id == 1)
{
OpenMenu(CharacterItemType.Mouth, 0);
}
if (id == 2)
{
OpenMenu(CharacterItemType.Detail, 0);
}
if (id == 3)
{
OpenMenu(CharacterItemType.Detail, 1);
}
}
public void OpenMenu(CharacterItemType target, int slotNr)
{
CharacterItem[] array = null;
if (target == CharacterItemType.Eyes)
{
array = loader.eyes;
}
if (target == CharacterItemType.Mouth)
{
array = loader.mouths;
}
if (target == CharacterItemType.Detail)
{
array = loader.accessories;
}
for (int i = 0; i < sourceButton.transform.parent.childCount; i++)
{
if (sourceButton.transform.parent.GetChild(i).gameObject.activeSelf)
{
Object.Destroy(sourceButton.transform.parent.GetChild(i).gameObject);
}
}
for (int j = 0; j < array.Length; j++)
{
GameObject gameObject = Object.Instantiate(sourceButton, sourceButton.transform.parent);
gameObject.SetActive(value: true);
Transform parent = gameObject.transform.Find("ItemParent");
GameObject gameObject2 = Object.Instantiate(array[j].gameObject, parent);
gameObject.GetComponent<CharacterItemButton>().itemType = target;
gameObject.GetComponent<CharacterItemButton>().slotNr = slotNr;
gameObject.GetComponentInChildren<CharacterItem>().sprite = array[j].gameObject.GetComponent<SpriteRenderer>().sprite;
gameObject2.GetComponentInChildren<CharacterItem>().GetComponent<SpriteRenderer>().sortingOrder = array[j].gameObject.GetComponent<SpriteRenderer>().sortingOrder;
gameObject2.GetComponentInChildren<CharacterItem>().scale = array[j].scale;
gameObject2.GetComponentInChildren<CharacterItem>().itemType = target;
gameObject2.GetComponentInChildren<CharacterItem>().offset = array[j].offset;
gameObject2.GetComponentInChildren<CharacterItem>().slotNr = slotNr;
gameObject2.GetComponentInChildren<SpriteRenderer>().transform.localPosition = array[j].offset;
gameObject2.GetComponentInChildren<SpriteRenderer>().transform.localScale = array[j].scale * Vector2.one;
if (target == CharacterItemType.Eyes && j == creator.currentPlayerFace.eyeID)
{
gameObject.transform.Find("SelectedDot").gameObject.SetActive(value: true);
}
if (target == CharacterItemType.Mouth && j == creator.currentPlayerFace.mouthID)
{
gameObject.transform.Find("SelectedDot").gameObject.SetActive(value: true);
}
if (target == CharacterItemType.Detail && j == creator.currentPlayerFace.detailID && slotNr == 0)
{
gameObject.transform.Find("SelectedDot").gameObject.SetActive(value: true);
}
if (target == CharacterItemType.Detail && slotNr == 1 && j == creator.currentPlayerFace.detail2ID)
{
gameObject.transform.Find("SelectedDot").gameObject.SetActive(value: true);
}
}
}
public void SelectButton(CharacterItemType itemType, int slotNr)
{
for (int i = 0; i < sourceButton.transform.parent.childCount; i++)
{
GameObject gameObject = sourceButton.transform.parent.GetChild(i).gameObject;
if (itemType == CharacterItemType.Eyes)
{
if (i - 1 == creator.currentPlayerFace.eyeID)
{
gameObject.transform.Find("SelectedDot").gameObject.SetActive(value: true);
}
else
{
gameObject.transform.Find("SelectedDot").gameObject.SetActive(value: false);
}
}
if (itemType == CharacterItemType.Mouth)
{
if (i - 1 == creator.currentPlayerFace.mouthID)
{
gameObject.transform.Find("SelectedDot").gameObject.SetActive(value: true);
}
else
{
gameObject.transform.Find("SelectedDot").gameObject.SetActive(value: false);
}
}
if (itemType == CharacterItemType.Detail)
{
if (i - 1 == creator.currentPlayerFace.detailID && slotNr == 0)
{
gameObject.transform.Find("SelectedDot").gameObject.SetActive(value: true);
}
else
{
gameObject.transform.Find("SelectedDot").gameObject.SetActive(value: false);
}
}
if (itemType == CharacterItemType.Detail && slotNr == 1)
{
if (i - 1 == creator.currentPlayerFace.detail2ID)
{
gameObject.transform.Find("SelectedDot").gameObject.SetActive(value: true);
}
else
{
gameObject.transform.Find("SelectedDot").gameObject.SetActive(value: false);
}
}
}
}
}
|