home *** CD-ROM | disk | FTP | other *** search
- class LevelDesignItem
- {
- var mcRef;
- var nType;
- var bRandomAssignPass;
- var bRandomAssignForce;
- var nWait;
- static var nBONUS_FAIRY_CROWN = 1;
- static var sLINKAGE_BONUS_FAIRY_CROWN = "mcFairyCrown";
- static var nBONUS_CC_POWERSUIT = 2;
- static var sLINKAGE_BONUS_CC_POWERSUIT = "mcCCPowerSuit";
- static var nBONUS_CC_SYMBOL = 3;
- static var sLINKAGE_BONUS_CC_SYMBOL = "mcCCSymbol";
- static var nPOWERDOWN_ROCKET = 4;
- static var sLINKAGE_POWERDOWN_ROCKET = "mcRocket";
- static var nBONUS_TRAMPOLINE = 5;
- static var sLINKAGE_BONUS_TRAMPOLINE = "mcTrampoline";
- static var nPOWERDOWN_JACKBOX = 6;
- static var sLINKAGE_POWERDOWN_JACKBOX = "mcJackBox";
- static var nBONUS_CHEWINGGUM = 7;
- static var sLINKAGE_BONUS_CHEWINGGUM = "mcChewingGum";
- static var nBONUS_MAGICWAND = 8;
- static var sLINKAGE_BONUS_MAGICWAND = "mcMagicWand";
- static var nPOWERDOWN_PING = 9;
- static var sLINKAGE_POWERDOWN_PING = "mcPING";
- static var nPOWERDOWN_ROCKET_SPEED = 4;
- static var nPOWERDOWN_ROCKET_TIME = 10000;
- static var nBONUS_TRAMPOLINE_TIME = 15000;
- static var nPOWERDOWN_JACKBOX_TIME = 15000;
- static var nPOWERDOWN_PIXIES_TIME = 30000;
- static var nBONUS_CHEWINGGUM_HITS = 5;
- static var nBONUS_MAGICWAND_SHOTS = 5;
- static var nBONUS_CC_SYMBOL_POINTS = 25000;
- static var nWAIT_TIME = 1;
- function LevelDesignItem(_mcRef, _nType)
- {
- this.mcRef = _mcRef;
- this.nType = _nType;
- this.mcRef._visible = false;
- this.bRandomAssignPass = false;
- this.bRandomAssignForce = false;
- this.nWait = LevelDesignItem.nWAIT_TIME;
- LevelManager.Instance.doAddListener(this);
- }
- function doEnterFrame()
- {
- this.nWait = this.nWait - 1;
- if(this.nWait == 0)
- {
- if(!this.bRandomAssignPass)
- {
- this.doSearchTargeted();
- }
- else
- {
- this.doAssignRandom();
- }
- }
- }
- function doDestroy()
- {
- LevelManager.Instance.doRemoveListener(this);
- this.mcRef.swapDepths(LevelManager.Instance.RemoveDepth);
- this.mcRef.removeMovieClip();
- delete this.mcRef;
- }
- function doAssignRandom()
- {
- var _loc3_ = new Array();
- var _loc2_ = LevelManager.Instance.Blocks;
- for(var _loc4_ in _loc2_)
- {
- if(!_loc2_[_loc4_].NeverDies)
- {
- if(!_loc2_[_loc4_].BonusAssigned || this.bRandomAssignForce)
- {
- _loc3_.push(_loc2_[_loc4_]);
- }
- }
- }
- if(_loc3_.length > 0)
- {
- var _loc5_ = Library.Utils.MoreMath.getRandomRange(0,_loc3_.length - 1);
- _loc3_[_loc5_].doAddItem(this.nType);
- this.doDestroy();
- }
- else
- {
- this.bRandomAssignForce = true;
- this.bRandomAssignPass = true;
- this.nWait = 1;
- }
- }
- function doSearchTargeted()
- {
- var _loc3_ = LevelManager.Instance.Blocks;
- var _loc4_ = false;
- for(var _loc5_ in _loc3_)
- {
- if(!_loc3_[_loc5_].NeverDies)
- {
- var _loc2_ = _loc3_[_loc5_].Bounds;
- if(this.mcRef._x > _loc2_.xMin && this.mcRef._x < _loc2_.xMax)
- {
- if(this.mcRef._y > _loc2_.yMin && this.mcRef._y < _loc2_.yMax)
- {
- _loc3_[_loc5_].doAddItem(this.nType);
- _loc4_ = true;
- }
- }
- }
- }
- if(!_loc4_)
- {
- this.bRandomAssignPass = true;
- this.nWait = 1;
- }
- else
- {
- this.doDestroy();
- }
- }
- }
-