-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstance.cpp
More file actions
353 lines (270 loc) · 8.98 KB
/
Copy pathInstance.cpp
File metadata and controls
353 lines (270 loc) · 8.98 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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*--------------------------------****************************************----------------------------------
| * * |
| Ether's Quest * Instance class Definitions * |
| * * |
---------------------------------****************************************----------------------------------*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
The Instance class creates game instances objects
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "Instance.hpp"
#include "Exit_game.hpp"
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//--------------------------------------------- Instance Class --------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------
// Constructors
//----------------------------------------------------------------------------------
Instance::Instance()
{
// Empty
}
/*-----------------------------------------------------------------------
constructor-1 one button, ambience
Instances: Menu
-----------------------------------------------------------------------*/
Instance::Instance(unsigned inst_type, Texture2D &img, Button &btn1, Sound &ambience)
{
this->inst_type = inst_type;
this->img = img;
this->btn1 = btn1;
this->ambience = ambience;
//---- Ambience volume
SetSoundVolume(ambience, 0.3);
}
/*--------------------------------------------------------------------
constructor-2 one button, voice, ambience
Instances: Place and Monster
--------------------------------------------------------------------*/
Instance::Instance(unsigned inst_type, Texture2D &img, Button &btn1, Sound &voice, Sound &ambience)
{
this->inst_type = inst_type;
this->img = img;
this->btn1 = btn1;
this->voice = voice;
is_voice = true;
this->ambience = ambience;
//---- Ambience volume
SetSoundVolume(ambience, 0.3);
}
/*-------------------------------------------------------------------
constructor-3 one button, monster, font, ambience
Instance: Fight
-------------------------------------------------------------------*/
Instance::Instance(unsigned inst_type, Texture2D &img, Button &btn1, Monster &monster, Font &font, Sound &ambience)
{
this->inst_type = inst_type;
this->img = img;
this->btn1 = btn1;
this->font = font;
is_font = true;
this->monster = monster;
is_monster = true;
this->ambience = ambience;
//---- Ambience volume
SetSoundVolume(ambience, 0.3);
}
/*-------------------------------------------------------------------
constructor-4 one button, font, voice, ambience
Instance: Won
-------------------------------------------------------------------*/
Instance::Instance(unsigned inst_type, Texture2D &img, Button &btn1, Font &font, Sound voice, Sound &ambience)
{
this->inst_type = inst_type;
this->img = img;
this->btn1 = btn1;
this->font = font;
is_font = true;
this->monster = monster;
this->voice = voice;
is_voice = true;
is_monster = true;
this->ambience = ambience;
//---- Ambience volume
SetSoundVolume(ambience, 0.3);
}
/*--------------------------------------------------------------------
constructor-5 two buttons, ambience
Instances: Menu
--------------------------------------------------------------------*/
Instance::Instance(unsigned inst_type, Texture2D &img, Button &btn1, Button btn2, Sound &ambience)
{
this->inst_type = inst_type;
this->img = img;
this->btn1 = btn1;
this->btn2 = btn2;
is_two_btn = true;
this->ambience = ambience;
//---- Ambience volume
SetSoundVolume(ambience, 0.3);
}
/*--------------------------------------------------------------------
constructor-6 two buttons, voice, ambience
Instances: Quest and Direction
--------------------------------------------------------------------*/
Instance::Instance(unsigned inst_type, Texture2D &img, Button &btn1, Button btn2, Sound voice, Sound &ambience)
{
this->inst_type = inst_type;
this->img = img;
this->btn1 = btn1;
this->btn2 = btn2;
is_two_btn = true;
this->voice = voice;
is_voice = true;
this->ambience = ambience;
//---- Ambience volume
SetSoundVolume(ambience, 0.3);
}
/*--------------------------------------------------------------------
constructor-7 three buttons.
Instance: Menu
--------------------------------------------------------------------*/
Instance::Instance(unsigned inst_type, Texture2D &img, Button &btn1, Button &btn2, Button &btn3, Sound &ambience)
{
this->inst_type = inst_type;
this->img = img;
this->btn1 = btn1;
this->btn2 = btn2;
this->btn3 = btn3;
is_three_btn = true;
this->ambience = ambience;
//---- Ambience volume
SetSoundVolume(ambience, 0.3);
}
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
// Accessors
//----------------------------------------------------------------------------------
unsigned Instance::type()
{
return inst_type;
}
//-------------------------------------------------
Texture2D Instance::image()
{
return img;
}
Rectangle Instance::img_source()
{
return img_source_rec;
}
//-------------------------------------------------
Button Instance::button()
{
return btn1;
}
/*--------------------------------------------------------------------
Return btn1 and btn2
--------------------------------------------------------------------*/
vector<Button> Instance::button2()
{
vector<Button> buttons;
if (!is_two_btn)
{
throw "This instance has less than or more than 2 buttons";
}
else
{
buttons.push_back(btn1);
buttons.push_back(btn2);
}
return buttons;
}
/*--------------------------------------------------------------------
Return btn1, btn2, and btn2
--------------------------------------------------------------------*/
vector<Button> Instance::button3()
{
vector<Button> buttons;
if (!is_three_btn)
{
throw "This instance has less than 3 buttons";
}
else
{
buttons.push_back(btn1);
buttons.push_back(btn2);
buttons.push_back(btn3);
}
return buttons;
};
/*--------------------------------------------------------------------
Returns btn1 source rectangle
--------------------------------------------------------------------*/
Rectangle Instance::btn_source()
{
return btn1.org_size;
}
/*--------------------------------------------------------------------
Returns btn1 and btn2 source rectangles
--------------------------------------------------------------------*/
vector<Rectangle> Instance::btn_source2()
{
vector<Rectangle> buttons_rec;
if (is_two_btn)
{
buttons_rec = { btn1.org_size, btn2.org_size };
}
else
{
throw "This instance has only one button";
}
return buttons_rec;
}
/*--------------------------------------------------------------------
Returns btn1, btn2, and btn3 source rectangles
--------------------------------------------------------------------*/
vector<Rectangle> Instance::btn_source3()
{
vector<Rectangle> buttons_rec;
if (is_three_btn)
{
buttons_rec = { btn1.org_size, btn2.org_size, btn3.org_size };
}
else
{
throw "This instance has less then 3 buttons";
}
return buttons_rec;
}
/*--------------------------------------------------------------------
Returns font
--------------------------------------------------------------------*/
Font Instance::get_font()
{
if (!is_font) throw "This instance has no font";
return font;
}
/*--------------------------------------------------------------------
Returns monster
--------------------------------------------------------------------*/
Monster Instance::get_monster()
{
if (!is_monster) throw "This instance has no monster";
return monster;
}
/*--------------------------------------------------------------------
Returns Narrators' voices
--------------------------------------------------------------------*/
Sound Instance::get_voice()
{
if (!is_voice) throw "This instance has no narrators' voices";
return voice;
}
/*--------------------------------------------------------------------
Returns backgrond ambience
--------------------------------------------------------------------*/
Sound Instance::get_ambience()
{
return ambience;
}
/*--------------------------------------------------------------------
Returns is voice, true or false
--------------------------------------------------------------------*/
bool Instance::get_is_voice()
{
return is_voice;
}