home *** CD-ROM | disk | FTP | other *** search
- class Player
- {
- var mc;
- var timer;
- var playerPosition;
- var saveFramePosition;
- var mcProperties;
- var orientHandler;
- var speedHandler;
- var mouseCalculator;
- var playField;
- var orientAction;
- var isBallOwner;
- var tacleDistMax;
- var ball;
- var tacleVector;
- var smoothTrainee = true;
- function Player(mc, playField)
- {
- this.mc = mc;
- this.mc.gotoAndStop(1);
- this.mc.mcTrainee._visible = false;
- this.mc.mcDirection._visible = false;
- this.mc.mcLine._visible = false;
- this.mc.mcRollOver._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.saveFramePosition.frameMobile = 1;
- this.saveFramePosition.frameTacle = 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.mouseCalculator = new MouseMovieClipAngleCalculator(this.mc);
- this.playField = playField;
- this.orientAction = "mobile";
- this.isBallOwner = false;
- this.tacleDistMax = 30;
- }
- 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.mouseCalculator.getMouseAngleDEG();
- var _loc2_ = this.orientHandler.getPlayerOrientation(_loc3_,"mobile");
- return _loc2_.orient;
- }
- function getLine()
- {
- return this.mc.mcLine;
- }
- function getRollOver()
- {
- return this.mc.mcRollOver;
- }
- function setImmobile()
- {
- this.orientAction = "static";
- var _loc4_ = this.mouseCalculator.getMouseAngleDEG();
- 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 _loc3_ = this.orientHandler.getPlayerOrientation(_loc4_,this.orientAction);
- if(this.orientHandler.isFrameChanged())
- {
- this.mc.mcFootPlayer.mcColorMaillot.gotoAndStop(_loc3_.frame);
- this.mc.mcFootPlayer.gotoAndStop(_loc3_.frame);
- }
- else
- {
- this.mc.mcFootPlayer.mcColorMaillot.gotoAndStop(this.mc.mcFootPlayer._currentframe);
- this.mc.mcFootPlayer.gotoAndStop(this.mc.mcFootPlayer._currentframe);
- }
- if(this.smoothTrainee)
- {
- this.mc.mcTrainee._rotation = _loc4_;
- this.mc.mcDirection._rotation = _loc4_;
- this.mc.mcLine._rotation = _loc4_;
- }
- else
- {
- this.mc.mcTrainee._rotation = _loc3_.flash;
- this.mc.mcDirection._rotation = _loc3_.flash;
- this.mc.mcLine._rotation = _loc3_.flash;
- }
- if(this.isBallOwner == true)
- {
- var _loc5_ = new Vector2D(new Point2D(this.mc._x,this.mc._y),new Point2D(_root._xmouse,_root._ymouse));
- var _loc8_ = _loc5_.getX() / _loc5_.getNorme();
- var _loc7_ = _loc5_.getY() / _loc5_.getNorme();
- var _loc6_ = 8;
- this.ball.moveInField(this.mc._x + _loc8_ * _loc6_,this.mc._y + _loc7_ * _loc6_);
- }
- }
- function setImmobileStaticRollOver()
- {
- this.setImmobile();
- this.mc.mcBoost._visible = false;
- this.manageRollOver();
- if(this.isBallOwnerTest() == true)
- {
- this.mc.mcRollOver._visible = false;
- }
- }
- function setImmobileStatic()
- {
- this.setImmobile();
- this.mc.mcBoost._visible = false;
- }
- function manageRollOver()
- {
- if(_root._xmouse > this.mc._x - 40 && _root._xmouse < this.mc._x + 40)
- {
- if(_root._ymouse > this.mc._y - 40 && _root._ymouse < this.mc._y + 40)
- {
- if(this.isBallOwnerTest() == false)
- {
- this.mc.mcRollOver._visible = true;
- }
- }
- }
- else
- {
- this.mc.mcRollOver._visible = false;
- }
- }
- function setMobile(orientAction)
- {
- var _loc11_ = undefined;
- if(orientAction == "mobile")
- {
- _loc11_ = 7;
- }
- if(orientAction == "tacle")
- {
- _loc11_ = 4;
- }
- var _loc4_ = this.mouseCalculator.getMouseAngleDEG();
- this.speedHandler.boostAnalyser();
- this.speedHandler.setBoostLock(false);
- var _loc3_ = this.orientHandler.getPlayerOrientation(_loc4_,orientAction);
- if(this.smoothTrainee)
- {
- this.mc.mcTrainee._rotation = _loc4_;
- this.mc.mcDirection._rotation = _loc4_;
- this.mc.mcLine._rotation = _loc4_;
- }
- else
- {
- this.mc.mcTrainee._rotation = _loc3_.flash;
- this.mc.mcDirection._rotation = _loc3_.flash;
- this.mc.mcLine._rotation = _loc3_.flash;
- }
- var _loc12_ = this.timer.getElapsedTimeMs();
- if(_loc12_ >= this.speedHandler.getPlayerFramerate())
- {
- this.timer.setOldTimer(getTimer());
- var _loc7_ = undefined;
- if(orientAction == "mobile")
- {
- this.saveFramePosition.frameMobile = (this.saveFramePosition.frameMobile + 1) % 7;
- _loc7_ = this.saveFramePosition.frameMobile;
- }
- if(orientAction == "tacle")
- {
- this.saveFramePosition.frameTacle = (this.saveFramePosition.frameTacle + 1) % 4;
- _loc7_ = this.saveFramePosition.frameTacle;
- }
- this.mc.mcFootPlayer.mcColorMaillot.gotoAndPlay(_loc3_.frame + _loc7_);
- this.mc.mcFootPlayer.gotoAndPlay(_loc3_.frame + _loc7_);
- }
- var _loc5_ = new Vector2D(new Point2D(this.mc._x,this.mc._y),new Point2D(_root._xmouse,_root._ymouse));
- var _loc10_ = _loc5_.getX() / _loc5_.getNorme() * this.speedHandler.getSpeed() * this.speedHandler.getBoostPower();
- var _loc8_ = _loc5_.getY() / _loc5_.getNorme() * this.speedHandler.getSpeed() * this.speedHandler.getBoostPower();
- this.move(this.mc._x + _loc10_,this.mc._y + _loc8_);
- this.playerPosition.setX(this.mc._x);
- this.playerPosition.setY(this.mc._y);
- if(this.isBallOwner == true)
- {
- var _loc9_ = 20;
- this.ball.moveInField(this.mc._x + _loc10_ * _loc9_,this.mc._y + _loc8_ * _loc9_);
- }
- }
- function setMobileTacle()
- {
- var _loc10_ = 4;
- var _loc8_ = Math.atan2(this.tacleVector.getY(),this.tacleVector.getX());
- var _loc3_ = _loc8_ * 180 / 3.141592653589793;
- this.speedHandler.boostAnalyser();
- this.speedHandler.setBoostLock(false);
- var _loc2_ = this.orientHandler.getPlayerOrientation(_loc3_,"tacle");
- if(this.smoothTrainee)
- {
- this.mc.mcTrainee._rotation = _loc3_;
- this.mc.mcDirection._rotation = _loc3_;
- this.mc.mcLine._rotation = _loc3_;
- }
- else
- {
- this.mc.mcTrainee._rotation = _loc2_.flash;
- this.mc.mcDirection._rotation = _loc2_.flash;
- this.mc.mcLine._rotation = _loc2_.flash;
- }
- var _loc9_ = this.timer.getElapsedTimeMs();
- if(_loc9_ >= this.speedHandler.getPlayerFramerate())
- {
- this.timer.setOldTimer(getTimer());
- var _loc4_ = undefined;
- this.saveFramePosition.frameTacle = (this.saveFramePosition.frameTacle + 1) % 4;
- _loc4_ = this.saveFramePosition.frameTacle;
- this.mc.mcFootPlayer.mcColorMaillot.gotoAndPlay(_loc2_.frame + _loc4_);
- this.mc.mcFootPlayer.gotoAndPlay(_loc2_.frame + _loc4_);
- }
- var _loc7_ = this.tacleVector.getX() / this.tacleVector.getNorme() * this.speedHandler.getSpeed() * this.speedHandler.getBoostPower();
- var _loc5_ = this.tacleVector.getY() / this.tacleVector.getNorme() * this.speedHandler.getSpeed() * this.speedHandler.getBoostPower();
- this.move(this.mc._x + _loc7_,this.mc._y + _loc5_);
- this.playerPosition.setX(this.mc._x);
- this.playerPosition.setY(this.mc._y);
- if(this.isBallOwner == true)
- {
- var _loc6_ = 10;
- this.ball.moveInField(this.mc._x + _loc7_ * _loc6_,this.mc._y + _loc5_ * _loc6_);
- }
- }
- function modeNoSelected()
- {
- this.mc.mcBoost._visible = false;
- this.mc.mcSelection._visible = false;
- this.mc.mcTrainee._visible = false;
- this.mc.mcLine._xscale = 0;
- }
- function modeSelected()
- {
- var _loc2_ = this.mouseCalculator.getMouseDistance();
- var _loc3_ = this.mouseCalculator.getMouseAngleDEG();
- if(_loc2_ <= 2)
- {
- this.setImmobile();
- }
- else
- {
- this.mc.mcDirection._rotation = _loc3_;
- this.mc.mcLine._xscale = _loc2_ * 2;
- this.setMobile("mobile");
- }
- }
- function modeSelectedStatic()
- {
- var _loc2_ = this.mouseCalculator.getMouseDistance();
- var _loc3_ = this.mouseCalculator.getMouseAngleDEG();
- this.mc.mcSelection._visible = true;
- this.mc.mcDirection._rotation = _loc3_;
- this.mc.mcLine._xscale = _loc2_ * 2;
- }
- function modeTacle()
- {
- var _loc2_ = this.mouseCalculator.getMouseDistance();
- var _loc3_ = this.mouseCalculator.getMouseAngleDEG();
- this.mc.mcDirection._rotation = _loc3_;
- this.mc.mcLine._xscale = _loc2_ * 2;
- this.setMobile("tacle");
- }
- function modeTacle2()
- {
- this.setSpeedBoost(false);
- var _loc2_ = this.mouseCalculator.getMouseDistance();
- var _loc3_ = this.mouseCalculator.getMouseAngleDEG();
- this.mc.mcFootPlayer.mcDirection._rotation = _loc3_;
- this.mc.mcLine._xscale = _loc2_ * 2;
- this.setMobileTacle();
- }
- 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 setPlayerBallOwner(bool)
- {
- this.isBallOwner = bool;
- this.ball.moveInField(this.playerPosition.getX(),this.playerPosition.getY());
- this.ball.updateTrueValues();
- }
- function isBallOwnerTest()
- {
- return this.isBallOwner;
- }
- function setTacleVector(tacleVector)
- {
- this.tacleVector = tacleVector;
- }
- function getTacleVector(tacleVector)
- {
- return this.tacleVector;
- }
- function setDirectionVisible(bool)
- {
- this.mc.mcDirection._visible = bool;
- }
- function setLineVisible(bool)
- {
- this.mc.mcLine._visible = bool;
- }
- function trace()
- {
- trace("Player: " + this.mc);
- }
- }
-