optimization: new methods

This commit is contained in:
cha0s 2019-04-24 02:46:08 -05:00
parent 73bb7e1477
commit 3dc6596483

View File

@ -3,29 +3,39 @@ import {Proton, TextNode, TextNodeRenderer} from '@avocado/graphics';
class DamageTextNode extends TextNode {
constructor(damage) {
const {amount, damageSpec, isDamage} = damage;
const {amount} = damage;
super(amount);
this.damage = damage;
}
sizeInPx() {
const {amount} = this.damage;
// Big numbers are literally big.
if (amount > 999) {
this.span.style.fontSize = '12px';
return 12;
}
else if (amount > 99) {
this.span.style.fontSize = '10px';
return 10;
}
else if (amount > 9) {
this.span.style.fontSize = '8px';
return 8;
}
else {
this.span.style.fontSize = '6px';
return 6;
}
// Class by affinity and whether it's damage or healing.
this.span.className += ' ' + damageSpec.affinity;
}
spanClassName() {
const {damageSpec, isDamage} = this.damage;
let className = super.spanClassName();
className += ' ' + damageSpec.affinity;
if (isDamage) {
this.span.className += ' is-damage';
className += ' is-damage';
}
else {
this.span.className += ' is-healing';
className += ' is-healing';
}
return className;
}
copyFrom(other) {
@ -68,7 +78,7 @@ export class DamageEmitter {
];
// Heh, bugs.
const rot = new Proton.Rotate(0, 0, 0);
rot.a = new Proton.Span(-.008, .008);
rot.a = new Proton.Span(-.05, .05);
const behaviors = [
new Proton.Alpha(1, .25),
new Proton.Scale(.8, 1.2),