Check that saber and hit beat match color (fix #116)
This commit is contained in:
@@ -60,6 +60,11 @@ AFRAME.registerComponent('beat', {
|
|||||||
|
|
||||||
this.particles = document.getElementById('saberParticles');
|
this.particles = document.getElementById('saberParticles');
|
||||||
|
|
||||||
|
this.saberColors = {
|
||||||
|
right: 'blue',
|
||||||
|
left: 'red'
|
||||||
|
};
|
||||||
|
|
||||||
this.initBlock();
|
this.initBlock();
|
||||||
this.initColliders();
|
this.initColliders();
|
||||||
this.initFragments();
|
this.initFragments();
|
||||||
@@ -436,6 +441,7 @@ AFRAME.registerComponent('beat', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
checkCollisions: function () {
|
checkCollisions: function () {
|
||||||
|
const saberColors = this.saberColors;
|
||||||
const saberEls = this.saberEls;
|
const saberEls = this.saberEls;
|
||||||
const hitBoundingBox = this.hitColliderEl && this.hitBoundingBox.setFromObject(
|
const hitBoundingBox = this.hitColliderEl && this.hitBoundingBox.setFromObject(
|
||||||
this.hitColliderEl.getObject3D('mesh'));
|
this.hitColliderEl.getObject3D('mesh'));
|
||||||
@@ -448,7 +454,8 @@ AFRAME.registerComponent('beat', {
|
|||||||
if (!saberBoundingBox) { break; }
|
if (!saberBoundingBox) { break; }
|
||||||
|
|
||||||
if (hitBoundingBox && saberBoundingBox.intersectsBox(hitBoundingBox)) {
|
if (hitBoundingBox && saberBoundingBox.intersectsBox(hitBoundingBox)) {
|
||||||
if (saberEls[i].components['saber-controls'].swinging) {
|
debugger;
|
||||||
|
if (saberEls[i].components['saber-controls'].swinging && this.data.color === saberColors[saberEls[i].getAttribute('saber-controls').hand]) {
|
||||||
this.el.emit('beathit', null, true);
|
this.el.emit('beathit', null, true);
|
||||||
} else {
|
} else {
|
||||||
this.wrongHit(saberEls[i].getAttribute('saber-controls').hand);
|
this.wrongHit(saberEls[i].getAttribute('saber-controls').hand);
|
||||||
@@ -461,7 +468,7 @@ AFRAME.registerComponent('beat', {
|
|||||||
if (saberBoundingBox.intersectsBox(beatBoundingBox)) {
|
if (saberBoundingBox.intersectsBox(beatBoundingBox)) {
|
||||||
this.el.parentNode.components['beat-hit-sound'].playSound(this.el);
|
this.el.parentNode.components['beat-hit-sound'].playSound(this.el);
|
||||||
this.destroyBeat(saberEls[i]);
|
this.destroyBeat(saberEls[i]);
|
||||||
if (this.data.type === 'dot' && saberEls[i].components['saber-controls'].swinging) {
|
if (this.data.type === 'dot' && saberEls[i].components['saber-controls'].swinging && saberColors[saberEls[i].getAttribute('saber-controls').hand]) {
|
||||||
this.el.emit('beathit', null, true);
|
this.el.emit('beathit', null, true);
|
||||||
} else {
|
} else {
|
||||||
this.wrongHit(saberEls[i].getAttribute('saber-controls').hand);
|
this.wrongHit(saberEls[i].getAttribute('saber-controls').hand);
|
||||||
|
|||||||
Reference in New Issue
Block a user