home *** CD-ROM | disk | FTP | other *** search
Wrap
class BaseObject extends Library.State { var nOriginalScaleX; var mcRef; var nOriginalScaleY; var bDropDownMotion; var bLevelEnded; var nOriginalPositionX; var nOriginalPositionY; var oTweenListener; var twX; var twY; var oStateBounds; var bPaused; static var nDROP_DOWN_HEIGHT = 400; static var nDROP_DISTANCE_MOVE_PERCENT = 0.35; static var nDROP_MAX_SPEED = 40; static var nDROP_MIN_MOVE = 4; static var nBOUNCE_DURATION = 15; static var nBOUNCE_VERTICAL_STRETCH = 65; static var nBOUNCE_HORIZONTAL_STRETCH = 60; static var nBOUNCE_VERTICAL_SPEED_RATIO = 2; static var nBOUNCE_HORIZONTAL_SPEED_RATIO = 2; function BaseObject(_mcRef) { super(_mcRef); this.nOriginalScaleX = this.mcRef._xscale; this.nOriginalScaleY = this.mcRef._yscale; this.bDropDownMotion = false; this.bLevelEnded = false; this.nOriginalPositionX = this.mcRef._x; this.nOriginalPositionY = this.mcRef._y; this.oTweenListener = new Object(); this.oTweenListener.onMotionFinished = Library.Utils.Delegate.create(this,this.onTweenComplete); } function doEnterFrame() { super.doEnterFrame(); if(this.bDropDownMotion) { var _loc4_ = this.nOriginalPositionY - this.mcRef._y; var _loc3_ = undefined; if(_loc4_ > BaseObject.nDROP_MIN_MOVE) { _loc3_ = _loc4_ * BaseObject.nDROP_DISTANCE_MOVE_PERCENT; } else { _loc3_ = _loc4_; LevelManager.Instance.onDropDownCompleteForElement(this); this.bDropDownMotion = false; } if(_loc3_ > BaseObject.nDROP_MAX_SPEED) { _loc3_ = BaseObject.nDROP_MAX_SPEED; } this.mcRef._y += _loc3_; } } function onLevelEnded() { this.bLevelEnded = true; } function doLevelEndedAnim() { this.setState("Explode"); } function onHideForDropDown() { this.mcRef._y = this.nOriginalPositionY - BaseObject.nDROP_DOWN_HEIGHT; } function onStartDropDownMove() { this.bDropDownMotion = true; } function doPause() { super.doPause(); this.twX.stop(); this.twY.stop(); } function doResume() { super.doResume(); this.twX.resume(); this.twY.resume(); } function onTweenComplete(__twTween) { if(__twTween == this.twX) { delete this.twX; } else if(__twTween == this.twY) { delete this.twY; } } function doDestroy() { this.mcRef.swapDepths(LevelManager.Instance.RemoveDepth); this.mcRef.removeMovieClip(); if(this.bLevelEnded) { LevelManager.Instance.onLevelEndAnimEnded(this); } this.twX.stop(); this.twY.stop(); delete this.twX; delete this.twY; delete this.mcRef; delete this.oStateBounds; } function get Ref() { return this.mcRef; } function get StateBounds() { return this.oStateBounds; } function get Bounds() { var _loc2_ = new Object(); _loc2_.xMin = this.mcRef._x + this.oStateBounds.xMin; _loc2_.xMax = this.mcRef._x + this.oStateBounds.xMax; _loc2_.yMin = this.mcRef._y + this.oStateBounds.yMin; _loc2_.yMax = this.mcRef._y + this.oStateBounds.yMax; return _loc2_; } function doExplode() { if(this.isStateComplete()) { this.doDestroy(); } } function doBounce(__nXStrength, __nYStrength) { if(!this.bPaused) { var _loc2_ = 100 - Math.abs(__nXStrength) * BaseObject.nBOUNCE_HORIZONTAL_SPEED_RATIO; var _loc3_ = 100 - Math.abs(__nYStrength) * BaseObject.nBOUNCE_VERTICAL_SPEED_RATIO; if(_loc2_ < BaseObject.nBOUNCE_HORIZONTAL_STRETCH || _loc2_ > 100) { _loc2_ = BaseObject.nBOUNCE_HORIZONTAL_STRETCH; } if(_loc3_ < BaseObject.nBOUNCE_VERTICAL_STRETCH || _loc3_ > 100) { _loc3_ = BaseObject.nBOUNCE_VERTICAL_STRETCH; } this.doReinitScale(); if(this.twX != undefined) { this.twX.stop(); } if(this.twY != undefined) { this.twY.stop(); } this.twX = new mx.transitions.Tween(this.mcRef,"_xscale",mx.transitions.easing.Elastic.easeOut,_loc2_,this.mcRef._xscale,BaseObject.nBOUNCE_DURATION,false); this.twY = new mx.transitions.Tween(this.mcRef,"_yscale",mx.transitions.easing.Elastic.easeOut,_loc3_,this.mcRef._yscale,BaseObject.nBOUNCE_DURATION,false); this.twX.addListener(this.oTweenListener); this.twY.addListener(this.oTweenListener); } } function doReinitScale() { this.mcRef._xscale = this.nOriginalScaleX; this.mcRef._yscale = this.nOriginalScaleY; } function getCollideBottom(_oTargetObject, _nX, _nY) { if(_nX == undefined) { _nX = this.Ref._x; } if(_nY == undefined) { _nY = this.Ref._y; } var _loc2_ = false; if(_nX > _oTargetObject.Bounds.xMin && _nX < _oTargetObject.Bounds.xMax) { var _loc7_ = Library.Utils.MoreMath.getBoundsCenter(_oTargetObject.Bounds).y; var _loc5_ = Library.Utils.MoreMath.getBoundsCenter(this.Bounds).y; if(_nY + this.StateBounds.yMax > _oTargetObject.Bounds.yMin && _loc5_ < _loc7_) { _loc2_ = true; } } return _loc2_; } function getCollideTop(_oTargetObject, _nX, _nY) { if(_nX == undefined) { _nX = this.Ref._x; } if(_nY == undefined) { _nY = this.Ref._y; } var _loc2_ = false; if(_nX > _oTargetObject.Bounds.xMin && _nX < _oTargetObject.Bounds.xMax) { var _loc7_ = Library.Utils.MoreMath.getBoundsCenter(_oTargetObject.Bounds).y; var _loc5_ = Library.Utils.MoreMath.getBoundsCenter(this.Bounds).y; if(_nY + this.StateBounds.yMin < _oTargetObject.Bounds.yMax && _loc5_ > _loc7_) { _loc2_ = true; } } return _loc2_; } function getCollideRight(_oTargetObject, _nX, _nY) { if(_nX == undefined) { _nX = this.Ref._x; } if(_nY == undefined) { _nY = this.Ref._y; } var _loc2_ = false; if(_nY > _oTargetObject.Bounds.yMin && _nY < _oTargetObject.Bounds.yMax) { var _loc7_ = Library.Utils.MoreMath.getBoundsCenter(_oTargetObject.Bounds).x; var _loc5_ = Library.Utils.MoreMath.getBoundsCenter(this.Bounds).x; if(_nX + this.StateBounds.xMax > _oTargetObject.Bounds.xMin && _loc5_ < _loc7_) { _loc2_ = true; } } return _loc2_; } function getCollideLeft(_oTargetObject, _nX, _nY) { if(_nX == undefined) { _nX = this.Ref._x; } if(_nY == undefined) { _nY = this.Ref._y; } var _loc2_ = false; if(_nY > _oTargetObject.Bounds.yMin && _nY < _oTargetObject.Bounds.yMax) { var _loc7_ = Library.Utils.MoreMath.getBoundsCenter(_oTargetObject.Bounds).x; var _loc5_ = Library.Utils.MoreMath.getBoundsCenter(this.Bounds).x; if(_nX + this.StateBounds.xMin < _oTargetObject.Bounds.xMax && _loc5_ > _loc7_) { _loc2_ = true; } } return _loc2_; } function doLoadStateAction() { if(this.mcRef.mcState.mcHit != undefined) { this.oStateBounds = this.mcRef.mcState.mcHit.getBounds(this.mcRef); } else { this.oStateBounds = this.mcRef.mcState.getBounds(this.mcRef); } } }