home *** CD-ROM | disk | FTP | other *** search
- class Player extends LRG.LRGMovieClip
- {
- var m_kController;
- var m_fAngularVelocity;
- var m_fSpeed;
- var m_fLastUpdateTime;
- var m_fLastShootTime;
- var m_bTurningLeft;
- var m_bTurningRight;
- var m_bEndingTurn;
- var m_fLastRotation;
- var m_bFiring;
- var m_fFireRate;
- var m_kFireBeamEmissionPoint;
- function Player()
- {
- super();
- }
- function init()
- {
- super.init();
- this.setClock(_global.getGameTimer());
- var _loc4_ = new Object();
- _loc4_.m_sName = "GENERIC";
- _loc4_.m_fFPS = 120;
- var _loc5_ = new LRG.LRGGenericAction(_loc4_);
- this.addAction(_loc5_);
- this.setupTurnAnimationActions();
- this.m_kController = undefined;
- this.m_fAngularVelocity = 0;
- this.m_fSpeed = 0;
- this.m_fLastUpdateTime = this.getClipTime();
- this.m_fLastShootTime = this.getClipTime();
- this.m_bTurningLeft = false;
- this.m_bTurningRight = false;
- this.m_bEndingTurn = false;
- }
- function setupTurnAnimationActions()
- {
- var _loc6_ = new Object();
- _loc6_.m_sName = "START_LEFT_TURN";
- _loc6_.m_fFPS = 120;
- _loc6_.m_fStartFrame = 83;
- _loc6_.m_fEndFrame = 112;
- _loc6_.m_bLoop = false;
- _loc6_.m_fDirection = 1;
- var _loc12_ = new LRG.LRGAnimationAction(_loc6_);
- this.addAction(_loc12_);
- var _loc4_ = new Object();
- _loc4_.m_sName = "LOOP_LEFT_TURN";
- _loc4_.m_fFPS = 120;
- _loc4_.m_fStartFrame = 113;
- _loc4_.m_fEndFrame = 142;
- _loc4_.m_bLoop = false;
- _loc4_.m_fDirection = 1;
- var _loc13_ = new LRG.LRGAnimationAction(_loc4_);
- this.addAction(_loc13_);
- var _loc5_ = new Object();
- _loc5_.m_sName = "STOP_LEFT_TURN";
- _loc5_.m_fFPS = 20;
- _loc5_.m_fStartFrame = 83;
- _loc5_.m_fEndFrame = 112;
- _loc5_.m_bLoop = false;
- _loc5_.m_fDirection = -1;
- var _loc8_ = new LRG.LRGAnimationAction(_loc5_);
- this.addAction(_loc8_);
- var _loc2_ = new Object();
- _loc2_.m_sName = "START_RIGHT_TURN";
- _loc2_.m_fFPS = 120;
- _loc2_.m_fStartFrame = 23;
- _loc2_.m_fEndFrame = 52;
- _loc2_.m_bLoop = false;
- _loc2_.m_fDirection = 1;
- var _loc9_ = new LRG.LRGAnimationAction(_loc2_);
- this.addAction(_loc9_);
- var _loc3_ = new Object();
- _loc3_.m_sName = "LOOP_RIGHT_TURN";
- _loc3_.m_fFPS = 120;
- _loc3_.m_fStartFrame = 53;
- _loc3_.m_fEndFrame = 82;
- _loc3_.m_bLoop = false;
- _loc3_.m_fDirection = 1;
- var _loc10_ = new LRG.LRGAnimationAction(_loc3_);
- this.addAction(_loc10_);
- var _loc7_ = new Object();
- _loc7_.m_sName = "STOP_RIGHT_TURN";
- _loc7_.m_fFPS = 20;
- _loc7_.m_fStartFrame = 23;
- _loc7_.m_fEndFrame = 52;
- _loc7_.m_bLoop = false;
- _loc7_.m_fDirection = -1;
- var _loc11_ = new LRG.LRGAnimationAction(_loc7_);
- this.addAction(_loc11_);
- }
- function onStartGame()
- {
- this.m_kController.onStartGame();
- }
- function onStartRound()
- {
- this.setSpeed(Settings(_global.getSettings()).getSetting("PLAYER_TURN_SPEED"));
- this.setFireRate(Settings(_global.getSettings()).getSetting("PLAYER_FIRE_RATE"));
- this.m_fLastUpdateTime = this.getClipTime();
- this.m_fLastShootTime = 0;
- this.startAction("GENERIC",null,true);
- this.m_kController.onStartRound();
- this.m_fLastRotation = 0;
- this.m_bFiring = false;
- this.gotoAndStop("Normal");
- }
- function onEndRound()
- {
- this.m_kController.onEndRound();
- this.stopAction("GENERIC",false);
- }
- function setController(kController)
- {
- this.m_kController = kController;
- this.m_kController.setPlayer(this);
- }
- function setAngularVelocity(fVel)
- {
- this.m_fAngularVelocity = fVel;
- }
- function getAngularVelocity()
- {
- return this.m_fAngularVelocity;
- }
- function setSpeed(fSpeed)
- {
- this.m_fSpeed = fSpeed;
- }
- function getSpeed()
- {
- return this.m_fSpeed;
- }
- function setFireRate(fFireRate)
- {
- this.m_fFireRate = fFireRate;
- }
- function getFireRate()
- {
- return this.m_fFireRate;
- }
- function isFiring()
- {
- return this.m_bFiring;
- }
- function onRequestTurnLeft()
- {
- this.setAngularVelocity(- this.m_fSpeed);
- }
- function onRequestTurnRight()
- {
- this.setAngularVelocity(this.m_fSpeed);
- }
- function onRequestStop()
- {
- this.setAngularVelocity(0);
- }
- function onRequestShootFireBeam()
- {
- if(!this.m_bFiring)
- {
- var _loc4_ = _global.g_kApplication.m_kGameScreen;
- var _loc3_ = this.getClipTime() - this.m_fLastShootTime;
- if(_loc3_ > 1 / this.m_fFireRate)
- {
- this.playAnimation("SHOOT_FIRE",45,11,21,false,1);
- this.m_bFiring = true;
- }
- }
- }
- function doEnterFrame()
- {
- if(ApplicationState(_global.getApplicationState()).isPaused())
- {
- return undefined;
- }
- var _loc3_ = this.getClipTime() - this.m_fLastUpdateTime;
- this.m_kController.update(_loc3_);
- this._rotation += this.m_fAngularVelocity * _loc3_;
- if(this._rotation != this.m_fLastRotation && !this.m_bFiring)
- {
- if(!this.m_bTurningLeft && !this.m_bTurningRight)
- {
- var _loc5_ = Math.abs(this._rotation - this.m_fLastRotation + 360) % 360;
- var _loc4_ = Math.abs(this.m_fLastRotation - this._rotation + 360) % 360;
- if(_loc5_ < _loc4_)
- {
- if(this.m_bEndingTurn)
- {
- this.m_bEndingTurn = false;
- this.startAction("LOOP_RIGHT_TURN",null,true);
- }
- else
- {
- this.startAction("START_RIGHT_TURN",null,true);
- }
- this.m_bTurningRight = true;
- }
- else
- {
- if(this.m_bEndingTurn)
- {
- this.m_bEndingTurn = false;
- this.startAction("LOOP_LEFT_TURN",null,true);
- }
- else
- {
- this.startAction("START_LEFT_TURN",null,true);
- }
- this.m_bTurningLeft = true;
- }
- }
- }
- this.m_fLastRotation = this._rotation;
- this.m_fLastUpdateTime = this.getClipTime();
- }
- function onActionCompleted(sActionKey)
- {
- switch(sActionKey)
- {
- case "SHOOT_FIRE":
- var _loc4_ = _global.g_kApplication.m_kGameScreen;
- this.m_bFiring = false;
- if(_loc4_.getFireBeam())
- {
- _loc4_.onRequestRemoveFireBeam();
- }
- _global.playSound("fma_roy_shoots.wav",1,this);
- PlayerState(_global.getPlayerState()).setShotsThisRound(PlayerState(_global.getPlayerState()).getShotsThisRound() + 1);
- PlayerState(_global.getPlayerState()).setShotsTotal(PlayerState(_global.getPlayerState()).getShotsTotal() + 1);
- this.m_fLastShootTime = this.getClipTime();
- var _loc3_ = {x:this.m_kFireBeamEmissionPoint._x,y:this.m_kFireBeamEmissionPoint._y};
- this.localToGlobal(_loc3_);
- _loc4_.shootFireBeam(_loc3_.x,_loc3_.y,this._rotation,Settings(_global.getSettings()).getSetting("FIRE_BEAM_SPEED"));
- case "START_LEFT_TURN":
- case "START_RIGHT_TURN":
- case "LOOP_LEFT_TURN":
- case "LOOP_RIGHT_TURN":
- if(this._rotation != this.m_fLastRotation)
- {
- var _loc6_ = Math.abs(this._rotation - this.m_fLastRotation + 360) % 360;
- var _loc5_ = Math.abs(this.m_fLastRotation - this._rotation + 360) % 360;
- if(_loc6_ < _loc5_)
- {
- this.startAction("LOOP_RIGHT_TURN",null,true);
- this.m_bTurningRight = true;
- this.m_bTurningLeft = false;
- }
- else
- {
- this.startAction("LOOP_LEFT_TURN",null,true);
- this.m_bTurningLeft = true;
- this.m_bTurningRight = false;
- }
- }
- else
- {
- if(this.m_bTurningLeft)
- {
- this.startAction("STOP_LEFT_TURN",null,true);
- }
- else
- {
- this.startAction("STOP_RIGHT_TURN",null,true);
- }
- this.m_bEndingTurn = true;
- this.m_bTurningLeft = false;
- this.m_bTurningRight = false;
- }
- break;
- case "STOP_LEFT_TURN":
- case "STOP_RIGHT_TURN":
- this.m_bEndingTurn = false;
- this.gotoAndStop("Stand");
- }
- }
- }
-