home *** CD-ROM | disk | FTP | other *** search
- class PlayerTargetTracker
- {
- var mc;
- var timer;
- var playerPosition;
- var saveFramePosition;
- var mcProperties;
- var orientHandler;
- var speedHandler;
- var targetCalculator;
- var playField;
- var mcTarget;
- var isBallOwner;
- var ball;
- var smoothTrainee = true;
- function PlayerTargetTracker(mc, playField, mcTarget)
- {
- this.mc = mc;
- this.mc.gotoAndStop(1);
- this.mc.mcTrainee._visible = false;
- this.mc.mcDirection._visible = false;
- this.mc.mcLine._visible = false;
- this.timer = new TimerSynchronizer();
- this.playerPosition = new Point2D(this.mc._x,this.mc._y);
- this.saveFramePosition = new Object();
- this.saveFramePosition.player = 1;
- this.saveFramePosition.maillot = 1;
- this.saveFramePosition.frameSeq = 1;
- this.mcProperties = new Object();
- this.mcProperties.umountDirection = 8;
- this.mcProperties.orientation = -1;
- this.orientHandler = new PlayerOrientationHandler();
- this.speedHandler = new PlayerSpeedHandler(this.mc.mcBoost,this.mc.mcTrainee);
- this.targetCalculator = new TargetMovieClipAngleCalculator(this.mc,mcTarget);
- this.playField = playField;
- this.mcTarget = mcTarget;
- }
- function move(x, y)
- {
- var _loc2_ = undefined;
- var _loc3_ = undefined;
- _loc2_ = x;
- _loc3_ = y;
- if(this.playField != null)
- {
- if(this.mc._x < this.playField.getMinX() || x < this.playField.getMinX())
- {
- _loc2_ = this.playField.getMinX();
- }
- if(this.mc._x > this.playField.getMaxX() || x > this.playField.getMaxX())
- {
- _loc2_ = this.playField.getMaxX();
- }
- if(this.mc._y < this.playField.getMinY() || y < this.playField.getMinY())
- {
- _loc3_ = this.playField.getMinY();
- }
- if(this.mc._y > this.playField.getMaxY() || y > this.playField.getMaxY())
- {
- _loc3_ = this.playField.getMaxY();
- }
- }
- this.mc._x = _loc2_;
- this.mc._y = _loc3_;
- this.playerPosition.setX(_loc2_);
- this.playerPosition.setY(_loc3_);
- }
- function getX()
- {
- return this.mc._x;
- }
- function getY()
- {
- return this.mc._y;
- }
- function getOrientation()
- {
- var _loc3_ = this.targetCalculator.getTargetAngleDEG();
- var _loc2_ = this.orientHandler.getPlayerOrientation(_loc3_,"mobile");
- return _loc2_.orient;
- }
- function setImmobile()
- {
- var _loc3_ = this.targetCalculator.getTargetAngleDEG();
- this.speedHandler.boostAnalyser();
- this.speedHandler.setBoostLock(true);
- this.mc.mcTrainee._visible = false;
- this.saveFramePosition.player = this.mc.mcFootPlayer._currentframe;
- this.saveFramePosition.maillot = this.mc.mcFootPlayer.mcColorMaillot._currentframe;
- var _loc2_ = this.orientHandler.getPlayerOrientation(_loc3_,"static");
- if(this.orientHandler.isFrameChanged())
- {
- this.mc.mcFootPlayer.mcColorMaillot.gotoAndStop(_loc2_.frame);
- this.mc.mcFootPlayer.gotoAndStop(_loc2_.frame);
- }
- else
- {
- this.mc.mcFootPlayer.mcColorMaillot.gotoAndStop(this.mc.mcFootPlayer._currentframe);
- this.mc.mcFootPlayer.gotoAndStop(this.mc.mcFootPlayer._currentframe);
- }
- if(this.isBallOwner == true)
- {
- }
- }
- function setMobile()
- {
- var _loc4_ = this.targetCalculator.getTargetAngleDEG();
- this.speedHandler.setBoostLock(false);
- this.mc.mcFootPlayer.mcDirection._visible = true;
- var _loc3_ = this.orientHandler.getPlayerOrientation(_loc4_,"mobile");
- if(this.smoothTrainee)
- {
- this.mc.mcTrainee._rotation = _loc4_;
- }
- else
- {
- this.mc.mcTrainee._rotation = _loc3_.flash;
- }
- var _loc9_ = this.timer.getElapsedTimeMs();
- if(_loc9_ >= this.speedHandler.getPlayerFramerate())
- {
- this.timer.setOldTimer(getTimer());
- this.saveFramePosition.frameSeq = (this.saveFramePosition.frameSeq + 1) % 7;
- var _loc5_ = this.saveFramePosition.frameSeq;
- this.mc.mcFootPlayer.mcColorMaillot.gotoAndPlay(_loc3_.frame + _loc5_);
- this.mc.mcFootPlayer.gotoAndPlay(_loc3_.frame + _loc5_);
- }
- var _loc2_ = new Vector2D(new Point2D(this.mc._x,this.mc._y),new Point2D(this.mcTarget._x,this.mcTarget._y));
- var _loc8_ = _loc2_.getX() / _loc2_.getNorme() * this.speedHandler.getSpeed() * this.speedHandler.getBoostPower();
- var _loc6_ = _loc2_.getY() / _loc2_.getNorme() * this.speedHandler.getSpeed() * this.speedHandler.getBoostPower();
- this.move(this.mc._x + _loc8_,this.mc._y + _loc6_);
- this.playerPosition.setX(this.mc._x);
- this.playerPosition.setY(this.mc._y);
- if(this.isBallOwner == true)
- {
- var _loc7_ = 6;
- this.ball.setRotationDEG(_loc4_);
- this.ball.moveInField(this.mc._x + _loc8_ * _loc7_,this.mc._y + _loc6_ * _loc7_);
- }
- }
- function modeNoSelected()
- {
- this.mc.mcBoost._visible = false;
- this.mc.mcSelection._visible = false;
- this.mc.mcTrainee._visible = false;
- }
- function modeSelected()
- {
- var _loc2_ = this.targetCalculator.getTargetDistance();
- var _loc3_ = this.targetCalculator.getTargetAngleDEG();
- if(_loc2_ <= 2)
- {
- this.setImmobile();
- }
- else
- {
- this.mc.mcFootPlayer.mcDirection._rotation = _loc3_;
- this.setMobile();
- }
- }
- function setSpeedBoost(bool)
- {
- if(bool == true && this.speedHandler.getBoostLock() == false)
- {
- this.speedHandler.boostActivation();
- return undefined;
- }
- if(bool == false || this.speedHandler.getBoostLock() == false)
- {
- this.speedHandler.boostDesactivation();
- return undefined;
- }
- }
- function getBallInstance(ball)
- {
- this.ball = ball;
- }
- function getMovieClip()
- {
- return this.mc;
- }
- function setRunSpeed(speed)
- {
- this.speedHandler.setSpeed(speed);
- }
- function setPlayerBallOwner(bool)
- {
- this.isBallOwner = bool;
- this.ball.moveInField(this.playerPosition.getX(),this.playerPosition.getY());
- }
- function isBallOwnerTest()
- {
- return this.isBallOwner;
- }
- function setDirectionVisible(bool)
- {
- this.mc.mcDirection._visible = bool;
- }
- function setLineVisible(bool)
- {
- this.mc.mcLine._visible = bool;
- }
- }
-