Fix restart state and pirate volley damage
This commit is contained in:
parent
47c251208c
commit
6e68a6ddb1
28
src/game-entry.js
Normal file
28
src/game-entry.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import Phaser from 'phaser';
|
||||||
|
|
||||||
|
const originalRestart = Phaser.Scenes.ScenePlugin.prototype.restart;
|
||||||
|
Phaser.Scenes.ScenePlugin.prototype.restart = function restartWithFreshRunState(data) {
|
||||||
|
const scene = this.scene;
|
||||||
|
|
||||||
|
if (scene?.sys?.settings?.key === 'game') {
|
||||||
|
scene.playerSpeed = 0;
|
||||||
|
scene.playerHull = 100;
|
||||||
|
scene.gameState = 'playing';
|
||||||
|
scene.lastPlayerShot = 0;
|
||||||
|
scene.wave = 1;
|
||||||
|
scene.defeated = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return originalRestart.call(this, data);
|
||||||
|
};
|
||||||
|
|
||||||
|
const originalSetData = Phaser.GameObjects.GameObject.prototype.setData;
|
||||||
|
Phaser.GameObjects.GameObject.prototype.setData = function setBalancedDamage(key, value) {
|
||||||
|
if (key === 'damage' && this.texture?.key === 'pirate-shot') {
|
||||||
|
value = Math.min(Number(value) || 0, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return originalSetData.call(this, key, value);
|
||||||
|
};
|
||||||
|
|
||||||
|
await import('./game-v4.js');
|
||||||
Loading…
x
Reference in New Issue
Block a user