@almadar/std 2.1.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/behaviors/async.d.ts +12 -7
- package/dist/behaviors/async.js +1085 -312
- package/dist/behaviors/async.js.map +1 -1
- package/dist/behaviors/data-management.d.ts +27 -13
- package/dist/behaviors/data-management.js +600 -244
- package/dist/behaviors/data-management.js.map +1 -1
- package/dist/behaviors/domain/commerce.d.ts +51 -0
- package/dist/behaviors/domain/commerce.js +1093 -0
- package/dist/behaviors/domain/commerce.js.map +1 -0
- package/dist/behaviors/domain/content.d.ts +51 -0
- package/dist/behaviors/domain/content.js +1294 -0
- package/dist/behaviors/domain/content.js.map +1 -0
- package/dist/behaviors/domain/dashboard.d.ts +45 -0
- package/dist/behaviors/domain/dashboard.js +783 -0
- package/dist/behaviors/domain/dashboard.js.map +1 -0
- package/dist/behaviors/domain/education.d.ts +41 -0
- package/dist/behaviors/domain/education.js +738 -0
- package/dist/behaviors/domain/education.js.map +1 -0
- package/dist/behaviors/domain/finance.d.ts +49 -0
- package/dist/behaviors/domain/finance.js +660 -0
- package/dist/behaviors/domain/finance.js.map +1 -0
- package/dist/behaviors/domain/game-2d-platformer.d.ts +50 -0
- package/dist/behaviors/domain/game-2d-platformer.js +810 -0
- package/dist/behaviors/domain/game-2d-platformer.js.map +1 -0
- package/dist/behaviors/domain/game-2d-puzzle.d.ts +42 -0
- package/dist/behaviors/domain/game-2d-puzzle.js +622 -0
- package/dist/behaviors/domain/game-2d-puzzle.js.map +1 -0
- package/dist/behaviors/domain/game-2d-rpg.d.ts +48 -0
- package/dist/behaviors/domain/game-2d-rpg.js +860 -0
- package/dist/behaviors/domain/game-2d-rpg.js.map +1 -0
- package/dist/behaviors/domain/game-2d-strategy.d.ts +48 -0
- package/dist/behaviors/domain/game-2d-strategy.js +692 -0
- package/dist/behaviors/domain/game-2d-strategy.js.map +1 -0
- package/dist/behaviors/domain/geospatial.d.ts +35 -0
- package/dist/behaviors/domain/geospatial.js +634 -0
- package/dist/behaviors/domain/geospatial.js.map +1 -0
- package/dist/behaviors/domain/healthcare.d.ts +36 -0
- package/dist/behaviors/domain/healthcare.js +1068 -0
- package/dist/behaviors/domain/healthcare.js.map +1 -0
- package/dist/behaviors/domain/iot.d.ts +45 -0
- package/dist/behaviors/domain/iot.js +589 -0
- package/dist/behaviors/domain/iot.js.map +1 -0
- package/dist/behaviors/domain/media.d.ts +41 -0
- package/dist/behaviors/domain/media.js +771 -0
- package/dist/behaviors/domain/media.js.map +1 -0
- package/dist/behaviors/domain/scheduling.d.ts +41 -0
- package/dist/behaviors/domain/scheduling.js +930 -0
- package/dist/behaviors/domain/scheduling.js.map +1 -0
- package/dist/behaviors/domain/simulation.d.ts +36 -0
- package/dist/behaviors/domain/simulation.js +706 -0
- package/dist/behaviors/domain/simulation.js.map +1 -0
- package/dist/behaviors/domain/social.d.ts +41 -0
- package/dist/behaviors/domain/social.js +840 -0
- package/dist/behaviors/domain/social.js.map +1 -0
- package/dist/behaviors/domain/workflow.d.ts +41 -0
- package/dist/behaviors/domain/workflow.js +879 -0
- package/dist/behaviors/domain/workflow.js.map +1 -0
- package/dist/behaviors/feedback.d.ts +10 -5
- package/dist/behaviors/feedback.js +279 -194
- package/dist/behaviors/feedback.js.map +1 -1
- package/dist/behaviors/game-core.d.ts +15 -8
- package/dist/behaviors/game-core.js +412 -80
- package/dist/behaviors/game-core.js.map +1 -1
- package/dist/behaviors/game-entity.d.ts +17 -10
- package/dist/behaviors/game-entity.js +544 -237
- package/dist/behaviors/game-entity.js.map +1 -1
- package/dist/behaviors/game-ui.d.ts +16 -8
- package/dist/behaviors/game-ui.js +451 -316
- package/dist/behaviors/game-ui.js.map +1 -1
- package/dist/behaviors/index.d.ts +18 -1
- package/dist/behaviors/index.js +18905 -2140
- package/dist/behaviors/index.js.map +1 -1
- package/dist/behaviors/infrastructure.d.ts +9 -8
- package/dist/behaviors/infrastructure.js +597 -169
- package/dist/behaviors/infrastructure.js.map +1 -1
- package/dist/behaviors/registry.d.ts +11 -11
- package/dist/behaviors/registry.js +18904 -2139
- package/dist/behaviors/registry.js.map +1 -1
- package/dist/behaviors/types.d.ts +19 -2
- package/dist/behaviors/types.js.map +1 -1
- package/dist/behaviors/ui-interaction.d.ts +20 -14
- package/dist/behaviors/ui-interaction.js +928 -518
- package/dist/behaviors/ui-interaction.js.map +1 -1
- package/dist/index.js +18906 -2141
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
|
@@ -1,58 +1,326 @@
|
|
|
1
1
|
// behaviors/game-ui.ts
|
|
2
|
+
var GAME_UI_THEME = {
|
|
3
|
+
name: "game-ui-amber",
|
|
4
|
+
tokens: {
|
|
5
|
+
colors: {
|
|
6
|
+
primary: "#d97706",
|
|
7
|
+
"primary-hover": "#b45309",
|
|
8
|
+
"primary-foreground": "#ffffff",
|
|
9
|
+
accent: "#f59e0b",
|
|
10
|
+
"accent-foreground": "#000000",
|
|
11
|
+
success: "#22c55e",
|
|
12
|
+
warning: "#f59e0b",
|
|
13
|
+
error: "#ef4444"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var KFLOW_ASSETS = "https://almadar-kflow-assets.web.app/shared";
|
|
18
|
+
var GAME_MANIFEST = {
|
|
19
|
+
terrain: {
|
|
20
|
+
stone: "/terrain/Isometric/stoneSide_N.png",
|
|
21
|
+
dirt: "/terrain/Isometric/dirt_N.png",
|
|
22
|
+
bridge: "/terrain/Isometric/stoneStep_N.png",
|
|
23
|
+
wall: "/terrain/Isometric/stoneWallArchway_N.png"
|
|
24
|
+
},
|
|
25
|
+
units: {
|
|
26
|
+
guardian: "/sprite-sheets/guardian-sprite-sheet-se.png",
|
|
27
|
+
breaker: "/sprite-sheets/breaker-sprite-sheet-se.png",
|
|
28
|
+
archivist: "/sprite-sheets/archivist-sprite-sheet-se.png"
|
|
29
|
+
},
|
|
30
|
+
features: {
|
|
31
|
+
gold_mine: "/world-map/gold_mine.png",
|
|
32
|
+
portal: "/world-map/portal_open.png",
|
|
33
|
+
treasure: "/world-map/treasure_chest_closed.png",
|
|
34
|
+
battle_marker: "/world-map/battle_marker.png",
|
|
35
|
+
power_node: "/world-map/power_node.png"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var TILES_5X5 = [
|
|
39
|
+
{ x: 0, y: 0, terrain: "stone" },
|
|
40
|
+
{ x: 1, y: 0, terrain: "dirt" },
|
|
41
|
+
{ x: 2, y: 0, terrain: "stone" },
|
|
42
|
+
{ x: 3, y: 0, terrain: "dirt" },
|
|
43
|
+
{ x: 4, y: 0, terrain: "stone" },
|
|
44
|
+
{ x: 0, y: 1, terrain: "dirt" },
|
|
45
|
+
{ x: 1, y: 1, terrain: "stone" },
|
|
46
|
+
{ x: 2, y: 1, terrain: "dirt" },
|
|
47
|
+
{ x: 3, y: 1, terrain: "stone" },
|
|
48
|
+
{ x: 4, y: 1, terrain: "dirt" },
|
|
49
|
+
{ x: 0, y: 2, terrain: "stone" },
|
|
50
|
+
{ x: 1, y: 2, terrain: "dirt" },
|
|
51
|
+
{ x: 2, y: 2, terrain: "bridge" },
|
|
52
|
+
{ x: 3, y: 2, terrain: "dirt" },
|
|
53
|
+
{ x: 4, y: 2, terrain: "stone" },
|
|
54
|
+
{ x: 0, y: 3, terrain: "dirt" },
|
|
55
|
+
{ x: 1, y: 3, terrain: "stone" },
|
|
56
|
+
{ x: 2, y: 3, terrain: "dirt" },
|
|
57
|
+
{ x: 3, y: 3, terrain: "stone" },
|
|
58
|
+
{ x: 4, y: 3, terrain: "dirt" },
|
|
59
|
+
{ x: 0, y: 4, terrain: "stone" },
|
|
60
|
+
{ x: 1, y: 4, terrain: "dirt" },
|
|
61
|
+
{ x: 2, y: 4, terrain: "stone" },
|
|
62
|
+
{ x: 3, y: 4, terrain: "wall" },
|
|
63
|
+
{ x: 4, y: 4, terrain: "stone" }
|
|
64
|
+
];
|
|
65
|
+
var gameMenuView = ["render-ui", "main", {
|
|
66
|
+
type: "game-menu",
|
|
67
|
+
title: "@entity.title",
|
|
68
|
+
subtitle: "Press Start to begin",
|
|
69
|
+
menuItems: [
|
|
70
|
+
{ label: "Start Game", event: "START", variant: "primary" }
|
|
71
|
+
]
|
|
72
|
+
}];
|
|
73
|
+
var gamePlayingCanvasView = ["render-ui", "main", {
|
|
74
|
+
type: "isometric-canvas",
|
|
75
|
+
tiles: TILES_5X5,
|
|
76
|
+
units: [{ id: "player", x: 2, y: 2, unitType: "guardian" }],
|
|
77
|
+
scale: 0.5,
|
|
78
|
+
boardWidth: 5,
|
|
79
|
+
boardHeight: 5,
|
|
80
|
+
enableCamera: true,
|
|
81
|
+
assetBaseUrl: KFLOW_ASSETS,
|
|
82
|
+
assetManifest: GAME_MANIFEST
|
|
83
|
+
}];
|
|
84
|
+
var gamePlayingHud = ["render-ui", "overlay", {
|
|
85
|
+
type: "game-hud",
|
|
86
|
+
position: "top",
|
|
87
|
+
elements: [
|
|
88
|
+
{ label: "Status", value: "@entity.status", icon: "activity" },
|
|
89
|
+
{ label: "Time", value: "@entity.playTime", icon: "clock" },
|
|
90
|
+
{ label: "Attempts", value: "@entity.attempts", icon: "hash" }
|
|
91
|
+
]
|
|
92
|
+
}];
|
|
93
|
+
var gamePausedView = ["render-ui", "main", {
|
|
94
|
+
type: "game-menu",
|
|
95
|
+
title: "Paused",
|
|
96
|
+
subtitle: "Game is paused",
|
|
97
|
+
menuItems: [
|
|
98
|
+
{ label: "Resume", event: "RESUME", variant: "primary" },
|
|
99
|
+
{ label: "Restart", event: "RESTART", variant: "secondary" }
|
|
100
|
+
]
|
|
101
|
+
}];
|
|
102
|
+
var gameOverView = ["render-ui", "main", {
|
|
103
|
+
type: "game-over-screen",
|
|
104
|
+
title: "Game Over",
|
|
105
|
+
message: "Better luck next time!",
|
|
106
|
+
variant: "defeat",
|
|
107
|
+
menuItems: [
|
|
108
|
+
{ label: "Try Again", event: "RESTART" }
|
|
109
|
+
]
|
|
110
|
+
}];
|
|
111
|
+
var dialogueModalView = ["render-ui", "modal", {
|
|
112
|
+
type: "stack",
|
|
113
|
+
direction: "vertical",
|
|
114
|
+
gap: "lg",
|
|
115
|
+
children: [
|
|
116
|
+
{ type: "stack", direction: "horizontal", gap: "sm", justify: "space-between", children: [
|
|
117
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
118
|
+
{ type: "icon", name: "message-square" },
|
|
119
|
+
{ type: "typography", content: "@entity.speaker", variant: "h2" }
|
|
120
|
+
] }
|
|
121
|
+
] },
|
|
122
|
+
{ type: "divider" },
|
|
123
|
+
{ type: "typography", content: "@entity.displayedText", variant: "body" },
|
|
124
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
125
|
+
{ type: "typography", content: "@entity.currentNode", variant: "label" },
|
|
126
|
+
{ type: "typography", content: "/", variant: "label" },
|
|
127
|
+
{ type: "typography", content: "@entity.totalNodes", variant: "label" }
|
|
128
|
+
] },
|
|
129
|
+
{ type: "progress-bar", value: "@entity.currentNode", max: "@entity.totalNodes" },
|
|
130
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
131
|
+
{ type: "button", label: "Next", action: "NEXT", icon: "arrow-right", variant: "primary" },
|
|
132
|
+
{ type: "button", label: "Close", action: "CLOSE", icon: "x", variant: "secondary" }
|
|
133
|
+
] }
|
|
134
|
+
]
|
|
135
|
+
}];
|
|
136
|
+
var dialogueChoiceModalView = ["render-ui", "modal", {
|
|
137
|
+
type: "stack",
|
|
138
|
+
direction: "vertical",
|
|
139
|
+
gap: "lg",
|
|
140
|
+
children: [
|
|
141
|
+
{ type: "stack", direction: "horizontal", gap: "sm", justify: "space-between", children: [
|
|
142
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
143
|
+
{ type: "icon", name: "list" },
|
|
144
|
+
{ type: "typography", content: "Choose Response", variant: "h3" }
|
|
145
|
+
] }
|
|
146
|
+
] },
|
|
147
|
+
{ type: "divider" },
|
|
148
|
+
{ type: "typography", content: "@entity.displayedText", variant: "body" },
|
|
149
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
150
|
+
{ type: "button", label: "Continue", action: "NEXT", icon: "arrow-right", variant: "primary" },
|
|
151
|
+
{ type: "button", label: "Close", action: "CLOSE", icon: "x", variant: "secondary" }
|
|
152
|
+
] }
|
|
153
|
+
]
|
|
154
|
+
}];
|
|
155
|
+
var dialogueHiddenCanvasView = ["render-ui", "main", {
|
|
156
|
+
type: "isometric-canvas",
|
|
157
|
+
tiles: TILES_5X5,
|
|
158
|
+
units: [{ id: "npc", x: 2, y: 2, unitType: "archivist" }],
|
|
159
|
+
scale: 0.5,
|
|
160
|
+
boardWidth: 5,
|
|
161
|
+
boardHeight: 5,
|
|
162
|
+
enableCamera: false,
|
|
163
|
+
assetBaseUrl: KFLOW_ASSETS,
|
|
164
|
+
assetManifest: GAME_MANIFEST
|
|
165
|
+
}];
|
|
166
|
+
var dialogueHiddenOverlay = ["render-ui", "overlay", {
|
|
167
|
+
type: "stack",
|
|
168
|
+
direction: "vertical",
|
|
169
|
+
gap: "md",
|
|
170
|
+
children: [
|
|
171
|
+
{ type: "typography", content: "No active dialogue", variant: "body" },
|
|
172
|
+
{ type: "button", label: "Start Dialogue", action: "SHOW", icon: "message-square", variant: "primary" }
|
|
173
|
+
]
|
|
174
|
+
}];
|
|
175
|
+
var dialogueShowingCanvasView = ["render-ui", "main", {
|
|
176
|
+
type: "isometric-canvas",
|
|
177
|
+
tiles: TILES_5X5,
|
|
178
|
+
units: [{ id: "npc", x: 2, y: 2, unitType: "archivist" }],
|
|
179
|
+
scale: 0.5,
|
|
180
|
+
boardWidth: 5,
|
|
181
|
+
boardHeight: 5,
|
|
182
|
+
enableCamera: false,
|
|
183
|
+
assetBaseUrl: KFLOW_ASSETS,
|
|
184
|
+
assetManifest: GAME_MANIFEST
|
|
185
|
+
}];
|
|
186
|
+
var levelBrowsingView = ["render-ui", "main", {
|
|
187
|
+
type: "game-menu",
|
|
188
|
+
title: "Select Level",
|
|
189
|
+
subtitle: "Choose your challenge",
|
|
190
|
+
menuItems: [
|
|
191
|
+
{ label: "Level 1", event: "SELECT_LEVEL" },
|
|
192
|
+
{ label: "Level 2", event: "SELECT_LEVEL" },
|
|
193
|
+
{ label: "Level 3", event: "SELECT_LEVEL" }
|
|
194
|
+
]
|
|
195
|
+
}];
|
|
196
|
+
var levelBrowsingHud = ["render-ui", "overlay", {
|
|
197
|
+
type: "stack",
|
|
198
|
+
direction: "vertical",
|
|
199
|
+
gap: "md",
|
|
200
|
+
children: [
|
|
201
|
+
{ type: "game-hud", position: "top", elements: [
|
|
202
|
+
{ label: "Current", value: "@entity.currentLevel", icon: "target" },
|
|
203
|
+
{ label: "Total", value: "@entity.totalLevels", icon: "layers" },
|
|
204
|
+
{ label: "Completed", value: "@entity.completedLevels", icon: "check-circle" }
|
|
205
|
+
] },
|
|
206
|
+
{ type: "progress-bar", value: "@entity.completedLevels", max: "@entity.totalLevels" }
|
|
207
|
+
]
|
|
208
|
+
}];
|
|
209
|
+
var levelPlayingCanvasView = ["render-ui", "main", {
|
|
210
|
+
type: "isometric-canvas",
|
|
211
|
+
tiles: TILES_5X5,
|
|
212
|
+
units: [{ id: "player", x: 2, y: 2, unitType: "guardian" }],
|
|
213
|
+
scale: 0.5,
|
|
214
|
+
boardWidth: 5,
|
|
215
|
+
boardHeight: 5,
|
|
216
|
+
enableCamera: true,
|
|
217
|
+
assetBaseUrl: KFLOW_ASSETS,
|
|
218
|
+
assetManifest: GAME_MANIFEST
|
|
219
|
+
}];
|
|
220
|
+
var levelPlayingHud = ["render-ui", "overlay", {
|
|
221
|
+
type: "stack",
|
|
222
|
+
direction: "vertical",
|
|
223
|
+
gap: "md",
|
|
224
|
+
children: [
|
|
225
|
+
{ type: "game-hud", position: "top", elements: [
|
|
226
|
+
{ label: "Level", value: "@entity.currentLevel", icon: "target" },
|
|
227
|
+
{ label: "Name", value: "@entity.levelName", icon: "tag" }
|
|
228
|
+
] },
|
|
229
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
230
|
+
{ type: "button", label: "Complete Level", action: "COMPLETE_LEVEL", icon: "check", variant: "primary" },
|
|
231
|
+
{ type: "button", label: "Back to Levels", action: "BACK_TO_SELECT", icon: "arrow-left", variant: "secondary" }
|
|
232
|
+
] }
|
|
233
|
+
]
|
|
234
|
+
}];
|
|
235
|
+
var levelCompleteView = ["render-ui", "main", {
|
|
236
|
+
type: "game-over-screen",
|
|
237
|
+
title: "Level Complete",
|
|
238
|
+
message: "Well done! Ready for the next challenge?",
|
|
239
|
+
variant: "victory",
|
|
240
|
+
menuItems: [
|
|
241
|
+
{ label: "Next Level", event: "COMPLETE_LEVEL" },
|
|
242
|
+
{ label: "Back to Levels", event: "BACK_TO_SELECT" }
|
|
243
|
+
]
|
|
244
|
+
}];
|
|
245
|
+
var levelCompleteHud = ["render-ui", "overlay", {
|
|
246
|
+
type: "stack",
|
|
247
|
+
direction: "vertical",
|
|
248
|
+
gap: "md",
|
|
249
|
+
children: [
|
|
250
|
+
{ type: "game-hud", position: "top", elements: [
|
|
251
|
+
{ label: "Level", value: "@entity.currentLevel", icon: "target" },
|
|
252
|
+
{ label: "Completed", value: "@entity.completedLevels", icon: "check-circle" }
|
|
253
|
+
] },
|
|
254
|
+
{ type: "progress-bar", value: "@entity.completedLevels", max: "@entity.totalLevels" }
|
|
255
|
+
]
|
|
256
|
+
}];
|
|
257
|
+
var allLevelsCompleteView = ["render-ui", "main", {
|
|
258
|
+
type: "game-over-screen",
|
|
259
|
+
title: "All Levels Complete",
|
|
260
|
+
message: "Congratulations! You conquered every challenge!",
|
|
261
|
+
variant: "victory",
|
|
262
|
+
menuItems: [
|
|
263
|
+
{ label: "Refresh", event: "INIT" }
|
|
264
|
+
]
|
|
265
|
+
}];
|
|
266
|
+
var allLevelsCompleteHud = ["render-ui", "overlay", {
|
|
267
|
+
type: "stack",
|
|
268
|
+
direction: "vertical",
|
|
269
|
+
gap: "md",
|
|
270
|
+
children: [
|
|
271
|
+
{ type: "game-hud", position: "top", elements: [
|
|
272
|
+
{ label: "Completed", value: "@entity.completedLevels", icon: "check-circle" },
|
|
273
|
+
{ label: "Total", value: "@entity.totalLevels", icon: "layers" }
|
|
274
|
+
] },
|
|
275
|
+
{ type: "progress-bar", value: "@entity.completedLevels", max: "@entity.totalLevels" }
|
|
276
|
+
]
|
|
277
|
+
}];
|
|
2
278
|
var GAME_FLOW_BEHAVIOR = {
|
|
3
279
|
name: "std-gameflow",
|
|
4
280
|
version: "1.0.0",
|
|
5
|
-
description: "Master game flow: menu, play, pause, game over
|
|
281
|
+
description: "Master game flow: menu, play, pause, game over",
|
|
6
282
|
orbitals: [
|
|
7
283
|
{
|
|
8
284
|
name: "GameFlowOrbital",
|
|
285
|
+
theme: GAME_UI_THEME,
|
|
9
286
|
entity: {
|
|
10
|
-
name: "
|
|
287
|
+
name: "GameFlowData",
|
|
11
288
|
persistence: "runtime",
|
|
12
289
|
fields: [
|
|
13
290
|
{ name: "id", type: "string", required: true },
|
|
14
291
|
{ name: "playTime", type: "number", default: 0 },
|
|
15
292
|
{ name: "attempts", type: "number", default: 0 },
|
|
16
|
-
{ name: "lastState", type: "string", default: "Menu" },
|
|
17
293
|
{ name: "title", type: "string", default: "Game" },
|
|
18
|
-
{ name: "
|
|
294
|
+
{ name: "status", type: "string", default: "menu" }
|
|
19
295
|
]
|
|
20
296
|
},
|
|
21
297
|
traits: [
|
|
22
298
|
{
|
|
23
299
|
name: "GameFlow",
|
|
24
|
-
linkedEntity: "
|
|
300
|
+
linkedEntity: "GameFlowData",
|
|
25
301
|
category: "interaction",
|
|
26
302
|
stateMachine: {
|
|
27
303
|
states: [
|
|
28
304
|
{ name: "Menu", isInitial: true },
|
|
29
305
|
{ name: "Playing" },
|
|
30
306
|
{ name: "Paused" },
|
|
31
|
-
{ name: "GameOver"
|
|
32
|
-
{ name: "Victory", isTerminal: true }
|
|
307
|
+
{ name: "GameOver" }
|
|
33
308
|
],
|
|
34
309
|
events: [
|
|
310
|
+
{ key: "INIT", name: "Initialize" },
|
|
35
311
|
{ key: "START", name: "Start" },
|
|
36
312
|
{ key: "PAUSE", name: "Pause" },
|
|
37
313
|
{ key: "RESUME", name: "Resume" },
|
|
38
314
|
{ key: "GAME_OVER", name: "Game Over" },
|
|
39
|
-
{ key: "
|
|
40
|
-
{ key: "RESTART", name: "Restart" },
|
|
41
|
-
{ key: "QUIT", name: "Quit" }
|
|
315
|
+
{ key: "RESTART", name: "Restart" }
|
|
42
316
|
],
|
|
43
317
|
transitions: [
|
|
44
318
|
{
|
|
45
319
|
from: "Menu",
|
|
46
320
|
to: "Menu",
|
|
47
|
-
event: "
|
|
321
|
+
event: "INIT",
|
|
48
322
|
effects: [
|
|
49
|
-
|
|
50
|
-
["render-ui", "screen", {
|
|
51
|
-
type: "game-menu",
|
|
52
|
-
title: "@entity.title",
|
|
53
|
-
options: [{ event: "START", label: "Start Game" }],
|
|
54
|
-
onSelect: "START"
|
|
55
|
-
}]
|
|
323
|
+
gameMenuView
|
|
56
324
|
]
|
|
57
325
|
},
|
|
58
326
|
{
|
|
@@ -60,124 +328,75 @@ var GAME_FLOW_BEHAVIOR = {
|
|
|
60
328
|
to: "Playing",
|
|
61
329
|
event: "START",
|
|
62
330
|
effects: [
|
|
331
|
+
["fetch", "GameFlowData"],
|
|
63
332
|
["set", "@entity.attempts", ["+", "@entity.attempts", 1]],
|
|
64
333
|
["set", "@entity.playTime", 0],
|
|
65
|
-
["
|
|
334
|
+
["set", "@entity.status", "playing"],
|
|
335
|
+
gamePlayingCanvasView,
|
|
336
|
+
gamePlayingHud
|
|
66
337
|
]
|
|
67
338
|
},
|
|
68
339
|
{
|
|
69
340
|
from: "Playing",
|
|
70
341
|
to: "Paused",
|
|
71
342
|
event: "PAUSE",
|
|
72
|
-
guard: "@entity.allowPause",
|
|
73
343
|
effects: [
|
|
74
|
-
["set", "@entity.
|
|
75
|
-
|
|
76
|
-
["render-ui", "overlay", {
|
|
77
|
-
type: "game-over-screen",
|
|
78
|
-
title: "Paused",
|
|
79
|
-
variant: "pause",
|
|
80
|
-
actions: [
|
|
81
|
-
{ event: "RESUME", label: "Resume" },
|
|
82
|
-
{ event: "QUIT", label: "Quit" }
|
|
83
|
-
]
|
|
84
|
-
}]
|
|
344
|
+
["set", "@entity.status", "paused"],
|
|
345
|
+
gamePausedView
|
|
85
346
|
]
|
|
86
347
|
},
|
|
87
348
|
{
|
|
88
349
|
from: "Paused",
|
|
89
350
|
to: "Playing",
|
|
90
351
|
event: "RESUME",
|
|
91
|
-
effects: [["emit", "GAME_LOOP_RESUME"]]
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
from: "Playing",
|
|
95
|
-
to: "GameOver",
|
|
96
|
-
event: "GAME_OVER",
|
|
97
352
|
effects: [
|
|
98
|
-
["
|
|
99
|
-
["
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
stats: [
|
|
103
|
-
{ label: "Play Time", value: "@entity.playTime" },
|
|
104
|
-
{ label: "Attempts", value: "@entity.attempts" }
|
|
105
|
-
],
|
|
106
|
-
actions: [
|
|
107
|
-
{ event: "RESTART", label: "Try Again" },
|
|
108
|
-
{ event: "QUIT", label: "Quit" }
|
|
109
|
-
]
|
|
110
|
-
}]
|
|
353
|
+
["fetch", "GameFlowData"],
|
|
354
|
+
["set", "@entity.status", "playing"],
|
|
355
|
+
gamePlayingCanvasView,
|
|
356
|
+
gamePlayingHud
|
|
111
357
|
]
|
|
112
358
|
},
|
|
113
359
|
{
|
|
114
360
|
from: "Playing",
|
|
115
|
-
to: "
|
|
116
|
-
event: "
|
|
361
|
+
to: "GameOver",
|
|
362
|
+
event: "GAME_OVER",
|
|
117
363
|
effects: [
|
|
118
|
-
["
|
|
119
|
-
|
|
120
|
-
type: "game-over-screen",
|
|
121
|
-
title: "Victory!",
|
|
122
|
-
variant: "success",
|
|
123
|
-
stats: [
|
|
124
|
-
{ label: "Play Time", value: "@entity.playTime" },
|
|
125
|
-
{ label: "Attempts", value: "@entity.attempts" }
|
|
126
|
-
],
|
|
127
|
-
actions: [
|
|
128
|
-
{ event: "RESTART", label: "Play Again" },
|
|
129
|
-
{ event: "QUIT", label: "Quit" }
|
|
130
|
-
]
|
|
131
|
-
}]
|
|
364
|
+
["set", "@entity.status", "gameover"],
|
|
365
|
+
gameOverView
|
|
132
366
|
]
|
|
133
367
|
},
|
|
134
368
|
{
|
|
135
369
|
from: "GameOver",
|
|
136
|
-
to: "
|
|
370
|
+
to: "Menu",
|
|
137
371
|
event: "RESTART",
|
|
138
372
|
effects: [
|
|
139
|
-
["
|
|
140
|
-
["
|
|
373
|
+
["set", "@entity.status", "menu"],
|
|
374
|
+
["set", "@entity.playTime", 0],
|
|
375
|
+
gameMenuView
|
|
141
376
|
]
|
|
142
377
|
},
|
|
143
378
|
{
|
|
144
|
-
from: "
|
|
145
|
-
to: "
|
|
379
|
+
from: "Paused",
|
|
380
|
+
to: "Menu",
|
|
146
381
|
event: "RESTART",
|
|
147
382
|
effects: [
|
|
148
|
-
["
|
|
149
|
-
["
|
|
383
|
+
["set", "@entity.status", "menu"],
|
|
384
|
+
["set", "@entity.playTime", 0],
|
|
385
|
+
gameMenuView
|
|
150
386
|
]
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
from: "Playing",
|
|
154
|
-
to: "Menu",
|
|
155
|
-
event: "QUIT",
|
|
156
|
-
effects: [["emit", "STOP"]]
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
from: "Paused",
|
|
160
|
-
to: "Menu",
|
|
161
|
-
event: "QUIT",
|
|
162
|
-
effects: [["emit", "STOP"]]
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
from: "GameOver",
|
|
166
|
-
to: "Menu",
|
|
167
|
-
event: "QUIT",
|
|
168
|
-
effects: [["emit", "STOP"]]
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
from: "Victory",
|
|
172
|
-
to: "Menu",
|
|
173
|
-
event: "QUIT",
|
|
174
|
-
effects: [["emit", "STOP"]]
|
|
175
387
|
}
|
|
176
388
|
]
|
|
177
389
|
}
|
|
178
390
|
}
|
|
179
391
|
],
|
|
180
|
-
pages: [
|
|
392
|
+
pages: [
|
|
393
|
+
{
|
|
394
|
+
name: "GamePage",
|
|
395
|
+
path: "/game",
|
|
396
|
+
isInitial: true,
|
|
397
|
+
traits: [{ ref: "GameFlow" }]
|
|
398
|
+
}
|
|
399
|
+
]
|
|
181
400
|
}
|
|
182
401
|
]
|
|
183
402
|
};
|
|
@@ -188,269 +407,201 @@ var DIALOGUE_BEHAVIOR = {
|
|
|
188
407
|
orbitals: [
|
|
189
408
|
{
|
|
190
409
|
name: "DialogueOrbital",
|
|
410
|
+
theme: GAME_UI_THEME,
|
|
191
411
|
entity: {
|
|
192
|
-
name: "
|
|
412
|
+
name: "DialogueData",
|
|
193
413
|
persistence: "runtime",
|
|
194
414
|
fields: [
|
|
195
415
|
{ name: "id", type: "string", required: true },
|
|
196
|
-
{ name: "dialogueTree", type: "array", default: [] },
|
|
197
416
|
{ name: "currentNode", type: "number", default: 0 },
|
|
198
417
|
{ name: "displayedText", type: "string", default: "" },
|
|
199
|
-
{ name: "isTyping", type: "boolean", default: false },
|
|
200
418
|
{ name: "speaker", type: "string", default: "" },
|
|
201
|
-
{ name: "
|
|
202
|
-
{ name: "lastTypeTime", type: "number", default: 0 },
|
|
203
|
-
{ name: "typingSpeed", type: "number", default: 50 }
|
|
419
|
+
{ name: "totalNodes", type: "number", default: 0 }
|
|
204
420
|
]
|
|
205
421
|
},
|
|
206
422
|
traits: [
|
|
207
423
|
{
|
|
208
424
|
name: "Dialogue",
|
|
209
|
-
linkedEntity: "
|
|
425
|
+
linkedEntity: "DialogueData",
|
|
210
426
|
category: "interaction",
|
|
211
427
|
stateMachine: {
|
|
212
428
|
states: [
|
|
213
429
|
{ name: "Hidden", isInitial: true },
|
|
214
|
-
{ name: "Typing" },
|
|
215
430
|
{ name: "Showing" },
|
|
216
431
|
{ name: "Choice" }
|
|
217
432
|
],
|
|
218
433
|
events: [
|
|
219
|
-
{ key: "
|
|
434
|
+
{ key: "INIT", name: "Initialize" },
|
|
435
|
+
{ key: "SHOW", name: "Show", payloadSchema: [
|
|
436
|
+
{ name: "speaker", type: "string", required: true },
|
|
437
|
+
{ name: "text", type: "string", required: true },
|
|
438
|
+
{ name: "totalNodes", type: "number", required: true }
|
|
439
|
+
] },
|
|
220
440
|
{ key: "NEXT", name: "Next" },
|
|
221
|
-
{ key: "SELECT_CHOICE", name: "Select Choice"
|
|
222
|
-
|
|
441
|
+
{ key: "SELECT_CHOICE", name: "Select Choice", payloadSchema: [
|
|
442
|
+
{ name: "index", type: "number", required: true }
|
|
443
|
+
] },
|
|
223
444
|
{ key: "CLOSE", name: "Close" },
|
|
224
|
-
{ key: "
|
|
225
|
-
{ key: "TYPE_COMPLETE", name: "Type Complete" }
|
|
445
|
+
{ key: "CANCEL", name: "Cancel" }
|
|
226
446
|
],
|
|
227
447
|
transitions: [
|
|
228
448
|
{
|
|
229
449
|
from: "Hidden",
|
|
230
|
-
to: "
|
|
231
|
-
event: "
|
|
450
|
+
to: "Hidden",
|
|
451
|
+
event: "INIT",
|
|
232
452
|
effects: [
|
|
233
|
-
["
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
["set", "@entity.displayedText", ""],
|
|
237
|
-
["set", "@entity.typeIndex", 0],
|
|
238
|
-
["set", "@entity.lastTypeTime", "@now"],
|
|
239
|
-
["emit", "GAME_PAUSE"],
|
|
240
|
-
["render-ui", "overlay.dialogue", {
|
|
241
|
-
type: "dialogue-box",
|
|
242
|
-
dialogue: {
|
|
243
|
-
speaker: "@entity.speaker",
|
|
244
|
-
text: "@entity.displayedText",
|
|
245
|
-
isTyping: "@entity.isTyping"
|
|
246
|
-
},
|
|
247
|
-
onAdvance: "NEXT"
|
|
248
|
-
}]
|
|
453
|
+
["fetch", "DialogueData"],
|
|
454
|
+
dialogueHiddenCanvasView,
|
|
455
|
+
dialogueHiddenOverlay
|
|
249
456
|
]
|
|
250
457
|
},
|
|
251
458
|
{
|
|
252
|
-
from: "
|
|
253
|
-
to: "
|
|
254
|
-
event: "
|
|
459
|
+
from: "Hidden",
|
|
460
|
+
to: "Showing",
|
|
461
|
+
event: "SHOW",
|
|
255
462
|
effects: [
|
|
256
|
-
[
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
["set", "@entity.lastTypeTime", "@now"]
|
|
264
|
-
]
|
|
265
|
-
]
|
|
463
|
+
["fetch", "DialogueData"],
|
|
464
|
+
["set", "@entity.speaker", "@payload.speaker"],
|
|
465
|
+
["set", "@entity.displayedText", "@payload.text"],
|
|
466
|
+
["set", "@entity.totalNodes", "@payload.totalNodes"],
|
|
467
|
+
["set", "@entity.currentNode", 0],
|
|
468
|
+
dialogueShowingCanvasView,
|
|
469
|
+
dialogueModalView
|
|
266
470
|
]
|
|
267
471
|
},
|
|
268
472
|
{
|
|
269
|
-
from: "
|
|
270
|
-
to: "Showing",
|
|
271
|
-
event: "TYPE_COMPLETE",
|
|
272
|
-
effects: [["set", "@entity.isTyping", false]]
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
from: "Typing",
|
|
473
|
+
from: "Showing",
|
|
276
474
|
to: "Showing",
|
|
277
|
-
event: "
|
|
475
|
+
event: "NEXT",
|
|
476
|
+
guard: ["<", "@entity.currentNode", ["-", "@entity.totalNodes", 1]],
|
|
278
477
|
effects: [
|
|
279
|
-
[
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
"do",
|
|
284
|
-
["set", "@entity.isTyping", false],
|
|
285
|
-
["set", "@entity.displayedText", "@currentDialogue.text"]
|
|
286
|
-
]
|
|
287
|
-
]
|
|
478
|
+
["fetch", "DialogueData"],
|
|
479
|
+
["set", "@entity.currentNode", ["+", "@entity.currentNode", 1]],
|
|
480
|
+
dialogueShowingCanvasView,
|
|
481
|
+
dialogueModalView
|
|
288
482
|
]
|
|
289
483
|
},
|
|
290
484
|
{
|
|
291
485
|
from: "Showing",
|
|
292
|
-
to: "
|
|
486
|
+
to: "Hidden",
|
|
293
487
|
event: "NEXT",
|
|
294
|
-
guard: ["
|
|
488
|
+
guard: [">=", "@entity.currentNode", ["-", "@entity.totalNodes", 1]],
|
|
295
489
|
effects: [
|
|
296
|
-
[
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
["emit", "CLOSE"],
|
|
300
|
-
[
|
|
301
|
-
"do",
|
|
302
|
-
["set", "@entity.currentNode", ["+", "@entity.currentNode", 1]],
|
|
303
|
-
["set", "@entity.isTyping", true],
|
|
304
|
-
["set", "@entity.displayedText", ""],
|
|
305
|
-
["set", "@entity.typeIndex", 0]
|
|
306
|
-
]
|
|
307
|
-
]
|
|
490
|
+
["set", "@entity.displayedText", ""],
|
|
491
|
+
["set", "@entity.speaker", ""],
|
|
492
|
+
["render-ui", "modal", null]
|
|
308
493
|
]
|
|
309
494
|
},
|
|
310
495
|
{
|
|
311
496
|
from: "Showing",
|
|
312
497
|
to: "Choice",
|
|
313
|
-
event: "
|
|
314
|
-
guard: ["object/get", ["array/nth", "@entity.dialogueTree", "@entity.currentNode"], "choices"],
|
|
498
|
+
event: "SELECT_CHOICE",
|
|
315
499
|
effects: [
|
|
316
|
-
|
|
317
|
-
"let",
|
|
318
|
-
[["currentDialogue", ["array/nth", "@entity.dialogueTree", "@entity.currentNode"]]],
|
|
319
|
-
["render-ui", "overlay.dialogue", {
|
|
320
|
-
type: "dialogue-box",
|
|
321
|
-
dialogue: {
|
|
322
|
-
speaker: "Choose",
|
|
323
|
-
choices: "@currentDialogue.choices"
|
|
324
|
-
},
|
|
325
|
-
onChoice: "SELECT_CHOICE"
|
|
326
|
-
}]
|
|
327
|
-
]
|
|
500
|
+
dialogueChoiceModalView
|
|
328
501
|
]
|
|
329
502
|
},
|
|
330
503
|
{
|
|
331
504
|
from: "Choice",
|
|
332
|
-
to: "
|
|
333
|
-
event: "
|
|
505
|
+
to: "Showing",
|
|
506
|
+
event: "NEXT",
|
|
334
507
|
effects: [
|
|
335
|
-
[
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
"let",
|
|
340
|
-
[["choice", ["array/nth", "@currentDialogue.choices", "@payload.index"]]],
|
|
341
|
-
[
|
|
342
|
-
"do",
|
|
343
|
-
[
|
|
344
|
-
"if",
|
|
345
|
-
"@choice.nextNode",
|
|
346
|
-
["set", "@entity.currentNode", "@choice.nextNode"],
|
|
347
|
-
["set", "@entity.currentNode", ["+", "@entity.currentNode", 1]]
|
|
348
|
-
],
|
|
349
|
-
["if", "@choice.effect", ["emit", "@choice.effect"]]
|
|
350
|
-
]
|
|
351
|
-
]
|
|
352
|
-
],
|
|
353
|
-
["set", "@entity.isTyping", true],
|
|
354
|
-
["set", "@entity.displayedText", ""],
|
|
355
|
-
["set", "@entity.typeIndex", 0]
|
|
508
|
+
["fetch", "DialogueData"],
|
|
509
|
+
["set", "@entity.currentNode", ["+", "@entity.currentNode", 1]],
|
|
510
|
+
dialogueShowingCanvasView,
|
|
511
|
+
dialogueModalView
|
|
356
512
|
]
|
|
357
513
|
},
|
|
358
514
|
{
|
|
359
|
-
from: "
|
|
515
|
+
from: "Showing",
|
|
360
516
|
to: "Hidden",
|
|
361
517
|
event: "CLOSE",
|
|
362
518
|
effects: [
|
|
363
|
-
["set", "@entity.
|
|
364
|
-
["set", "@entity.
|
|
365
|
-
["
|
|
519
|
+
["set", "@entity.displayedText", ""],
|
|
520
|
+
["set", "@entity.speaker", ""],
|
|
521
|
+
["render-ui", "modal", null]
|
|
366
522
|
]
|
|
367
523
|
},
|
|
368
524
|
{
|
|
369
|
-
from: "
|
|
525
|
+
from: "Choice",
|
|
370
526
|
to: "Hidden",
|
|
371
527
|
event: "CLOSE",
|
|
372
528
|
effects: [
|
|
373
|
-
["set", "@entity.
|
|
374
|
-
["set", "@entity.
|
|
375
|
-
["
|
|
529
|
+
["set", "@entity.displayedText", ""],
|
|
530
|
+
["set", "@entity.speaker", ""],
|
|
531
|
+
["render-ui", "modal", null]
|
|
376
532
|
]
|
|
377
533
|
},
|
|
378
534
|
{
|
|
379
535
|
from: "Choice",
|
|
380
536
|
to: "Hidden",
|
|
381
|
-
event: "
|
|
537
|
+
event: "CANCEL",
|
|
382
538
|
effects: [
|
|
383
|
-
["set", "@entity.
|
|
384
|
-
["set", "@entity.
|
|
385
|
-
["
|
|
539
|
+
["set", "@entity.displayedText", ""],
|
|
540
|
+
["set", "@entity.speaker", ""],
|
|
541
|
+
["render-ui", "modal", null]
|
|
542
|
+
]
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
from: "Showing",
|
|
546
|
+
to: "Hidden",
|
|
547
|
+
event: "CANCEL",
|
|
548
|
+
effects: [
|
|
549
|
+
["set", "@entity.displayedText", ""],
|
|
550
|
+
["set", "@entity.speaker", ""],
|
|
551
|
+
["render-ui", "modal", null]
|
|
386
552
|
]
|
|
387
553
|
}
|
|
388
554
|
]
|
|
389
|
-
}
|
|
390
|
-
ticks: [
|
|
391
|
-
{
|
|
392
|
-
name: "TypewriterEffect",
|
|
393
|
-
interval: "frame",
|
|
394
|
-
guard: ["and", "@entity.isTyping", [">", ["-", "@now", "@entity.lastTypeTime"], ["/", 1e3, "@entity.typingSpeed"]]],
|
|
395
|
-
effects: [
|
|
396
|
-
[
|
|
397
|
-
"let",
|
|
398
|
-
[["currentDialogue", ["array/nth", "@entity.dialogueTree", "@entity.currentNode"]]],
|
|
399
|
-
[
|
|
400
|
-
"if",
|
|
401
|
-
["<", "@entity.typeIndex", ["str/len", "@currentDialogue.text"]],
|
|
402
|
-
["emit", "TYPE_CHAR"],
|
|
403
|
-
["emit", "TYPE_COMPLETE"]
|
|
404
|
-
]
|
|
405
|
-
]
|
|
406
|
-
]
|
|
407
|
-
}
|
|
408
|
-
]
|
|
555
|
+
}
|
|
409
556
|
}
|
|
410
557
|
],
|
|
411
|
-
pages: [
|
|
558
|
+
pages: [
|
|
559
|
+
{
|
|
560
|
+
name: "DialoguePage",
|
|
561
|
+
path: "/dialogue",
|
|
562
|
+
isInitial: true,
|
|
563
|
+
traits: [{ ref: "Dialogue" }]
|
|
564
|
+
}
|
|
565
|
+
]
|
|
412
566
|
}
|
|
413
567
|
]
|
|
414
568
|
};
|
|
415
569
|
var LEVEL_PROGRESS_BEHAVIOR = {
|
|
416
570
|
name: "std-levelprogress",
|
|
417
571
|
version: "1.0.0",
|
|
418
|
-
description: "Level progression with
|
|
572
|
+
description: "Level progression with selection and completion tracking",
|
|
419
573
|
orbitals: [
|
|
420
574
|
{
|
|
421
575
|
name: "LevelProgressOrbital",
|
|
576
|
+
theme: GAME_UI_THEME,
|
|
422
577
|
entity: {
|
|
423
|
-
name: "
|
|
578
|
+
name: "LevelData",
|
|
424
579
|
persistence: "runtime",
|
|
425
580
|
fields: [
|
|
426
581
|
{ name: "id", type: "string", required: true },
|
|
427
582
|
{ name: "currentLevel", type: "number", default: 0 },
|
|
428
|
-
{ name: "
|
|
429
|
-
{ name: "
|
|
430
|
-
{ name: "
|
|
431
|
-
{ name: "
|
|
432
|
-
{ name: "starsPerLevel", type: "number", default: 3 },
|
|
433
|
-
{ name: "unlockNext", type: "boolean", default: true },
|
|
434
|
-
{ name: "persistProgress", type: "boolean", default: true }
|
|
583
|
+
{ name: "totalLevels", type: "number", default: 10 },
|
|
584
|
+
{ name: "completedLevels", type: "number", default: 0 },
|
|
585
|
+
{ name: "levelName", type: "string", default: "" },
|
|
586
|
+
{ name: "status", type: "string", default: "browsing" }
|
|
435
587
|
]
|
|
436
588
|
},
|
|
437
589
|
traits: [
|
|
438
590
|
{
|
|
439
591
|
name: "LevelProgress",
|
|
440
|
-
linkedEntity: "
|
|
592
|
+
linkedEntity: "LevelData",
|
|
441
593
|
category: "interaction",
|
|
442
594
|
stateMachine: {
|
|
443
595
|
states: [
|
|
444
596
|
{ name: "Browsing", isInitial: true },
|
|
445
|
-
{ name: "
|
|
446
|
-
{ name: "InLevel" }
|
|
597
|
+
{ name: "Playing" }
|
|
447
598
|
],
|
|
448
599
|
events: [
|
|
449
600
|
{ key: "INIT", name: "Initialize" },
|
|
450
|
-
{ key: "SELECT_LEVEL", name: "Select Level"
|
|
451
|
-
|
|
601
|
+
{ key: "SELECT_LEVEL", name: "Select Level", payloadSchema: [
|
|
602
|
+
{ name: "level", type: "number", required: true }
|
|
603
|
+
] },
|
|
452
604
|
{ key: "COMPLETE_LEVEL", name: "Complete Level" },
|
|
453
|
-
{ key: "UNLOCK_LEVEL", name: "Unlock Level" },
|
|
454
605
|
{ key: "BACK_TO_SELECT", name: "Back To Select" }
|
|
455
606
|
],
|
|
456
607
|
transitions: [
|
|
@@ -459,89 +610,73 @@ var LEVEL_PROGRESS_BEHAVIOR = {
|
|
|
459
610
|
to: "Browsing",
|
|
460
611
|
event: "INIT",
|
|
461
612
|
effects: [
|
|
462
|
-
["
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
onSelect: "SELECT_LEVEL"
|
|
467
|
-
}]
|
|
613
|
+
["fetch", "LevelData"],
|
|
614
|
+
["set", "@entity.status", "browsing"],
|
|
615
|
+
levelBrowsingView,
|
|
616
|
+
levelBrowsingHud
|
|
468
617
|
]
|
|
469
618
|
},
|
|
470
619
|
{
|
|
471
620
|
from: "Browsing",
|
|
472
|
-
to: "
|
|
621
|
+
to: "Playing",
|
|
473
622
|
event: "SELECT_LEVEL",
|
|
474
|
-
guard: ["
|
|
623
|
+
guard: ["<=", "@payload.level", "@entity.totalLevels"],
|
|
475
624
|
effects: [
|
|
476
|
-
["
|
|
477
|
-
["
|
|
625
|
+
["fetch", "LevelData"],
|
|
626
|
+
["set", "@entity.currentLevel", "@payload.level"],
|
|
627
|
+
["set", "@entity.status", "playing"],
|
|
628
|
+
levelPlayingCanvasView,
|
|
629
|
+
levelPlayingHud
|
|
478
630
|
]
|
|
479
631
|
},
|
|
480
632
|
{
|
|
481
|
-
from: "
|
|
482
|
-
to: "
|
|
483
|
-
event: "LEVEL_LOADED",
|
|
484
|
-
effects: [["emit", "START"]]
|
|
485
|
-
},
|
|
486
|
-
{
|
|
487
|
-
from: "InLevel",
|
|
488
|
-
to: "InLevel",
|
|
633
|
+
from: "Playing",
|
|
634
|
+
to: "Playing",
|
|
489
635
|
event: "COMPLETE_LEVEL",
|
|
636
|
+
guard: ["<", "@entity.currentLevel", "@entity.totalLevels"],
|
|
490
637
|
effects: [
|
|
491
|
-
["set", "@entity.
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
["math/max", "@payload.stars", ["object/get", "@entity.levelStars", ["str/toString", "@entity.currentLevel"], 0]]
|
|
496
|
-
]],
|
|
497
|
-
["set", "@entity.totalStars", ["array/reduce", ["object/values", "@entity.levelStars"], ["fn", "sum", "v", ["+", "@sum", "@v"]], 0]],
|
|
498
|
-
[
|
|
499
|
-
"if",
|
|
500
|
-
["and", "@entity.unlockNext", ["<", "@entity.currentLevel", ["-", ["array/len", "@entity.levels"], 1]]],
|
|
501
|
-
["emit", "UNLOCK_LEVEL", { levelIndex: ["+", "@entity.currentLevel", 1] }]
|
|
502
|
-
],
|
|
503
|
-
[
|
|
504
|
-
"if",
|
|
505
|
-
"@entity.persistProgress",
|
|
506
|
-
["persist", "save", "LevelProgress", {
|
|
507
|
-
unlockedLevels: "@entity.unlockedLevels",
|
|
508
|
-
levelStars: "@entity.levelStars"
|
|
509
|
-
}]
|
|
510
|
-
]
|
|
638
|
+
["set", "@entity.completedLevels", ["+", "@entity.completedLevels", 1]],
|
|
639
|
+
["set", "@entity.currentLevel", ["+", "@entity.currentLevel", 1]],
|
|
640
|
+
levelCompleteView,
|
|
641
|
+
levelCompleteHud
|
|
511
642
|
]
|
|
512
643
|
},
|
|
513
644
|
{
|
|
514
|
-
from: "
|
|
515
|
-
to: "
|
|
516
|
-
event: "
|
|
517
|
-
guard: ["
|
|
645
|
+
from: "Playing",
|
|
646
|
+
to: "Browsing",
|
|
647
|
+
event: "COMPLETE_LEVEL",
|
|
648
|
+
guard: [">=", "@entity.currentLevel", "@entity.totalLevels"],
|
|
518
649
|
effects: [
|
|
519
|
-
["
|
|
650
|
+
["fetch", "LevelData"],
|
|
651
|
+
["set", "@entity.completedLevels", ["+", "@entity.completedLevels", 1]],
|
|
652
|
+
["set", "@entity.status", "browsing"],
|
|
653
|
+
allLevelsCompleteView,
|
|
654
|
+
allLevelsCompleteHud
|
|
520
655
|
]
|
|
521
656
|
},
|
|
522
657
|
{
|
|
523
|
-
from: "
|
|
658
|
+
from: "Playing",
|
|
524
659
|
to: "Browsing",
|
|
525
660
|
event: "BACK_TO_SELECT",
|
|
526
|
-
effects: [
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
effects: []
|
|
533
|
-
},
|
|
534
|
-
{
|
|
535
|
-
from: "InLevel",
|
|
536
|
-
to: "Browsing",
|
|
537
|
-
event: "INIT",
|
|
538
|
-
effects: []
|
|
661
|
+
effects: [
|
|
662
|
+
["fetch", "LevelData"],
|
|
663
|
+
["set", "@entity.status", "browsing"],
|
|
664
|
+
levelBrowsingView,
|
|
665
|
+
levelBrowsingHud
|
|
666
|
+
]
|
|
539
667
|
}
|
|
540
668
|
]
|
|
541
669
|
}
|
|
542
670
|
}
|
|
543
671
|
],
|
|
544
|
-
pages: [
|
|
672
|
+
pages: [
|
|
673
|
+
{
|
|
674
|
+
name: "LevelsPage",
|
|
675
|
+
path: "/levels",
|
|
676
|
+
isInitial: true,
|
|
677
|
+
traits: [{ ref: "LevelProgress" }]
|
|
678
|
+
}
|
|
679
|
+
]
|
|
545
680
|
}
|
|
546
681
|
]
|
|
547
682
|
};
|