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

  1. class WorldInstruction
  2. {
  3.    var minChance;
  4.    var maxChance;
  5.    var chance;
  6.    var iterator;
  7.    var subInstructions;
  8.    var enemyType;
  9.    var enemyNum;
  10.    var eof;
  11.    function WorldInstruction(myChance)
  12.    {
  13.       this.minChance = 0;
  14.       this.maxChance = 0;
  15.       this.chance = myChance;
  16.       this.iterator = -1;
  17.       this.subInstructions = new Array();
  18.       this.enemyType = "";
  19.       this.enemyNum = 0;
  20.       this.eof = true;
  21.    }
  22.    function SetRange(loChance, hiChance)
  23.    {
  24.       this.minChance = loChance;
  25.       this.maxChance = hiChance;
  26.    }
  27.    function GetNumInstructions()
  28.    {
  29.       return this.subInstructions.length;
  30.    }
  31.    function AddInstruction(enemyType, minNum, maxNum)
  32.    {
  33.       var _loc2_ = Math.round(Math.random() * (maxNum - minNum)) + minNum;
  34.       this.subInstructions.push({linkage:enemyType,numAmount:_loc2_});
  35.       if(this.iterator == this.subInstructions.length)
  36.       {
  37.          this.eof = true;
  38.       }
  39.       else
  40.       {
  41.          this.eof = false;
  42.       }
  43.    }
  44.    function Begin()
  45.    {
  46.       this.iterator = 0;
  47.       if(this.iterator == this.subInstructions.length)
  48.       {
  49.          this.eof = true;
  50.       }
  51.       this.enemyType = this.subInstructions[this.iterator].linkage;
  52.       this.enemyNum = this.subInstructions[this.iterator].numAmount;
  53.    }
  54.    function Next()
  55.    {
  56.       this.iterator = this.iterator + 1;
  57.       if(this.iterator == this.subInstructions.length)
  58.       {
  59.          this.iterator = this.iterator - 1;
  60.          this.eof = true;
  61.       }
  62.       this.enemyType = this.subInstructions[this.iterator].linkage;
  63.       this.enemyNum = this.subInstructions[this.iterator].numAmount;
  64.    }
  65. }
  66.