-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.js
376 lines (342 loc) · 15.3 KB
/
configuration.js
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
//& This file setup all variables for the global game
let debugMode = false;
let gameIsStarting = true;
let acteTwoIsStarting = false;
let fightIsReset = false;
let eIsPressed = false;
let escapeIsPressed = false;
let leftButtonIsPressed = false;
function keyReleased() {
if (keyCode === 69) {
eIsPressed = true
setTimeout(() => {
if (!canInteract) {
eIsPressed = false;
}
}, 50);
}
if (keyCode === 27) {
escapeIsPressed = true;
setTimeout(() => {
escapeIsPressed = false;
}, 50);
}
if (keyCode === 32) {
spaceIsPressed = true;
setTimeout(() => {
spaceIsPressed = false;
}, 50);
}
}
function mouseReleased(event) {
if (event.button === 0) {
leftButtonIsPressed = true;
setTimeout(() => {
leftButtonIsPressed = false;
}, 50);
}
}
let actualQuestName = "seedsBagQuest"
let startingIsDialogsFinish = false;
let canShowArrows = false;
let alphaArrows = 0;
let canChangeObjectInventory = false;
let canShowObjectInAnimation = true;
let newObjectToAdd = undefined;
let canShowInventoryAnimation = false;
let objectAsBeenAdToInventoryWithAnimation = false;
let animationActeTwoStart = false;
let actualChestStatusForWrench = undefined;
let canOpenChest = false;
let canShowClickImage = true;
let newObjectSize = 128;
let newObjectOldX = 0;
let newObjectOldY = 0;
let canUpObjectSize = true;
//+ This set screen settings
let screenWidth = 1632;
let screenHeight = 918;
let frameRateNumber = 60;
//+ Set engines names to variables
const ENGINE_ONE = "engine_one";
const ENGINE_TWO = "engine_two";
const MENU = "menu";
let newEngineSelected = ENGINE_TWO;
//+ Set the start engine
let currentEngine = MENU;
let tempCurrentEngine = ENGINE_TWO;
//+ Set the player cut size
let spriteCutSize = 20;
//+ Set player state and direction
let playerState = "idle";
let Direction = [0, 0];
let canMovePlayer = true;
//+ Set global NPC speed
let npcSpeed = 5;
//+ Set inventory Params
let inventorySquareSize = 96;
let inventoryHeigthStart = 8;
let inventoryTab = [];
let inventoryTabNumber = 0;
let actualInventoryChoose = 1;
inventoryTab.length = 3;
let inventoryWidthStart = screenWidth - (inventoryTab.length * inventorySquareSize) - 10 * inventoryTab.length - 10;
//+ Set NPC interaction params
let canInteract = false;
let tempText = "";
let i = 0;
let index = 0;
let bool = false;
let actualDialog = [];
let speak = false;
let key = false;
let actualNPCCollision = '';
let actualPlayersOrder = [];
let actualHead = undefined;
//+ Set global Variable to see if talk to an NPC
let canTalkingToNPC = false;
//+ Set NPC globals moves
let canMoveAllNPC = true;
let canTalkGlobalNPC = true;
//+ Set a boolean if can draw inventory
let canDrawMenus = true;
//+ Set switch case to know the first engine
switch (currentEngine) {
case ENGINE_ONE:
spritePlayerSize = 140;
playerPosX = screenWidth / 2 - spritePlayerSize / 2;
playerPosY = screenHeight / 2 - spritePlayerSize / 2;
break;
case ENGINE_TWO:
spritePlayerSize = screenHeight / 2.58;
playerPosX = screenWidth / 1.5 - spritePlayerSize / 2;
playerPosY = screenHeight - spritePlayerSize - 58;
break;
}
//^ This function is used to detect engines changes
function changeEngine() {
if (currentEngine != tempCurrentEngine) {
if (currentEngine == "engine_one") {
spritePlayerSize = 140;
playerPosX = screenWidth / 2 - spritePlayerSize / 2;
playerPosY = screenHeight / 2 - spritePlayerSize / 2;
} else {
switch (actualMapEngineTwo) {
case "cloneMap":
spritePlayerSize = screenHeight / 2.58;
playerPosX = screenWidth / 1.5 - spritePlayerSize / 2;
playerPosY = screenHeight - spritePlayerSize - 61;
break;
case "botanicMap":
spritePlayerSize = screenHeight / 2.58;
playerPosX = screenWidth / 3 - spritePlayerSize / 2;
playerPosY = screenHeight - spritePlayerSize - 61;
break;
case "commandMap":
spritePlayerSize = screenHeight / 2.58;
playerPosX = screenWidth / 1.5 - spritePlayerSize / 2;
playerPosY = screenHeight - spritePlayerSize - 61;
break;
case "capsuleMap":
spritePlayerSize = screenHeight / 2.58;
playerPosX = screenWidth / 1.3 - spritePlayerSize / 2;
playerPosY = screenHeight - spritePlayerSize - 61;
break;
case "dormsMap":
spritePlayerSize = screenHeight / 2.58;
playerPosX = screenWidth / 1.5 - spritePlayerSize / 2;
playerPosY = screenHeight - spritePlayerSize - 47;
break;
}
}
tempCurrentEngine = currentEngine;
}
}
let textEnter = false;
//^ This function is used to show the text of dialogue feature
function writeText(actualDialog) {
if (canInteract) {
if (keyIsDown(69)) {
image(skipButton.get(41, 0, 41, 15), (screenWidth - 890) / 2, (screenHeight / 1.5) + 25, 205, 75);
} else {
image(skipButton.get(0, 0, 41, 15), (screenWidth - 890) / 2, (screenHeight / 1.5) + 25, 205, 75);
}
textLeading(30);
image(dialogsBackground, (screenWidth - 900) / 2, screenHeight - 200, 896, 176)
noFill();
if (bool) {
if (i === actualDialog[index].length && !textEnter) {
key = true
canMovePlayer = false;
canInteract = true;
speak = true
textEnter = true;
}
if (eIsPressed && !textEnter && !key) {
eIsPressed = false;
tempText = actualDialog[index]
textEnter = true;
setTimeout(() => {
key = true
canMovePlayer = false;
canInteract = true;
speak = true
}, 500);
}
if (speak) {
if (key && eIsPressed) {
if (index < actualDialog.length - 1) {
eIsPressed = false;
canMovePlayer = false;
i = 0;
tempText = "";
textEnter = false;
index += 1;
key = false;
} else if (!canMovePlayer) {
if (!quests.lastQuest.canDrawEve) {
eIsPressed = false;
textEnter = false;
clearInterval(idInterval);
i = 0;
tempText = "";
speak = false;
bool = false;
key = false;
index = 0;
canInteract = false;
startingIsDialogsFinish = true;
canMoveAllNPC = true;
canOpenChest = false;
actualHead = [-1];
if (quests.fight.haveShotTwoAmmo && !quests.fight.fightIsFinished) {
alienStatus = "move";
alienCanMove = true;
indexAlienSprite = 0;
canShoot = true;
}
if (quests.fight.animationFightCanStart && quests.fight.haveFinishAnimationFirstPart) {
quests.fight.animationFightCanStart = false;
quests.fight.dialogsFightIsOver = true;
quests.fight.canStartFigth = false;
fightIsReset = false;
console.log('%c<----Dialog Have End With Success---->', 'color:rgb(0, 0, 255)')
console.log('%c<----Fight Dialog Have End With Success---->', 'color:rgb(255, 0, 0)')
}
if (!quests.fight.dialogsFitghtIsStart && !quests.fight.haveShotTwoAmmo) {
if (!gameIsStarting && !quests.seedsBagQuest.canAddToInventorySeedBag && !quests.repareCapsulesMap.canAddWrenchToInventory && !animationActeTwoStart) {
canDrawMenus = true;
setTimeout(() => {
canMovePlayer = true;
console.log('%c<----Dialog Have End With Success---->', 'color:rgb(0, 0, 255)')
}, 200);
}
if (quests.seedsBagQuest.canAddToInventorySeedBag) {
canDrawMenus = true;
canShowInventoryAnimation = true;
newObjectToAdd = "seedsBagBotanicMap";
setTimeout(() => {
canMovePlayer = true;
quests.seedsBagQuest.canAddToInventorySeedBag = false;
console.log('%c<----Dialog Have End With Success---->', 'color:rgb(0, 0, 255)')
}, 3500);
setTimeout(() => {
objectAsBeenAdToInventoryWithAnimation = false;
}, 20000);
}
if (quests.repareCapsulesMap.canAddWrenchToInventory) {
canDrawMenus = true;
canShowInventoryAnimation = true;
newObjectToAdd = "wrenchCapsulesMap";
setTimeout(() => {
canMovePlayer = true;
quests.repareCapsulesMap.canAddWrenchToInventory = false;
quests.repareCapsulesMap.canTakeWrench = false;
console.log('%c<----Dialog Have End With Success---->', 'color:rgb(0, 0, 255)')
}, 3500);
setTimeout(() => {
objectAsBeenAdToInventoryWithAnimation = false;
console.log('%c<----Object Have Been Add To Inventory With Success---->', 'color:rgb(0, 140, 255)')
}, 20000);
}
if (quests.repareCapsulesMap.hadTalkToFinn) {
quests.repareCapsulesMap.canRepareWall = true;
}
if (quests.goToCloneMapAfterSleep.canShowMoreInformationAboutAlert) {
quests.goToCloneMapAfterSleep.canShowMoreInformationAboutAlert = false;
quests.goToCloneMapAfterSleep.haveShowMoreInformationAboutAlert = true;
}
if (quests.goToCloneMapAfterSleep.canShowDialogsAfterWeakingUp) {
quests.goToCloneMapAfterSleep.canShowDialogsAfterWeakingUp = false;
quests.goToCloneMapAfterSleep.canShowMoreInformationAboutAlert = true;
quests.goToCloneMapAfterSleephaveShowAfterWeakingUp = true;
}
if (animationActeTwoStart) {
canInteract = false;
actualQuestName = "goToCloneMapAfterSleep"
quests.goToCloneMapAfterSleep.goToCloneMapAfterSleepIsStarted = true;
leftDoorsAreClosed = true;
rigthDoorsAreClosed = true;
animationActeTwoStart = false;
console.log('%c<----Dialog Have End With Success---->', 'color:rgb(0, 0, 255)')
console.log('%c<----Act Two Introduction Have End With Success---->', 'color:rgb(0, 140, 255)')
console.log('%c<----Act Two Successfully Started---->', 'color:rgb(255, 0, 0)')
}
if (!animationActeTwoStart) {
setTimeout(() => {
canTalkGlobalNPC = true;
canActiveDoorBool = false;
}, 1000);
}
if (gameIsStarting) {
setTimeout(() => {
gameIsStarting = false;
canMovePlayer = true;
canShowArrows = true;
canDrawMenus = true;
console.log('%c<----Dialog Have End With Success---->', 'color:rgb(0, 0, 255)')
console.log('%c<----Introduction Have End With Success---->', 'color:rgb(0, 140, 255)')
}, 7000);
}
}
} else {
if (indexOfExplosionCapsuleMap === 10) {
indexOfExplosionCapsuleMap = 0
}
quests.lastQuest.canShowExplosion = true;
setTimeout(() => {
if (!quests.lastQuest.canShowEnd) {
quests.lastQuest.canShowEnd = true;
canDoTransition = true;
newEngineSelected = MENU;
}
}, 800);
}
}
}
} else {
speak = true
idInterval = setInterval(() => {
if (i < actualDialog[index].length && !textEnter) {
tempText = tempText + actualDialog[index][i];
actualHead = actualPlayersOrder[index]
i++;
}
}, 30);
}
} else {
bool = true
}
if (!canMovePlayer) {
noStroke();
textSize(35);
fill("rgb(255,255,255)");
text(tempText, (screenWidth - 855) / 2, screenHeight - 150, 595, 120);
noFill();
image(
dialogsHeads.get(16 * actualHead, 0, 16, 16),
(screenWidth) / 2 + 100, screenHeight - 344, 384, 384
);
}
}
}