Take damage when hitting mines

This commit is contained in:
Diego Marcos
2018-10-16 13:50:03 -07:00
parent 77e767db4f
commit 797a24c022
2 changed files with 10 additions and 1 deletions

View File

@@ -144,7 +144,7 @@ AFRAME.registerComponent('beat', {
var hitColliderConfiguration;
var hitColliderEl;
if (this.data.type === 'dot') { return; }
if (this.data.type === 'dot' || this.data.type === 'mine') { return; }
hitColliderConfiguration = {
position: {x: 0, y: data.size / 2, z: 0},
@@ -467,6 +467,11 @@ AFRAME.registerComponent('beat', {
if (saberBoundingBox.intersectsBox(beatBoundingBox)) {
this.el.parentNode.components['beat-hit-sound'].playSound(this.el);
this.destroyBeat(saberEls[i]);
if (this.data.type === 'mine') {
this.el.emit('minehit', null, true);
break;
}
if (this.data.type === 'dot' && saberEls[i].components['saber-controls'].swinging && this.data.color === saberColors[saberEls[i].getAttribute('saber-controls').hand]) {
this.el.emit('beathit', null, true);
} else {

View File

@@ -186,6 +186,10 @@ AFRAME.registerState({
state.menuSelectedChallenge.difficulty = difficulty;
},
minehit: state => {
takeDamage(state);
},
pausegame: (state) => {
if (!state.isPlaying) { return; }
state.isPaused = true;