Renames active to isActive; movePerMs no longer a getter.
authordsc <david.schoonover@gmail.com>
Thu, 31 Mar 2011 10:11:23 +0000 (03:11 -0700)
committerdsc <david.schoonover@gmail.com>
Thu, 31 Mar 2011 10:11:23 +0000 (03:11 -0700)
src/tanks/item/item.cjs
src/tanks/map/wall.cjs
src/tanks/thing/bullet.cjs
src/tanks/thing/component.cjs
src/tanks/thing/shield.cjs
src/tanks/thing/tank.cjs
src/tanks/thing/thing.cjs

index b967801..1dd7844 100644 (file)
@@ -35,7 +35,7 @@ Thing.subclass('Item', {
     dealDamage : op.nop,
     
     // inactive in the event loop
-    active     : false,
+    isActive     : false,
     
     /// Instance Properties ///
     name     : 'Dummy',     // {String} Display name
@@ -103,7 +103,7 @@ Thing.subclass('Item', {
     
     /**
      * 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){
@@ -111,7 +111,7 @@ Thing.subclass('Item', {
             var evt = unit;
             unit = evt.data.unit;
         }
-        if (unit && unit.isUnit) {
+        if (unit && unit.isThing) {
             this.owner = unit;
             this.removeFromMap();
         }
index fc35e99..dc94900 100644 (file)
@@ -36,7 +36,7 @@ Thing.subclass('Wall', {
     
     
     // inactive
-    active : false,
+    isActive : false,
     createCooldowns : op.nop,
     tick : op.nop,
     
index ed2cd84..3f1a565 100644 (file)
@@ -63,7 +63,7 @@ Thing.subclass('Bullet', {
         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);
     },
index c9779db..18bbb48 100644 (file)
@@ -17,7 +17,7 @@ Thing.subclass('Component', {
     
     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?
index 7d3ed53..b2a00b9 100644 (file)
@@ -20,10 +20,10 @@ Component.subclass('Shield', {
     // 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?
index a30cf84..1cdca54 100644 (file)
@@ -28,8 +28,9 @@ exports['Tank'] =
 Thing.subclass('Tank', function(Tank){
     
     Y.core.descriptors(this, {
+        isUnit      : true,
         isCombatant : true,
-        lootTable : '',
+        lootTable   : '',
         
         colors : {
             body   : '#83BB32',
@@ -218,7 +219,7 @@ Thing.subclass('Tank', function(Tank){
         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) ;
index abd4000..9a04e02 100644 (file)
@@ -18,7 +18,9 @@ var Y           = require('Y').Y
 ,
 
 
-
+/**
+ * A Thing is any object that can be added to the Map.
+ */
 Thing =
 exports['Thing'] =
 new evt.Class('Thing', {
@@ -30,13 +32,13 @@ 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 : {
@@ -59,14 +61,15 @@ new evt.Class('Thing', {
     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?
@@ -75,7 +78,6 @@ new evt.Class('Thing', {
     // Location
     loc : null,
     bbox : null,
-    ownBbox : null,
     
     // Rotation (rads)
     rotation : 0,
@@ -90,14 +92,18 @@ new evt.Class('Thing', {
     '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();
@@ -205,6 +211,7 @@ new evt.Class('Thing', {
     },
     
     draw : function draw(){
+        // TODO: Test whether in viewport bounds? Or do it in Game?
         if (!this.dead) {
             if (this.dirty) {
                 this.dirty = false;