January 28, 2014♦
☀
E
F
F
L
U
E
N
C
E
☀
EVR.Level.Countdown.Glyph = function(container, character, is_shadow)
{
EVR.Graphic.call(this, container, RATIO_HEIGHT, null, ALIGN_CENTER);
this.is_shadow = is_shadow || false;
this.character = character;
this.color = COUNTDOWN_COLOR;
this.size = COUNTDOWN_FONT_SIZE;
this.build();
}
EVR.Level.Countdown.Glyph.prototype = new EVR.Graphic;
EVR.Level.Countdown.Glyph.prototype.build = function()
{
this.set_proportions(.75, COUNTDOWN_HEIGHT);
this.place();
this.set_z();
this.set_text();
this.css.fontWeight = COUNTDOWN_FONT_WEIGHT;
if (!this.is_shadow)
{
this.shadow = new EVR.Level.Countdown.Glyph(this.container, this.character, true);
}
}
EVR.Level.Countdown.Glyph.prototype.place = function(modifier)
{
modifier = modifier || 0;
var shadow_offset = COUNTDOWN_SHADOW_OFFSET;
var x = this.is_shadow ? shadow_offset[0] * modifier : 0;
var y = ROAD_OFFSET;
y += this.is_shadow ? shadow_offset[1] * modifier : 0;
EVR.Graphic.prototype.place.call(this, x, y);
}
EVR.Level.Countdown.Glyph.prototype.set_z = function()
{
var depth = COUNTDOWN_DEPTH;
if (this.is_shadow)
{
depth--;
}
EVR.Graphic.prototype.set_z.call(this, depth);
}
EVR.Level.Countdown.Glyph.prototype.set_text = function()
{
var character = this.character;
var font = COUNTDOWN_FONT;
var color = this.is_shadow ? this.color[1] : this.color[0];
EVR.Graphic.prototype.set_text.call(this, character, font, color, this.size);
}
EVR.Level.Countdown.Glyph.prototype.draw = function()
{
EVR.Graphic.prototype.draw.call(this);
this.set_line_height();
!!this.shadow && this.shadow.draw();
}
EVR.Level.Countdown.Glyph.prototype.append = function()
{
!!this.shadow && this.shadow.append();
EVR.Graphic.prototype.append.call(this);
}
EVR.Level.Countdown.Glyph.prototype.remove = function()
{
EVR.Graphic.prototype.remove.call(this);
!!this.shadow && this.shadow.remove();
}
EVR.Level.Countdown.Glyph.prototype.grow = function(modifier)
{
this.text.size -= this.size * modifier;
this.text.set_font_size();
if (!!this.shadow)
{
this.shadow.text.size -= this.size * modifier;
this.shadow.text.set_font_size();
this.shadow.place(modifier);
}
}
EVR.Level.Countdown.Glyph.prototype.set_line_height = function()
{
this.css.lineHeight = this.get_dimensions()[1] + "px";
}
EVR.Level.Countdown.Glyph.prototype.toString = function()
{
return "[EVR.Level.Countdown.Glyph]";
}
EVR.include("level/indicators/Indicator.js");
EVR.Level.Indicators = function(level)
{
EVR.Animation.call(this, LEVEL_INDICATOR_FRAME_RATE);
this.step = LEVEL_INDICATOR_STEP;
this.shifted = false;
this.register = new EVR.Level.Indicators.Indicator(
level, LEVEL_INDICATOR_REGISTER_TEXT, LEVEL_INDICATOR_REGISTER_OFFSET,
LEVEL_INDICATOR_TOP_OFFSET);
this.pattern = new EVR.Level.Indicators.Indicator(
level, LEVEL_INDICATOR_PATTERN_TEXT, LEVEL_INDICATOR_PATTERN_OFFSET,
LEVEL_INDICATOR_TOP_OFFSET);
this.meter = new EVR.Level.Indicators.Indicator(
level, LEVEL_INDICATOR_METER_TEXT, LEVEL_INDICATOR_METER_OFFSET,
LEVEL_INDICATOR_BOTTOM_OFFSET, true);
this.register.append();
this.pattern.append();
this.meter.append();
// this.play();
}
EVR.Level.Indicators.prototype = new EVR.Animation;
EVR.Level.Indicators.prototype.sequence = function()
{
var shifted = this.shifted;
var step = this.step * (shifted ? 1 : -1);
this.register.move(null, step);
this.pattern.move(null, step);
this.meter.move(null, step);
this.shifted = !shifted;
}
EVR.Level.Indicators.prototype.draw = function()
{
this.register.draw();
this.pattern.draw();
this.meter.draw();
}
EVR.Level.Indicators.prototype.remove = function()
{
this.stop();
this.register.attached && this.register.remove();
this.pattern.attached && this.pattern.remove();
this.meter.attached && this.meter.remove();
}
EVR.Level.Indicators.prototype.toString = function()
{
return "[object EVR.Level.Indicators]";
}
EVR.Level.Indicators.Indicator = function(level, message, x, y, bottom)
{
this.level = level;
this.message = message;
this.x = x;
this.y = y;
this.bottom = bottom || false;
this.set_icon();
this.initialize();
}
EVR.Level.Indicators.Indicator.prototype = new EVR.Prompt;
EVR.Level.Indicators.Indicator.prototype.set_icon = function()
{
var icon;
if (this.bottom)
{
icon = "↑";
}
else
{
icon = "↓";
}
this.icon = icon;
}
EVR.Level.Indicators.Indicator.prototype.initialize = function()
{
var container = this.level.container;
var icon = this.icon;
var text = icon + " <i>" + this.message + "</i> " + icon;
var color = LEVEL_INDICATOR_FONT_COLOR;
var size = LEVEL_INDICATOR_FONT_SIZE;
var family = LEVEL_INDICATOR_FONT_FAMILY;
var alignment = ALIGN_LEFT;
var offset = [this.x, this.y];
var spacing = LEVEL_INDICATOR_LETTER_SPACING;
EVR.Prompt.call(
this, container, text, color, size, null, null, null, offset,
spacing);
}
EVR.Level.Indicators.Indicator.prototype.toString = function()
{
return "[object EVR.Level.Indicators.Indicator]";
}
EVR.include("level/meter/Reading.js");
EVR.Level.Meter = function(level)
{
EVR.Graphic.call(
this, level.road, null, null, ALIGN_BOTTOM_LEFT, level.road.container);
this.level = level;
this.clock = level.clock;
this.height = this.level.clock.get_dimensions(true)[1];
this.build();
this.append();
this.reading = new EVR.Level.Meter.Reading(this);
}
EVR.Level.Meter.prototype = new EVR.Graphic;
EVR.Level.Meter.prototype.build = function()
{
this.set_color();
this.set_opacity(this.clock.get_opacity());
}
EVR.Level.Meter.prototype.set_color = function(color)
{
if (!!color)
{
this.reading.set_color(color);
}
EVR.Graphic.prototype.set_color.call(this, this.clock.get_color());
}
EVR.Level.Meter.prototype.shape = function()
{
EVR.Graphic.prototype.shape.call(this);
var dimensions = this.clock.get_dimensions();
var width = this.container.get_dimensions()[0] - dimensions[0];
this.set_dimensions(width, dimensions[1]);
}
EVR.Level.Meter.prototype.place = function()
{
EVR.Graphic.prototype.place.call(this);
var y = this.clock.get_coordinates()[1];
this.set_coordinates([null, y]);
}
EVR.Level.Meter.prototype.draw = function()
{
EVR.Graphic.prototype.draw.call(this);
!!this.reading && this.reading.draw();
}
EVR.Level.Meter.prototype.adjust = function(amount)
{
this.reading.adjust(amount);
}
EVR.Level.Meter.prototype.read = function()
{
return this.reading.remaining;
}
EVR.Level.Meter.prototype.toString = function()
{
return "[object EVR.Level.Meter]";
}