start victory screen stats

This commit is contained in:
Kevin Ngo
2018-10-16 02:57:07 -07:00
parent 251a6ca822
commit abc3f73800
2 changed files with 64 additions and 6 deletions

View File

@@ -56,9 +56,14 @@ AFRAME.registerState({
},
multiplierText: '1x',
score: {
accuracy: '',
beatsHit: 0,
beatsMissed: 0,
combo: 0,
score: 0,
multiplier: 1
maxCombo: 0,
multiplier: 1,
rank: '',
score: 0
},
search: {
active: true,
@@ -85,16 +90,24 @@ AFRAME.registerState({
if (state.damage > DAMAGE_DECAY) {
state.damage -= DAMAGE_DECAY;
}
state.score.score += 1;
state.score.combo += 1;
state.score.multiplier = state.score.combo >= 8 ? 8 : 2 * Math.floor(Math.log2(state.score.combo));
state.score.beatsHit++;
state.score.score++;
state.score.combo++;
if (state.score.combo > state.score.maxCombo) {
state.score.maxCombo = state.score.combo;
}
state.score.multiplier = state.score.combo >= 8
? 8
: 2 * Math.floor(Math.log2(state.score.combo));
},
beatmiss: state => {
state.score.beatsMissed++;
takeDamage(state);
},
beatwrong: state => {
state.score.beatsMissed++;
takeDamage(state);
},
@@ -252,6 +265,23 @@ AFRAME.registerState({
victory: function (state) {
state.isVictory = true;
const accuracy = state.beatsHit / (state.beatsMissed + state.beatsHit);
state.score.accuracy = `${(accuracy * 100).toFixed()}%`;
if (accuracy === 1) {
state.rank = 'S';
} else if (accuracy >= .90) {
state.rank = 'A';
} else if (accuracy >= .80) {
state.rank = 'B';
} else if (accuracy >= .70) {
state.rank = 'C';
} else if (accuracy >= .60) {
state.rank = 'D';
} else {
state.rank = 'F';
}
},
wallhitstart: function (state) {
@@ -345,7 +375,10 @@ function checkGameOver (state) {
function resetScore (state) {
state.damage = 0;
state.score.beatsHit = 0;
state.score.beatsMissed = 0;
state.score.combo = 0;
state.score.maxCombo = 0;
state.score.score = 0;
state.score.multiplier = 1;
}

View File

@@ -49,7 +49,7 @@
<a-entity mixin="gameMenuButtonText" text="value: EXIT TO MENU"></a-entity>
</a-entity>
<a-entity id="gameMenuSongInfoContainer" position="1.64 -0.12 0.798" rotation="0 -55 0">
<a-entity id="gameMenuSongInfoContainer" position="-1.64 -0.12 0.798" rotation="0 55 0">
<a-entity mixin="slice" slice9="width: 0.77; height: 1; padding: 0.04" position="0 0.110 -0.03"></a-entity>
<a-entity id="gameMenuSongImage"
@@ -65,4 +65,29 @@
mixin="textFont" text="align: center; color: #FF185B; wrapCount: 22; baseline: top; lineHeight: 36; width: 0.81"
bind__text="value: menuSelectedChallenge.songName"></a-entity>
</a-entity>
</a-entity>
<a-entity id="victoryInfoContainer" position="1.64 -0.12 0.798" rotation="0 -55 0" bind__visible="isVictory">
<a-entity mixin="slice" slice9="width: 0.77; height: 1; padding: 0.04" position="0 0.110 -0.03"></a-entity>
<a-entity id="victoryInfo" layout="type: box; columns: 1; margin: -0.9">
<a-entity
id="victoryInfoRank"
mixin="textFont"
text="wrapCount: 40; align: center; color: #FF185B"
bind__text="value: score.rank"></a-entity>
<a-entity
id="victoryInfoScore"
mixin="textFont"
text="wrapCount: 40; align: center; color: #FF185B"
bind__text="value: score.score"></a-entity>
<a-entity
id="victoryInfoAccuracy"
mixin="textFont"
text="align: center; color: #FF185B; wrapCount: 22; baseline: top; lineHeight: 36; width: 0.81"
bind__text="value: score.accuracy"></a-entity>
</a-entity>
</a-entity>
</a-entity>