victory rank color

This commit is contained in:
Kevin Ngo
2018-10-25 07:17:08 -07:00
parent d5bb21253c
commit 5e0e243592
7 changed files with 116 additions and 45 deletions

View File

@@ -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);
}
});