home *** CD-ROM | disk | FTP | other *** search
- class com.leadpipe.attentionhog.Player extends MovieClip
- {
- var startPos;
- var speed;
- var accel;
- var accelCntr;
- var accelInc;
- var spinInc;
- var gotoX;
- var gotoY;
- var moveMode;
- var ghostMode;
- var baconMode;
- var timerBacon;
- var grunt;
- var squeal;
- var timerAttentionSpan;
- var attentionSpan_mc;
- var attentionSpanShowSwitch;
- var redTrans;
- var normalTrans;
- var trans;
- var body_mc;
- var warningSwitch;
- var dead;
- var abilities;
- var radiant_mc;
- var isPaused;
- var lastXMouse;
- var lastYMouse;
- var warningInterval;
- var warningThresholdLow;
- var warningThresholdHigh;
- var feelingLove;
- var delta_x;
- var delta_y;
- var angle;
- var greasedPowerMode;
- var wholeHogMode;
- var hogTiedMode;
- var radiantMask_mc;
- var mouseIsDown;
- var captured;
- static var posX;
- static var posY;
- static var instance = null;
- static var play_maxY = 380;
- function Player()
- {
- super();
- this.startPos = new flash.geom.Point(Stage.width / 2,205);
- this._x = Stage.width / 2;
- this._y = 230;
- this.speed = 0;
- this.accel = 0;
- this.accelCntr = 0;
- this.accelInc = 1;
- this.spinInc = 0;
- this.gotoX = _root._xmouse;
- this.gotoY = _root._ymouse;
- this.moveMode = "WALK";
- this.ghostMode = false;
- com.leadpipe.attentionhog.Player.instance = this;
- this.baconMode = false;
- this.timerBacon = new com.leadpipe.attentionhog.Timer(this,"stopBaconMode",5000,5000);
- this.grunt = new Sound(this);
- this.grunt.attachSound("grunt2");
- this.squeal = new Sound(this);
- this.squeal.attachSound("squeal");
- this.timerAttentionSpan = new com.leadpipe.attentionhog.Timer(this,"fadeAttentionSpan",30,30);
- this.attentionSpan_mc._alpha = 0;
- this.attentionSpanShowSwitch = 0;
- this.redTrans = new flash.geom.ColorTransform(1,0.2,0.2,1,0,0,0,0);
- this.normalTrans = new flash.geom.ColorTransform(1,1,1,1,0,0,0,0);
- this.trans = new flash.geom.Transform(this.body_mc);
- this.trans.colorTransform = null;
- _root.bgBacon_mc._alpha = 0;
- this.warningSwitch = 0;
- this.dead = false;
- this.abilities = new Array(new com.leadpipe.attentionhog.Ability(this,"setGreasedPig",49,_root.hud_mc.gauge0.icon_mc,com.leadpipe.attentionhog.Game.instance.gaugeSlop[0],false),new com.leadpipe.attentionhog.Ability(this,"setWholeHog",50,_root.hud_mc.gauge1.icon_mc,com.leadpipe.attentionhog.Game.instance.gaugeSlop[1],false),new com.leadpipe.attentionhog.Ability(this,"setSwineAndDine",51,_root.hud_mc.gauge2.icon_mc,com.leadpipe.attentionhog.Game.instance.gaugeSlop[2],true),new com.leadpipe.attentionhog.Ability(this,"setBigHam",52,_root.hud_mc.gauge3.icon_mc,com.leadpipe.attentionhog.Game.instance.gaugeSlop[3],false),new com.leadpipe.attentionhog.Ability(this,"setPigsEye",53,_root.hud_mc.gauge4.icon_mc,com.leadpipe.attentionhog.Game.instance.gaugeSlop[4],false),new com.leadpipe.attentionhog.Ability(this,"setHogTied",54,_root.hud_mc.gauge5.icon_mc,com.leadpipe.attentionhog.Game.instance.gaugeSlop[5],false));
- this.radiant_mc._alpha = 0;
- }
- function pause(p)
- {
- this.isPaused = p;
- }
- function soundOn(s)
- {
- if(s)
- {
- this.grunt.setVolume(100);
- this.squeal.setVolume(100);
- }
- else
- {
- this.grunt.setVolume(0);
- this.squeal.setVolume(0);
- }
- }
- function startGrunt()
- {
- this.grunt.start(0,1);
- }
- function onMouseMove()
- {
- if(this.isPaused)
- {
- return undefined;
- }
- this.lastXMouse = _root._xmouse;
- if(_root._ymouse >= 30 && _root._ymouse <= com.leadpipe.attentionhog.Player.play_maxY)
- {
- this.lastYMouse = _root._ymouse;
- }
- this.gotoX = this.lastXMouse;
- this.gotoY = this.lastYMouse;
- }
- function warningFlash()
- {
- if(this._alpha == 0)
- {
- this._alpha = 100;
- }
- else
- {
- this._alpha = 0;
- }
- }
- function go()
- {
- if(this.dead)
- {
- return undefined;
- }
- var _loc2_ = com.leadpipe.attentionhog.Game.instance.gaugeMain.getLevel();
- if(_loc2_ <= 0)
- {
- this.dead = true;
- this.gotoAndPlay("dead");
- com.leadpipe.attentionhog.Game.instance.die();
- clearInterval(this.warningInterval);
- this._alpha = 100;
- return undefined;
- }
- if(_loc2_ <= 20)
- {
- this.warningSwitch = this.warningSwitch + 1;
- if(this.warningSwitch == 1)
- {
- this.warningThresholdLow = 0;
- this.warningThresholdHigh = 15;
- if(this.warningInterval != null)
- {
- clearInterval(this.warningInterval);
- }
- this.warningInterval = setInterval(this,"warningFlash",100);
- }
- }
- if(_loc2_ <= this.warningThresholdLow || _loc2_ >= this.warningThresholdHigh)
- {
- clearInterval(this.warningInterval);
- this._alpha = 100;
- this.warningSwitch = 0;
- }
- for(var _loc3_ in this.abilities)
- {
- this.abilities[_loc3_].check();
- }
- this.checkCapture();
- if(!this.feelingLove)
- {
- com.leadpipe.attentionhog.Game.instance.gaugeMain.decrease();
- }
- this.delta_x = this._x - this.gotoX;
- this.delta_y = this._y - this.gotoY;
- this.angle = (- Math.atan2(this.delta_x,this.delta_y)) / 0.017453292519943295;
- this.rotatePlayer();
- this.moveWalk();
- com.leadpipe.attentionhog.Player.posX = this._x;
- com.leadpipe.attentionhog.Player.posY = this._y;
- }
- function setGreasedPig(isActive, isPowerUp)
- {
- if(isActive && isPowerUp)
- {
- this.accelInc = 1000;
- }
- else if(isActive)
- {
- this.accelInc = 10;
- }
- else
- {
- this.greasedPowerMode = false;
- this.accelInc = 1;
- }
- }
- function setWholeHog(isActive, isPowerUp)
- {
- if(isActive && isPowerUp)
- {
- com.leadpipe.attentionhog.Game.instance.proxThreshold = 175;
- this.spinInc = 45;
- this.wholeHogMode = true;
- }
- else if(isActive)
- {
- com.leadpipe.attentionhog.Game.instance.proxThreshold = 125;
- this.spinInc = 20;
- this.wholeHogMode = true;
- }
- else
- {
- com.leadpipe.attentionhog.Game.instance.proxThreshold = 75;
- this.spinInc = 0;
- this.wholeHogMode = false;
- }
- this.attentionSpan_mc._width = com.leadpipe.attentionhog.Game.instance.proxThreshold * 2;
- this.attentionSpan_mc._height = com.leadpipe.attentionhog.Game.instance.proxThreshold * 2;
- }
- function setSwineAndDine(isActive, isPowerUp)
- {
- if(isActive && isPowerUp)
- {
- var _loc3_ = com.leadpipe.attentionhog.Ghost.instanceList.length;
- var _loc4_ = com.leadpipe.attentionhog.Game.instance.ghostDepthInit + _loc3_;
- _root.attachMovie("hog_mc","ghost" + _loc3_,_loc4_,{_alpha:60,_x:this._x,_y:this._y});
- com.leadpipe.attentionhog.Ghost.instanceList[_loc3_]._rotation = this.body_mc._rotation;
- }
- else if(isActive)
- {
- _loc3_ = com.leadpipe.attentionhog.Ghost.instanceList.length;
- _loc4_ = com.leadpipe.attentionhog.Game.instance.ghostDepthInit + _loc3_;
- _root.attachMovie("hog_mc","ghost" + _loc3_,_loc4_,{_alpha:60,_x:this._x,_y:this._y});
- com.leadpipe.attentionhog.Ghost.instanceList[_loc3_]._rotation = this.body_mc._rotation;
- this.ghostMode = true;
- }
- else
- {
- com.leadpipe.attentionhog.Ghost.beginFadeAll();
- this.ghostMode = false;
- }
- }
- function setBigHam(isActive, isPowerUp)
- {
- if(isActive && isPowerUp)
- {
- this.body_mc.gotoAndPlay("jump");
- this.body_mc.scale_mc.gotoAndPlay("jump");
- com.leadpipe.attentionhog.Game.instance.gaugeMain.setSpeed(0.03,0.2);
- }
- else if(isActive)
- {
- this.body_mc.gotoAndPlay("jump");
- this.body_mc.scale_mc.gotoAndPlay("jump");
- com.leadpipe.attentionhog.Game.instance.gaugeMain.setSpeed(0.02,0.2);
- }
- else
- {
- this.body_mc.gotoAndStop(1);
- this.body_mc.scale_mc.gotoAndStop(1);
- com.leadpipe.attentionhog.Game.instance.gaugeMain.setSpeed(0.01,0.2);
- }
- }
- function setPigsEye(isActive, isPowerUp)
- {
- if(isActive && isPowerUp)
- {
- this.body_mc.scale_mc.eye1_mc.gotoAndPlay("flashPowerUp");
- this.body_mc.scale_mc.eye2_mc.gotoAndPlay("flashPowerUp");
- for(var _loc2_ in com.leadpipe.attentionhog.Person.instanceList)
- {
- com.leadpipe.attentionhog.Person.instanceList[_loc2_].gauge.setSpeed(1,0.25);
- }
- }
- else if(isActive)
- {
- this.body_mc.scale_mc.eye1_mc.gotoAndPlay("flash");
- this.body_mc.scale_mc.eye2_mc.gotoAndPlay("flash");
- for(_loc2_ in com.leadpipe.attentionhog.Person.instanceList)
- {
- com.leadpipe.attentionhog.Person.instanceList[_loc2_].gauge.setSpeed(1,0.5);
- }
- }
- else
- {
- this.body_mc.scale_mc.eye1_mc.gotoAndStop(1);
- this.body_mc.scale_mc.eye2_mc.gotoAndStop(1);
- for(_loc2_ in com.leadpipe.attentionhog.Person.instanceList)
- {
- com.leadpipe.attentionhog.Person.instanceList[_loc2_].gauge.setSpeed(1,1);
- }
- }
- }
- function setHogTied(isActive, isPowerUp)
- {
- if(isActive && isPowerUp)
- {
- this.hogTiedMode = true;
- this.radiant_mc._alpha = 65;
- this.radiant_mc.gotoAndPlay(1);
- this.radiantMask_mc.gotoAndPlay(1);
- com.leadpipe.attentionhog.Person.followPlayerAll(true,2);
- }
- else if(isActive)
- {
- this.hogTiedMode = true;
- this.radiant_mc._alpha = 65;
- this.radiant_mc.gotoAndPlay(1);
- this.radiantMask_mc.gotoAndPlay(1);
- com.leadpipe.attentionhog.Person.followPlayerAll(true,1);
- }
- else
- {
- this.hogTiedMode = false;
- this.radiant_mc._alpha = 0;
- com.leadpipe.attentionhog.Person.followPlayerAll(false,1);
- }
- }
- function setBaconMode(b)
- {
- this.baconMode = b;
- if(this.baconMode)
- {
- this.squeal.start(0,1);
- this.timerBacon.start();
- this.trans.colorTransform = this.redTrans;
- _root.bgBacon_mc._alpha = 100;
- com.leadpipe.attentionhog.Ability.disableAll(true);
- }
- }
- function stopBaconMode()
- {
- this.timerBacon.clear();
- this.baconMode = false;
- this.trans.colorTransform = this.normalTrans;
- _root.bgBacon_mc._alpha = 0;
- com.leadpipe.attentionhog.Ability.disableAll(false);
- }
- function fadeAttentionSpan()
- {
- if(this.attentionSpan_mc._alpha <= 0)
- {
- this.timerAttentionSpan.clear();
- this.attentionSpanShowSwitch = 0;
- this.attentionSpan_mc._alpha = 0;
- }
- else
- {
- this.attentionSpan_mc._alpha -= 2;
- }
- }
- function onMouseDown()
- {
- if(this.isPaused)
- {
- return undefined;
- }
- this.mouseIsDown = true;
- this.attentionSpanShowSwitch = this.attentionSpanShowSwitch + 1;
- if(this.attentionSpanShowSwitch == 1)
- {
- this.attentionSpan_mc._alpha = 80;
- this.timerAttentionSpan.clear();
- this.timerAttentionSpan.start();
- }
- }
- function onMouseUp()
- {
- if(this.isPaused)
- {
- return undefined;
- }
- this.attentionSpanShowSwitch = 0;
- this.mouseIsDown = false;
- if(this.moveMode == "WALK")
- {
- this.moveMode = "JUMP";
- this.gotoAndPlay("jump");
- }
- }
- function checkCapture()
- {
- this.captured = 0;
- var _loc2_ = 0;
- while(_loc2_ < com.leadpipe.attentionhog.Person.instanceList.length)
- {
- if(com.leadpipe.attentionhog.Person.instanceList[_loc2_].checkCapture())
- {
- this.captured = this.captured + 1;
- }
- _loc2_ = _loc2_ + 1;
- }
- if(this.captured > 0)
- {
- this.feelingLove = true;
- }
- else
- {
- this.feelingLove = false;
- }
- com.leadpipe.attentionhog.Game.instance.setScore(this.captured);
- this.captured = 0;
- }
- function rotatePlayer()
- {
- if(this.wholeHogMode)
- {
- this.body_mc._rotation += this.spinInc;
- }
- else if(!(this.delta_x == 0 && this.delta_y == 0))
- {
- this.body_mc._rotation = this.angle;
- }
- }
- function moveWalk()
- {
- if(this.greasedPowerMode == true)
- {
- this._x = this.lastXMouse;
- this._y = this.lastYMouse;
- this.speed = 0;
- this.accel = 0;
- this.accelCntr = 0;
- }
- else
- {
- this.accelCntr += this.accelInc;
- this.accel = Math.pow(this.accelCntr,2);
- if(this.baconMode)
- {
- this.speed = 1;
- this.accelCntr = 0;
- }
- else
- {
- this.speed += this.accel / 3000;
- }
- if(Math.sqrt(this.delta_x * this.delta_x + this.delta_y * this.delta_y) > this.speed)
- {
- this._y -= this.speed * Math.cos(this.angle * 0.017453292519943295);
- this._x += this.speed * Math.sin(this.angle * 0.017453292519943295);
- }
- else
- {
- this.speed = 0;
- this.accel = 0;
- this.accelCntr = 0;
- this._x = this.lastXMouse;
- this._y = this.lastYMouse;
- }
- }
- }
- function moveJump()
- {
- this._x += (this.lastXMouse - this._x) / 5;
- this._y += (this.lastYMouse - this._y) / 5;
- }
- function destroy()
- {
- this.removeMovieClip();
- }
- static function getInstance()
- {
- if(com.leadpipe.attentionhog.Player.instance == null)
- {
- com.leadpipe.attentionhog.Player.instance = new com.leadpipe.attentionhog.Player();
- }
- return com.leadpipe.attentionhog.Player.instance;
- }
- }
-