dealDamage : op.nop,
// inactive in the event loop
- active : false,
+ isActive : false,
/// Instance Properties ///
name : 'Dummy', // {String} Display name
/**
* Equips this item to owner or given unit. Does not manipulate inventory, but does remove from map if newly acquired.
- * @param {Tank} [unit=this.owner] Unit to equip. If omitted, uses this.owner; if unowned, does nothing.
+ * @param {Tank} [unit=this.owner] Unit to equip. If omitted, uses this.owner; if omitted and unowned, does nothing.
* @return {this}
*/
equip : function equip(unit){
var evt = unit;
unit = evt.data.unit;
}
- if (unit && unit.isUnit) {
+ if (unit && unit.isThing) {
this.owner = unit;
this.removeFromMap();
}
// inactive
- active : false,
+ isActive : false,
createCooldowns : op.nop,
tick : op.nop,
Thing.init.call(this, owner.align);
this.position(x1,y1);
- this.trajectory = new LinearTrajectory(this, x1,y1, x2,y2, this.movePerMs);
+ this.trajectory = new LinearTrajectory(this, x1,y1, x2,y2, this.movePerMs());
this.on('collide', this.onCollide);
},
isComponent : true,
- active : false, // Owner will notify us to ensure we go at the right time
+ isActive : false, // Owner will notify us to ensure we go at the right time
isRenderable : true, // Agent will present itself for rendering when ready // FIXME: stupid hack
isReflective : false, // Projectiles bounce off agent rather than explode?
hasInventory : false, // Agent can acquire items?
// Instance
blocking : BoundsType.IRREGULAR, // Need to allow shields etc to passthrough like-aligned units
- isComponent : true,
- isShield : true,
+ isComponent : true,
+ isShield : true,
- active : false, // Owner will notify us to ensure we go at the right time
+ isActive : false, // Owner will notify us to ensure we go at the right time
isRenderable : true, // Agent will present itself for rendering when ready // FIXME: stupid hack
isReflective : false, // Projectiles bounce off agent rather than explode?
hasInventory : false, // Agent can acquire items?
Thing.subclass('Tank', function(Tank){
Y.core.descriptors(this, {
+ isUnit : true,
isCombatant : true,
- lootTable : '',
+ lootTable : '',
colors : {
body : '#83BB32',
if (x instanceof Array) { y=x[_Y]; x=x[_X]; }
var loc = this.loc;
- this.trajectory = new LinearTrajectory(this, loc.x,loc.y, x,y, this.movePerMs);
+ this.trajectory = new LinearTrajectory(this, loc.x,loc.y, x,y, this.movePerMs());
var tvsl = new Traversal(this)
, to = tvsl.traverse(this.elapsed, x,y) ;
,
-
+/**
+ * A Thing is any object that can be added to the Map.
+ */
Thing =
exports['Thing'] =
new evt.Class('Thing', {
// Attributes
stats: {
- hp : 1, // health
- move : 1.0, // move speed (squares/sec)
- power : 1, // attack power
- speed : 0.5, // attack cool (sec)
- shots : 5, // max projectiles in the air at once
- sight : 5, // distance this unit can see (squares)
- accuracy : 1.0
+ hp : Infinity, // health
+ move : 0, // move speed (squares/sec)
+ power : 0, // attack power
+ speed : 0, // attack cool (sec)
+ shots : 0, // max projectiles in the air at once
+ sight : 0, // distance this unit can see (squares)
+ accuracy : 0 // targeting accuracy (into formula of orthogonal drift from trajectory after 10 squares?)
},
cooldowns : {
blocking : BoundsType.BLOCKING,
density : DensityType.DENSE,
- isUnit : true,
+ isThing : true,
+ isUnit : false,
isCombatant : false,
isWall : false,
isProjectile : false,
isAccessory : false,
isComponent : false,
- active : true, // Agent takes actions?
+ isActive : true, // Agent takes actions?
isRenderable : false, // Agent will present itself for rendering when ready // FIXME: stupid hack
isReflective : false, // Projectiles bounce off agent rather than explode?
hasInventory : false, // Agent can acquire items?
// Location
loc : null,
bbox : null,
- ownBbox : null,
// Rotation (rads)
rotation : 0,
'set' : op.set.methodize(),
'attr' : op.attr.methodize(),
- get movePerMs(){
+ movePerMs : function movePerMs(){
var stat = this.stats.move;
return (typeof stat === "number" ? stat : stat.val)*REF_SIZE/1000;
},
- init : function init(align){
+ /**
+ * @constructor
+ * @param {Number} align Team number of this unit; 0 is Neutral.
+ */
+ init : function initThing(align){
this.align = align || this.align;
this.components = new Y.YArray();
this.createBoundingBox();
},
draw : function draw(){
+ // TODO: Test whether in viewport bounds? Or do it in Game?
if (!this.dead) {
if (this.dirty) {
this.dirty = false;