diff --git a/src/components/text-counter.js b/src/components/text-counter.js index 54c9f7e..de83375 100644 --- a/src/components/text-counter.js +++ b/src/components/text-counter.js @@ -1,16 +1,21 @@ AFRAME.registerComponent('text-counter', { dependencies: ['text'], + schema: { - value: {default: 0.0, type: 'float'}, + decimals: {default: 0}, dur: {default: 2000, type: 'int'}, + emit: {default: false}, prefix: {default: ''}, suffix: {default: ''}, - decimals: {default: 0} + value: {default: 0.0, type: 'float'} }, init: function () { this.startTime = null; - this.currentValue = -1; + this.currentValue = 0; + this.textValue = {value : ''}; + this.victoryInfoRank = document.getElementById('victoryInfoRank'); + this.victoryButtons = document.getElementById('victoryButtons'); }, decimals: function (n) { @@ -20,27 +25,26 @@ AFRAME.registerComponent('text-counter', { update: function (oldData) { this.startTime = null; - this.currentValue = -1; - this.el.setAttribute('text', { - value: `${this.data.prefix} ${this.decimals(0)} ${this.data.suffix}` - }); + this.currentValue = 0; + this.textValue.value = `${this.data.prefix} ${this.decimals(0)} ${this.data.suffix}`; + this.el.setAttribute('text', this.textValue); }, tick: function (time) { - if (this.currentValue < this.data.value) { - if (this.startTime === null) { this.startTime = time}; - const prevValue = Math.floor(this.currentValue); - this.currentValue = this.data.value * (time - this.startTime) / this.data.dur; - if (Math.floor(this.currentValue) !== prevValue) { - if (this.currentValue >= this.data.value) { - this.currentValue = this.data.value; - document.getElementById('victoryInfoRank').emit('appear'); - document.getElementById('victoryButtons').emit('appear'); - } - this.el.setAttribute('text', { - value: `${this.data.prefix} ${this.decimals(this.currentValue)} ${this.data.suffix}` - }); + if (this.currentValue >= this.data.value) { return; } + if (this.startTime === null) { this.startTime = time; return; }; + const prevValue = Math.floor(this.currentValue); + this.currentValue = this.data.value * (time - this.startTime) / this.data.dur; + if (Math.floor(this.currentValue) === prevValue) { return; } + if (this.currentValue >= this.data.value) { + this.currentValue = this.data.value; + if (this.data.emit) { + console.log(this.currentValue, this.data.value); + this.victoryInfoRank.emit('textcounterdone', null, false); + this.victoryButtons.emit('textcounterdone', null, false); } } + this.textValue.value = `${this.data.prefix} ${this.decimals(this.currentValue)} ${this.data.suffix}`; + this.el.setAttribute('text', this.textValue); } }) \ No newline at end of file diff --git a/src/components/victory-accuracy-ring.js b/src/components/victory-accuracy-ring.js index fdf9a91..2b71872 100644 --- a/src/components/victory-accuracy-ring.js +++ b/src/components/victory-accuracy-ring.js @@ -10,7 +10,7 @@ AFRAME.registerComponent('victory-accuracy-ring', { update: function () { this.el.getObject3D('mesh').material.uniforms.progress.value = 0; - this.el.setAttribute('animation', 'to', this.data.accuracy); + this.el.setAttribute('animation', 'to', this.data.accuracy / 100); this.el.components['animation'].beginAnimation(); } }); diff --git a/src/state/index.js b/src/state/index.js index 15b9692..2835614 100644 --- a/src/state/index.js +++ b/src/state/index.js @@ -7,7 +7,7 @@ const SONG_NAME_TRUNCATE = 24; const SONG_SUB_NAME_TRUNCATE = 32; const DAMAGE_DECAY = 0.25; -const DAMAGE_MAX = 1000000; +const DAMAGE_MAX = 10; const DEBUG_CHALLENGE = { author: 'Superman', diff --git a/src/templates/gameMenu.html b/src/templates/gameMenu.html index c73930d..54f59c8 100644 --- a/src/templates/gameMenu.html +++ b/src/templates/gameMenu.html @@ -55,33 +55,6 @@ - - - - - - - - - - - - diff --git a/src/templates/victory.html b/src/templates/victory.html index 7bfd116..7ad5a0f 100644 --- a/src/templates/victory.html +++ b/src/templates/victory.html @@ -27,15 +27,15 @@ bind__victory-rank="rank: score.rank" scale="0 0 0" position="0 0.2 0.05" - animation__rotation="property: object3D.rotation.y; from: 0; to: -360; loop: true; easing: linear; dur: 5000; startEvents: appear" - animation__scale="property: scale; to: 1 1 1; loop: false; easing: easeOutQuad; dur: 300; startEvents: appear" + animation__rotation="property: object3D.rotation.y; from: 0; to: -360; loop: true; easing: linear; dur: 5000; startEvents: textcounterdone" + animation__scale="property: scale; from: 0 0 0; to: 1 1 1; loop: false; easing: easeOutQuad; dur: 300; startEvents: textcounterdone" text="wrapCount: 2; align: center; baseline: top; width: 0.82; side: double"> @@ -50,9 +50,35 @@ id="victoryInfoMaxCombo" mixin="font" text="align: center; color: #FAFAFA; wrapCount: 22; baseline: top; width: 1" - text-counter="prefix: MAX COMBO: ;" + text-counter="prefix: MAX COMBO: " bind__text-counter="value: score.maxCombo" position="0 -0.3 0"> + + + + + + + + + +