Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Created by Zergur Vorghiz
- /* Changelog:
- 5/15/2020
- - Early in the morning: Started development
- - Later that day: Initial release
- */
- // --------------------------------------------------------------------------------------------------------------
- shieldBarScale = function (gen, totl) {
- maxx = (gen * 16) + totl;
- if (maxx === 0) {
- return 0;
- } else if (maxx < 500) {
- return 0.5;
- } else if(maxx < 5000) {
- return 1.58;
- } else if(maxx < 200000) {
- return 5;
- } else {
- return 15.81
- }
- }
- colors.redOrOrange = function(c) {
- if (c[1] > 75) {
- return [255, 0, 0, 255]
- } else {
- return [255, 150, 0, 255]
- }
- };
- _pipPos = v2.create()
- types.Unit.prototype.drawHPBar = function() {
- var burnColor, color, healthScale, i, j, max, number, pipScale, ref, results, s;
- burnColor = colors.redOrOrange(this.color);
- max = this.maxHP;
- if (max < 1000) {
- healthScale = 10;
- pipScale = 0.5;
- } else if(max < 10000) {
- healthScale = 100;
- pipScale = 1.58;
- } else if(max < 100000) {
- healthScale = 1000;
- pipScale = 5;
- } else {
- healthScale = 10000;
- pipScale = 15.81;
- }
- number = Math.round(this.maxHP / healthScale);
- results = [];
- for (i = j = 0, ref = number; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
- s = 20;
- _pipPos[0] = (i * s - number * s / 2 - s / 2) * pipScale;
- _pipPos[1] = [(this.radius * -0.8) - 100 + ((pipScale + shieldBarScale(this.genShield, this.maxShield)) * 18)];
- if (i < Math.round(this.maxHP / healthScale)) {
- if (i < Math.round(this.hp / healthScale)) {
- color = [this.color[0], this.color[1], this.color[2], 255];
- } else {
- color = [20, 20, 20, 150];
- }
- if (i < this.cloak / this.mass * this.maxHP / healthScale) {
- color[3] = 80;
- } else if (this.cloakFade > 0) {
- color[3] = 180;
- }
- } else {
- if (i < Math.round(this.maxHP / healthScale)) {
- color = [this.color[0], this.color[1], this.color[2], 100];
- } else {
- color = [0, 0, 0, 60];
- }
- }
- v2.add(this.pos, _pipPos, _pipPos);
- baseAtlas.drawSprite("img/pip1.png", _pipPos, [pipScale, pipScale], 0, color);
- if (Math.round((this.hp + this.shield - this.burn) / healthScale) < i && i < Math.round(this.hp / healthScale)) {
- results.push(baseAtlas.drawSprite("img/unitBar/flame.png", _pipPos, [pipScale * .25, pipScale * .25], Math.PI, burnColor));
- } else {
- results.push(void 0);
- }
- }
- return results;
- };
- types.Unit.prototype.drawShieldBar = function() {
- var burnColor, color, healthScale, i, j, max, number, pipScale, ref, results, s;
- burnColor = colors.redOrOrange(this.color);
- max = (this.genShield * 16) + this.maxShield;
- if (max < 500) {
- healthScale = 10;
- pipScale = 0.5;
- } else if(max < 5000) {
- healthScale = 100;
- pipScale = 1.58;
- } else if(max < 200000) {
- healthScale = 1000;
- pipScale = 5;
- } else {
- healthScale = 50000;
- pipScale = 15.81;
- }
- number = Math.round(((this.genShield * 16) + this.maxShield) / healthScale);
- results = [];
- for (i = j = 0, ref = number; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
- s = 20;
- _pipPos[0] = (i * s - number * s / 2 - s / 2) * pipScale;
- _pipPos[1] = [(this.radius * -0.8) - 100];
- if (i < ((Math.round(this.genShield * 16) + Math.round(this.maxShield)) / healthScale)) {
- if (i < Math.round((this.genShield * 16) / healthScale)) {
- color = [this.color[0], this.color[1], this.color[2], 220];
- } else if (i <= Math.round(this.genShield * 16 / healthScale) + Math.round(this.shield / healthScale)) {
- color = [this.color[0], this.color[1], this.color[2], 140];
- } else {
- color = [255, 255, 255, 30];
- }
- }
- v2.add(this.pos, _pipPos, _pipPos);
- if (i >= Math.round((this.genShield * 16) / healthScale)) {
- baseAtlas.drawSprite("img/pip1.png", _pipPos, [pipScale, pipScale], 0, color);
- } else {
- results.push(baseAtlas.drawSprite("img/unitBar/energyPip.png", _pipPos, [pipScale, pipScale], 0, color));
- }
- if (((this.genShield * 16) + this.maxShield - this.burn) / healthScale <= i && i >= Math.round((this.genShield * 16) / healthScale)) {
- results.push(baseAtlas.drawSprite("img/unitBar/flame.png", _pipPos, [pipScale * .25, pipScale * .25], Math.PI, burnColor));
- }
- }
- return results;
- };
- types.Unit.prototype.drawEnergyBar = function() {
- var color, healthScale, i, j, max, number, pipScale, ref, results, s;
- max = this.storeEnergy;
- if (max < 48001) {
- healthScale = 1000;
- pipScale = 0.4;
- } else if(max < 160001){
- healthScale = 8000;
- pipScale = 1.13;
- } else {
- healthScale = 32000;
- pipScale = 2.26;
- }
- number = Math.round(this.storeEnergy / healthScale);
- results = [];
- for (i = j = 0, ref = number; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
- s = 20;
- _pipPos[0] = (i * s - number * s / 2 - s / 2) * pipScale;
- _pipPos[1] = [(this.radius * -0.8) - 100 - ((pipScale + shieldBarScale(this.genShield, this.maxShield)) * 18)];
- if (i < this.energy / healthScale) {
- color = [80, 255, 255, 255];
- } else {
- color = [20, 20, 20, 80];
- }
- v2.add(this.pos, _pipPos, _pipPos);
- results.push(baseAtlas.drawSprite("img/unitBar/energyPip.png", _pipPos, [pipScale, pipScale], 0, color));
- }
- return results;
- };
- types.Unit.prototype.drawSelection = function() {
- var alpha, angle, distance, i, j, len, order, orders, prev, results, target;
- this.drawHPBar();
- this.drawEnergyBar();
- this.drawShieldBar();
- if (this.holdPosition) {
- baseAtlas.drawSprite("img/unitBar/circle.png", this.pos, [1, 1], 0, [255, 255, 255, 100]);
- }
- while (this.preOrders.length > 0 && this.preOrders[0].id < this.onOrderId) {
- this.preOrders.shift();
- }
- if (!battleMode.shiftOrder && battleMode.ordering) {
- return;
- }
- if (this.owner === commander.number) {
- prev = this.pos;
- orders = this.preOrders;
- results = [];
- for (i = j = 0, len = orders.length; j < len; i = ++j) {
- order = orders[i];
- if (order.type === "Move") {
- if (order.dest == null) {
- continue;
- }
- distance = v2.distance(order.dest, prev);
- if (i === 0 && distance < 255 + 10) {
- alpha = distance - 10;
- } else {
- alpha = 255;
- }
- angle = v2.angle(v2.sub(order.dest, prev, v2.create()));
- if (orders.length - 1 === i) {
- baseAtlas.drawSprite("img/arrow01.png", order.dest, [.9, .9], angle, [255, 255, 255, alpha]);
- } else {
- baseAtlas.drawSprite("img/arrow01.png", order.dest, [.8, .8], angle, [255, 255, 255, alpha]);
- }
- results.push(prev = order.dest);
- } else if (order.type === "Follow") {
- target = intp.things[order.targetId];
- if (target != null) {
- results.push(baseAtlas.drawSprite("img/unitBar/target.png", target.pos, [1, 1], 0, [255, 0, 0, 100]));
- } else {
- results.push(void 0);
- }
- } else {
- results.push(void 0);
- }
- }
- return results;
- }
- };
Add Comment
Please, Sign In to add comment