feat: implemented checkpoint
This commit is contained in:
parent
c38273f1a3
commit
832e42affa
|
@ -51,7 +51,8 @@
|
||||||
"y": 10,
|
"y": 10,
|
||||||
"possibility": 1
|
"possibility": 1
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"checkPoint": [5, 19, 5, 5]
|
||||||
},
|
},
|
||||||
"exit": {
|
"exit": {
|
||||||
"width": 30,
|
"width": 30,
|
||||||
|
|
|
@ -173,6 +173,8 @@ export default class GameLevel extends Scene {
|
||||||
|
|
||||||
this.startpos = this.rmg.getPlayer().scale(32);
|
this.startpos = this.rmg.getPlayer().scale(32);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//call super after extending story with scene
|
//call super after extending story with scene
|
||||||
|
|
||||||
|
|
||||||
|
@ -191,6 +193,9 @@ export default class GameLevel extends Scene {
|
||||||
this.subscribeToEvents();
|
this.subscribeToEvents();
|
||||||
this.addUI();
|
this.addUI();
|
||||||
|
|
||||||
|
const checkPoint = this.rmg.getCheckPoint();
|
||||||
|
this.addLevelEnd(new Vec2(checkPoint[0], checkPoint[1]), new Vec2(checkPoint[2], checkPoint[3]));
|
||||||
|
|
||||||
// Create an enemies array
|
// Create an enemies array
|
||||||
// Send the player and enemies to the battle manager
|
// Send the player and enemies to the battle manager
|
||||||
this.battleManager.setPlayers([<PlayerController>this.player._ai]);
|
this.battleManager.setPlayers([<PlayerController>this.player._ai]);
|
||||||
|
@ -900,6 +905,13 @@ export default class GameLevel extends Scene {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected addLevelEnd(startingTile: Vec2, size: Vec2): void {
|
||||||
|
this.levelEndArea = <Rect>this.add.graphic(GraphicType.RECT, "primary", {position: startingTile.scale(32), size: size.scale(32)});
|
||||||
|
this.levelEndArea.addPhysics(undefined, undefined, false, true);
|
||||||
|
// this.levelEndArea.setTrigger("player", somelevelendevent, null);
|
||||||
|
this.levelEndArea.color = new Color(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* damages the player if they collide with an enemy
|
* damages the player if they collide with an enemy
|
||||||
|
|
|
@ -25,6 +25,7 @@ export default class RandomMapGenerator {
|
||||||
private exitFacing: Facing;
|
private exitFacing: Facing;
|
||||||
private enemies: Array<Enemy>;
|
private enemies: Array<Enemy>;
|
||||||
private player: Vec2;
|
private player: Vec2;
|
||||||
|
private checkPoint: [number, number, number, number];
|
||||||
|
|
||||||
constructor(JSONFilePath: string, seed: any) {
|
constructor(JSONFilePath: string, seed: any) {
|
||||||
let xhr = new XMLHttpRequest();
|
let xhr = new XMLHttpRequest();
|
||||||
|
@ -44,6 +45,7 @@ export default class RandomMapGenerator {
|
||||||
this.rooms = new Array();
|
this.rooms = new Array();
|
||||||
this.enemies = new Array();
|
this.enemies = new Array();
|
||||||
this.player = new Vec2();
|
this.player = new Vec2();
|
||||||
|
this.checkPoint = [0,0,0,0];
|
||||||
let gen = require('random-seed');
|
let gen = require('random-seed');
|
||||||
this.gen = new gen(seed);
|
this.gen = new gen(seed);
|
||||||
this.hasExit = false;
|
this.hasExit = false;
|
||||||
|
@ -115,6 +117,10 @@ export default class RandomMapGenerator {
|
||||||
return new Vec2(this.player.x - this.minX, this.player.y - this.minY);
|
return new Vec2(this.player.x - this.minX, this.player.y - this.minY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCheckPoint(): [number, number, number, number] {
|
||||||
|
return [this.checkPoint[0] - this.minX, this.checkPoint[1] - this.minY, this.checkPoint[2], this.checkPoint[3]];
|
||||||
|
}
|
||||||
|
|
||||||
getEnemies(): Array<Enemy> {
|
getEnemies(): Array<Enemy> {
|
||||||
return this.enemies;
|
return this.enemies;
|
||||||
}
|
}
|
||||||
|
@ -372,6 +378,11 @@ export default class RandomMapGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (old.checkPoint) {
|
||||||
|
this.checkPoint = [...old.checkPoint];
|
||||||
|
this.checkPoint[0] += posX;
|
||||||
|
this.checkPoint[1] += posY;
|
||||||
|
}
|
||||||
if (posX < this.minX)
|
if (posX < this.minX)
|
||||||
this.minX = posX;
|
this.minX = posX;
|
||||||
if (posY < this.minY)
|
if (posY < this.minY)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user