home *** CD-ROM | disk | FTP | other *** search
- class Vehicule
- {
- var SPEED_MAX = 30;
- var SPEED_MIN = -2;
- var SPEED_ACCEL = 1;
- var SPEED_BRAKE = 0.8;
- var SPEED_DECEL = 0.95;
- var SPEED_IDLE = 20;
- var STEERING = 18;
- var STEERING_SPEED = 10;
- var STEERING_MIN_SPEED = 5;
- var STEERING_FACTOR = 3;
- var etat = new String();
- var oldEtat = new String();
- var nom = new String();
- var speed = new Number();
- var changeDir = new String();
- var bounce = new Boolean();
- var mcRef = null;
- var stateLocked = new Boolean();
- var paused = new Boolean();
- function Vehicule(l_mcRef)
- {
- this.nom = l_mcRef._name;
- this.etat = "MoveIdle";
- this.oldEtat = "MoveIdle";
- this.speed = 0;
- this.changeDir = null;
- this.bounce = false;
- this.mcRef = l_mcRef;
- this.stateLocked = false;
- this.paused = false;
- }
- function DoClipHitTest(l_obj, l_mcZone)
- {
- var _loc2_ = new Boolean();
- if(l_mcZone != undefined)
- {
- _loc2_ = this.mcRef[l_mcZone].hitTest(l_obj);
- }
- else
- {
- _loc2_ = this.mcRef.hitTest(l_obj);
- }
- return _loc2_;
- }
- function DoHitTest(l_coord, l_mcZone)
- {
- var _loc2_ = new Boolean();
- if(l_mcZone != undefined)
- {
- _loc2_ = this.mcRef[l_mcZone].hitTest(l_coord.x,l_coord.y,true);
- }
- else
- {
- _loc2_ = this.mcRef.hitTest(l_coord.x,l_coord.y,true);
- }
- return _loc2_;
- }
- function EastOrWeast()
- {
- var _loc2_ = new String();
- if(this.GetPropRotation() >= 0)
- {
- _loc2_ = "e";
- }
- else
- {
- _loc2_ = "w";
- }
- return _loc2_;
- }
- function EnterFrame()
- {
- if(!this.paused)
- {
- this[this.etat]();
- }
- }
- function GetName()
- {
- return this.nom;
- }
- function GetPropCoord()
- {
- var _loc2_ = new Object();
- _loc2_.x = this.mcRef._x;
- _loc2_.y = this.mcRef._y;
- return _loc2_;
- }
- function GetPropRotation()
- {
- return this.mcRef._rotation;
- }
- function GetRotation()
- {
- return this.mcRef._rotation;
- }
- function GetSpeed()
- {
- return this.speed;
- }
- function GetStageCoord()
- {
- var _loc2_ = this.GetPropCoord();
- this.mcRef._parent.localToGlobal(_loc2_);
- return _loc2_;
- }
- function GetState()
- {
- var _loc2_ = new String();
- if(this.stateLocked)
- {
- _loc2_ = "Locked";
- }
- else
- {
- _loc2_ = this.etat;
- }
- return _loc2_;
- }
- function GetTrajectory()
- {
- return this.changeDir;
- }
- function GetZone()
- {
- var _loc3_ = this.GetPropCoord();
- this.mcRef._parent.localToGlobal(_loc3_);
- return _global.C.utils.GetHitZone(_loc3_);
- }
- function Idle()
- {
- if(this.changeDir == "Left")
- {
- this.RotateVeh(- this.STEERING);
- }
- else if(this.changeDir == "Right")
- {
- this.RotateVeh(this.STEERING);
- }
- }
- function IsBouncing()
- {
- return this.bounce;
- }
- function MoveBack()
- {
- var _loc2_ = this.GetSpeed();
- if(_loc2_ > 0)
- {
- _loc2_ *= this.SPEED_BRAKE;
- this.SetSpeed(_loc2_);
- this.MoveVeh();
- }
- }
- function MoveForw()
- {
- if(!this.bounce)
- {
- var _loc2_ = this.GetSpeed();
- _loc2_ += this.SPEED_ACCEL;
- this.SetSpeed(_loc2_);
- this.MoveVeh();
- }
- else
- {
- this.SetSpeed(this.GetSpeed() * this.SPEED_DECEL);
- this.MoveVeh();
- }
- }
- function MoveIdle()
- {
- if(!this.bounce && this.etat != "Inflating")
- {
- if(this.speed > this.SPEED_IDLE)
- {
- this.SetSpeed(this.GetSpeed() * this.SPEED_DECEL);
- }
- else if(this.speed < this.SPEED_IDLE)
- {
- this.SetSpeed(this.GetSpeed() + this.SPEED_ACCEL);
- }
- }
- else
- {
- this.SetSpeed(this.GetSpeed() * this.SPEED_DECEL);
- if(this.GetSpeed() < 1)
- {
- this.SetCommand("Idle");
- }
- }
- this.MoveVeh();
- }
- function MoveVeh()
- {
- }
- function NorthOrSouth()
- {
- var _loc2_ = new String();
- if(Math.abs(this.GetPropRotation()) <= 90)
- {
- _loc2_ = "n";
- }
- else
- {
- _loc2_ = "s";
- }
- return _loc2_;
- }
- function Pause()
- {
- this.mcRef.Etat.stop();
- this.paused = true;
- }
- function RotateVeh(l_steeringValue)
- {
- l_steeringValue /= this.STEERING_FACTOR;
- l_steeringValue += this.GetPropRotation();
- this.SetPropRotation(l_steeringValue);
- }
- function SetCommand(l_state)
- {
- if(!this.stateLocked)
- {
- this.oldEtat = this.etat;
- this.etat = l_state;
- }
- }
- function SetPropRotation(l_rotation)
- {
- this.mcRef._rotation = l_rotation;
- }
- function SetSpeed(l_speed)
- {
- if(l_speed <= this.SPEED_MAX && l_speed >= this.SPEED_MIN)
- {
- this.speed = l_speed;
- }
- if(Math.abs(this.speed) < 1 && Math.abs(this.speed) > 0)
- {
- this.speed = 0;
- }
- }
- function SetState(l_newState)
- {
- if(l_newState != undefined && l_newState != this.etat && !this.stateLocked)
- {
- this.oldEtat = this.etat;
- this.etat = l_newState;
- this.mcRef.gotoAndPlay(l_newState);
- }
- }
- function SetStateLocked()
- {
- this.stateLocked = true;
- }
- function SetTrajectory(l_TurnTo)
- {
- if(!this.stateLocked)
- {
- if(this.changeDir != l_TurnTo && (l_TurnTo == "Left" || l_TurnTo == "Right" || l_TurnTo == null))
- {
- this.changeDir = l_TurnTo;
- }
- }
- }
- function UnPause()
- {
- this.mcRef.Etat.play();
- this.paused = false;
- }
- }
-