@gamebob/axon-surge 0.6.0 → 0.7.0
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/axon-surge.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class B {
|
|
2
2
|
listeners = /* @__PURE__ */ new Map();
|
|
3
3
|
on(t, e) {
|
|
4
4
|
return this.listeners.has(t) || this.listeners.set(t, /* @__PURE__ */ new Set()), this.listeners.get(t).add(e), () => this.off(t, e);
|
|
@@ -15,7 +15,7 @@ class k {
|
|
|
15
15
|
this.listeners.clear();
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
class
|
|
18
|
+
class H {
|
|
19
19
|
animationFrameId = null;
|
|
20
20
|
lastTime = 0;
|
|
21
21
|
isRunning = !1;
|
|
@@ -36,7 +36,7 @@ class B {
|
|
|
36
36
|
this.lastTime = t, this.updateCallback(e), this.renderCallback(), this.animationFrameId = requestAnimationFrame(this.tick);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
class
|
|
39
|
+
class K {
|
|
40
40
|
position;
|
|
41
41
|
radius = 32;
|
|
42
42
|
integrity = 3;
|
|
@@ -60,7 +60,7 @@ class H {
|
|
|
60
60
|
this.position = { x: t, y: e }, this.integrity = this.maxIntegrity, this.pulsePhase = 0;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
class
|
|
63
|
+
class O {
|
|
64
64
|
id;
|
|
65
65
|
position = { x: 0, y: 0 };
|
|
66
66
|
velocity = { x: 0, y: 0 };
|
|
@@ -114,7 +114,7 @@ class N {
|
|
|
114
114
|
this.active = !1, this.isGrabbed = !1, this.isThrown = !1, this.wasManipulated = !1, this.isDying = !1, this.deathType = "none", this.deathTimer = 0, this.sliceAngle = 0, this.position = { x: 0, y: 0 }, this.velocity = { x: 0, y: 0 }, this.rotation = 0, this.strategy = null, this.maxSpeed = 200;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
class
|
|
117
|
+
class W {
|
|
118
118
|
pointerPosition = { x: 0, y: 0 };
|
|
119
119
|
isPointerDown = !1;
|
|
120
120
|
grabbedEnemy = null;
|
|
@@ -218,7 +218,7 @@ class K {
|
|
|
218
218
|
this.grabbedEnemy = null, this.dragStart = null, this.pointerHistory = [], this.isPointerDown = !1;
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
class
|
|
221
|
+
class V {
|
|
222
222
|
cellSize;
|
|
223
223
|
grid = /* @__PURE__ */ new Map();
|
|
224
224
|
constructor(t = 100) {
|
|
@@ -245,7 +245,7 @@ class W {
|
|
|
245
245
|
return i;
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
|
-
class
|
|
248
|
+
class F {
|
|
249
249
|
hitstopTime = 0;
|
|
250
250
|
shakeTime = 0;
|
|
251
251
|
shakeDuration = 0.14;
|
|
@@ -631,7 +631,7 @@ const w = {
|
|
|
631
631
|
tutorialStep2Text: "步骤 2: 朝目标快速挥动抛投",
|
|
632
632
|
tutorialDragWarning: "最佳策略是快速挥动抛投!"
|
|
633
633
|
}
|
|
634
|
-
},
|
|
634
|
+
}, k = [
|
|
635
635
|
"es",
|
|
636
636
|
"en",
|
|
637
637
|
"fr",
|
|
@@ -648,30 +648,49 @@ const w = {
|
|
|
648
648
|
"ko",
|
|
649
649
|
"zh"
|
|
650
650
|
];
|
|
651
|
-
function
|
|
652
|
-
return
|
|
651
|
+
function R(E) {
|
|
652
|
+
return k.includes(E);
|
|
653
653
|
}
|
|
654
|
-
const
|
|
654
|
+
const G = "axon_surge_language";
|
|
655
655
|
class Y {
|
|
656
656
|
currentLanguage;
|
|
657
657
|
constructor(t) {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
658
|
+
this.currentLanguage = this.detectLanguage(t);
|
|
659
|
+
}
|
|
660
|
+
detectLanguage(t) {
|
|
661
|
+
try {
|
|
662
|
+
const e = localStorage.getItem(G);
|
|
663
|
+
if (e && R(e))
|
|
664
|
+
return e;
|
|
665
|
+
} catch {
|
|
666
|
+
}
|
|
667
|
+
if (t && R(t))
|
|
668
|
+
return t;
|
|
669
|
+
try {
|
|
670
|
+
const e = (document.documentElement.lang || document.body?.getAttribute("lang") || "").toLowerCase();
|
|
671
|
+
if (e) {
|
|
672
|
+
const i = e.split("-")[0];
|
|
673
|
+
if (i && R(i))
|
|
674
|
+
return i;
|
|
675
|
+
}
|
|
676
|
+
} catch {
|
|
677
|
+
}
|
|
678
|
+
try {
|
|
679
|
+
const e = (navigator.language || navigator.languages && navigator.languages[0] || "").toLowerCase();
|
|
680
|
+
if (e) {
|
|
681
|
+
const i = e.split("-")[0];
|
|
682
|
+
if (i && R(i))
|
|
683
|
+
return i;
|
|
666
684
|
}
|
|
667
|
-
|
|
685
|
+
} catch {
|
|
668
686
|
}
|
|
687
|
+
return "en";
|
|
669
688
|
}
|
|
670
689
|
setLanguage(t) {
|
|
671
690
|
if (w[t]) {
|
|
672
691
|
this.currentLanguage = t;
|
|
673
692
|
try {
|
|
674
|
-
localStorage.setItem(
|
|
693
|
+
localStorage.setItem(G, t);
|
|
675
694
|
} catch {
|
|
676
695
|
}
|
|
677
696
|
}
|
|
@@ -680,7 +699,7 @@ class Y {
|
|
|
680
699
|
return this.currentLanguage;
|
|
681
700
|
}
|
|
682
701
|
translate(t, e) {
|
|
683
|
-
let s = (w[this.currentLanguage] || w.
|
|
702
|
+
let s = (w[this.currentLanguage] || w.en)[t] || w.en[t] || String(t);
|
|
684
703
|
return e && Object.entries(e).forEach(([a, l]) => {
|
|
685
704
|
s = s.replace(`{${a}}`, String(l));
|
|
686
705
|
}), s;
|
|
@@ -847,7 +866,7 @@ class $ {
|
|
|
847
866
|
}
|
|
848
867
|
class S {
|
|
849
868
|
static createEnemy(t, e, i) {
|
|
850
|
-
const s = `enemy_${Date.now()}_${Math.random()}`, a = new
|
|
869
|
+
const s = `enemy_${Date.now()}_${Math.random()}`, a = new O(s);
|
|
851
870
|
return this.configureEnemy(a, t, e, i), a;
|
|
852
871
|
}
|
|
853
872
|
static configureEnemy(t, e, i, s) {
|
|
@@ -867,7 +886,7 @@ class z {
|
|
|
867
886
|
currentThrowKills = 0;
|
|
868
887
|
currentThrowPos = null;
|
|
869
888
|
constructor(t, e) {
|
|
870
|
-
this.spatialHash = new
|
|
889
|
+
this.spatialHash = new V(100), this.eventBus = t, this.i18n = e;
|
|
871
890
|
}
|
|
872
891
|
update(t, e, i, s, a, l, r, n, o, h, c, u, p, f) {
|
|
873
892
|
this.spatialHash.clear();
|
|
@@ -1039,11 +1058,11 @@ class z {
|
|
|
1039
1058
|
const I = g * Math.PI * 2 / 8, v = {
|
|
1040
1059
|
x: this.currentThrowPos.x + Math.cos(I) * 15,
|
|
1041
1060
|
y: this.currentThrowPos.y + Math.sin(I) * 15
|
|
1042
|
-
},
|
|
1061
|
+
}, D = S.createEnemy("micro", v, {
|
|
1043
1062
|
x: v.x + Math.cos(I) * 220,
|
|
1044
1063
|
y: v.y + Math.sin(I) * 220
|
|
1045
1064
|
});
|
|
1046
|
-
|
|
1065
|
+
D.isThrown = !0, i.push(D);
|
|
1047
1066
|
}
|
|
1048
1067
|
this.killEnemyWithChainReaction(d, b, s, a, l, r, i), this.killEnemyWithChainReaction(m, b, s, a, l, r, i);
|
|
1049
1068
|
} else
|
|
@@ -1129,7 +1148,7 @@ class _ {
|
|
|
1129
1148
|
pool = [];
|
|
1130
1149
|
constructor(t = 500) {
|
|
1131
1150
|
for (let e = 0; e < t; e++) {
|
|
1132
|
-
const i = new
|
|
1151
|
+
const i = new O(`pool_enemy_${e}`);
|
|
1133
1152
|
this.pool.push(i);
|
|
1134
1153
|
}
|
|
1135
1154
|
}
|
|
@@ -1137,7 +1156,7 @@ class _ {
|
|
|
1137
1156
|
for (const e of this.pool)
|
|
1138
1157
|
if (!e.active)
|
|
1139
1158
|
return e.reset(), e;
|
|
1140
|
-
const t = new
|
|
1159
|
+
const t = new O(`fallback_enemy_${Date.now()}_${Math.random()}`);
|
|
1141
1160
|
return this.pool.push(t), t;
|
|
1142
1161
|
}
|
|
1143
1162
|
resetAll() {
|
|
@@ -1293,7 +1312,7 @@ class q {
|
|
|
1293
1312
|
}
|
|
1294
1313
|
}
|
|
1295
1314
|
}
|
|
1296
|
-
const
|
|
1315
|
+
const N = {
|
|
1297
1316
|
bioluminescent: {
|
|
1298
1317
|
bgInner: "#081220",
|
|
1299
1318
|
bgMid: "#050b16",
|
|
@@ -1342,38 +1361,57 @@ const R = {
|
|
|
1342
1361
|
tendrilMagenta: "#b5008c",
|
|
1343
1362
|
tendrilCyan: "#0077b6"
|
|
1344
1363
|
}
|
|
1345
|
-
},
|
|
1364
|
+
}, P = "axon_surge_theme";
|
|
1346
1365
|
class j {
|
|
1347
1366
|
currentTheme = "bioluminescent";
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1367
|
+
isExplicit = !1;
|
|
1368
|
+
targetElement;
|
|
1369
|
+
constructor(t, e) {
|
|
1370
|
+
if (e !== void 0 && (this.targetElement = e), t)
|
|
1371
|
+
this.isExplicit = !0, this.setTheme(t);
|
|
1351
1372
|
else {
|
|
1352
1373
|
try {
|
|
1353
|
-
const
|
|
1354
|
-
|
|
1374
|
+
const i = localStorage.getItem(P);
|
|
1375
|
+
i && N[i] && (this.currentTheme = i, this.isExplicit = !0);
|
|
1355
1376
|
} catch {
|
|
1356
1377
|
}
|
|
1357
|
-
this.applyThemeToDOM();
|
|
1378
|
+
this.isExplicit && this.applyThemeToDOM();
|
|
1358
1379
|
}
|
|
1359
1380
|
}
|
|
1381
|
+
setTargetElement(t) {
|
|
1382
|
+
this.targetElement = t, this.isExplicit && this.applyThemeToDOM();
|
|
1383
|
+
}
|
|
1360
1384
|
setTheme(t) {
|
|
1361
|
-
if (
|
|
1362
|
-
this.currentTheme = t, this.applyThemeToDOM();
|
|
1385
|
+
if (N[t]) {
|
|
1386
|
+
this.currentTheme = t, this.isExplicit = !0, this.applyThemeToDOM();
|
|
1363
1387
|
try {
|
|
1364
|
-
localStorage.setItem(
|
|
1388
|
+
localStorage.setItem(P, t);
|
|
1365
1389
|
} catch {
|
|
1366
1390
|
}
|
|
1367
1391
|
}
|
|
1368
1392
|
}
|
|
1393
|
+
clearExplicitTheme() {
|
|
1394
|
+
this.isExplicit = !1;
|
|
1395
|
+
try {
|
|
1396
|
+
localStorage.removeItem(P);
|
|
1397
|
+
} catch {
|
|
1398
|
+
}
|
|
1399
|
+
this.removeThemeClasses();
|
|
1400
|
+
}
|
|
1369
1401
|
getTheme() {
|
|
1370
1402
|
return this.currentTheme;
|
|
1371
1403
|
}
|
|
1372
1404
|
getPalette() {
|
|
1373
|
-
return
|
|
1405
|
+
return N[this.currentTheme] || N.bioluminescent;
|
|
1406
|
+
}
|
|
1407
|
+
removeThemeClasses() {
|
|
1408
|
+
const t = ["theme-bioluminescent", "theme-dark", "theme-light"];
|
|
1409
|
+
this.targetElement && this.targetElement.classList.remove(...t), document.documentElement.classList.remove(...t), document.documentElement.removeAttribute("data-theme");
|
|
1374
1410
|
}
|
|
1375
1411
|
applyThemeToDOM() {
|
|
1376
|
-
|
|
1412
|
+
if (this.removeThemeClasses(), !this.isExplicit) return;
|
|
1413
|
+
const t = `theme-${this.currentTheme}`;
|
|
1414
|
+
this.targetElement && this.targetElement.classList.add(t), document.documentElement.classList.add(t);
|
|
1377
1415
|
}
|
|
1378
1416
|
}
|
|
1379
1417
|
class Q {
|
|
@@ -1746,7 +1784,7 @@ class nt {
|
|
|
1746
1784
|
ko: "한국어 (KO)",
|
|
1747
1785
|
zh: "中文 (ZH)"
|
|
1748
1786
|
};
|
|
1749
|
-
for (const y of
|
|
1787
|
+
for (const y of k) {
|
|
1750
1788
|
const g = document.createElement("option");
|
|
1751
1789
|
g.value = y, g.textContent = l[y], this.i18n.getLanguage() === y && (g.selected = !0), a.appendChild(g);
|
|
1752
1790
|
}
|
|
@@ -1825,7 +1863,7 @@ class nt {
|
|
|
1825
1863
|
this.modal.close();
|
|
1826
1864
|
}
|
|
1827
1865
|
}
|
|
1828
|
-
const
|
|
1866
|
+
const U = "axon_surge_show_tutorial";
|
|
1829
1867
|
class ot {
|
|
1830
1868
|
isActive = !1;
|
|
1831
1869
|
showWarning = !1;
|
|
@@ -1835,14 +1873,14 @@ class ot {
|
|
|
1835
1873
|
initialTargetPos = { x: 0, y: 0 };
|
|
1836
1874
|
isTutorialEnabled() {
|
|
1837
1875
|
try {
|
|
1838
|
-
return localStorage.getItem(
|
|
1876
|
+
return localStorage.getItem(U) !== "false";
|
|
1839
1877
|
} catch {
|
|
1840
1878
|
return !0;
|
|
1841
1879
|
}
|
|
1842
1880
|
}
|
|
1843
1881
|
setTutorialEnabled(t) {
|
|
1844
1882
|
try {
|
|
1845
|
-
localStorage.setItem(
|
|
1883
|
+
localStorage.setItem(U, String(t));
|
|
1846
1884
|
} catch {
|
|
1847
1885
|
}
|
|
1848
1886
|
}
|
|
@@ -2041,7 +2079,7 @@ class ct {
|
|
|
2041
2079
|
isRunning = !1;
|
|
2042
2080
|
isPaused = !1;
|
|
2043
2081
|
constructor(t) {
|
|
2044
|
-
this.container = t.root, this.container.classList.add("axon-game-root"), this.i18n = new Y(t.language), this.themeManager = new j(t.theme), this.platform = t.platform || new lt(), this.canvas = document.createElement("canvas"), this.canvas.className = "axon-canvas", this.container.appendChild(this.canvas), this.resizeCanvas(), window.addEventListener("resize", () => this.resizeCanvas()), this.eventBus = new
|
|
2082
|
+
this.container = t.root, this.container.classList.add("axon-game-root"), this.i18n = new Y(t.language), this.themeManager = new j(t.theme, this.container), this.platform = t.platform || new lt(), this.canvas = document.createElement("canvas"), this.canvas.className = "axon-canvas", this.container.appendChild(this.canvas), this.resizeCanvas(), window.addEventListener("resize", () => this.resizeCanvas()), this.eventBus = new B(), this.core = new K(this.canvas.width / 2, this.canvas.height / 2), this.inputManager = new W(this.canvas), this.physicsEngine = new z(this.eventBus, this.i18n), this.waveDirector = new q(), this.renderer = new it(this.canvas, this.themeManager), this.juice = new F(), this.settingsModal = new nt(
|
|
2045
2083
|
this.container,
|
|
2046
2084
|
this.i18n,
|
|
2047
2085
|
this.themeManager,
|
|
@@ -2054,7 +2092,7 @@ class ct {
|
|
|
2054
2092
|
this.isPaused = !0, this.settingsModal.show();
|
|
2055
2093
|
}), this.hud.show(), this.progressBar = new ht(this.hud.progressSlot, (e) => {
|
|
2056
2094
|
this.waveDirector.wave = e;
|
|
2057
|
-
}), this.startMenu = new at(this.container, this.i18n, () => this.startGame()), this.initAmbientArena(), this.gameLoop = new
|
|
2095
|
+
}), this.startMenu = new at(this.container, this.i18n, () => this.startGame()), this.initAmbientArena(), this.gameLoop = new H(
|
|
2058
2096
|
(e) => this.update(e),
|
|
2059
2097
|
() => this.render()
|
|
2060
2098
|
), this.setupEvents(), this.gameLoop.start();
|
|
@@ -2176,8 +2214,8 @@ function dt(E) {
|
|
|
2176
2214
|
export {
|
|
2177
2215
|
lt as BrowserPlatform,
|
|
2178
2216
|
ct as GameEngine,
|
|
2179
|
-
|
|
2217
|
+
k as LANGUAGES,
|
|
2180
2218
|
j as ThemeManager,
|
|
2181
2219
|
dt as createAxonSurge,
|
|
2182
|
-
|
|
2220
|
+
R as isLanguage
|
|
2183
2221
|
};
|
|
@@ -2,6 +2,7 @@ import type { Language, Translations } from "./locales";
|
|
|
2
2
|
export declare class I18nService {
|
|
3
3
|
private currentLanguage;
|
|
4
4
|
constructor(initialLanguage?: Language);
|
|
5
|
+
private detectLanguage;
|
|
5
6
|
setLanguage(language: Language): void;
|
|
6
7
|
getLanguage(): Language;
|
|
7
8
|
translate<K extends keyof Translations>(key: K, params?: Record<string, string | number>): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18nService.d.ts","sourceRoot":"","sources":["../../src/i18n/I18nService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAIxD,qBAAa,WAAW;IACpB,OAAO,CAAC,eAAe,CAAW;gBAEtB,eAAe,CAAC,EAAE,QAAQ;
|
|
1
|
+
{"version":3,"file":"I18nService.d.ts","sourceRoot":"","sources":["../../src/i18n/I18nService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAIxD,qBAAa,WAAW;IACpB,OAAO,CAAC,eAAe,CAAW;gBAEtB,eAAe,CAAC,EAAE,QAAQ;IAItC,OAAO,CAAC,cAAc;IAmCf,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IASrC,WAAW,IAAI,QAAQ;IAIvB,SAAS,CAAC,CAAC,SAAS,MAAM,YAAY,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM;CAW3G"}
|