home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Acao / bubble_tanks_2.swf / scripts / __Packages / MapNode.as < prev    next >
Encoding:
Text File  |  2008-09-02  |  3.0 KB  |  143 lines

  1. class MapNode
  2. {
  3.    var arrChildren;
  4.    var strLabel;
  5.    var intIterator;
  6.    var nodeData;
  7.    var parentNode;
  8.    function MapNode()
  9.    {
  10.       this.arrChildren = new Array();
  11.       this.strLabel = "";
  12.       this.intIterator = -1;
  13.       this.nodeData = new StateData();
  14.    }
  15.    function GetParent()
  16.    {
  17.       return this.parentNode;
  18.    }
  19.    function SetParent(newParent)
  20.    {
  21.       this.parentNode = newParent;
  22.    }
  23.    function AddChild()
  24.    {
  25.       var _loc2_ = new MapNode();
  26.       _loc2_.SetParent(this);
  27.       this.arrChildren.push(_loc2_);
  28.       if(this.arrChildren.length > 0)
  29.       {
  30.          this.intIterator = this.arrChildren.length - 1;
  31.       }
  32.    }
  33.    function PointToNode(node)
  34.    {
  35.       node.SetParent(this);
  36.       this.arrChildren.push(node);
  37.       if(this.arrChildren.length > 0)
  38.       {
  39.          this.intIterator = this.arrChildren.length - 1;
  40.       }
  41.    }
  42.    function Print()
  43.    {
  44.       var _loc2_ = 0;
  45.       while(_loc2_ < this.arrChildren.length)
  46.       {
  47.          this.arrChildren[_loc2_].Print();
  48.          _loc2_ = _loc2_ + 1;
  49.       }
  50.    }
  51.    function Reset()
  52.    {
  53.       if(this.arrChildren.length > 0)
  54.       {
  55.          this.intIterator = 0;
  56.       }
  57.       else
  58.       {
  59.          this.intIterator = -1;
  60.       }
  61.       var _loc2_ = 0;
  62.       while(_loc2_ < this.arrChildren.length)
  63.       {
  64.          this.arrChildren[_loc2_].Reset();
  65.          _loc2_ = _loc2_ + 1;
  66.       }
  67.    }
  68.    function GetChild()
  69.    {
  70.       if(this.intIterator != -1)
  71.       {
  72.          return this.arrChildren[this.intIterator];
  73.       }
  74.       return undefined;
  75.    }
  76.    function NextChild()
  77.    {
  78.       this.intIterator = this.intIterator + 1;
  79.       if(this.intIterator >= this.arrChildren.length)
  80.       {
  81.          if(this.arrChildren.length == 0)
  82.          {
  83.             this.intIterator = -1;
  84.          }
  85.          else
  86.          {
  87.             this.intIterator = 0;
  88.          }
  89.          return false;
  90.       }
  91.       return true;
  92.    }
  93.    function PrevChild()
  94.    {
  95.       this.intIterator = this.intIterator - 1;
  96.       if(this.intIterator < 0)
  97.       {
  98.          if(this.arrChildren.length == 0)
  99.          {
  100.             this.intIterator = -1;
  101.          }
  102.          else
  103.          {
  104.             this.intIterator = this.arrChildren.length - 1;
  105.          }
  106.          return false;
  107.       }
  108.       return true;
  109.    }
  110.    function FirstChild()
  111.    {
  112.       if(this.arrChildren.length == 0)
  113.       {
  114.          this.intIterator = -1;
  115.          return false;
  116.       }
  117.       this.intIterator = 0;
  118.       return true;
  119.    }
  120.    function GetNumChildren()
  121.    {
  122.       return this.arrChildren.length;
  123.    }
  124.    function PrintPathTest()
  125.    {
  126.       var _loc2_ = this.strLabel + ", ";
  127.       if(this.arrChildren.length > 0)
  128.       {
  129.          var _loc3_ = Math.round(Math.random() * (this.arrChildren.length - 1));
  130.          _loc2_ += this.arrChildren[_loc3_].PrintPathTest();
  131.       }
  132.       return _loc2_;
  133.    }
  134.    function GetLabel()
  135.    {
  136.       return this.strLabel;
  137.    }
  138.    function SetLabel(newLabel)
  139.    {
  140.       this.strLabel = newLabel;
  141.    }
  142. }
  143.