-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathRedBlock.js
More file actions
30 lines (26 loc) · 1.01 KB
/
RedBlock.js
File metadata and controls
30 lines (26 loc) · 1.01 KB
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
class RedBlock extends SwitchableBlock {
constructor(x, y, tileSize, type, tilemapHandler, extraAttributes = {}) {
super(x, y, tileSize, type, tilemapHandler, AnimationHelper.switchableBlockColors.red, extraAttributes);
this.setBlockState(this.activeTileIndex, true);
this.checkCurrentlyActiveBlock();
}
resetObject() {
if(this.tilemapHandler && !PlayMode.checkActiveCheckPoints()) {
this.setBlockState(this.activeTileIndex, true);
}
}
checkCurrentlyActiveBlock(){
const result = this?.tilemapHandler?.levelObjects && this.tilemapHandler.levelObjects.find(levelObject => levelObject.type === ObjectTypes.RED_BLUE_BLOCK_SWITCH);
if(!result) {
this.setBlockState(this.activeTileIndex, true);
}
else if(result.currentlyActiveColor === this.color) {
this.setBlockState(this.activeTileIndex, true);
}
else {
this.setBlockState(0, false);
}
}
collisionEvent() {
}
}