-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathItemsManager.cs
193 lines (164 loc) · 4.73 KB
/
ItemsManager.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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ItemsManager : MonoBehaviour
{
public int currentPotions;
private HealthManager playerHealthManager;
public int hpPointsValue= 5;
private int potionvalue = 150;
public GameObject potionObject;
public int currentEthers;
private MPManager playerMPManager;
public int etherValue = 20;
public GameObject etherObject;
public int currentPhoenixDown;
public GameObject phoenixDownObject;
public Dictionary<string, string> chestsDict = new Dictionary<string, string>();
private void Start()
{
playerHealthManager = GetComponentInParent<HealthManager>();
playerMPManager = GetComponentInParent<MPManager>();
}
public List<GameObject> questItems = new List<GameObject>();
private List<GameObject> regularItems = new List<GameObject>();
public void AddPotions(int potionCollected)
{
currentPotions += potionCollected;
//regularItems.Add(potion);
}
public void UsePotion()
{
if (currentPotions <= 0)
{
currentPotions = 0;
SFXManager.SharedInstance.PlaySFX(SFXType.SoundType.UI_MENU_ERROR);
return;
}
currentPotions--;
playerHealthManager.AddHealthPoints(potionvalue);
SFXManager.SharedInstance.PlaySFX(SFXType.SoundType.USE_ITEM);
if (currentPotions < 0)
{
currentPotions = 0;
}
}
public void AddEthers(int etherCollected)
{
currentEthers += etherCollected;
}
public void UseEther()
{
if(currentEthers <= 0)
{
currentEthers = 0;
SFXManager.SharedInstance.PlaySFX(SFXType.SoundType.UI_MENU_ERROR);
return;
}
currentEthers--;
playerMPManager.AddMPPoints(etherValue);
SFXManager.SharedInstance.PlaySFX(SFXType.SoundType.USE_ITEM);
if (currentEthers < 0)
{
currentEthers = 0;
}
}
public void AddPD(int pd)
{
currentPhoenixDown += pd;
}
public void UsePD()
{
if (currentPhoenixDown <= 0)
{
currentPhoenixDown = 0;
SFXManager.SharedInstance.PlaySFX(SFXType.SoundType.UI_MENU_ERROR);
return;
}
currentPhoenixDown--;
playerHealthManager.AddHealthPoints(75);
SFXManager.SharedInstance.PlaySFX(SFXType.SoundType.USE_ITEM);
if (currentPhoenixDown < 0)
{
currentPhoenixDown = 0;
}
}
public List<GameObject> GetRegularItems()
{
return regularItems;
}
public GameObject GetRegularItemAt(int pos)
{
return regularItems[pos];
}
public void AddHP(int hpvalue)
{
playerHealthManager.AddHealthPoints(hpvalue);
}
public List<GameObject> GetQuestItems()
{
List<GameObject> questItemInInventory = new List<GameObject>();
foreach(GameObject qitem in questItems)
{
if (qitem.GetComponent<QuestItem>().inInventory)
{
questItemInInventory.Add(qitem);
}
}
return questItemInInventory;
}
public List<string> GetQuestItemsByName()
{
List<string> listQI = new List<string>();
foreach(GameObject g in questItems)
{
if (g.GetComponent<QuestItem>().inInventory)
{
listQI.Add(g.GetComponent<QuestItem>().itemName);
}
}
return listQI;
}
public QuestItem GetItemAt(int idx)
{
return questItems[idx].GetComponent<QuestItem>();
}
public bool HasTheQuestItem(QuestItem item)
{
foreach(GameObject qi in questItems)
{
if((qi.GetComponent<QuestItem>().itemName == item.itemName) && qi.GetComponent<QuestItem>().inInventory)
{
return true;
}
}
return false;
}
public void AddQuestItem(string iname)
{
foreach (GameObject qitem in questItems)
{
if (qitem.GetComponent<QuestItem>().itemName == iname)
{
qitem.GetComponent<QuestItem>().inInventory = true;
}
}
}
public void RemoveQuestItems()
{
foreach (GameObject qitem in questItems)
{
qitem.GetComponent<QuestItem>().inInventory = false;
}
}
public void AddQuestItemByName(string itemname)
{
foreach (GameObject item in questItems)
{
if (item.GetComponent<QuestItem>().itemName == itemname)
{
item.GetComponent<QuestItem>().inInventory = true;
}
}
}
}