home *** CD-ROM | disk | FTP | other *** search
Text File | 2005-11-18 | 32.4 KB | 1,079 lines |
- class Ed extends Vehicule
- {
- var FR_INFLATING = 59;
- var FR_HANDBRAKE = 34;
- var FR_JUMPING1 = 38;
- var FR_JUMPING2 = 30;
- var FR_JUMPING3 = 30;
- var FR_BOUNCE = 10;
- var FR_THROW_FORW = 5;
- var FR_THROW_LEFT = 5;
- var FR_THROW_RIGHT = 5;
- var FR_FALLING = 47;
- var FR_DEFLATING = 54;
- var ANIM_SPEED_ACC = 14;
- var SPEED_MAX = 38;
- var SPEED_ACCEL = 1;
- var STEERING = 22;
- var SPEED_JUMP = 0.99;
- var van = new Object();
- var vanAi = new Object();
- var pack = new Object();
- var oldTrajectory = new String();
- var nextAnimToPlay = new String();
- var oldSpeed = new Number();
- var wasBreaking = new Boolean();
- var oldPosX = new Number();
- var oldPosY = new Number();
- var oldZone = new Object();
- var noFrame = new Number();
- var powerUpSpeedFactor = new Number();
- var powerUpAccelFactor = new Number();
- function Ed(l_mc)
- {
- super(l_mc);
- this.noFrame = 25;
- this.oldTrajectory = null;
- this.wasBreaking = false;
- this.van = _global.C[_global.C.G_van];
- this.vanAi = _global.C[_global.C.G_vanAi];
- this.pack = _global.C[_global.C.G_package];
- this.CenterVehToStartPos();
- this.powerUpSpeedFactor = 1;
- this.powerUpAccelFactor = 1;
- this.nextAnimToPlay = null;
- this.oldZone = this.GetZone();
- this.mcRef.PU.burnInsigna.gotoAndStop("PasLa");
- this.mcRef.PU.deetsInsigna.gotoAndStop("PasLa");
- this.mcRef.PU.loogieInsigna.gotoAndStop("PasLa");
- }
- function Bounce()
- {
- if(this.mcRef.Etat._currentframe >= this.FR_BOUNCE)
- {
- this.SetState("MoveIdle");
- }
- else
- {
- this.MoveIdle();
- }
- }
- function CenterVehToStartPos()
- {
- var _loc3_ = new Object();
- _loc3_.x = _global.C._parent.ScrollMap.Items.Map.HitContainer["StartPos" + this.nom]._x;
- _loc3_.y = _global.C._parent.ScrollMap.Items.Map.HitContainer["StartPos" + this.nom]._y;
- _loc3_ = _global.C.utils.ConvertHitPosToMap(_loc3_);
- _global.C._parent.ScrollMap.Items.Map._x = _loc3_.x;
- _global.C._parent.ScrollMap.Items.Map._y = _loc3_.y;
- _global.C._parent.ScrollMap.Items.Front._x = _loc3_.x;
- _global.C._parent.ScrollMap.Items.Front._y = _loc3_.y;
- _global.C._parent.ScrollMap.Items.Parallax._x = _loc3_.x;
- _global.C._parent.ScrollMap.Items.Parallax._y = _loc3_.y;
- this.mcRef._rotation = 90;
- }
- function DesactivateItems()
- {
- var _loc5_ = _global.C.G_hitObjTab[this.oldZone.x][this.oldZone.y].length;
- var _loc4_ = new Object();
- if(_loc5_ > 0)
- {
- var _loc3_ = 0;
- while(_loc3_ < _loc5_)
- {
- _loc4_ = _global.C[_global.C.G_hitObjTab[this.oldZone.x][this.oldZone.y][_loc3_]];
- _loc4_.GotoMcState("PasLa",false);
- _loc3_ = _loc3_ + 1;
- }
- }
- }
- function Activate(l_zoneX, l_zoneY)
- {
- var _loc4_ = new Object();
- var _loc3_ = new String();
- _loc4_.x = l_zoneX;
- _loc4_.y = l_zoneY;
- var _loc5_ = _global.C.G_hitObjTab[_loc4_.x][_loc4_.y].length;
- if(_loc5_ > 0)
- {
- var _loc2_ = 0;
- while(_loc2_ < _loc5_)
- {
- _loc3_ = _global.C.G_hitObjTab[_loc4_.x][_loc4_.y][_loc2_];
- if(_global.C[_loc3_].GetMissionId() <= _global.C.G_missionId)
- {
- _global.C[_loc3_].GotoMcState(_global.C[_loc3_].GetMcState(),true);
- }
- _loc2_ = _loc2_ + 1;
- }
- }
- }
- function Desactivate(l_zoneX, l_zoneY)
- {
- var _loc5_ = new Object();
- var _loc4_ = new String();
- _loc5_.x = l_zoneX;
- _loc5_.y = l_zoneY;
- var _loc3_ = _global.C.G_hitObjTab[_loc5_.x][_loc5_.y].length;
- if(_loc3_ > 0)
- {
- var _loc2_ = 0;
- while(_loc2_ < _loc3_)
- {
- _global.C[_loc4_].GotoMcState("PasLa",false);
- _loc2_ = _loc2_ + 1;
- }
- }
- }
- function ActivateItems()
- {
- var _loc3_ = new String();
- var _loc2_ = this.GetZone();
- if(_loc2_.x == this.oldZone.x)
- {
- if(_loc2_.y < this.oldZone.y)
- {
- this.Activate(_loc2_.x,_loc2_.y - 1);
- this.Activate(_loc2_.x - 1,_loc2_.y - 1);
- this.Activate(_loc2_.x + 1,_loc2_.y - 1);
- this.Desactivate(_loc2_.x,_loc2_.y + 2);
- this.Desactivate(_loc2_.x - 1,_loc2_.y + 2);
- this.Desactivate(_loc2_.x + 1,_loc2_.y + 2);
- }
- else
- {
- this.Activate(_loc2_.x,_loc2_.y + 1);
- this.Activate(_loc2_.x - 1,_loc2_.y + 1);
- this.Activate(_loc2_.x + 1,_loc2_.y + 1);
- this.Desactivate(_loc2_.x,_loc2_.y - 2);
- this.Desactivate(_loc2_.x - 1,_loc2_.y - 2);
- this.Desactivate(_loc2_.x + 1,_loc2_.y - 2);
- }
- }
- else if(_loc2_.x < this.oldZone.x)
- {
- this.Activate(_loc2_.x - 1,_loc2_.y);
- this.Activate(_loc2_.x - 1,_loc2_.y + 1);
- this.Activate(_loc2_.x - 1,_loc2_.y - 1);
- this.Desactivate(_loc2_.x + 2,_loc2_.y);
- this.Desactivate(_loc2_.x + 2,_loc2_.y + 1);
- this.Desactivate(_loc2_.x + 2,_loc2_.y - 1);
- }
- else
- {
- this.Activate(_loc2_.x + 1,_loc2_.y);
- this.Activate(_loc2_.x + 1,_loc2_.y + 1);
- this.Activate(_loc2_.x + 1,_loc2_.y - 1);
- this.Desactivate(_loc2_.x - 2,_loc2_.y);
- this.Desactivate(_loc2_.x - 2,_loc2_.y + 1);
- this.Desactivate(_loc2_.x - 2,_loc2_.y - 1);
- }
- }
- function CheckHit()
- {
- if(this.etat != "Falling")
- {
- var _loc6_ = this.GetStageCoord();
- var _loc5_ = this.GetZone();
- var _loc7_ = _global.C.G_hitObjTab[_loc5_.x][_loc5_.y].length;
- var _loc8_ = false;
- if(this.oldZone.x != _loc5_.x || this.oldZone.y != _loc5_.y)
- {
- this.ActivateItems();
- this.oldZone.x = _loc5_.x;
- this.oldZone.y = _loc5_.y;
- }
- if(this.etat != "Jumping1" && this.etat != "Jumping2")
- {
- this.CheckColliders(_global.C._parent.ScrollMap.Items.Map.HitContainer.Roads);
- if(_loc7_ > 0)
- {
- var _loc4_ = null;
- var _loc3_ = 0;
- while(_loc3_ < _loc7_)
- {
- _loc4_ = _global.C.G_hitObjTab[_loc5_.x][_loc5_.y][_loc3_];
- if(_global.C[_loc4_].GetMissionId() <= _global.C.G_missionId)
- {
- if(_global.C._parent.ScrollMap.Items.Map.HitContainer[_loc4_].hitTest(_loc6_.x,_loc6_.y,true))
- {
- _global.C[_loc4_].CollisionHappen(this);
- }
- }
- _loc3_ = _loc3_ + 1;
- }
- }
- }
- if(this.etat != "Deflating" && _global.C[_global.C.G_van].GetState() != "Exploding")
- {
- this.CheckHitVan();
- }
- }
- }
- function CheckHitVan()
- {
- if(this.GetState() != "Locked" && this.van.GetState() != "Locked" && this.van.GetState() != "PasLa")
- {
- var _loc4_ = this.van.GetZone();
- var _loc3_ = this.GetZone();
- if(_loc4_.x == _loc3_.x && _loc4_.y == _loc3_.y)
- {
- if(this.van.DoHitTest(this.GetStageCoord(),"CollideZone"))
- {
- if(!_global.C[_global.C.G_package].AttachedToVan())
- {
- _global.C[_global.C.G_interface].packageStolen(true);
- _global.C._parent.Overlays.gotoAndPlay("packageStolen");
- _global.C[_global.C.G_package].AttachToVan();
- _global.C[_global.C.G_interface].UpdateEdFace("Hangry");
- this.SetState("Inflating");
- this.SetTrajectory(null);
- this.SetStateLocked();
- }
- else if(this.GetState() != "Locked" && this.van.GetState() != "Locked")
- {
- _global.C[_global.C.G_interface].packageStolen(false);
- _global.C[_global.C.G_package].AttachToDropZone();
- _global.C[_global.C.G_van].LoosePackage();
- _global.C[_global.C.G_interface].UpdateEdFace("Happy");
- _global.C._parent.Overlays.gotoAndPlay("packageBack");
- _global.S.PlaySound("explosion",100);
- }
- }
- }
- }
- }
- function CheckColliders(l_collider)
- {
- var _loc3_ = new Object();
- var _loc9_ = false;
- var _loc10_ = false;
- var _loc12_ = this.GetPropRotation();
- var _loc7_ = 0;
- var _loc8_ = 0;
- var _loc11_ = 0;
- var _loc6_ = null;
- if(!this.IsBouncing())
- {
- _loc3_.x = this.mcRef.HitFront._x;
- _loc3_.y = this.mcRef.HitFront._y;
- this.mcRef.localToGlobal(_loc3_);
- }
- else
- {
- _loc3_.x = this.mcRef.HitBack._x;
- _loc3_.y = this.mcRef.HitBack._y;
- this.mcRef.localToGlobal(_loc3_);
- }
- if(l_collider.hitTest(_loc3_.x,_loc3_.y,true))
- {
- _loc3_.x = _global.C._parent.ScrollMap.Items[this.nom].HitEd.Front._x;
- _loc3_.y = _global.C._parent.ScrollMap.Items[this.nom].HitEd.Front._y;
- _global.C._parent.ScrollMap.Items[this.nom].HitEd.localToGlobal(_loc3_);
- if(l_collider.hitTest(_loc3_.x,_loc3_.y,true))
- {
- _loc9_ = true;
- }
- _loc3_.x = _global.C._parent.ScrollMap.Items[this.nom].HitEd.Front._x;
- _loc3_.y = _global.C._parent.ScrollMap.Items[this.nom].HitEd.Front._y;
- _global.C._parent.ScrollMap.Items[this.nom].HitEd.localToGlobal(_loc3_);
- if(l_collider.hitTest(_loc3_.x,_loc3_.y,true))
- {
- _loc9_ = true;
- }
- if(!_loc9_ && _loc10_)
- {
- _loc6_ = "s";
- }
- else
- {
- var _loc4_ = 1;
- while(_loc4_ <= 4)
- {
- _loc3_.x = _global.C._parent.ScrollMap.Items[this.nom].HitEd["G" + _loc4_]._x;
- _loc3_.y = _global.C._parent.ScrollMap.Items[this.nom].HitEd["G" + _loc4_]._y;
- _global.C._parent.ScrollMap.Items[this.nom].HitEd.localToGlobal(_loc3_);
- if(!l_collider.hitTest(_loc3_.x,_loc3_.y,true))
- {
- break;
- }
- _loc7_ = _loc4_;
- _loc4_ = _loc4_ + 1;
- }
- _loc4_ = 1;
- while(_loc4_ <= 4)
- {
- _loc3_.x = _global.C._parent.ScrollMap.Items[this.nom].HitEd["D" + _loc4_]._x;
- _loc3_.y = _global.C._parent.ScrollMap.Items[this.nom].HitEd["D" + _loc4_]._y;
- _global.C._parent.ScrollMap.Items[this.nom].HitEd.localToGlobal(_loc3_);
- if(!l_collider.hitTest(_loc3_.x,_loc3_.y,true))
- {
- break;
- }
- _loc8_ = _loc4_;
- _loc4_ = _loc4_ + 1;
- }
- if(_loc9_)
- {
- if(_loc8_ == 1 && _loc7_ == 1)
- {
- _loc6_ = "b";
- }
- else if(_loc8_ < 1)
- {
- _loc6_ = "r";
- }
- else if(_loc7_ < 1)
- {
- _loc6_ = "l";
- }
- else
- {
- _loc6_ = "b";
- }
- }
- else
- {
- _loc6_ = "s";
- }
- }
- if(_loc6_ == "s")
- {
- if(this.etat == "MoveBack" || this.bounce)
- {
- _loc6_ = "s";
- }
- else
- {
- _loc6_ = null;
- }
- }
- switch(_loc6_)
- {
- case "l":
- _loc4_ = 1;
- while(_loc4_ <= 4)
- {
- _loc3_.x = _global.C._parent.ScrollMap.Items[this.nom].HitEd["FG" + _loc4_]._x;
- _loc3_.y = _global.C._parent.ScrollMap.Items[this.nom].HitEd["FG" + _loc4_]._y;
- _global.C._parent.ScrollMap.Items[this.nom].HitEd.localToGlobal(_loc3_);
- if(!l_collider.hitTest(_loc3_.x,_loc3_.y,true))
- {
- break;
- }
- _loc4_ = _loc4_ + 1;
- }
- _global.C._parent.ScrollMap.Items[this.nom]._rotation -= _loc4_ * 6;
- break;
- case "r":
- _loc4_ = 1;
- while(_loc4_ <= 4)
- {
- _loc3_.x = _global.C._parent.ScrollMap.Items[this.nom].HitEd["FD" + _loc4_]._x;
- _loc3_.y = _global.C._parent.ScrollMap.Items[this.nom].HitEd["FD" + _loc4_]._y;
- _global.C._parent.ScrollMap.Items[this.nom].HitEd.localToGlobal(_loc3_);
- if(!l_collider.hitTest(_loc3_.x,_loc3_.y,true))
- {
- break;
- }
- _loc4_ = _loc4_ + 1;
- }
- _global.C._parent.ScrollMap.Items[this.nom]._rotation += _loc4_ * 6;
- break;
- case "b":
- this.SetState("Bounce");
- _global.S.PlaySound("bounce",38,0);
- this.bounce = true;
- break;
- case "s":
- this.SetState("Bounce");
- this.bounce = !this.bounce;
- }
- }
- }
- function Deflating()
- {
- if(this.mcRef.Etat._currentframe >= this.FR_DEFLATING)
- {
- this.stateLocked = false;
- this.mcRef.gotoAndPlay("Idle");
- this.SetState("Idle");
- }
- }
- function Fall()
- {
- this.stateLocked = false;
- this.SetTrajectory(null);
- this.SetState("Falling");
- _global.S.PlaySound("fall",25,0);
- this.SetStateLocked();
- }
- function Falling()
- {
- if(this.mcRef.Etat._currentframe >= this.FR_FALLING)
- {
- _global.C[_global.C.G_interface].LooseLife("Fall");
- var _loc3_ = new Object();
- this.ExtractFromHole();
- this.etat = "Deflating";
- this.mcRef.gotoAndPlay("Deflating");
- }
- this.MoveBack();
- }
- function GetNextAnim()
- {
- return this.nextAnimToPlay;
- }
- function Handbrake()
- {
- if(this.mcRef.Etat._currentframe == 4)
- {
- _global.S.PlaySound("handBrake",50,0);
- }
- else if(this.mcRef.Etat._currentframe >= this.FR_HANDBRAKE)
- {
- var _loc3_ = 180 + this.GetPropRotation();
- var _loc4_ = - this.GetSpeed();
- _global.C.KeyPress = "none";
- this.SetPropRotation(_loc3_);
- this.stateLocked = false;
- this.mcRef.gotoAndPlay("Idle");
- this.HandleAnim();
- }
- else
- {
- this.MoveHandbrake();
- }
- }
- function HandleAnim()
- {
- if(!this.stateLocked)
- {
- var _loc3_ = this.GetTrajectory();
- if(_global.C.G_forwPressed)
- {
- if(this.wasBreaking)
- {
- this.wasBreaking = false;
- this.SetCommand("MoveForw");
- if(_loc3_ == null)
- {
- this.mcRef.gotoAndPlay("BreakToForw");
- this.nextAnimToPlay = "MoveForw";
- }
- else if(_loc3_ == "Left")
- {
- this.mcRef.gotoAndPlay("BreakToLeft");
- this.nextAnimToPlay = "MoveLeft";
- }
- else if(_loc3_ == "Right")
- {
- this.mcRef.gotoAndPlay("BreakToRight");
- this.nextAnimToPlay = "MoveRight";
- }
- }
- else if(_loc3_ == null)
- {
- if(this.oldTrajectory == null)
- {
- this.SetCommand("MoveForw");
- }
- else if(this.oldTrajectory == "Left")
- {
- this.SetState("Left2Idle");
- }
- else if(this.oldTrajectory == "Right")
- {
- this.SetState("Right2Idle");
- }
- if(Math.floor(this.speed) >= this.ANIM_SPEED_ACC)
- {
- this.nextAnimToPlay = "MoveFast";
- }
- else
- {
- this.nextAnimToPlay = "MoveForw";
- }
- }
- else if(_loc3_ == "Left")
- {
- if(this.oldTrajectory == null)
- {
- this.SetState("Idle2Left");
- this.nextAnimToPlay = "MoveLeft";
- }
- else if(this.oldTrajectory == "Left")
- {
- this.SetState("MoveLeft");
- }
- }
- else if(_loc3_ == "Right")
- {
- if(this.oldTrajectory == null)
- {
- this.SetState("Idle2Right");
- this.nextAnimToPlay = "MoveRight";
- }
- else if(this.oldTrajectory == "Right")
- {
- this.SetState("MoveRight");
- }
- }
- }
- else if(_global.C.G_backPressed)
- {
- this.wasBreaking = true;
- if(_loc3_ == null)
- {
- if(Math.floor(this.speed) >= this.ANIM_SPEED_ACC)
- {
- this.mcRef.gotoAndPlay("MoveFastToBreak");
- }
- else
- {
- this.mcRef.gotoAndPlay("IdleToBreak");
- }
- }
- else if(_loc3_ == "Left")
- {
- this.mcRef.gotoAndPlay("Left2Break");
- }
- else if(_loc3_ == "Right")
- {
- this.mcRef.gotoAndPlay("Right2Break");
- }
- _global.S.PlaySound("decel",25,0);
- this.nextAnimToPlay = "MoveBreak";
- this.SetCommand("MoveBack");
- }
- else if(this.wasBreaking)
- {
- this.wasBreaking = false;
- this.SetCommand("MoveIdle");
- if(_loc3_ == null)
- {
- this.mcRef.gotoAndPlay("BreakToForw");
- this.nextAnimToPlay = "MoveIdle";
- }
- else if(_loc3_ == "Left")
- {
- this.mcRef.gotoAndPlay("BreakToLeft");
- this.nextAnimToPlay = "MoveLeft";
- }
- else if(_loc3_ == "Right")
- {
- this.mcRef.gotoAndPlay("BreakToRight");
- this.nextAnimToPlay = "MoveRight";
- }
- }
- else if(_loc3_ == null)
- {
- if(this.oldTrajectory == null)
- {
- this.SetCommand("MoveIdle");
- }
- else if(this.oldTrajectory == "Left")
- {
- this.SetState("Left2Idle");
- }
- else if(this.oldTrajectory == "Right")
- {
- this.SetState("Right2Idle");
- }
- this.nextAnimToPlay = "MoveIdle";
- }
- else if(_loc3_ == "Left")
- {
- if(this.oldTrajectory == null)
- {
- this.SetState("Idle2Left");
- this.nextAnimToPlay = "MoveLeft";
- }
- else if(this.oldTrajectory == "Left")
- {
- this.SetState("MoveLeft");
- }
- }
- else if(_loc3_ == "Right")
- {
- if(this.oldTrajectory == null)
- {
- this.SetState("Idle2Right");
- this.nextAnimToPlay = "MoveRight";
- }
- else if(this.oldTrajectory == "Right")
- {
- this.SetState("MoveRight");
- }
- }
- }
- }
- function Idle2Left()
- {
- if(_global.C.G_forwPressed)
- {
- this.MoveForw();
- }
- else
- {
- this.MoveIdle();
- }
- }
- function Inflating()
- {
- if(this.mcRef.Etat._currentframe == 4)
- {
- _global.S.PlaySound("inflate",50,0);
- }
- else if(this.mcRef.Etat._currentframe >= this.FR_INFLATING)
- {
- this.stateLocked = false;
- this.mcRef.gotoAndPlay("Idle");
- this.HandleAnim();
- }
- else
- {
- this.MoveIdle();
- }
- }
- function Jump(l_specialJump)
- {
- if(!this.paused)
- {
- if(this.GetSpeed() >= 5)
- {
- if(this.etat != "Jumping1" && this.etat != "Jumping2")
- {
- this.noFrame = 0;
- _global.S.PlaySound("jump",50,0);
- }
- this.SetTrajectory(null);
- if(l_specialJump)
- {
- this.SetState("Jumping3");
- }
- else if(_global.C.utils.GetRandomB(1,4) == 4)
- {
- this.SetState("Jumping2");
- }
- else
- {
- this.SetState("Jumping1");
- }
- this.SetStateLocked();
- }
- this.MoveForw();
- }
- }
- function Jumping1()
- {
- if(this.mcRef.Etat._currentframe >= this.FR_JUMPING1)
- {
- this.JumpingEnd();
- }
- else
- {
- this.MoveJump();
- }
- }
- function Jumping2()
- {
- if(this.mcRef.Etat._currentframe >= this.FR_JUMPING2)
- {
- this.JumpingEnd();
- }
- else
- {
- this.MoveJump();
- }
- }
- function Jumping3()
- {
- if(this.mcRef.Etat._currentframe >= this.FR_JUMPING3)
- {
- this.JumpingEnd(true);
- _global.C[_global.C.G_vanAi].UnPause();
- _global.C[_global.C.G_van].UnPause();
- }
- }
- function JumpingEnd(l_specialJumping)
- {
- var _loc3_ = this.GetStageCoord();
- this.stateLocked = false;
- _global.C.KeyPressL = false;
- _global.C.KeyPressR = false;
- if(_global.C._parent.ScrollMap.Items.Map.HitContainer.Roads.hitTest(_loc3_.x,_loc3_.y,true))
- {
- if(!l_specialJumping)
- {
- this.Fall();
- }
- }
- else
- {
- if(Math.floor(this.speed) >= this.ANIM_SPEED_ACC)
- {
- this.mcRef.gotoAndPlay("MoveFast");
- }
- else
- {
- this.mcRef.gotoAndPlay("MoveForw");
- }
- this.HandleAnim();
- }
- }
- function Left2Idle()
- {
- if(_global.C.G_forwPressed)
- {
- this.MoveForw();
- }
- else
- {
- this.MoveIdle();
- }
- }
- function Idle2Right()
- {
- if(_global.C.G_forwPressed)
- {
- this.MoveForw();
- }
- else
- {
- this.MoveIdle();
- }
- }
- function MoveHandbrake()
- {
- this.SetSpeed(this.GetSpeed() * this.SPEED_DECEL);
- this.MoveVeh();
- }
- function MoveForw()
- {
- if(!this.bounce)
- {
- var _loc2_ = this.GetSpeed();
- _loc2_ += this.SPEED_ACCEL * this.powerUpAccelFactor;
- this.SetSpeed(_loc2_);
- this.MoveVeh();
- }
- else
- {
- this.SetSpeed(this.GetSpeed() * this.SPEED_DECEL);
- this.MoveVeh();
- }
- }
- function MoveJump()
- {
- if(this.speed != 0)
- {
- this.SetSpeed(this.GetSpeed() * this.SPEED_JUMP);
- this.MoveVeh();
- }
- else
- {
- this.SetCommand("Idle");
- }
- }
- function MoveLeft()
- {
- if(_global.C.G_forwPressed)
- {
- this.MoveForw();
- }
- else
- {
- this.MoveIdle();
- }
- }
- function Idle()
- {
- if(this.changeDir == "Left")
- {
- this.RotateVeh(- this.STEERING);
- }
- else if(this.changeDir == "Right")
- {
- this.RotateVeh(this.STEERING);
- }
- this.CheckHit();
- }
- function MoveRight()
- {
- if(_global.C.G_forwPressed)
- {
- this.MoveForw();
- }
- else
- {
- this.MoveIdle();
- }
- }
- function Right2Idle()
- {
- if(_global.C.G_forwPressed)
- {
- this.MoveForw();
- }
- else
- {
- this.MoveIdle();
- }
- }
- function MoveVeh()
- {
- var _loc3_ = new Number();
- var _loc6_ = false;
- if(!_global.C.KeyPressL && !_global.C.KeyPressR)
- {
- if(this.GetPropRotation() > 45 && this.GetPropRotation() < 90)
- {
- this.changeDir = "Right";
- _loc3_ = 90 - this.GetPropRotation();
- }
- else if(this.GetPropRotation() > 90 && this.GetPropRotation() < 135)
- {
- this.changeDir = "Left";
- _loc3_ = this.GetPropRotation() - 90;
- }
- else if(this.GetPropRotation() > 135 && this.GetPropRotation() < 180)
- {
- this.changeDir = "Right";
- _loc3_ = 180 - this.GetPropRotation();
- }
- else if(this.GetPropRotation() > -180 && this.GetPropRotation() < -135)
- {
- this.changeDir = "Left";
- _loc3_ = this.GetPropRotation() + 180;
- }
- else if(this.GetPropRotation() < -45 && this.GetPropRotation() > -90)
- {
- this.changeDir = "Left";
- _loc3_ = this.GetPropRotation() + 90;
- }
- else if(this.GetPropRotation() < -90 && this.GetPropRotation() > -135)
- {
- this.changeDir = "Right";
- _loc3_ = -90 - this.GetPropRotation();
- }
- else if(this.GetPropRotation() > -45 && this.GetPropRotation() < 0)
- {
- this.changeDir = "Right";
- _loc3_ = - this.GetPropRotation();
- }
- else if(this.GetPropRotation() > 0 && this.GetPropRotation() < 45)
- {
- this.changeDir = "Left";
- _loc3_ = this.GetPropRotation() - 0;
- }
- _loc6_ = true;
- }
- if(_loc6_)
- {
- if(this.changeDir == "Left")
- {
- this.RotateVeh(- _loc3_);
- }
- else if(this.changeDir == "Right")
- {
- this.RotateVeh(_loc3_);
- }
- this.changeDir = null;
- }
- else if(this.changeDir == "Left")
- {
- this.RotateVeh(- this.STEERING);
- }
- else if(this.changeDir == "Right")
- {
- this.RotateVeh(this.STEERING);
- }
- if(this.etat != "Falling" && this.etat != "Jumping1" && this.etat != "Jumping2")
- {
- this.noFrame = this.noFrame + 1;
- if(this.noFrame == 30)
- {
- this.oldPosX = _global.C._parent.ScrollMap.Items.Map._x;
- this.oldPosY = _global.C._parent.ScrollMap.Items.Map._y;
- this.noFrame = 0;
- }
- }
- if(!this.bounce)
- {
- var _loc5_ = Math.sin(this.GetRotation() * 0.017453292519943295) * this.GetSpeed();
- var _loc4_ = Math.cos(this.GetRotation() * 0.017453292519943295) * this.GetSpeed() * -1;
- _global.C._parent.ScrollMap.Items.Map._x -= _loc5_;
- _global.C._parent.ScrollMap.Items.Map._y -= _loc4_;
- _global.C._parent.ScrollMap.Items.Front._x -= _loc5_;
- _global.C._parent.ScrollMap.Items.Front._y -= _loc4_;
- _global.C._parent.ScrollMap.Items.Parallax._x -= _loc5_ * 2.1;
- _global.C._parent.ScrollMap.Items.Parallax._y -= _loc4_ * 2.1;
- }
- else
- {
- this.SetSpeed(this.GetSpeed() * 0.92);
- _loc5_ = Math.sin(this.GetRotation() * 0.017453292519943295) * (this.GetSpeed() * this.SPEED_BRAKE);
- _loc4_ = Math.cos(this.GetRotation() * 0.017453292519943295) * (this.GetSpeed() * this.SPEED_BRAKE) * -1;
- _global.C._parent.ScrollMap.Items.Map._x += _loc5_;
- _global.C._parent.ScrollMap.Items.Map._y += _loc4_;
- _global.C._parent.ScrollMap.Items.Front._x += _loc5_;
- _global.C._parent.ScrollMap.Items.Front._y += _loc4_;
- _global.C._parent.ScrollMap.Items.Parallax._x += _loc5_ * 2.1;
- _global.C._parent.ScrollMap.Items.Parallax._y += _loc4_ * 2.1;
- if(Math.abs(this.speed) < 1)
- {
- this.bounce = false;
- }
- }
- this.CheckHit();
- if(!_global.C.G_backPressed && !this.stateLocked)
- {
- if(Math.floor(this.speed) == this.ANIM_SPEED_ACC)
- {
- if(this.oldSpeed < this.speed)
- {
- if(this.changeDir == null)
- {
- this.mcRef.gotoAndPlay("MoveAcc");
- }
- this.nextAnimToPlay = "MoveFast";
- }
- else if(this.oldSpeed > this.speed)
- {
- if(this.changeDir == null)
- {
- this.mcRef.gotoAndPlay("MoveDecc");
- }
- this.nextAnimToPlay = "MoveForw";
- }
- }
- }
- }
- function ReceivePackage()
- {
- this.stateLocked = false;
- this.pack.AttachToDropZone();
- _global.C[_global.C.G_interface].UpdateEdFace("Happy");
- this.vanAi.SetState("Explode");
- this.HandleAnim();
- }
- function SetSpeed(l_speed)
- {
- if(l_speed <= this.SPEED_MAX * this.powerUpSpeedFactor && l_speed >= this.SPEED_MIN)
- {
- this.oldSpeed = this.speed;
- this.speed = l_speed;
- }
- else if(l_speed > this.SPEED_MAX * this.powerUpSpeedFactor)
- {
- this.oldSpeed = this.speed;
- this.speed *= 0.9;
- }
- if(Math.abs(this.speed) < 1 && Math.abs(this.speed) > 0)
- {
- this.speed = 0;
- }
- }
- function ThrowForw()
- {
- if(this.mcRef.Etat._currentframe >= this.FR_THROW_FORW)
- {
- this.ReceivePackage();
- }
- if(_global.C.G_forwPressed)
- {
- this.MoveForw();
- }
- else
- {
- this.MoveIdle();
- }
- }
- function ThrowLeft()
- {
- if(this.mcRef.Etat._currentframe >= this.FR_THROW_LEFT)
- {
- this.ReceivePackage();
- }
- this.MoveLeft();
- }
- function ThrowRight()
- {
- if(this.mcRef.Etat._currentframe >= this.FR_THROW_RIGHT)
- {
- this.ReceivePackage();
- }
- this.MoveRight();
- }
- function ShowPowerUp(l_powerUp, l_start)
- {
- if(l_start)
- {
- this.mcRef.PU[l_powerUp].gotoAndPlay("Idle");
- }
- else
- {
- this.mcRef.PU[l_powerUp].gotoAndStop("PasLa");
- }
- }
- function SetInvisible()
- {
- this.mcRef._visible = false;
- this.mcRef._parent.Hud_Fleche._visible = false;
- }
- function SetVisible()
- {
- this.mcRef._parent.Hud_Fleche._visible = true;
- this.mcRef._visible = true;
- }
- function SetPowerUpSpeedFactor(l_factorSpeedMax, l_factorAccel)
- {
- this.powerUpSpeedFactor = l_factorSpeedMax;
- this.powerUpAccelFactor = l_factorAccel;
- }
- 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);
- if(this.etat === "Idle")
- {
- this.oldTrajectory = null;
- if(this.changeDir == "Left")
- {
- this.mcRef.gotoAndPlay("Left2Idle");
- }
- else if(this.changeDir == "Right")
- {
- this.mcRef.gotoAndPlay("Right2Idle");
- }
- this.bounce = false;
- }
- }
- }
- function SetTrajectory(l_TurnTo)
- {
- if(!this.stateLocked)
- {
- if(this.changeDir != l_TurnTo && (l_TurnTo == "Left" || l_TurnTo == "Right" || l_TurnTo == null))
- {
- this.oldTrajectory = this.changeDir;
- this.changeDir = l_TurnTo;
- }
- }
- }
- function UnSetPowerUpSpeedFactor()
- {
- this.powerUpSpeedFactor = 1;
- this.powerUpAccelFactor = 1;
- }
- function ExtractFromHole()
- {
- _global.C._parent.ScrollMap.Items.Map._x = _global.C._parent.ScrollMap.Items.Front._x = _global.C._parent.ScrollMap.Items.Parallax._x = this.oldPosX;
- _global.C._parent.ScrollMap.Items.Map._y = _global.C._parent.ScrollMap.Items.Front._y = _global.C._parent.ScrollMap.Items.Parallax._y = this.oldPosY;
- }
- }
-