var Y = require('Y').Y;
Y.extend(exports, {
- 'Layer' : require('ezl/layer').Layer,
-
+ 'math' : require('ezl/math'),
'loc' : require('ezl/loc'),
+ 'util' : require('ezl/util'),
+
'loop' : require('ezl/loop'),
- 'math' : require('ezl/math'),
+
+ 'layer' : require('ezl/layer'),
'shape' : require('ezl/shape'),
- 'util' : require('ezl/util'),
'widget' : require('ezl/widget')
});
//#ensure "jquery"
-
-var undefined
-, Y = require('Y').Y
-, Vec = require('ezl/math/vec').Vec
-, loc = require('ezl/loc')
-, Loc = loc.Loc
-, BoundingBox = loc.BoundingBox
-, Animation = require('ezl/loop/fx').Animation
+var Y = require('Y').Y
+, Vec = require('ezl/math/vec').Vec
+, Loc = require('ezl/loc/loc').Loc
+, BoundingBox = require('ezl/loc/boundingbox').BoundingBox
+, Animation = require('ezl/loop/fx').Animation
,
+
CONTEXT_ATTRS = Y('globalAlpha globalCompositeOperation strokeStyle fillStyle lineWidth lineCap lineJoin miterLimit shadowOffsetX shadowOffsetY shadowBlur shadowColor'.split(' ')),
FAUX_ACCESSORS = Y('width height position stroke fill origin rotate scale translate title'.split(' '))
-,_X = 0, _Y = 1
+, _X = 0, _Y = 1
,
-var Y = require('Y').Y
-, Shape = require('ezl/shape/shape').Shape
+var Shape = require('ezl/shape/shape').Shape
,
Circle =
var Y = require('Y').Y
, math = require('ezl/math')
-, Layer = require('ezl/layer').Layer
+, Layer = require('ezl/layer/layer').Layer
, Shape = require('ezl/shape/shape').Shape
,
-var Y = require('Y').Y
-, Layer = require('ezl/layer').Layer
+var Layer = require('ezl/layer/layer').Layer
,
Shape =
var end = graph.nodes[1][2];
astar.search(graph.nodes, start, end);
*/
-var BinaryHeap = require('ezl/util/binaryheap').BinaryHeap;
+var BinaryHeap = require('ezl/util/tree/binaryheap').BinaryHeap;
exports['init'] = init;
function init(grid) {
var Y = require('Y').Y
-, Layer = require('ezl/layer').Layer
+, Layer = require('ezl/layer/layer').Layer
, PI = Math.PI
, QUARTER_PI = PI/4
+++ /dev/null
-Calc = {
-
-
-
-};
\ No newline at end of file
// game.addThing(new Tank(2), 1,0);
// game.addThing(new Tank(2), 8,1);
- // I = game.addThing(new Item(), 8,8);
+ I = game.addThing(new Item(), 8,8);
},
addWall : function addWall(x,y, w,h, isBoundary){
, math = require('ezl/math')
, vec = require('ezl/math/vec')
, QuadTree = require('ezl/util/tree/quadtree').QuadTree
-, BinaryHeap = require('ezl/util/binaryheap').BinaryHeap
+, BinaryHeap = require('ezl/util/tree/binaryheap').BinaryHeap
, Vec = vec.Vec
, Line = math.Line
},
collide : function collide(blocker){
- var thing = this.thing
- , data = { 'traversal':this, 'thing':thing, 'blocker':blocker };
+ var thing = this.thing;
- thing.fire('collide', blocker, data);
- blocker.fire('collide', thing, data);
+ thing.fire('collide', blocker, { 'traversal':this, 'unit':blocker });
+ blocker.fire('collide', thing, { 'traversal':this, 'unit':thing });
},
rewind : function rewind(blocker){
var traj = this.trajectory
, ng, d = evt.data
+ , unit = d.unit
, tvsl = d.traversal
, to = tvsl.to
- , unit = d.blocker
- , isReflective = unit instanceof Wall // XXX: unit.reflective
+ , isReflective = unit.isReflective
;
// Ignore collisions with zones
, map = require('tanks/map/map')
, Thing = require('tanks/thing/thing').Thing
-, SIZE = REF_SIZE * 0.5
+, ITEM_SIZE = REF_SIZE * 0.5
,
Item =
exports['Item'] =
Thing.subclass('Item', {
- blocking : map.ZONE,
- active : false,
+ align : 0, // 0 reserved for neutral units
- width : SIZE,
- height : SIZE,
+ blocking : map.ZONE,
+ width : ITEM_SIZE,
+ height : ITEM_SIZE,
- stats : { hp:1, move:0, power:0 },
+ // indestructable
+ stats : { hp:Infinity, move:0, power:0 },
+ dealDamage : op.nop,
// inactive
- createCooldowns : op.nop,
- updateCooldowns : op.nop,
- act : op.nop,
+ active : false,
+
+
+ /// Instance Properties ///
+ type : 'dummy', // {String} Item type identifier (unique, for config lookup)
+ name : 'Dummy', // {String} Display name
+ icon_inv : '', // {String} URL to inventory icon file (TODO)
+ icon_map : '', // {String} URL to map icon file (TODO)
+ buffs : Y([]), // {Buff...} Passive effects (triggered on pickup)
+ effects : Y([]), // {Function...} Active effects (triggered on activation)
+ owner : null, // {Unit} Owner when picked up.
- // indestructable
- dealDamage : op.nop,
- init : function initItem(){
+ // XXX: Setting these per-instance only while testing
+ init : function initItem(name, buffs, effects){
Thing.init.call(this, 0);
+ if (name) this.name = name;
+
+ if (buffs)
+ this.buffs = Y(buffs);
+ else
+ this.buffs = this.buffs.clone();
+
+ if (effects)
+ this.effects = Y(effects);
+ else
+ this.effects = this.effects.clone();
this.addEventListener('collide', this.onCollide.bind(this));
},
+ activate : function activate(){
+ if (!this.owner) return;
+ },
+
+ acquired : function acquired(unit){
+ this.owner = unit;
+ console.log(unit+' acquired '+this+'!');
+ // TODO: apply buffs
+ unit.fire('acquire', this, { 'unit':unit, 'item':this });