From e0e99e99a57b745516fcdb9512a17170d6b20130 Mon Sep 17 00:00:00 2001 From: Diego Marcos Date: Fri, 12 Oct 2018 11:44:47 -1000 Subject: [PATCH] Dot beats can be cut from any direction --- src/components/beat.js | 13 ++++++++----- src/index.html | 4 ++-- src/state/index.js | 10 +++++----- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/components/beat.js b/src/components/beat.js index e45b628..b1d46d5 100644 --- a/src/components/beat.js +++ b/src/components/beat.js @@ -202,14 +202,14 @@ AFRAME.registerComponent('beat', { this.setObjModelFromTemplate(cutRightEl, this.models.dot); }, - wrongCut: function (hand) { + wrongHit: function (hand) { var wrongEl = hand === 'left' ? this.wrongElLeft : this.wrongElRight; if (!wrongEl) { return; } wrongEl.object3D.position.copy(this.el.object3D.position); wrongEl.object3D.position.y += 0.2; wrongEl.object3D.position.z -= 0.5; wrongEl.object3D.visible = true; - wrongEl.emit('beatwrong', null, false); + wrongEl.emit('wronghit', null, false); this.destroyed = true; }, @@ -421,16 +421,19 @@ AFRAME.registerComponent('beat', { saberBoundingBox = saberEls[i].components['saber-controls'].boundingBox; if (!boundingBox || !saberBoundingBox) { break; } if (saberBoundingBox.intersectsBox(boundingBox)) { - this.el.emit('beathit', null, false); + this.el.emit('goodhit', null, false); this.el.parentNode.components['beat-hit-sound'].playSound(this.el); this.destroyBeat(saberEls[i]); break; } if (saberBoundingBox.intersectsBox(beatBoundingBox)) { - this.el.emit('beathit', null, false); this.el.parentNode.components['beat-hit-sound'].playSound(this.el); this.destroyBeat(saberEls[i]); - this.wrongCut(saberEls[i].getAttribute('saber-controls').hand); + if (this.data.type === 'dot') { + this.el.emit('goodhit', null, false); + } else { + this.wrongHit(saberEls[i].getAttribute('saber-controls').hand); + } break; } } diff --git a/src/index.html b/src/index.html index f23fde9..e3ef752 100644 --- a/src/index.html +++ b/src/index.html @@ -93,8 +93,8 @@ geometry="primitive: plane" material="shader: flat; transparent: true" visible="false" - animation__posz="property: object3D.position.z; to: -8; startEvents: beatwrong; easing: easeOutQuart; dur: 4000" - animation__alpha="property: components.material.material.opacity; from: 1; to: 0; startEvents: beatwrong; easing: easeOutQuart; dur: 4000"> + animation__posz="property: object3D.position.z; to: -8; startEvents: wronghit; easing: easeOutQuart; dur: 4000" + animation__alpha="property: components.material.material.opacity; from: 1; to: 0; startEvents: wronghit; easing: easeOutQuart; dur: 4000"> diff --git a/src/state/index.js b/src/state/index.js index 819b9e6..a4e762d 100644 --- a/src/state/index.js +++ b/src/state/index.js @@ -83,7 +83,7 @@ AFRAME.registerState({ localStorage.setItem('activeHand', state.activeHand); }, - beathit: state => { + goodhit: state => { if (state.damage > DAMAGE_DECAY) { state.damage -= DAMAGE_DECAY; } @@ -98,10 +98,6 @@ AFRAME.registerState({ takeDamage(state); }, - beatwrong: state => { - takeDamage(state); - }, - beatloaderfinish: (state) => { state.challenge.isLoading = false; }, @@ -248,6 +244,10 @@ AFRAME.registerState({ victory: function (state) { state.isVictory = true; + }, + + wronghit: state => { + takeDamage(state); } },