home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / breakawish.swf / scripts / __Packages / LevelDesignItem.as < prev    next >
Encoding:
Text File  |  2007-09-28  |  3.6 KB  |  124 lines

  1. class LevelDesignItem
  2. {
  3.    var mcRef;
  4.    var nType;
  5.    var bRandomAssignPass;
  6.    var bRandomAssignForce;
  7.    var nWait;
  8.    static var nBONUS_FAIRY_CROWN = 1;
  9.    static var sLINKAGE_BONUS_FAIRY_CROWN = "mcFairyCrown";
  10.    static var nBONUS_CC_POWERSUIT = 2;
  11.    static var sLINKAGE_BONUS_CC_POWERSUIT = "mcCCPowerSuit";
  12.    static var nBONUS_CC_SYMBOL = 3;
  13.    static var sLINKAGE_BONUS_CC_SYMBOL = "mcCCSymbol";
  14.    static var nPOWERDOWN_ROCKET = 4;
  15.    static var sLINKAGE_POWERDOWN_ROCKET = "mcRocket";
  16.    static var nBONUS_TRAMPOLINE = 5;
  17.    static var sLINKAGE_BONUS_TRAMPOLINE = "mcTrampoline";
  18.    static var nPOWERDOWN_JACKBOX = 6;
  19.    static var sLINKAGE_POWERDOWN_JACKBOX = "mcJackBox";
  20.    static var nBONUS_CHEWINGGUM = 7;
  21.    static var sLINKAGE_BONUS_CHEWINGGUM = "mcChewingGum";
  22.    static var nBONUS_MAGICWAND = 8;
  23.    static var sLINKAGE_BONUS_MAGICWAND = "mcMagicWand";
  24.    static var nPOWERDOWN_PING = 9;
  25.    static var sLINKAGE_POWERDOWN_PING = "mcPING";
  26.    static var nPOWERDOWN_ROCKET_SPEED = 4;
  27.    static var nPOWERDOWN_ROCKET_TIME = 10000;
  28.    static var nBONUS_TRAMPOLINE_TIME = 15000;
  29.    static var nPOWERDOWN_JACKBOX_TIME = 15000;
  30.    static var nPOWERDOWN_PIXIES_TIME = 30000;
  31.    static var nBONUS_CHEWINGGUM_HITS = 5;
  32.    static var nBONUS_MAGICWAND_SHOTS = 5;
  33.    static var nBONUS_CC_SYMBOL_POINTS = 25000;
  34.    static var nWAIT_TIME = 1;
  35.    function LevelDesignItem(_mcRef, _nType)
  36.    {
  37.       this.mcRef = _mcRef;
  38.       this.nType = _nType;
  39.       this.mcRef._visible = false;
  40.       this.bRandomAssignPass = false;
  41.       this.bRandomAssignForce = false;
  42.       this.nWait = LevelDesignItem.nWAIT_TIME;
  43.       LevelManager.Instance.doAddListener(this);
  44.    }
  45.    function doEnterFrame()
  46.    {
  47.       this.nWait = this.nWait - 1;
  48.       if(this.nWait == 0)
  49.       {
  50.          if(!this.bRandomAssignPass)
  51.          {
  52.             this.doSearchTargeted();
  53.          }
  54.          else
  55.          {
  56.             this.doAssignRandom();
  57.          }
  58.       }
  59.    }
  60.    function doDestroy()
  61.    {
  62.       LevelManager.Instance.doRemoveListener(this);
  63.       this.mcRef.swapDepths(LevelManager.Instance.RemoveDepth);
  64.       this.mcRef.removeMovieClip();
  65.       delete this.mcRef;
  66.    }
  67.    function doAssignRandom()
  68.    {
  69.       var _loc3_ = new Array();
  70.       var _loc2_ = LevelManager.Instance.Blocks;
  71.       for(var _loc4_ in _loc2_)
  72.       {
  73.          if(!_loc2_[_loc4_].NeverDies)
  74.          {
  75.             if(!_loc2_[_loc4_].BonusAssigned || this.bRandomAssignForce)
  76.             {
  77.                _loc3_.push(_loc2_[_loc4_]);
  78.             }
  79.          }
  80.       }
  81.       if(_loc3_.length > 0)
  82.       {
  83.          var _loc5_ = Library.Utils.MoreMath.getRandomRange(0,_loc3_.length - 1);
  84.          _loc3_[_loc5_].doAddItem(this.nType);
  85.          this.doDestroy();
  86.       }
  87.       else
  88.       {
  89.          this.bRandomAssignForce = true;
  90.          this.bRandomAssignPass = true;
  91.          this.nWait = 1;
  92.       }
  93.    }
  94.    function doSearchTargeted()
  95.    {
  96.       var _loc3_ = LevelManager.Instance.Blocks;
  97.       var _loc4_ = false;
  98.       for(var _loc5_ in _loc3_)
  99.       {
  100.          if(!_loc3_[_loc5_].NeverDies)
  101.          {
  102.             var _loc2_ = _loc3_[_loc5_].Bounds;
  103.             if(this.mcRef._x > _loc2_.xMin && this.mcRef._x < _loc2_.xMax)
  104.             {
  105.                if(this.mcRef._y > _loc2_.yMin && this.mcRef._y < _loc2_.yMax)
  106.                {
  107.                   _loc3_[_loc5_].doAddItem(this.nType);
  108.                   _loc4_ = true;
  109.                }
  110.             }
  111.          }
  112.       }
  113.       if(!_loc4_)
  114.       {
  115.          this.bRandomAssignPass = true;
  116.          this.nWait = 1;
  117.       }
  118.       else
  119.       {
  120.          this.doDestroy();
  121.       }
  122.    }
  123. }
  124.