質問編集履歴
3
短くなったので再投稿(エラーが起きてるのでまだまだです)
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
using System.Collections;
|
17
17
|
using System.Collections.Generic;
|
18
18
|
using static System.Collections.IEnumerable;
|
19
|
+
using System;
|
19
20
|
using System.Linq;
|
20
21
|
using UnityEngine;
|
21
22
|
using UnityEngine.UI;
|
@@ -23,9 +24,8 @@
|
|
23
24
|
|
24
25
|
public class InventoryManagement : MonoBehaviour
|
25
26
|
{
|
26
|
-
public
|
27
|
+
public ItemInInventory[] skill_inventory = new ItemInInventory[6];
|
27
|
-
public
|
28
|
+
public ItemInInventory[] item_inventory = new ItemInInventory[16];
|
28
|
-
//今からこの配列を複雑構造にする
|
29
29
|
|
30
30
|
public ItemDataBase database;
|
31
31
|
public Category item_category;
|
@@ -35,20 +35,18 @@
|
|
35
35
|
public GameObject text;
|
36
36
|
private TextMeshProUGUI _text;
|
37
37
|
|
38
|
-
public List<ItemInInventory> skill_list = new List<ItemInInventory>();
|
39
|
-
public List<ItemInInventory> item_list = new List<ItemInInventory>();
|
40
|
-
|
41
38
|
public struct ItemInInventory
|
42
39
|
{
|
43
|
-
string id;
|
40
|
+
public string id;
|
44
|
-
string type;
|
41
|
+
public string type;
|
45
|
-
int cooldown;
|
42
|
+
public int cooldown;
|
46
|
-
int ability_haste;
|
43
|
+
public int ability_haste;
|
47
|
-
int arm_power;
|
44
|
+
public int arm_power;
|
48
|
-
int absolute_dig;
|
45
|
+
public int absolute_dig;
|
49
|
-
float ratio_dig;
|
46
|
+
public float ratio_dig;
|
50
|
-
int money_invested;
|
47
|
+
public int money_invested;
|
51
|
-
bool availability;
|
48
|
+
public bool availability;
|
49
|
+
|
52
50
|
public ItemInInventory(string id,string type, int cooldown, int ability_haste, int arm_power, int absolute_dig, float ratio_dig, int money_invested, bool availability)
|
53
51
|
{
|
54
52
|
this.id = id;
|
@@ -90,17 +88,17 @@
|
|
90
88
|
AssignImageFromArray(skill_inventory);
|
91
89
|
}
|
92
90
|
|
93
|
-
private void AssignImageFromArray(
|
91
|
+
private void AssignImageFromArray(ItemInInventory[] array)
|
94
92
|
{
|
95
93
|
var i = 0;
|
96
|
-
foreach(
|
94
|
+
foreach(ItemInInventory item in array)
|
97
95
|
{
|
98
96
|
if(item_iconBox[i] != null)//まだiconBoxの割り当てが済んでいないため あとでやる(やらないパターン)
|
99
97
|
{
|
100
|
-
if(id != "")
|
98
|
+
if(item.id != "")
|
101
99
|
{
|
102
|
-
if(array.Length == 6){skill_iconBox[i].GetComponent<Image>().sprite = SearchItemFromID(id).item_image;}//parameterの配列がskillかitem由来か確認
|
100
|
+
if(array.Length == 6){skill_iconBox[i].GetComponent<Image>().sprite = SearchItemFromID(item.id).item_image;}//parameterの配列がskillかitem由来か確認
|
103
|
-
else{item_iconBox[i].GetComponent<Image>().sprite = SearchItemFromID(id).item_image;}
|
101
|
+
else{item_iconBox[i].GetComponent<Image>().sprite = SearchItemFromID(item.id).item_image;}
|
104
102
|
}
|
105
103
|
else
|
106
104
|
{
|
@@ -118,11 +116,11 @@
|
|
118
116
|
Item selected_item;
|
119
117
|
if(i >= 6)
|
120
118
|
{
|
121
|
-
selected_item = SearchItemFromID(item_inventory[i-6]);
|
119
|
+
selected_item = SearchItemFromID(item_inventory[i-6].id);
|
122
120
|
}
|
123
121
|
else
|
124
122
|
{
|
125
|
-
selected_item = SearchItemFromID(skill_inventory[i]);
|
123
|
+
selected_item = SearchItemFromID(skill_inventory[i].id);
|
126
124
|
}
|
127
125
|
if(selected_item!=null)
|
128
126
|
{
|
@@ -194,54 +192,21 @@
|
|
194
192
|
|
195
193
|
public void AddNewItems(string newID)
|
196
194
|
{
|
197
|
-
List<ItemInInventory> list;
|
195
|
+
//List<ItemInInventory> list;
|
198
|
-
|
196
|
+
ItemInInventory[] array;
|
197
|
+
|
199
|
-
if(SearchItemFromID(newID).type.ToString() == "Skill"){
|
198
|
+
if(SearchItemFromID(newID).type.ToString() == "Skill"){array = skill_inventory;}
|
200
|
-
else{
|
199
|
+
else{array = item_inventory;}
|
201
|
-
|
200
|
+
|
202
|
-
i
|
201
|
+
int index = Array.IndexOf(array, null);
|
203
|
-
|
202
|
+
if (index >= 0) array[index] = ConvertIDintoStructedItem(newID);
|
204
203
|
|
205
204
|
DisplayItems();
|
206
205
|
}
|
207
206
|
|
208
|
-
/*
|
209
|
-
public void AddItems(string newID)
|
210
|
-
{
|
211
|
-
bool _ifSkill;
|
212
|
-
string[] inventory;
|
213
|
-
var i = 0;
|
214
|
-
|
215
|
-
if(SearchItemFromID(newID).type.ToString() == "Skill")
|
216
|
-
{
|
217
|
-
_ifSkill = true;
|
218
|
-
inventory = skill_inventory;
|
219
|
-
}
|
220
|
-
else
|
221
|
-
{
|
222
|
-
_ifSkill = false;
|
223
|
-
inventory = item_inventory;
|
224
|
-
}
|
225
|
-
|
226
|
-
foreach(string id in inventory)
|
227
|
-
{
|
228
|
-
if(id == "")
|
229
|
-
{
|
230
|
-
break;
|
231
|
-
}
|
232
|
-
i++;
|
233
|
-
}
|
234
|
-
|
235
|
-
if(_ifSkill){skill_inventory[i] = newID;}
|
236
|
-
else{item_inventory[i] = newID;}
|
237
|
-
|
238
|
-
DisplayItems();
|
239
|
-
}
|
240
|
-
*/
|
241
|
-
|
242
207
|
public void ItemUsed(int i, GameObject icon)
|
243
208
|
{
|
244
|
-
Item selected_item = SearchItemFromID(item_inventory[i]);
|
209
|
+
Item selected_item = SearchItemFromID(item_inventory[i].id);
|
245
210
|
|
246
211
|
if(selected_item.type.ToString()=="Reusable")
|
247
212
|
{
|
@@ -251,7 +216,7 @@
|
|
251
216
|
|
252
217
|
public void SkillUsed(int i, GameObject icon)
|
253
218
|
{
|
254
|
-
Debug.Log(SearchItemFromID(skill_inventory[i]).item_name);
|
219
|
+
Debug.Log(SearchItemFromID(skill_inventory[i].id).item_name);
|
255
220
|
//ここに効果発動させるコマンドと、周りを光の尾で照らすコマンドをかく
|
256
221
|
}
|
257
222
|
|
@@ -268,43 +233,12 @@
|
|
268
233
|
}
|
269
234
|
}
|
270
235
|
|
271
|
-
return null;
|
236
|
+
return null;
|
272
237
|
|
273
238
|
}
|
274
239
|
|
275
240
|
}
|
276
241
|
|
277
|
-
//class ItemInInventory : MonoBehaviour
|
278
|
-
struct ItemInInventory
|
279
|
-
{
|
280
|
-
string id;
|
281
|
-
string type;
|
282
|
-
int cooldown;//
|
283
|
-
int ability_haste;
|
284
|
-
int arm_power;
|
285
|
-
int absolute_dig;
|
286
|
-
float ratio_dig;
|
287
|
-
int money_invested;//
|
288
|
-
//これの必要の有無をどう設定したらいいかわからん もし二つ兼ね備えるのが来たらどうする
|
289
|
-
//結論 アイテム側の数値も増やす!
|
290
|
-
//もし値が0じゃなかったらnullじゃないってしよかー!結論:できない、、処理側で0じゃなかったら作動するようにしよか(めんどい!)
|
291
|
-
//まあこれは値格納するためだけの存在やから...(KONAMI)
|
292
|
-
|
293
|
-
/*
|
294
|
-
ItemInInventory(Item item)
|
295
|
-
{
|
296
|
-
this.id = item.item_id;
|
297
|
-
this.type = item.type.ToString();
|
298
|
-
this.cooldown = item.cooldown;
|
299
|
-
this.ability_haste = item.ability_haste;
|
300
|
-
this.arm_power = item.arm_power;
|
301
|
-
this.absolute_dig = item.absolute_dig;
|
302
|
-
this.ratio_dig = item.ratio_dig;
|
303
|
-
this.money_invested = item.money_invested;
|
304
|
-
}
|
305
|
-
*/
|
306
|
-
|
307
|
-
}
|
308
242
|
|
309
243
|
```
|
310
244
|
|
2
コード変えました(途中けいか)
test
CHANGED
File without changes
|
test
CHANGED
@@ -15,6 +15,8 @@
|
|
15
15
|
```c#
|
16
16
|
using System.Collections;
|
17
17
|
using System.Collections.Generic;
|
18
|
+
using static System.Collections.IEnumerable;
|
19
|
+
using System.Linq;
|
18
20
|
using UnityEngine;
|
19
21
|
using UnityEngine.UI;
|
20
22
|
using TMPro;
|
@@ -23,56 +25,92 @@
|
|
23
25
|
{
|
24
26
|
public string[] skill_inventory = new string[6];
|
25
27
|
public string[] item_inventory = new string[16];
|
28
|
+
//今からこの配列を複雑構造にする
|
26
29
|
|
27
30
|
public ItemDataBase database;
|
31
|
+
public Category item_category;
|
28
32
|
|
29
33
|
public GameObject[] skill_iconBox = new GameObject[6];
|
30
34
|
public GameObject[] item_iconBox = new GameObject[16];
|
31
35
|
public GameObject text;
|
32
36
|
private TextMeshProUGUI _text;
|
33
37
|
|
38
|
+
public List<ItemInInventory> skill_list = new List<ItemInInventory>();
|
39
|
+
public List<ItemInInventory> item_list = new List<ItemInInventory>();
|
40
|
+
|
41
|
+
public struct ItemInInventory
|
42
|
+
{
|
43
|
+
string id;
|
44
|
+
string type;
|
45
|
+
int cooldown;
|
46
|
+
int ability_haste;
|
47
|
+
int arm_power;
|
48
|
+
int absolute_dig;
|
49
|
+
float ratio_dig;
|
50
|
+
int money_invested;
|
51
|
+
bool availability;
|
52
|
+
public ItemInInventory(string id,string type, int cooldown, int ability_haste, int arm_power, int absolute_dig, float ratio_dig, int money_invested, bool availability)
|
53
|
+
{
|
54
|
+
this.id = id;
|
55
|
+
this.type = type;
|
56
|
+
this.cooldown = cooldown;
|
57
|
+
this.ability_haste = ability_haste;
|
58
|
+
this.arm_power = arm_power;
|
59
|
+
this.absolute_dig = absolute_dig;
|
60
|
+
this.ratio_dig = ratio_dig;
|
61
|
+
this.money_invested = money_invested;
|
62
|
+
this.availability = availability;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
34
66
|
void Start()
|
35
67
|
{
|
36
68
|
_text = text.GetComponent<TextMeshProUGUI>();
|
37
69
|
DisplayItems();
|
70
|
+
DebugCheck();
|
71
|
+
}
|
72
|
+
|
73
|
+
private void DebugCheck()
|
74
|
+
{
|
75
|
+
AddNewItems("pickaxe_diamond_1");
|
76
|
+
AddNewItems("pickaxe_wood_1");
|
77
|
+
AddNewItems("runner");
|
78
|
+
}
|
79
|
+
|
80
|
+
private ItemInInventory ConvertIDintoStructedItem(string newID)
|
81
|
+
{
|
82
|
+
string id = newID;
|
83
|
+
Item item = SearchItemFromID(id);
|
84
|
+
return new ItemInInventory(id,item.type.ToString(),item.cooldown,item.ability_haste,item.arm_power,item.absolute_dig,item.ratio_dig,item.money_invested,true);
|
38
85
|
}
|
39
86
|
|
40
87
|
public void DisplayItems()
|
41
88
|
{
|
89
|
+
AssignImageFromArray(item_inventory);
|
90
|
+
AssignImageFromArray(skill_inventory);
|
91
|
+
}
|
92
|
+
|
93
|
+
private void AssignImageFromArray(string[] array)
|
94
|
+
{
|
42
95
|
var i = 0;
|
43
|
-
foreach(string id in
|
96
|
+
foreach(string id in array)
|
44
97
|
{
|
45
98
|
if(item_iconBox[i] != null)//まだiconBoxの割り当てが済んでいないため あとでやる(やらないパターン)
|
46
99
|
{
|
47
100
|
if(id != "")
|
48
101
|
{
|
102
|
+
if(array.Length == 6){skill_iconBox[i].GetComponent<Image>().sprite = SearchItemFromID(id).item_image;}//parameterの配列がskillかitem由来か確認
|
49
|
-
item_iconBox[i].GetComponent<Image>().sprite = SearchItemFromID(id).item_image;
|
103
|
+
else{item_iconBox[i].GetComponent<Image>().sprite = SearchItemFromID(id).item_image;}
|
50
104
|
}
|
51
105
|
else
|
52
106
|
{
|
107
|
+
if(array.Length == 6){skill_iconBox[i].GetComponent<Image>().sprite = null;}
|
53
|
-
item_iconBox[i].GetComponent<Image>().sprite = null;
|
108
|
+
else{item_iconBox[i].GetComponent<Image>().sprite = null;}
|
54
109
|
|
55
110
|
}
|
56
111
|
}
|
57
112
|
i++;
|
58
113
|
}
|
59
|
-
i = 0;
|
60
|
-
foreach(string id in skill_inventory)
|
61
|
-
{
|
62
|
-
if(skill_iconBox[i] != null)//まだiconBoxの割り当てが済んでいないため あとでやる(やらないパターン)
|
63
|
-
{
|
64
|
-
if(id != "")
|
65
|
-
{
|
66
|
-
skill_iconBox[i].GetComponent<Image>().sprite = SearchItemFromID(id).item_image;
|
67
|
-
}
|
68
|
-
else
|
69
|
-
{
|
70
|
-
skill_iconBox[i].GetComponent<Image>().sprite = null;
|
71
|
-
|
72
|
-
}
|
73
|
-
}
|
74
|
-
i++;
|
75
|
-
}
|
76
114
|
}
|
77
115
|
|
78
116
|
public void DisplayItemDescription(int i)
|
@@ -88,53 +126,118 @@
|
|
88
126
|
}
|
89
127
|
if(selected_item!=null)
|
90
128
|
{
|
91
|
-
|
129
|
+
_text.text = GenerateText(selected_item,"others");
|
92
|
-
_text.text = "<size=20>"+ selected_item.item_name +"</size>"+"\n\n <size=16>"+selected_item.information+"</size>";
|
93
|
-
}
|
130
|
+
}
|
94
|
-
|
131
|
+
|
95
|
-
}
|
132
|
+
}
|
133
|
+
|
134
|
+
private string GenerateText(Item item, string _availability)
|
135
|
+
{
|
136
|
+
string name; string text_parameter; string num_parameter; string type; string item_info;
|
137
|
+
|
138
|
+
name = "<size=20>" + item.item_name + "</size>";
|
139
|
+
|
140
|
+
text_parameter = "<size=16>" + SearchCategoryFromItem(item,"text") + "</size>";
|
141
|
+
|
142
|
+
num_parameter = "";
|
143
|
+
|
144
|
+
type = "";
|
145
|
+
|
146
|
+
if(_availability == "others")
|
147
|
+
{
|
148
|
+
type = "<size=16>" + item.type.ToString() + "</size>";
|
149
|
+
}
|
150
|
+
else if(_availability == "true")
|
151
|
+
{
|
152
|
+
type = "<size=16>" + "Available" + "</size>";
|
153
|
+
}
|
154
|
+
else if(_availability == "false")
|
155
|
+
{
|
156
|
+
type = "<size=16>" + "Unavailable" + "</size>";
|
157
|
+
}
|
158
|
+
|
159
|
+
item_info = "<size=10> \n" + item.information + "</size>";
|
160
|
+
|
161
|
+
|
162
|
+
return name + text_parameter + num_parameter + type + item_info;
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
private string SearchCategoryFromItem(Item item,string purpose)
|
167
|
+
{
|
168
|
+
if(purpose == "text")
|
169
|
+
{
|
170
|
+
if(item_category.Diggable.Contains(item))
|
171
|
+
{
|
172
|
+
return "Diggable:";
|
173
|
+
}
|
174
|
+
else if(item_category.Investable.Contains(item))
|
175
|
+
{
|
176
|
+
return "Investable:";
|
177
|
+
}
|
178
|
+
}
|
179
|
+
else if(purpose == "unit")
|
180
|
+
{
|
181
|
+
if(item_category.Unit_KiloTon.Contains(item))
|
182
|
+
{
|
183
|
+
return "kt";
|
184
|
+
}
|
185
|
+
}
|
186
|
+
|
187
|
+
return "";
|
188
|
+
}
|
189
|
+
|
96
190
|
public void ResetText()
|
97
191
|
{
|
98
192
|
|
99
193
|
}
|
100
194
|
|
101
|
-
public void Item
|
195
|
+
public void AddNewItems(string newID)
|
102
|
-
{
|
196
|
+
{
|
197
|
+
List<ItemInInventory> list;
|
198
|
+
|
199
|
+
if(SearchItemFromID(newID).type.ToString() == "Skill"){list = skill_list;}
|
200
|
+
else{list = item_list;}
|
201
|
+
|
202
|
+
if(list.Count<=6 || (list.Count<=16 && SearchItemFromID(newID).type.ToString() != "Skill"))
|
203
|
+
list.Add(ConvertIDintoStructedItem(newID));
|
204
|
+
|
205
|
+
DisplayItems();
|
206
|
+
}
|
207
|
+
|
208
|
+
/*
|
209
|
+
public void AddItems(string newID)
|
210
|
+
{
|
211
|
+
bool _ifSkill;
|
212
|
+
string[] inventory;
|
103
213
|
var i = 0;
|
214
|
+
|
215
|
+
if(SearchItemFromID(newID).type.ToString() == "Skill")
|
216
|
+
{
|
217
|
+
_ifSkill = true;
|
218
|
+
inventory = skill_inventory;
|
219
|
+
}
|
220
|
+
else
|
221
|
+
{
|
222
|
+
_ifSkill = false;
|
223
|
+
inventory = item_inventory;
|
224
|
+
}
|
225
|
+
|
104
|
-
foreach(string id in i
|
226
|
+
foreach(string id in inventory)
|
105
227
|
{
|
106
228
|
if(id == "")
|
107
229
|
{
|
108
|
-
item_inventory[i] = newItemID;
|
109
230
|
break;
|
110
231
|
}
|
111
|
-
else
|
112
|
-
{
|
113
|
-
|
232
|
+
i++;
|
114
|
-
continue;
|
115
|
-
|
233
|
+
}
|
234
|
+
|
235
|
+
if(_ifSkill){skill_inventory[i] = newID;}
|
116
|
-
}
|
236
|
+
else{item_inventory[i] = newID;}
|
237
|
+
|
117
238
|
DisplayItems();
|
118
239
|
}
|
119
|
-
|
120
|
-
public void SkillAdded(string newSkillID)
|
121
|
-
{
|
122
|
-
var i = 0;
|
123
|
-
foreach(string id in skill_inventory)
|
124
|
-
{
|
125
|
-
if(id == "")
|
126
|
-
{
|
127
|
-
skill_inventory[i] = newSkillID;
|
128
|
-
|
240
|
+
*/
|
129
|
-
}
|
130
|
-
else
|
131
|
-
{
|
132
|
-
i++;
|
133
|
-
continue;
|
134
|
-
}
|
135
|
-
}
|
136
|
-
DisplayItems();
|
137
|
-
}
|
138
241
|
|
139
242
|
public void ItemUsed(int i, GameObject icon)
|
140
243
|
{
|
@@ -144,7 +247,6 @@
|
|
144
247
|
{
|
145
248
|
icon.GetComponent<Image>().color = new Color32(58,58,58,255);
|
146
249
|
}
|
147
|
-
|
148
250
|
}
|
149
251
|
|
150
252
|
public void SkillUsed(int i, GameObject icon)
|
@@ -172,5 +274,37 @@
|
|
172
274
|
|
173
275
|
}
|
174
276
|
|
277
|
+
//class ItemInInventory : MonoBehaviour
|
278
|
+
struct ItemInInventory
|
279
|
+
{
|
280
|
+
string id;
|
281
|
+
string type;
|
282
|
+
int cooldown;//
|
283
|
+
int ability_haste;
|
284
|
+
int arm_power;
|
285
|
+
int absolute_dig;
|
286
|
+
float ratio_dig;
|
287
|
+
int money_invested;//
|
288
|
+
//これの必要の有無をどう設定したらいいかわからん もし二つ兼ね備えるのが来たらどうする
|
289
|
+
//結論 アイテム側の数値も増やす!
|
290
|
+
//もし値が0じゃなかったらnullじゃないってしよかー!結論:できない、、処理側で0じゃなかったら作動するようにしよか(めんどい!)
|
291
|
+
//まあこれは値格納するためだけの存在やから...(KONAMI)
|
292
|
+
|
293
|
+
/*
|
294
|
+
ItemInInventory(Item item)
|
295
|
+
{
|
296
|
+
this.id = item.item_id;
|
297
|
+
this.type = item.type.ToString();
|
298
|
+
this.cooldown = item.cooldown;
|
299
|
+
this.ability_haste = item.ability_haste;
|
300
|
+
this.arm_power = item.arm_power;
|
301
|
+
this.absolute_dig = item.absolute_dig;
|
302
|
+
this.ratio_dig = item.ratio_dig;
|
303
|
+
this.money_invested = item.money_invested;
|
304
|
+
}
|
305
|
+
*/
|
306
|
+
|
307
|
+
}
|
308
|
+
|
175
309
|
```
|
176
310
|
|
1
コードそのままコピペしました
test
CHANGED
File without changes
|
test
CHANGED
@@ -9,3 +9,168 @@
|
|
9
9
|
皆さんの意見を聞かせてください
|
10
10
|
|
11
11
|
|
12
|
+
### 今のコード
|
13
|
+
|
14
|
+
行数の多さが今気になってます。
|
15
|
+
```c#
|
16
|
+
using System.Collections;
|
17
|
+
using System.Collections.Generic;
|
18
|
+
using UnityEngine;
|
19
|
+
using UnityEngine.UI;
|
20
|
+
using TMPro;
|
21
|
+
|
22
|
+
public class InventoryManagement : MonoBehaviour
|
23
|
+
{
|
24
|
+
public string[] skill_inventory = new string[6];
|
25
|
+
public string[] item_inventory = new string[16];
|
26
|
+
|
27
|
+
public ItemDataBase database;
|
28
|
+
|
29
|
+
public GameObject[] skill_iconBox = new GameObject[6];
|
30
|
+
public GameObject[] item_iconBox = new GameObject[16];
|
31
|
+
public GameObject text;
|
32
|
+
private TextMeshProUGUI _text;
|
33
|
+
|
34
|
+
void Start()
|
35
|
+
{
|
36
|
+
_text = text.GetComponent<TextMeshProUGUI>();
|
37
|
+
DisplayItems();
|
38
|
+
}
|
39
|
+
|
40
|
+
public void DisplayItems()
|
41
|
+
{
|
42
|
+
var i = 0;
|
43
|
+
foreach(string id in item_inventory)
|
44
|
+
{
|
45
|
+
if(item_iconBox[i] != null)//まだiconBoxの割り当てが済んでいないため あとでやる(やらないパターン)
|
46
|
+
{
|
47
|
+
if(id != "")
|
48
|
+
{
|
49
|
+
item_iconBox[i].GetComponent<Image>().sprite = SearchItemFromID(id).item_image;
|
50
|
+
}
|
51
|
+
else
|
52
|
+
{
|
53
|
+
item_iconBox[i].GetComponent<Image>().sprite = null;
|
54
|
+
|
55
|
+
}
|
56
|
+
}
|
57
|
+
i++;
|
58
|
+
}
|
59
|
+
i = 0;
|
60
|
+
foreach(string id in skill_inventory)
|
61
|
+
{
|
62
|
+
if(skill_iconBox[i] != null)//まだiconBoxの割り当てが済んでいないため あとでやる(やらないパターン)
|
63
|
+
{
|
64
|
+
if(id != "")
|
65
|
+
{
|
66
|
+
skill_iconBox[i].GetComponent<Image>().sprite = SearchItemFromID(id).item_image;
|
67
|
+
}
|
68
|
+
else
|
69
|
+
{
|
70
|
+
skill_iconBox[i].GetComponent<Image>().sprite = null;
|
71
|
+
|
72
|
+
}
|
73
|
+
}
|
74
|
+
i++;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
public void DisplayItemDescription(int i)
|
79
|
+
{
|
80
|
+
Item selected_item;
|
81
|
+
if(i >= 6)
|
82
|
+
{
|
83
|
+
selected_item = SearchItemFromID(item_inventory[i-6]);
|
84
|
+
}
|
85
|
+
else
|
86
|
+
{
|
87
|
+
selected_item = SearchItemFromID(skill_inventory[i]);
|
88
|
+
}
|
89
|
+
if(selected_item!=null)
|
90
|
+
{
|
91
|
+
//_text.text = selected_item.item_name;
|
92
|
+
_text.text = "<size=20>"+ selected_item.item_name +"</size>"+"\n\n <size=16>"+selected_item.information+"</size>";
|
93
|
+
}
|
94
|
+
|
95
|
+
}
|
96
|
+
public void ResetText()
|
97
|
+
{
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
public void ItemAdded(string newItemID)
|
102
|
+
{
|
103
|
+
var i = 0;
|
104
|
+
foreach(string id in item_inventory)
|
105
|
+
{
|
106
|
+
if(id == "")
|
107
|
+
{
|
108
|
+
item_inventory[i] = newItemID;
|
109
|
+
break;
|
110
|
+
}
|
111
|
+
else
|
112
|
+
{
|
113
|
+
i++;
|
114
|
+
continue;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
DisplayItems();
|
118
|
+
}
|
119
|
+
|
120
|
+
public void SkillAdded(string newSkillID)
|
121
|
+
{
|
122
|
+
var i = 0;
|
123
|
+
foreach(string id in skill_inventory)
|
124
|
+
{
|
125
|
+
if(id == "")
|
126
|
+
{
|
127
|
+
skill_inventory[i] = newSkillID;
|
128
|
+
break;
|
129
|
+
}
|
130
|
+
else
|
131
|
+
{
|
132
|
+
i++;
|
133
|
+
continue;
|
134
|
+
}
|
135
|
+
}
|
136
|
+
DisplayItems();
|
137
|
+
}
|
138
|
+
|
139
|
+
public void ItemUsed(int i, GameObject icon)
|
140
|
+
{
|
141
|
+
Item selected_item = SearchItemFromID(item_inventory[i]);
|
142
|
+
|
143
|
+
if(selected_item.type.ToString()=="Reusable")
|
144
|
+
{
|
145
|
+
icon.GetComponent<Image>().color = new Color32(58,58,58,255);
|
146
|
+
}
|
147
|
+
|
148
|
+
}
|
149
|
+
|
150
|
+
public void SkillUsed(int i, GameObject icon)
|
151
|
+
{
|
152
|
+
Debug.Log(SearchItemFromID(skill_inventory[i]).item_name);
|
153
|
+
//ここに効果発動させるコマンドと、周りを光の尾で照らすコマンドをかく
|
154
|
+
}
|
155
|
+
|
156
|
+
private Item SearchItemFromID(string given_ID)
|
157
|
+
{
|
158
|
+
Item selected_item;
|
159
|
+
|
160
|
+
foreach(Item item in database.items)
|
161
|
+
{
|
162
|
+
if(item.item_id == given_ID)
|
163
|
+
{
|
164
|
+
selected_item = item;
|
165
|
+
return selected_item;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
|
169
|
+
return null; //if matched id isnt found
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
```
|
176
|
+
|