// -*- mode: JavaScript; tab-width: 4; indent-tabs-mode: nil; -*-
-//@require('jquery')
-//@require('lessly/future')
-//@require('Y')
+//@package ezl
+//@require jquery
+//@require lessly/future
+//@require Y
+++ /dev/null
-Ability = Agent.subclass('Ability', {
- init : function(owner, target, loc){
- this.owner = owner;
- this.facing = owner.facing;
- this.target = target;
-
- Agent.init.call(this, owner.game, owner.align);
-
- if ( loc ) {
- var x = loc.x, y = loc.y;
- } else {
- var x = owner.front()
- , y = owner.loc.toSquare().midpoint().y;
- }
-
- this.setLocation(x,y);
- },
- blocking : false,
- ticks : 0,
-
- stats : {
- move : 2.0, // move speed (squares/sec)
- range : 0.1 // attack range (squares)
- },
-
- fillStats : function(){
- this.stats = Y( {},
- Agent.fillStats(this.owner.stats),
- Agent.fillStats(this.stats) ).end();
- },
-
- act : function(){
- this.ticks += 1;
- Agent.prototype.act.call(this);
- },
-
- filterTarget : function(unit){
- return (unit.align !== this.align && unit !== this && unit !== this.owner);
- },
-
- doAttack : function(target){
- this.target = target;
- var damage = Calc.unitDamage(this, target),
- killed = false;
-
- target.stats.hp -= damage;
- if ( target.stats.hp <= 0 ) {
- killed = true;
- target.destroy();
- // this.game.killAgent(target);
- }
- this.destroy();
-
- logger(this.owner+"'s", this, 'hits', target, 'for', damage, 'damage'+(killed? ', killing it!' : '!'));
- },
-
- toString : function(){
- return this.className+this.id;
- }
-
-});
\ No newline at end of file
+++ /dev/null
-Laser = Ability.subclass('Laser', {
- init : function(owner, target, loc){
- Ability.init.apply(this, arguments);
- this.duration = (1000 / this.stats.speed) * 0.5;
- this.expires = NOW + this.duration;
-
- this.owner.addEventListener('destroy', this.destroy.bind(this));
- },
- duration : 1.0,
- elapsed : 0.0,
-
- stats : {
- move : 0.0, // move speed (squares/sec)
- range : COLUMNS // attack range (squares)
- },
-
- act : function(){
- if (this.dead) return;
-
- this.elapsed += ELAPSED;
-
- if (this.elapsed >= this.duration)
- this.game.killAgent(this);
- else
- Agent.prototype.act.call(this);
- },
-
- drawShape : function(ctx){
- var thick = 4.0
- , obox = this.owner.boundingBox
- , tbox = this.target.boundingBox
- , omid = obox.midpoint()
- , tmid = tbox.midpoint()
- , x1 = tbox.right.x + 2
- , y1 = omid.y
- , x2 = obox.left.x - 2
- , y2 = omid.y
- ;
-
- ctx.beginPath();
- ctx.lineWidth = thick;
- // ctx.fillStyle = '#FFF6AE';
- ctx.strokeStyle = '#FFF6AE';
-
- ctx.moveTo(x1,y1);
- ctx.lineTo(x2,y2);
-
- // ctx.fill();
- ctx.stroke();
- ctx.closePath();
- },
-
- attack : function(target){
- this.target = target;
-
- var full_damage = Calc.unitDamage(this, target)
- , damage = full_damage * (ELAPSED / this.duration)
- , killed = false
- ;
-
- target.stats.hp -= damage;
- if ( target.stats.hp <= 0 ) {
- killed = true;
- // this.game.killAgent(target);
- target.destroy();
- }
-
- if ( killed || (this.elapsed >= this.duration) ) {
- this.destroy();
- // this.game.killAgent(this);
- logger(this.owner+"'s", this, 'hits', target, 'for', full_damage, 'damage'+(killed? ', killing it!' : '!'));
- }
- }
-
-});
+++ /dev/null
-Projectile = Ability.subclass('Projectile', {
- stats : {
- move : 2.0, // move speed (squares/sec)
- range : 0.1 // attack range (squares)
- },
-
-
-
- drawShape : function(ctx){
- var radius = 5.0
- , x1 = this.loc.x
- , y1 = this.loc.y
- , x2 = x1 + radius*2
- , y2 = y1
- ;
-
- ctx.beginPath();
- ctx.lineWidth = 3;
- ctx.fillStyle = '#5992FF';
- ctx.strokeStyle = '#244792';
-
- ctx.arc(x1,y1, radius, 0, TWO_PI, false);
-
- ctx.fill();
- ctx.stroke();
- ctx.closePath();
- }
-});
+++ /dev/null
-(function(){
-
-/* Inline all these */
-Calc = {
- moveX : function(unit){
- return unit.loc.x + (unit.facing * unit.stats.move * REF_SIZE * FRAMETH);
- },
-
- rangeX : function(unit){
- return unit.loc.x + (unit.facing * unit.stats.range * REF_SIZE);
- },
-
- damage : function(power, armor, hard){
- return Math.max(0, (power - hard) * (armor ? 1 - Math.log(armor/2)/5 : 1));
- },
-
- unitDamage : function(attacker, defender){
- var a = attacker.stats, d = defender.stats;
- return Calc.damage(a.power, d.armor, d.hard);
- }
-
-};
-
-})();
+++ /dev/null
-Y(Game.prototype).extend({
-
- initDraw : function(){
- this.canvas = $('<canvas />').appendTo(this.el);
- this.ctx = this.canvas[0].getContext('2d');
- this.resize();
- },
-
- clearGrid : function(){
- var ctx = this.ctx;
- ctx.beginPath();
- ctx.clearRect(0,0, this.canvas.width(),this.canvas.height());
- ctx.closePath();
- },
-
- drawGrid : function(){
- var ctx = this.ctx
- , w = REF_SIZE* COLUMNS
- , h = REF_SIZE* ROWS;
-
- ctx.beginPath();
- ctx.lineWidth = 1;
- ctx.strokeStyle = '#6E6E6E';
-
- for (var row=0, y=0; row<=ROWS; y = (++row) * REF_SIZE){
- ctx.moveTo(0,y);
- ctx.lineTo(w,y);
- }
-
- for (var col=0, x=0; col<=COLUMNS; x = (++col) * REF_SIZE){
- ctx.moveTo(x,0);
- ctx.lineTo(x,h);
- }
-
- ctx.stroke();
- ctx.closePath();
- },
-
- resize : function(){
- var ratio = COLUMNS / ROWS
- , el = this.el
- , p = el.parent()
- , pw = p.width(), ph = p.height()
- , pRatio = pw / ph
- ;
-
- if ( ratio > pRatio )
- CELL_SIZE = Math.floor((pw-GRID_OFFSET*2) / COLUMNS);
- else
- CELL_SIZE = Math.floor((ph-GRID_OFFSET*2) / ROWS);
-
- SCALE = CELL_SIZE/REF_SIZE;
-
- var w = COLUMNS*CELL_SIZE
- , h = ROWS*CELL_SIZE
- , canvas = this.canvas[0];
-
- this.el.width(w).height(h);
- this.canvas.width(w).height(h);
- canvas.width = w;
- canvas.height = h;
-
- this.el.offset({
- top : (ph - h) / 2,
- left : (pw - w) / 2
- });
-
- this.ctx.scale(SCALE,SCALE);
- }
-
-});
-
-
+++ /dev/null
-
-Game = new Y.Class('Game', {
-
- init : function(el){
- this.loop = new EventLoop(this, FRAME_RATE);
-
- // Seal all methods
- // Y.bindAll(this);
- this.resize = this.resize.bind(this);
- this.tick = this.tick.bind(this);
-
- this.el = $(el);
- this.initMap();
- this.initDraw();
-
- this.addEventListener('tick', this.tick);
- },
- showOverlay : false,
-
- /**
- * Main Event Loop.
- */
- tick : function(evt){
- var d = evt.data;
-
- NOW = d.now;
- ELAPSED = d.elapsed;
- TICKS = d.ticks;
-
- var ctx = this.ctx
- , Ps = this.abilities.clone()
- , Us = this.units.clone().sort(Unit.turnOrdering) // Copy to avoid mutation under iteration
- ;
-
- this.clearGrid();
- this.drawGrid();
-
- // Prompt all projectiles and units to act
- Ps.invoke('act');
- Us.invoke('act');
-
- // Prompt all remaining units to draw
- this.abilities.invoke('draw', ctx);
- this.units.invoke('draw', ctx);
-
- // XXX: Collect the dead
-
- this.grid.removeOverlay(this.el);
- if (this.showOverlay) this.grid.overlay(this.el);
- }
-
-});
-
-
+++ /dev/null
-Y(Game.prototype).extend({
-
- initMap : function(){
- var self = this;
-
- // this.blockers = new Y.YArray();
- this.byId = {};
- this.units = new Y.YArray();
- this.abilities = new Y.YArray();
- this.grid = new Grid(0,0, COLUMNS*REF_SIZE, ROWS*REF_SIZE, GRID_CAPACITY);
-
- Agent.addEventListener('create', function(evt){
- self.addAgent(evt.instance);
- });
- Agent.addEventListener('destroy', function(evt){
- self.killAgent(evt.instance);
- });
- },
-
-
- // *** Path Map Management *** //
-
- addBlocker : function(agent){
- var bb = agent.boundingBox;
- if (agent.blocking && bb)
- agent.region = this.grid.set(bb.x1,bb.y1, bb.x2,bb.y2, agent);
- return agent;
- },
-
- removeBlocker : function(agent){
- if (agent.region)
- this.grid.remove(agent.region);
- return agent;
- },
-
- updateBlocker : function(agent){
- this.removeBlocker(agent);
- this.addBlocker(agent);
- },
-
-
- // *** Agent Management *** //
-
- addAgent : function(agent){
- agent.game = this;
- if (agent.id === undefined) return agent;
-
- this.addBlocker(agent);
-
- if ( !this.byId[agent.id] ) {
- this.byId[agent.id] = agent;
- if (agent instanceof Ability)
- this.abilities.push(agent);
- else
- this.units.push(agent);
- }
-
- return agent;
- },
-
- killAgent : function(agent){
- delete this.byId[agent.id];
- if (agent instanceof Ability)
- this.abilities.remove(agent);
- else
- this.units.remove(agent);
-
- this.removeBlocker(agent);
- return agent;
- },
-
- moveAgentTo : function(agent, x,y){
- this.removeBlocker(agent);
- agent.setLocation(x,y);
- this.addBlocker(agent);
- return agent;
- },
-
- getUnitAt : function(x,y){
- return this.grid.get(x,y);
- },
-
- getUnitsAt : function(x1,y1, x2,y2){
- return this.grid.get(x1,y1, x2,y2);
- }
-
-});
-
-
+++ /dev/null
-var logger = new Log('#log')
-
-, PI = Math.PI
-, TWO_PI = PI*2
-, HALF_PI = PI/2
-
-, COLUMNS = 10
-, ROWS = 8
-, GRID_CAPACITY = 32
-
-, REF_SIZE = 50
-, CELL_SIZE = REF_SIZE
-, GRID_OFFSET = 10
-
-, VIEWPORT_DIST = 100
-, MIN_X_DIST = -1*VIEWPORT_DIST
-, MAX_X_DIST = COLUMNS*REF_SIZE + VIEWPORT_DIST
-
-, FRAME_RATE = 30
-, MS_PER_FRAME = 1000 / FRAME_RATE
-, FRAMETH = 1.0 / FRAME_RATE
-
-, SCALE = CELL_SIZE / REF_SIZE
-, SCALE_SPEED = SCALE / FRAME_RATE
-
-, FACING_RIGHT = 1
-, FACING_LEFT = -1
-
-, NOW = new Date().getTime() // Current tick's timestamp (ms)
-, ELAPSED = FRAMETH // Time (ms) since previous tick
-, TICKS = 0 // Ticks since start of game
-;
+++ /dev/null
-TestPlayer = new Y.Class('TestPlayer', {
- init : function(game){
- var self = this;
- this.game = game;
- this.game.el.bind('click', function(evt){
- evt.preventDefault();
- evt.stopPropagation();
- if (evt.shiftKey)
- self.addTowerClick(evt);
- else
- self.addCreepClick(evt);
- });
- },
-
- pageToGrid : function(x,y){
- var off = this.game.el.offset();
- return {
- 'x' : (x - off.left)/SCALE,
- 'y' : (y - off.top)/SCALE
- };
- },
-
- pageToCell : function(x,y){
- var pos = this.pageToGrid(x,y);
- return {
- 'x' : Math.floor(pos.x / REF_SIZE) * REF_SIZE,
- 'y' : Math.floor(pos.y / REF_SIZE) * REF_SIZE
- };
- },
-
- addTowerClick : function(evt){
- var cell = this.pageToCell(evt.pageX,evt.pageY)
- , units = this.game.getUnitsAt(cell.x,cell.y, cell.x+REF_SIZE,cell.y+REF_SIZE);
- if (units.size() === 0)
- new Creep(this.game, 1).addToSquare(cell.x/REF_SIZE, cell.y/REF_SIZE);
- else
- logger("Cannot create Creep -- unit exists there!");
- },
-
- addCreepClick : function(evt){
- var cell = this.pageToCell(evt.pageX,evt.pageY)
- , units = this.game.getUnitsAt(cell.x,cell.y, cell.x+REF_SIZE,cell.y+REF_SIZE);
- if (units.size() === 0)
- new Tower(this.game, 0).addToSquare(cell.x/REF_SIZE, cell.y/REF_SIZE);
- else
- logger("Cannot create Tower -- unit exists there!");
- }
-});
\ No newline at end of file
+++ /dev/null
-jQuery(function(){
- Simoon = new Game('#grid');
-
- pl = Simoon.player = new TestPlayer(Simoon);
-
- for (var row=0; row<ROWS; row++) {
- var c = new Creep(Simoon, 1);
- c.addToSquare(COLUMNS-(4 + row % 2),row);
- }
-
- for (var row=0; row<ROWS; row++) {
- var t = new Tower(Simoon, 0);
- t.addToSquare(0,row);
- }
-});
-
+++ /dev/null
-
-function shhh(evt){
- if (!evt) return false;
- evt.preventDefault();
- evt.stopPropagation();
-}
-
-
-function toggleGame(evt){
- if (Simoon.loop.running)
- Simoon.stop();
- else
- Simoon.start();
-
- updateInfo();
- return false;
-}
-
-// Update performance info periodically
-function updateInfo(){
- var loop = Simoon.loop
- , fps = loop.fps()
- , n_units = Simoon.units.size()
- , n_projs = Simoon.abilities.size()
- ;
-
- $('#info [name=fps]').val( fps.toFixed(2) + " / " + loop.framerate );
- $('#info [name=frame]').val( loop.frametime().toFixed(3)+" ms" );
- $('#info #state').text( loop.running ? 'Running!' : ('Paused (tick '+TICKS+')') );
-
- $('#info [name=agents]').val( n_units+n_projs );
- $('#info [name=units]').val( n_units );
- $('#info [name=bullets]').val( n_projs );
-
- return false;
-}
-
-function fixStartText(){
- var txt = (Simoon.loop.running ? 'pause' : 'start');
- $('.start_btn').text(txt).attr('title', txt);
- return false;
-}
-function fixOverlayText(){
- var txt = (Simoon.showOverlay ? 'hide' : 'show') + ' bounds';
- $('.overlay_btn').text(txt).attr('title', txt);
- return false;
-}
-
-
-
-jQuery(function($){
- logger('Click "Start" to begin!');
- $('#log').hide(); // Hide log-related crap
-
-
- // Tick once to draw grid, initial units
- Simoon.start();
- Simoon.stop();
-
- // Add Buttons
- // logger.menu.prepend('<a class="start_btn" />', ' | ', '<a class="overlay_btn"></a>', ' || ');
-
- setInterval(updateInfo, 1000);
- updateInfo();
-
- // Update Text on Click
- Simoon.addEventListener('start', fixStartText);
- Simoon.addEventListener('stop', fixStartText);
-
- // Start button (click or return key)
- $('.start_btn').bind('click', toggleGame);
- $(document).bind('keydown', 'return', toggleGame);
-
- $(document).bind('keydown', 'ctrl+l', function(evt){ $('#log').toggle(); });
- $(document).bind('keydown', 'ctrl+o', function(evt){ Simoon.showOverlay = !(Simoon.showOverlay); });
-
- // Show Overlays
- $('.overlay_btn').bind('click', function(evt){
- Simoon.showOverlay = !(Simoon.showOverlay);
- fixOverlayText();
- return false;
- });
-
- // Fix Starting text
- fixStartText();
- fixOverlayText();
-
- // Fix grid-size on resize
- $(window).bind('resize', function(evt){
- Simoon.resize(evt);
-
- if (!Simoon.loop.running) {
- Simoon.start();
- Simoon.stop();
- }
- });
-
- //
-});
\ No newline at end of file
+++ /dev/null
-(function(){
-var uid = 0;
-
-this.Agent = new Y.Class('Agent', {
- init : function(game, align){
- this.id = uid++;
- this.align = align;
- this.game = game;
-
- this.projectiles = new Y.YArray();
-
- // this.filterTarget = this.filterTarget.bind(this);
- this.fillStats();
- this.createCooldowns();
-
- this.fire('ready');
- },
-
- // Attributes
- stats: {
- hp : 100, // hitpoints
- move : 0.2, // move speed (squares/sec)
-
- range : 2.0, // attack range (squares)
- power : 1, // attack power
- speed : 1.0, // attacks/sec
-
- armor : 0.0, // armor
- hard : 0 // hardness (damage reduction)
- },
-
- // *** Bookkeeping *** //
-
- dead : false,
-
- destroy : function(){
- if (this.dead) return;
-
- this.dead = true;
- this.fire('destroy', this);
- },
-
- loc : null,
- boundingBox : null,
-
- facing : FACING_LEFT,
-
- // Bounding box size
- width : REF_SIZE,
- height : REF_SIZE,
-
- // Offset from top-left when squaring this unit
- offsetX : 0,
- offsetY : 0,
-
- setLocation : function(x,y){
- var loc = this.loc;
- if (loc && loc.x === x && loc.y === y)
- return loc;
- loc = this.loc = new Loc(x,y);
- this.boundingBox = new Rect(x,y, x+this.width,y+this.height);
- return loc;
- },
-
- /**
- * Front-most point of the agent, accounting for facing.
- */
- front : function(){
- return this.boundingBox[ this.facing === FACING_LEFT ? 'x1' : 'x2' ];
- },
-
-
-
- // *** Gameplay Methods *** //
-
- addToSquare : function(col,row){
- var x = col*REF_SIZE + this.offsetX
- , y = row*REF_SIZE + this.offsetY;
- this.setLocation(x,y);
- this.game.addAgent(this);
- return this;
- },
-
- fillStats : function(){
- this.stats = Agent.fillStats(this.stats);
- },
-
- createCooldowns : function(){
- this.cooldowns = Y({
- attack: new Cooldown(1000 * this.stats.speed)
- });
- },
-
- /**
- * Determines what the creep should do -- move, attack, etc.
- */
- act : function(){
- if (this.dead) return this;
-
- this.cooldowns.invoke('update', NOW);
-
- var bb = this.boundingBox
- , x1 = Calc.rangeX(this), x2 = bb.left.x
- , y1 = bb.top.y, y2 = bb.bottom.y
- , units = this.game
- .getUnitsAt(x1,y1, x2,y2)
- .filter(this.filterTarget, this)
- , target = this.closest(units)
- ;
- if (target)
- this.attack(target);
- else
- this.move();
-
- if (bb.x1 <= MIN_X_DIST || bb.x2 >= MAX_X_DIST)
- this.destroy();
-
- return this;
- },
-
- filterTarget : function(unit){ return unit.align !== this.align; },
-
- closest : function(units){
- if (units.length === 0 || units.size() === 0) return;
-
- var bb = this.boundingBox
- , d = this.facing
- , p = (d === FACING_LEFT ? 'x2' : 'x1')
- , x = (d === FACING_LEFT ? bb.x1 : bb.x2)
- , sign = (d === FACING_LEFT ? 1 : -1)
- , best = units
- .reduce(function(best, unit){
- var ub = unit.boundingBox
- , dist = (x - ub[p]) * sign
-
- if (dist < 0) dist = Infinity;
-
- if (!best || dist <= best.distance)
- return { unit:unit, distance:dist };
- else
- return best;
- }, null);
- return best.end().unit;
- },
-
- move : function(){
- this.game.moveAgentTo(this, Calc.moveX(this), this.loc.y);
- return this;
- },
-
- attack : function(unit){
- var atk_cool = this.cooldowns.attr('attack');
- if ( atk_cool.activate(NOW) ) {
- // logger(this+'.attack(', unit, ')');
- this.doAttack(unit);
- }
- return this;
- },
-
- doAttack : function(target){
- this.fireProjectile(target);
- },
-
- fireProjectile : function(target){
- var AbilityType = this.projectile
- , p = new AbilityType(this, target);
- this.projectiles.push(p);
- this.game.addAgent(p);
- return p;
- },
-
-
-
- draw : function(ctx){
- if (this.dead) return;
-
- this.drawShape(ctx);
- if (this.blocking) this.drawHealth(ctx);
- },
-
- drawShape : function(ctx){},
-
- drawHealth : function(ctx){
- var stats = this.stats
- , ratio = stats.hp / stats.hp_max
- , x = this.loc.x - this.offsetX
- , sq = this.loc.toSquare()
- , x1 = x + 5, x2 = x + REF_SIZE - 5
- , w = x2-x1, h = 5
- , y1 = sq.y2 - h - 3;
-
- // draw box outline
- ctx.beginPath();
- ctx.lineWidth = 1;
- ctx.strokeStyle = "#ffffff";
- ctx.fillStyle = "#980011";
- ctx.rect(x1,y1, w,h);
- ctx.fill();
- // ctx.stroke();
- ctx.closePath();
-
- // draw hp
- ctx.beginPath();
- ctx.fillStyle = "#83BB32";
- ctx.rect(x1,y1, w*ratio,h);
- ctx.fill();
- ctx.closePath();
-
- },
-
- toString : function(){
- return this.className+'(id='+this.id+', loc='+this.loc+')';
- }
-});
-
-
-
-Y(Agent).extend({
-
- fillStats : function(stats){
- var st = Y(stats)
- , stats = st.clone().end()
- ;
-
- st.forEach(function(v, k){
- var k = Y(k)
- , k_ = k.rtrim('_max')
- ;
-
- if ( k.endsWith('_max') ) {
- if ( stats[k_] === undefined )
- stats[k_] = v;
-
- } else if ( stats[k+'_max'] === undefined )
- stats[k+'_max'] = v;
-
- });
-
- return stats;
- }
-});
-
-})();
+++ /dev/null
-(function(){
-var
-OFF = 10,
-SIZE = REF_SIZE - 2*OFF,
-HALF = SIZE/2;
-
-this.Creep = Unit.subclass('Creep', {
- facing : FACING_LEFT,
- projectile : Laser,
-
- // Attributes
- stats: {
- hp : 10, // hitpoints
- move : 0.25, // move speed (squares/sec)
-
- range : 2.0, // attack range (squares)
- power : 2.0, // attack power
- speed : 0.5, // attacks/sec
-
- armor : 0.0, // armor
- hard : 0 // hardness (damage reduction)
- },
- offsetX : OFF,
- offsetY : OFF,
- width : SIZE,
- height : SIZE,
-
- drawShape : function(ctx){
- var x = this.loc.x
- , y = this.loc.y;
-
- ctx.beginPath();
- ctx.lineWidth = 0;
- ctx.fillStyle = '#E73075';
-
- ctx.moveTo(x,y+HALF);
- ctx.lineTo(x+SIZE,y);
- ctx.lineTo(x+SIZE,y+SIZE);
- ctx.lineTo(x,y+HALF);
-
- ctx.fill();
- ctx.closePath();
- }
-
-});
-
-})();
+++ /dev/null
-(function(){
-var
-OFFSET = 10,
-SIZE = REF_SIZE - 2*OFFSET,
-
-Tower = Unit.subclass('Tower', {
- facing : FACING_RIGHT,
- projectile : Projectile,
-
- // Attributes
- stats: {
- hp : 10, // hitpoints
- move : 0, // move speed (squares/sec)
-
- range : 5, // attack range (squares)
- power : 1, // attack power
- speed : 1.0, // attacks/sec
-
- armor : 10.0, // armor
- hard : 0 // hardness (damage reduction)
- },
-
- offsetX : OFFSET,
- offsetY : OFFSET,
- width : SIZE,
- height : SIZE,
-
- drawShape : function(ctx){
- var x = this.loc.x
- , y = this.loc.y;
-
- ctx.beginPath();
- ctx.lineWidth = 0;
- ctx.fillStyle = "#F25522";
- ctx.rect(x,y, SIZE,SIZE);
- ctx.fill();
- ctx.closePath();
- }
-
-});
-this.Tower = Tower;
-
-})();
+++ /dev/null
-Unit = Agent.subclass('Unit', {
- blocking : true,
- projectile : Projectile,
-
- move : function(){
- var d = this.facing
- , bb = this.boundingBox
- , x1 = Calc.moveX(this), x2 = bb.right.x - d
- , y1 = bb.top.y, y2 = bb.bottom.y
- , units = this.game.getUnitsAt(bb.left.x+(d*5),y1, x2,y2).remove(this);
- if (units.size() === 0)
- try {
- this.game.moveAgentTo(this, x1,this.loc.y);
- } catch (e) {
- console.log('Error moving units to ('+x1+','+this.loc.y+')', e);
- }
- }
-
-});
-
-Y(Unit).extend({
- turnOrdering : function(u1, u2){
- return Y(u1.stats.speed).compare( u2.stats.speed );
- }
-
-});