From 5e0e243592de74407528c40ff0ba6050f41c2b52 Mon Sep 17 00:00:00 2001 From: Kevin Ngo Date: Thu, 25 Oct 2018 07:17:08 -0700 Subject: [PATCH] victory rank color --- src/components/victory-rank.js | 45 +++++++++++++++++++++++++++++++++ src/index.html | 4 ++- src/state/index.js | 18 ++++++++++--- src/templates/gameMenu.html | 42 ++----------------------------- src/templates/loading.html | 4 ++- src/templates/menu.html | 2 ++ src/templates/victory.html | 46 ++++++++++++++++++++++++++++++++++ 7 files changed, 116 insertions(+), 45 deletions(-) create mode 100644 src/components/victory-rank.js create mode 100644 src/templates/victory.html diff --git a/src/components/victory-rank.js b/src/components/victory-rank.js new file mode 100644 index 0000000..18cf81c --- /dev/null +++ b/src/components/victory-rank.js @@ -0,0 +1,45 @@ +/** + * Rank color. + */ +AFRAME.registerComponent('victory-rank', { + schema: { + rank: {type: 'string'} + }, + + update: function () { + const rank = this.data.rank; + if (!rank) { return; } + + this.el.setAttribute('text', 'value', rank); + switch (rank[0]) { + case 'S': { + this.setColor('#FFF'); + break; + } + case 'A': { + this.setColor('#c2d076'); + break; + } + case 'B': { + this.setColor('#23f0c7'); + break; + } + case 'C': { + this.setColor('#ffe347'); + break; + } + case 'D': { + this.setColor('#ce6c47'); + break; + } + case 'F': { + this.setColor('##960200'); + break; + } + } + }, + + setColor: function (color) { + this.el.setAttribute('text', 'color', color); + } +}); diff --git a/src/index.html b/src/index.html index 16f293b..5f2bbc2 100644 --- a/src/index.html +++ b/src/index.html @@ -30,7 +30,7 @@ effect-bloom="strength: 1" gpu-preloader loading-screen="backgroundColor: #000;" - overlay="objects: #menu, #keyboard, #rightHand, #leftHand, [mixin~='cursorMesh'], #gameMenu, #stepback, #loadingSongInfoContainer" + overlay="objects: #rightHand, #leftHand, [mixin~='cursorMesh'], .overlay" pool__beat-arrow-blue="mixin: arrowBlueBeat; size: 5; container: #beatContainer" pool__beat-arrow-red="mixin: arrowRedBeat; size: 10; container: #beatContainer" pool__beat-dot-blue="mixin: dotBlueBeat; size: 10; container: #beatContainer" @@ -65,6 +65,7 @@ {% include './templates/score.html' %} {% include './templates/menu.html' %} {% include './templates/gameMenu.html' %} + {% include './templates/victory.html' %} @@ -186,6 +187,7 @@ diff --git a/src/state/index.js b/src/state/index.js index 466907d..2b8be7a 100644 --- a/src/state/index.js +++ b/src/state/index.js @@ -351,12 +351,24 @@ AFRAME.registerState({ if (accuracy === 1) { state.rank = 'S'; - } else if (accuracy >= .90) { + } else if (accuracy >= .98) { + state.rank = 'A+'; + } else if (accuracy >= .93) { state.rank = 'A'; - } else if (accuracy >= .80) { + } else if (accuracy >= .9) { + state.rank = 'A-'; + } else if (accuracy >= .88) { + state.rank = 'B+'; + } else if (accuracy >= .83) { state.rank = 'B'; - } else if (accuracy >= .70) { + } else if (accuracy >= .8) { + state.rank = 'B-'; + } else if (accuracy >= .78) { + state.rank = 'C+'; + } else if (accuracy >= .73) { state.rank = 'C'; + } else if (accuracy >= .7) { + state.rank = 'C-'; } else if (accuracy >= .60) { state.rank = 'D'; } else { diff --git a/src/templates/gameMenu.html b/src/templates/gameMenu.html index c494121..247fa98 100644 --- a/src/templates/gameMenu.html +++ b/src/templates/gameMenu.html @@ -1,5 +1,6 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/templates/loading.html b/src/templates/loading.html index b441332..09d67e7 100644 --- a/src/templates/loading.html +++ b/src/templates/loading.html @@ -1,4 +1,6 @@ - @@ -232,6 +233,7 @@ + + + + + + + + + + + + + + + + + +