-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoolManager.cs
More file actions
246 lines (202 loc) · 5.1 KB
/
PoolManager.cs
File metadata and controls
246 lines (202 loc) · 5.1 KB
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//Class to pool and reuse effects and other frequently initialized resources
public class PoolManager : MonoBehaviour {
//Only a single instance of PoolManager should be loaded
[HideInInspector] public static PoolManager instance = null;
//Each of these Pools are assigned within the Unity editor
[SerializeField]
private PrefabPool IndicatorTag;
[SerializeField]
private PrefabPool Explosion;
[SerializeField]
private PrefabPool RocketThrust;
[SerializeField]
private PrefabPool ImpactPuff;
[SerializeField]
private PrefabPool IndicatorArrow;
[SerializeField]
private PrefabPool WadingAnim;
[SerializeField]
private PrefabPool Shadow;
[SerializeField]
private PrefabPool CeilingDitherMask;
[SerializeField]
private PrefabPool PlayerPool;
[SerializeField]
private PrefabPool ConfettiPool;
[SerializeField]
private PrefabPool SplashPool;
[SerializeField]
private PrefabPool TrailPool;
[SerializeField]
private PrefabPool FireballPool;
[SerializeField]
private PrefabPool StegoSwingFXPool;
[SerializeField]
private PrefabPool DoorSlideFXPool;
[SerializeField]
private PrefabPool DustPuffFXPool;
[SerializeField]
private PrefabPool SpaceSuckFXPool;
[SerializeField]
private PrefabPool VacuumFXPool;
void Awake()
{
//Common Unity3D singleton pattern
if (instance == null)
{
instance = this;
}
else if (instance != this)
{
Destroy(gameObject);
}
}
//Wrapper methods for getting objects from PrefabPools
public GameObject GetPickupIndicatorTag()
{
return IndicatorTag.GetObject();
}
public void ReturnPickupIndicatorTag(GameObject obj)
{
IndicatorTag.ReturnObject(obj);
}
public GameObject GetExplosion()
{
return Explosion.GetObject();
}
public void ReturnExplosion(GameObject obj)
{
Explosion.ReturnObject(obj);
}
public GameObject GetThrust()
{
return RocketThrust.GetObject();
}
public void ReturnThrust(GameObject obj)
{
RocketThrust.ReturnObject(obj);
}
public GameObject GetImpactPuff()
{
return ImpactPuff.GetObject();
}
public void ReturnImpactPuff(GameObject obj)
{
ImpactPuff.ReturnObject(obj);
}
public GameObject GetIndicatorArrow()
{
return IndicatorArrow.GetObject();
}
public void ReturnIndicatorArrow(GameObject obj)
{
IndicatorArrow.ReturnObject(obj);
}
public GameObject GetWadingAnim()
{
return WadingAnim.GetObject();
}
public void ReturnWadingAnim(GameObject obj)
{
WadingAnim.ReturnObject(obj);
}
public GameObject GetShadow()
{
return Shadow.GetObject();
}
public void ReturnShadow(GameObject obj)
{
Shadow.ReturnObject(obj);
}
public GameObject GetCeilingDitherMask()
{
return CeilingDitherMask.GetObject();
}
public void ReturnCeilingDitherMask(GameObject obj)
{
CeilingDitherMask.ReturnObject(obj);
}
public GameObject GetPlayer()
{
return PlayerPool.GetObject();
}
public void ReturnPlayer(GameObject obj)
{
PlayerPool.ReturnObject(obj);
}
public GameObject GetConfetti()
{
return ConfettiPool.GetObject();
}
public void ReturnConfetti(GameObject obj)
{
ConfettiPool.ReturnObject(obj);
}
public GameObject GetSplash()
{
return SplashPool.GetObject();
}
public void ReturnSplash(GameObject obj)
{
SplashPool.ReturnObject(obj);
}
public GameObject GetTrail()
{
return TrailPool.GetObject();
}
public void ReturnTrail(GameObject obj)
{
TrailPool.ReturnObject(obj);
}
public GameObject GetFireball()
{
return FireballPool.GetObject();
}
public void ReturnFireball(GameObject obj)
{
FireballPool.ReturnObject(obj);
}
public GameObject GetStegoSwingFX()
{
return StegoSwingFXPool.GetObject();
}
public void ReturnStegoSwingFX(GameObject obj)
{
StegoSwingFXPool.ReturnObject(obj);
}
public GameObject GetDoorSlideFX()
{
return DoorSlideFXPool.GetObject();
}
public void ReturnDoorSlideFX(GameObject obj)
{
DoorSlideFXPool.ReturnObject(obj);
}
public GameObject GetDustPuffFX()
{
return DustPuffFXPool.GetObject();
}
public void ReturnDustPuffFX(GameObject obj)
{
DustPuffFXPool.ReturnObject(obj);
}
public GameObject GetSpaceSuckFX()
{
return SpaceSuckFXPool.GetObject();
}
public void ReturnSpaceSuckFX(GameObject obj)
{
SpaceSuckFXPool.ReturnObject(obj);
}
public GameObject GetVacuumFX()
{
return VacuumFXPool.GetObject();
}
public void ReturnVacuumFX(GameObject obj)
{
VacuumFXPool.ReturnObject(obj);
}
}