home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Aventura / lightsprites.swf / scripts / __Packages / Set.as < prev    next >
Encoding:
Text File  |  2007-09-27  |  2.0 KB  |  79 lines

  1. class Set
  2. {
  3.    var arrPieces;
  4.    var blnUsed;
  5.    var numSelectedMinNext;
  6.    var numSelectedMaxNext;
  7.    function Set()
  8.    {
  9.       this.arrPieces = new Array();
  10.       this.blnUsed = false;
  11.    }
  12.    function AddPiece(strIdentifier, numPercentChance, minNew, maxNew)
  13.    {
  14.       this.arrPieces.push({name:strIdentifier,chance:numPercentChance,minChance:0,maxChance:0,minNext:minNew,maxNext:maxNew});
  15.    }
  16.    function InUse()
  17.    {
  18.       this.blnUsed = true;
  19.    }
  20.    function Used()
  21.    {
  22.       return this.blnUsed;
  23.    }
  24.    function GetPiece()
  25.    {
  26.       var _loc3_ = 0;
  27.       var _loc4_ = 0;
  28.       var _loc7_ = 0;
  29.       var _loc5_ = 0;
  30.       var _loc2_ = 0;
  31.       while(_loc2_ < this.arrPieces.length)
  32.       {
  33.          _loc7_ += this.arrPieces[_loc2_].chance;
  34.          _loc2_ = _loc2_ + 1;
  35.       }
  36.       _loc5_ = Math.round(Math.random() * _loc7_);
  37.       _loc2_ = 0;
  38.       while(_loc2_ < this.arrPieces.length)
  39.       {
  40.          _loc4_ = _loc3_ + this.arrPieces[_loc2_].chance;
  41.          this.arrPieces[_loc2_].minChance = _loc3_;
  42.          this.arrPieces[_loc2_].maxChance = _loc4_;
  43.          _loc3_ = _loc4_;
  44.          _loc2_ = _loc2_ + 1;
  45.       }
  46.       var _loc6_ = -1;
  47.       _loc2_ = 0;
  48.       while(_loc2_ < this.arrPieces.length)
  49.       {
  50.          if(_loc5_ >= this.arrPieces[_loc2_].minChance && _loc5_ < this.arrPieces[_loc2_].maxChance)
  51.          {
  52.             _loc6_ = _loc2_;
  53.             break;
  54.          }
  55.          _loc2_ = _loc2_ + 1;
  56.       }
  57.       if(_loc6_ == -1)
  58.       {
  59.          _loc6_ = this.arrPieces.length - 1;
  60.       }
  61.       this.numSelectedMinNext = this.arrPieces[_loc6_].minNext;
  62.       this.numSelectedMaxNext = this.arrPieces[_loc6_].maxNext;
  63.       return this.arrPieces[_loc6_].name;
  64.    }
  65.    function GetMinNext()
  66.    {
  67.       return this.numSelectedMinNext;
  68.    }
  69.    function GetMaxNext()
  70.    {
  71.       return this.numSelectedMaxNext;
  72.    }
  73.    function SetMinMax(myMin, myMax)
  74.    {
  75.       this.numSelectedMinNext = myMin;
  76.       this.numSelectedMaxNext = myMax;
  77.    }
  78. }
  79.