home *** CD-ROM | disk | FTP | other *** search
- class com.leadpipe.attentionhog.Item extends MovieClip
- {
- var timerWarn;
- var timerEnd;
- var isPowerUp;
- var type;
- var itemImage_mc;
- var bounds_obj;
- var hit;
- var point;
- var pointPlayer;
- var distInit;
- static var play_maxY = 380;
- static var instanceList = new Array();
- function Item()
- {
- super();
- com.leadpipe.attentionhog.Item.instanceList.push(this);
- this.timerWarn = new com.leadpipe.attentionhog.Timer(this,"warn",6400,6400);
- this.timerWarn.start();
- this.timerEnd = new com.leadpipe.attentionhog.Timer(this,"destroy",7000,7000);
- this.timerEnd.start();
- this.setType();
- this.setPos();
- }
- function onEnterFrame()
- {
- if(this.checkCollision(_root.player_mc.body_mc))
- {
- _root.player_mc.startGrunt();
- if(this.isPowerUp)
- {
- com.leadpipe.attentionhog.Player.instance.abilities[this.type - 1].startPowerUp();
- }
- else
- {
- com.leadpipe.attentionhog.Game.instance.gaugeSlop[this.type - 1].increase();
- }
- this.destroy();
- }
- }
- function setType()
- {
- this.type = random(com.leadpipe.attentionhog.Game.instance.getItemsUnlocked()) + 1;
- if(random(12) == 0)
- {
- this.isPowerUp = true;
- this.itemImage_mc.gotoAndStop(this.type + 6);
- }
- else
- {
- this.isPowerUp = false;
- this.itemImage_mc.gotoAndStop(this.type);
- }
- }
- function checkCollision(mc)
- {
- this.bounds_obj = this.getBounds(_root);
- if(mc.hitTest(this.bounds_obj.xMin,this.bounds_obj.yMin,true) || mc.hitTest(this.bounds_obj.xMin,this.bounds_obj.yMax,true) || mc.hitTest(this.bounds_obj.xMax,this.bounds_obj.yMin,true) || mc.hitTest(this.bounds_obj.xMax,this.bounds_obj.yMax,true))
- {
- this.hit = true;
- }
- else
- {
- this.hit = false;
- }
- return this.hit;
- }
- function destroy()
- {
- this.timerWarn.clear();
- this.timerEnd.clear();
- for(var _loc2_ in com.leadpipe.attentionhog.Item.instanceList)
- {
- if(com.leadpipe.attentionhog.Item.instanceList[_loc2_] == this)
- {
- com.leadpipe.attentionhog.Item.instanceList.splice(_loc2_,1);
- break;
- }
- }
- this.removeMovieClip();
- }
- function warn()
- {
- this.timerWarn.clear();
- this.gotoAndPlay("warn");
- }
- function setPosRandom()
- {
- this._x = this.randomInt(50,Stage.width - 20);
- this._y = this.randomInt(50,410);
- }
- function setPos()
- {
- this.point = new flash.geom.Point(this.randomInt(50,Stage.width - 20),this.randomInt(50,410));
- this.pointPlayer = new flash.geom.Point(_root.player_mc._x,_root.player_mc._y);
- this.distInit = flash.geom.Point.distance(this.point,this.pointPlayer);
- while(this.distInit < 60)
- {
- this.point = new flash.geom.Point(this.randomInt(50,Stage.width - 20),this.randomInt(50,410));
- this.distInit = flash.geom.Point.distance(this.point,this.pointPlayer);
- }
- this._x = this.point.x;
- this._y = this.point.y;
- }
- function randomInt(min, max)
- {
- return Math.floor(Math.random() * (max - min + 1)) + min;
- }
- static function destroyAll()
- {
- for(var _loc1_ in com.leadpipe.attentionhog.Item.instanceList)
- {
- com.leadpipe.attentionhog.Item.instanceList[_loc1_].destroy();
- }
- com.leadpipe.attentionhog.Item.instanceList = new Array();
- }
- static function pauseAll()
- {
- for(var _loc1_ in com.leadpipe.attentionhog.Item.instanceList)
- {
- com.leadpipe.attentionhog.Item.instanceList[_loc1_].pause();
- }
- }
- static function resumeAll()
- {
- for(var _loc1_ in com.leadpipe.attentionhog.Item.instanceList)
- {
- com.leadpipe.attentionhog.Item.instanceList[_loc1_].resume();
- }
- }
- }
-