home *** CD-ROM | disk | FTP | other *** search
- class Bolt extends BaseObject
- {
- var nSpeed;
- var mcRef;
- static var sSTATE_FLYING = "Flying";
- static var sSTATE_EXPLODE = "Explode";
- static var nBOLT_SPEED = 6;
- function Bolt(_mcRef)
- {
- super(_mcRef);
- this.setState(Bolt.sSTATE_FLYING);
- this.nSpeed = Bolt.nBOLT_SPEED;
- var _loc3_ = Library.Sound.SoundManager.isSoundPlaying("Bolt_Shot.mp3");
- if(_loc3_.bPlaying)
- {
- _loc3_.oSound.doStop();
- _loc3_.oSound.doStart();
- }
- Library.Sound.SoundManager.doPlaySoundInCat(Main.sSOUND_CAT_SOUND,"Bolt_Shot.mp3",75,1,true);
- LevelManager.Instance.doAddListener(this);
- }
- function setPosition(_nPosX, _nPosY)
- {
- this.mcRef._x = _nPosX;
- this.mcRef._y = _nPosY;
- }
- function doDestroy()
- {
- LevelManager.Instance.doRemoveListener(this);
- super.doDestroy();
- }
- function doExplode()
- {
- if(this.isStateComplete())
- {
- this.doDestroy();
- }
- }
- function doFlying()
- {
- var _loc2_ = this.mcRef._y - this.nSpeed;
- _loc2_ = this.doCheckBlocks(_loc2_);
- _loc2_ = this.doCheckTop(_loc2_);
- this.mcRef._y = _loc2_;
- }
- function doCheckBlocks(_nFutureY)
- {
- var _loc3_ = LevelManager.Instance.getNearBlocksForObject(this);
- for(var _loc6_ in _loc3_)
- {
- if(this.getCollideTop(_loc3_[_loc6_],this.Ref._x,_nFutureY))
- {
- _loc3_[_loc6_].onBoltHit();
- var _loc4_ = true;
- if(_loc4_)
- {
- _nFutureY = _loc3_[_loc6_].Bounds.yMax - this.StateBounds.yMin;
- }
- this.setState(Bolt.sSTATE_EXPLODE);
- var _loc2_ = Library.Sound.SoundManager.isSoundPlaying("Bolt_Explode.mp3");
- if(_loc2_.bPlaying)
- {
- _loc2_.oSound.doStop();
- _loc2_.oSound.doStart();
- }
- Library.Sound.SoundManager.doPlaySoundInCat(Main.sSOUND_CAT_SOUND,"Bolt_Explode.mp3",60,1,true);
- }
- }
- return _nFutureY;
- }
- function doCheckTop(_nFutureY)
- {
- if(_nFutureY + this.StateBounds.yMin < LevelManager.nLIMITS_CEIL)
- {
- _nFutureY = LevelManager.nLIMITS_CEIL - this.StateBounds.yMin;
- this.setState(Bolt.sSTATE_EXPLODE);
- }
- return _nFutureY;
- }
- }
-