home *** CD-ROM | disk | FTP | other *** search
/ One Click 21 (Special) / OC021.iso / Juegos / 05-11-10-1.swf / scripts / __Packages / Ed.as < prev    next >
Encoding:
Text File  |  2005-11-18  |  32.4 KB  |  1,079 lines

  1. class Ed extends Vehicule
  2. {
  3.    var FR_INFLATING = 59;
  4.    var FR_HANDBRAKE = 34;
  5.    var FR_JUMPING1 = 38;
  6.    var FR_JUMPING2 = 30;
  7.    var FR_JUMPING3 = 30;
  8.    var FR_BOUNCE = 10;
  9.    var FR_THROW_FORW = 5;
  10.    var FR_THROW_LEFT = 5;
  11.    var FR_THROW_RIGHT = 5;
  12.    var FR_FALLING = 47;
  13.    var FR_DEFLATING = 54;
  14.    var ANIM_SPEED_ACC = 14;
  15.    var SPEED_MAX = 38;
  16.    var SPEED_ACCEL = 1;
  17.    var STEERING = 22;
  18.    var SPEED_JUMP = 0.99;
  19.    var van = new Object();
  20.    var vanAi = new Object();
  21.    var pack = new Object();
  22.    var oldTrajectory = new String();
  23.    var nextAnimToPlay = new String();
  24.    var oldSpeed = new Number();
  25.    var wasBreaking = new Boolean();
  26.    var oldPosX = new Number();
  27.    var oldPosY = new Number();
  28.    var oldZone = new Object();
  29.    var noFrame = new Number();
  30.    var powerUpSpeedFactor = new Number();
  31.    var powerUpAccelFactor = new Number();
  32.    function Ed(l_mc)
  33.    {
  34.       super(l_mc);
  35.       this.noFrame = 25;
  36.       this.oldTrajectory = null;
  37.       this.wasBreaking = false;
  38.       this.van = _global.C[_global.C.G_van];
  39.       this.vanAi = _global.C[_global.C.G_vanAi];
  40.       this.pack = _global.C[_global.C.G_package];
  41.       this.CenterVehToStartPos();
  42.       this.powerUpSpeedFactor = 1;
  43.       this.powerUpAccelFactor = 1;
  44.       this.nextAnimToPlay = null;
  45.       this.oldZone = this.GetZone();
  46.       this.mcRef.PU.burnInsigna.gotoAndStop("PasLa");
  47.       this.mcRef.PU.deetsInsigna.gotoAndStop("PasLa");
  48.       this.mcRef.PU.loogieInsigna.gotoAndStop("PasLa");
  49.    }
  50.    function Bounce()
  51.    {
  52.       if(this.mcRef.Etat._currentframe >= this.FR_BOUNCE)
  53.       {
  54.          this.SetState("MoveIdle");
  55.       }
  56.       else
  57.       {
  58.          this.MoveIdle();
  59.       }
  60.    }
  61.    function CenterVehToStartPos()
  62.    {
  63.       var _loc3_ = new Object();
  64.       _loc3_.x = _global.C._parent.ScrollMap.Items.Map.HitContainer["StartPos" + this.nom]._x;
  65.       _loc3_.y = _global.C._parent.ScrollMap.Items.Map.HitContainer["StartPos" + this.nom]._y;
  66.       _loc3_ = _global.C.utils.ConvertHitPosToMap(_loc3_);
  67.       _global.C._parent.ScrollMap.Items.Map._x = _loc3_.x;
  68.       _global.C._parent.ScrollMap.Items.Map._y = _loc3_.y;
  69.       _global.C._parent.ScrollMap.Items.Front._x = _loc3_.x;
  70.       _global.C._parent.ScrollMap.Items.Front._y = _loc3_.y;
  71.       _global.C._parent.ScrollMap.Items.Parallax._x = _loc3_.x;
  72.       _global.C._parent.ScrollMap.Items.Parallax._y = _loc3_.y;
  73.       this.mcRef._rotation = 90;
  74.    }
  75.    function DesactivateItems()
  76.    {
  77.       var _loc5_ = _global.C.G_hitObjTab[this.oldZone.x][this.oldZone.y].length;
  78.       var _loc4_ = new Object();
  79.       if(_loc5_ > 0)
  80.       {
  81.          var _loc3_ = 0;
  82.          while(_loc3_ < _loc5_)
  83.          {
  84.             _loc4_ = _global.C[_global.C.G_hitObjTab[this.oldZone.x][this.oldZone.y][_loc3_]];
  85.             _loc4_.GotoMcState("PasLa",false);
  86.             _loc3_ = _loc3_ + 1;
  87.          }
  88.       }
  89.    }
  90.    function Activate(l_zoneX, l_zoneY)
  91.    {
  92.       var _loc4_ = new Object();
  93.       var _loc3_ = new String();
  94.       _loc4_.x = l_zoneX;
  95.       _loc4_.y = l_zoneY;
  96.       var _loc5_ = _global.C.G_hitObjTab[_loc4_.x][_loc4_.y].length;
  97.       if(_loc5_ > 0)
  98.       {
  99.          var _loc2_ = 0;
  100.          while(_loc2_ < _loc5_)
  101.          {
  102.             _loc3_ = _global.C.G_hitObjTab[_loc4_.x][_loc4_.y][_loc2_];
  103.             if(_global.C[_loc3_].GetMissionId() <= _global.C.G_missionId)
  104.             {
  105.                _global.C[_loc3_].GotoMcState(_global.C[_loc3_].GetMcState(),true);
  106.             }
  107.             _loc2_ = _loc2_ + 1;
  108.          }
  109.       }
  110.    }
  111.    function Desactivate(l_zoneX, l_zoneY)
  112.    {
  113.       var _loc5_ = new Object();
  114.       var _loc4_ = new String();
  115.       _loc5_.x = l_zoneX;
  116.       _loc5_.y = l_zoneY;
  117.       var _loc3_ = _global.C.G_hitObjTab[_loc5_.x][_loc5_.y].length;
  118.       if(_loc3_ > 0)
  119.       {
  120.          var _loc2_ = 0;
  121.          while(_loc2_ < _loc3_)
  122.          {
  123.             _global.C[_loc4_].GotoMcState("PasLa",false);
  124.             _loc2_ = _loc2_ + 1;
  125.          }
  126.       }
  127.    }
  128.    function ActivateItems()
  129.    {
  130.       var _loc3_ = new String();
  131.       var _loc2_ = this.GetZone();
  132.       if(_loc2_.x == this.oldZone.x)
  133.       {
  134.          if(_loc2_.y < this.oldZone.y)
  135.          {
  136.             this.Activate(_loc2_.x,_loc2_.y - 1);
  137.             this.Activate(_loc2_.x - 1,_loc2_.y - 1);
  138.             this.Activate(_loc2_.x + 1,_loc2_.y - 1);
  139.             this.Desactivate(_loc2_.x,_loc2_.y + 2);
  140.             this.Desactivate(_loc2_.x - 1,_loc2_.y + 2);
  141.             this.Desactivate(_loc2_.x + 1,_loc2_.y + 2);
  142.          }
  143.          else
  144.          {
  145.             this.Activate(_loc2_.x,_loc2_.y + 1);
  146.             this.Activate(_loc2_.x - 1,_loc2_.y + 1);
  147.             this.Activate(_loc2_.x + 1,_loc2_.y + 1);
  148.             this.Desactivate(_loc2_.x,_loc2_.y - 2);
  149.             this.Desactivate(_loc2_.x - 1,_loc2_.y - 2);
  150.             this.Desactivate(_loc2_.x + 1,_loc2_.y - 2);
  151.          }
  152.       }
  153.       else if(_loc2_.x < this.oldZone.x)
  154.       {
  155.          this.Activate(_loc2_.x - 1,_loc2_.y);
  156.          this.Activate(_loc2_.x - 1,_loc2_.y + 1);
  157.          this.Activate(_loc2_.x - 1,_loc2_.y - 1);
  158.          this.Desactivate(_loc2_.x + 2,_loc2_.y);
  159.          this.Desactivate(_loc2_.x + 2,_loc2_.y + 1);
  160.          this.Desactivate(_loc2_.x + 2,_loc2_.y - 1);
  161.       }
  162.       else
  163.       {
  164.          this.Activate(_loc2_.x + 1,_loc2_.y);
  165.          this.Activate(_loc2_.x + 1,_loc2_.y + 1);
  166.          this.Activate(_loc2_.x + 1,_loc2_.y - 1);
  167.          this.Desactivate(_loc2_.x - 2,_loc2_.y);
  168.          this.Desactivate(_loc2_.x - 2,_loc2_.y + 1);
  169.          this.Desactivate(_loc2_.x - 2,_loc2_.y - 1);
  170.       }
  171.    }
  172.    function CheckHit()
  173.    {
  174.       if(this.etat != "Falling")
  175.       {
  176.          var _loc6_ = this.GetStageCoord();
  177.          var _loc5_ = this.GetZone();
  178.          var _loc7_ = _global.C.G_hitObjTab[_loc5_.x][_loc5_.y].length;
  179.          var _loc8_ = false;
  180.          if(this.oldZone.x != _loc5_.x || this.oldZone.y != _loc5_.y)
  181.          {
  182.             this.ActivateItems();
  183.             this.oldZone.x = _loc5_.x;
  184.             this.oldZone.y = _loc5_.y;
  185.          }
  186.          if(this.etat != "Jumping1" && this.etat != "Jumping2")
  187.          {
  188.             this.CheckColliders(_global.C._parent.ScrollMap.Items.Map.HitContainer.Roads);
  189.             if(_loc7_ > 0)
  190.             {
  191.                var _loc4_ = null;
  192.                var _loc3_ = 0;
  193.                while(_loc3_ < _loc7_)
  194.                {
  195.                   _loc4_ = _global.C.G_hitObjTab[_loc5_.x][_loc5_.y][_loc3_];
  196.                   if(_global.C[_loc4_].GetMissionId() <= _global.C.G_missionId)
  197.                   {
  198.                      if(_global.C._parent.ScrollMap.Items.Map.HitContainer[_loc4_].hitTest(_loc6_.x,_loc6_.y,true))
  199.                      {
  200.                         _global.C[_loc4_].CollisionHappen(this);
  201.                      }
  202.                   }
  203.                   _loc3_ = _loc3_ + 1;
  204.                }
  205.             }
  206.          }
  207.          if(this.etat != "Deflating" && _global.C[_global.C.G_van].GetState() != "Exploding")
  208.          {
  209.             this.CheckHitVan();
  210.          }
  211.       }
  212.    }
  213.    function CheckHitVan()
  214.    {
  215.       if(this.GetState() != "Locked" && this.van.GetState() != "Locked" && this.van.GetState() != "PasLa")
  216.       {
  217.          var _loc4_ = this.van.GetZone();
  218.          var _loc3_ = this.GetZone();
  219.          if(_loc4_.x == _loc3_.x && _loc4_.y == _loc3_.y)
  220.          {
  221.             if(this.van.DoHitTest(this.GetStageCoord(),"CollideZone"))
  222.             {
  223.                if(!_global.C[_global.C.G_package].AttachedToVan())
  224.                {
  225.                   _global.C[_global.C.G_interface].packageStolen(true);
  226.                   _global.C._parent.Overlays.gotoAndPlay("packageStolen");
  227.                   _global.C[_global.C.G_package].AttachToVan();
  228.                   _global.C[_global.C.G_interface].UpdateEdFace("Hangry");
  229.                   this.SetState("Inflating");
  230.                   this.SetTrajectory(null);
  231.                   this.SetStateLocked();
  232.                }
  233.                else if(this.GetState() != "Locked" && this.van.GetState() != "Locked")
  234.                {
  235.                   _global.C[_global.C.G_interface].packageStolen(false);
  236.                   _global.C[_global.C.G_package].AttachToDropZone();
  237.                   _global.C[_global.C.G_van].LoosePackage();
  238.                   _global.C[_global.C.G_interface].UpdateEdFace("Happy");
  239.                   _global.C._parent.Overlays.gotoAndPlay("packageBack");
  240.                   _global.S.PlaySound("explosion",100);
  241.                }
  242.             }
  243.          }
  244.       }
  245.    }
  246.    function CheckColliders(l_collider)
  247.    {
  248.       var _loc3_ = new Object();
  249.       var _loc9_ = false;
  250.       var _loc10_ = false;
  251.       var _loc12_ = this.GetPropRotation();
  252.       var _loc7_ = 0;
  253.       var _loc8_ = 0;
  254.       var _loc11_ = 0;
  255.       var _loc6_ = null;
  256.       if(!this.IsBouncing())
  257.       {
  258.          _loc3_.x = this.mcRef.HitFront._x;
  259.          _loc3_.y = this.mcRef.HitFront._y;
  260.          this.mcRef.localToGlobal(_loc3_);
  261.       }
  262.       else
  263.       {
  264.          _loc3_.x = this.mcRef.HitBack._x;
  265.          _loc3_.y = this.mcRef.HitBack._y;
  266.          this.mcRef.localToGlobal(_loc3_);
  267.       }
  268.       if(l_collider.hitTest(_loc3_.x,_loc3_.y,true))
  269.       {
  270.          _loc3_.x = _global.C._parent.ScrollMap.Items[this.nom].HitEd.Front._x;
  271.          _loc3_.y = _global.C._parent.ScrollMap.Items[this.nom].HitEd.Front._y;
  272.          _global.C._parent.ScrollMap.Items[this.nom].HitEd.localToGlobal(_loc3_);
  273.          if(l_collider.hitTest(_loc3_.x,_loc3_.y,true))
  274.          {
  275.             _loc9_ = true;
  276.          }
  277.          _loc3_.x = _global.C._parent.ScrollMap.Items[this.nom].HitEd.Front._x;
  278.          _loc3_.y = _global.C._parent.ScrollMap.Items[this.nom].HitEd.Front._y;
  279.          _global.C._parent.ScrollMap.Items[this.nom].HitEd.localToGlobal(_loc3_);
  280.          if(l_collider.hitTest(_loc3_.x,_loc3_.y,true))
  281.          {
  282.             _loc9_ = true;
  283.          }
  284.          if(!_loc9_ && _loc10_)
  285.          {
  286.             _loc6_ = "s";
  287.          }
  288.          else
  289.          {
  290.             var _loc4_ = 1;
  291.             while(_loc4_ <= 4)
  292.             {
  293.                _loc3_.x = _global.C._parent.ScrollMap.Items[this.nom].HitEd["G" + _loc4_]._x;
  294.                _loc3_.y = _global.C._parent.ScrollMap.Items[this.nom].HitEd["G" + _loc4_]._y;
  295.                _global.C._parent.ScrollMap.Items[this.nom].HitEd.localToGlobal(_loc3_);
  296.                if(!l_collider.hitTest(_loc3_.x,_loc3_.y,true))
  297.                {
  298.                   break;
  299.                }
  300.                _loc7_ = _loc4_;
  301.                _loc4_ = _loc4_ + 1;
  302.             }
  303.             _loc4_ = 1;
  304.             while(_loc4_ <= 4)
  305.             {
  306.                _loc3_.x = _global.C._parent.ScrollMap.Items[this.nom].HitEd["D" + _loc4_]._x;
  307.                _loc3_.y = _global.C._parent.ScrollMap.Items[this.nom].HitEd["D" + _loc4_]._y;
  308.                _global.C._parent.ScrollMap.Items[this.nom].HitEd.localToGlobal(_loc3_);
  309.                if(!l_collider.hitTest(_loc3_.x,_loc3_.y,true))
  310.                {
  311.                   break;
  312.                }
  313.                _loc8_ = _loc4_;
  314.                _loc4_ = _loc4_ + 1;
  315.             }
  316.             if(_loc9_)
  317.             {
  318.                if(_loc8_ == 1 && _loc7_ == 1)
  319.                {
  320.                   _loc6_ = "b";
  321.                }
  322.                else if(_loc8_ < 1)
  323.                {
  324.                   _loc6_ = "r";
  325.                }
  326.                else if(_loc7_ < 1)
  327.                {
  328.                   _loc6_ = "l";
  329.                }
  330.                else
  331.                {
  332.                   _loc6_ = "b";
  333.                }
  334.             }
  335.             else
  336.             {
  337.                _loc6_ = "s";
  338.             }
  339.          }
  340.          if(_loc6_ == "s")
  341.          {
  342.             if(this.etat == "MoveBack" || this.bounce)
  343.             {
  344.                _loc6_ = "s";
  345.             }
  346.             else
  347.             {
  348.                _loc6_ = null;
  349.             }
  350.          }
  351.          switch(_loc6_)
  352.          {
  353.             case "l":
  354.                _loc4_ = 1;
  355.                while(_loc4_ <= 4)
  356.                {
  357.                   _loc3_.x = _global.C._parent.ScrollMap.Items[this.nom].HitEd["FG" + _loc4_]._x;
  358.                   _loc3_.y = _global.C._parent.ScrollMap.Items[this.nom].HitEd["FG" + _loc4_]._y;
  359.                   _global.C._parent.ScrollMap.Items[this.nom].HitEd.localToGlobal(_loc3_);
  360.                   if(!l_collider.hitTest(_loc3_.x,_loc3_.y,true))
  361.                   {
  362.                      break;
  363.                   }
  364.                   _loc4_ = _loc4_ + 1;
  365.                }
  366.                _global.C._parent.ScrollMap.Items[this.nom]._rotation -= _loc4_ * 6;
  367.                break;
  368.             case "r":
  369.                _loc4_ = 1;
  370.                while(_loc4_ <= 4)
  371.                {
  372.                   _loc3_.x = _global.C._parent.ScrollMap.Items[this.nom].HitEd["FD" + _loc4_]._x;
  373.                   _loc3_.y = _global.C._parent.ScrollMap.Items[this.nom].HitEd["FD" + _loc4_]._y;
  374.                   _global.C._parent.ScrollMap.Items[this.nom].HitEd.localToGlobal(_loc3_);
  375.                   if(!l_collider.hitTest(_loc3_.x,_loc3_.y,true))
  376.                   {
  377.                      break;
  378.                   }
  379.                   _loc4_ = _loc4_ + 1;
  380.                }
  381.                _global.C._parent.ScrollMap.Items[this.nom]._rotation += _loc4_ * 6;
  382.                break;
  383.             case "b":
  384.                this.SetState("Bounce");
  385.                _global.S.PlaySound("bounce",38,0);
  386.                this.bounce = true;
  387.                break;
  388.             case "s":
  389.                this.SetState("Bounce");
  390.                this.bounce = !this.bounce;
  391.          }
  392.       }
  393.    }
  394.    function Deflating()
  395.    {
  396.       if(this.mcRef.Etat._currentframe >= this.FR_DEFLATING)
  397.       {
  398.          this.stateLocked = false;
  399.          this.mcRef.gotoAndPlay("Idle");
  400.          this.SetState("Idle");
  401.       }
  402.    }
  403.    function Fall()
  404.    {
  405.       this.stateLocked = false;
  406.       this.SetTrajectory(null);
  407.       this.SetState("Falling");
  408.       _global.S.PlaySound("fall",25,0);
  409.       this.SetStateLocked();
  410.    }
  411.    function Falling()
  412.    {
  413.       if(this.mcRef.Etat._currentframe >= this.FR_FALLING)
  414.       {
  415.          _global.C[_global.C.G_interface].LooseLife("Fall");
  416.          var _loc3_ = new Object();
  417.          this.ExtractFromHole();
  418.          this.etat = "Deflating";
  419.          this.mcRef.gotoAndPlay("Deflating");
  420.       }
  421.       this.MoveBack();
  422.    }
  423.    function GetNextAnim()
  424.    {
  425.       return this.nextAnimToPlay;
  426.    }
  427.    function Handbrake()
  428.    {
  429.       if(this.mcRef.Etat._currentframe == 4)
  430.       {
  431.          _global.S.PlaySound("handBrake",50,0);
  432.       }
  433.       else if(this.mcRef.Etat._currentframe >= this.FR_HANDBRAKE)
  434.       {
  435.          var _loc3_ = 180 + this.GetPropRotation();
  436.          var _loc4_ = - this.GetSpeed();
  437.          _global.C.KeyPress = "none";
  438.          this.SetPropRotation(_loc3_);
  439.          this.stateLocked = false;
  440.          this.mcRef.gotoAndPlay("Idle");
  441.          this.HandleAnim();
  442.       }
  443.       else
  444.       {
  445.          this.MoveHandbrake();
  446.       }
  447.    }
  448.    function HandleAnim()
  449.    {
  450.       if(!this.stateLocked)
  451.       {
  452.          var _loc3_ = this.GetTrajectory();
  453.          if(_global.C.G_forwPressed)
  454.          {
  455.             if(this.wasBreaking)
  456.             {
  457.                this.wasBreaking = false;
  458.                this.SetCommand("MoveForw");
  459.                if(_loc3_ == null)
  460.                {
  461.                   this.mcRef.gotoAndPlay("BreakToForw");
  462.                   this.nextAnimToPlay = "MoveForw";
  463.                }
  464.                else if(_loc3_ == "Left")
  465.                {
  466.                   this.mcRef.gotoAndPlay("BreakToLeft");
  467.                   this.nextAnimToPlay = "MoveLeft";
  468.                }
  469.                else if(_loc3_ == "Right")
  470.                {
  471.                   this.mcRef.gotoAndPlay("BreakToRight");
  472.                   this.nextAnimToPlay = "MoveRight";
  473.                }
  474.             }
  475.             else if(_loc3_ == null)
  476.             {
  477.                if(this.oldTrajectory == null)
  478.                {
  479.                   this.SetCommand("MoveForw");
  480.                }
  481.                else if(this.oldTrajectory == "Left")
  482.                {
  483.                   this.SetState("Left2Idle");
  484.                }
  485.                else if(this.oldTrajectory == "Right")
  486.                {
  487.                   this.SetState("Right2Idle");
  488.                }
  489.                if(Math.floor(this.speed) >= this.ANIM_SPEED_ACC)
  490.                {
  491.                   this.nextAnimToPlay = "MoveFast";
  492.                }
  493.                else
  494.                {
  495.                   this.nextAnimToPlay = "MoveForw";
  496.                }
  497.             }
  498.             else if(_loc3_ == "Left")
  499.             {
  500.                if(this.oldTrajectory == null)
  501.                {
  502.                   this.SetState("Idle2Left");
  503.                   this.nextAnimToPlay = "MoveLeft";
  504.                }
  505.                else if(this.oldTrajectory == "Left")
  506.                {
  507.                   this.SetState("MoveLeft");
  508.                }
  509.             }
  510.             else if(_loc3_ == "Right")
  511.             {
  512.                if(this.oldTrajectory == null)
  513.                {
  514.                   this.SetState("Idle2Right");
  515.                   this.nextAnimToPlay = "MoveRight";
  516.                }
  517.                else if(this.oldTrajectory == "Right")
  518.                {
  519.                   this.SetState("MoveRight");
  520.                }
  521.             }
  522.          }
  523.          else if(_global.C.G_backPressed)
  524.          {
  525.             this.wasBreaking = true;
  526.             if(_loc3_ == null)
  527.             {
  528.                if(Math.floor(this.speed) >= this.ANIM_SPEED_ACC)
  529.                {
  530.                   this.mcRef.gotoAndPlay("MoveFastToBreak");
  531.                }
  532.                else
  533.                {
  534.                   this.mcRef.gotoAndPlay("IdleToBreak");
  535.                }
  536.             }
  537.             else if(_loc3_ == "Left")
  538.             {
  539.                this.mcRef.gotoAndPlay("Left2Break");
  540.             }
  541.             else if(_loc3_ == "Right")
  542.             {
  543.                this.mcRef.gotoAndPlay("Right2Break");
  544.             }
  545.             _global.S.PlaySound("decel",25,0);
  546.             this.nextAnimToPlay = "MoveBreak";
  547.             this.SetCommand("MoveBack");
  548.          }
  549.          else if(this.wasBreaking)
  550.          {
  551.             this.wasBreaking = false;
  552.             this.SetCommand("MoveIdle");
  553.             if(_loc3_ == null)
  554.             {
  555.                this.mcRef.gotoAndPlay("BreakToForw");
  556.                this.nextAnimToPlay = "MoveIdle";
  557.             }
  558.             else if(_loc3_ == "Left")
  559.             {
  560.                this.mcRef.gotoAndPlay("BreakToLeft");
  561.                this.nextAnimToPlay = "MoveLeft";
  562.             }
  563.             else if(_loc3_ == "Right")
  564.             {
  565.                this.mcRef.gotoAndPlay("BreakToRight");
  566.                this.nextAnimToPlay = "MoveRight";
  567.             }
  568.          }
  569.          else if(_loc3_ == null)
  570.          {
  571.             if(this.oldTrajectory == null)
  572.             {
  573.                this.SetCommand("MoveIdle");
  574.             }
  575.             else if(this.oldTrajectory == "Left")
  576.             {
  577.                this.SetState("Left2Idle");
  578.             }
  579.             else if(this.oldTrajectory == "Right")
  580.             {
  581.                this.SetState("Right2Idle");
  582.             }
  583.             this.nextAnimToPlay = "MoveIdle";
  584.          }
  585.          else if(_loc3_ == "Left")
  586.          {
  587.             if(this.oldTrajectory == null)
  588.             {
  589.                this.SetState("Idle2Left");
  590.                this.nextAnimToPlay = "MoveLeft";
  591.             }
  592.             else if(this.oldTrajectory == "Left")
  593.             {
  594.                this.SetState("MoveLeft");
  595.             }
  596.          }
  597.          else if(_loc3_ == "Right")
  598.          {
  599.             if(this.oldTrajectory == null)
  600.             {
  601.                this.SetState("Idle2Right");
  602.                this.nextAnimToPlay = "MoveRight";
  603.             }
  604.             else if(this.oldTrajectory == "Right")
  605.             {
  606.                this.SetState("MoveRight");
  607.             }
  608.          }
  609.       }
  610.    }
  611.    function Idle2Left()
  612.    {
  613.       if(_global.C.G_forwPressed)
  614.       {
  615.          this.MoveForw();
  616.       }
  617.       else
  618.       {
  619.          this.MoveIdle();
  620.       }
  621.    }
  622.    function Inflating()
  623.    {
  624.       if(this.mcRef.Etat._currentframe == 4)
  625.       {
  626.          _global.S.PlaySound("inflate",50,0);
  627.       }
  628.       else if(this.mcRef.Etat._currentframe >= this.FR_INFLATING)
  629.       {
  630.          this.stateLocked = false;
  631.          this.mcRef.gotoAndPlay("Idle");
  632.          this.HandleAnim();
  633.       }
  634.       else
  635.       {
  636.          this.MoveIdle();
  637.       }
  638.    }
  639.    function Jump(l_specialJump)
  640.    {
  641.       if(!this.paused)
  642.       {
  643.          if(this.GetSpeed() >= 5)
  644.          {
  645.             if(this.etat != "Jumping1" && this.etat != "Jumping2")
  646.             {
  647.                this.noFrame = 0;
  648.                _global.S.PlaySound("jump",50,0);
  649.             }
  650.             this.SetTrajectory(null);
  651.             if(l_specialJump)
  652.             {
  653.                this.SetState("Jumping3");
  654.             }
  655.             else if(_global.C.utils.GetRandomB(1,4) == 4)
  656.             {
  657.                this.SetState("Jumping2");
  658.             }
  659.             else
  660.             {
  661.                this.SetState("Jumping1");
  662.             }
  663.             this.SetStateLocked();
  664.          }
  665.          this.MoveForw();
  666.       }
  667.    }
  668.    function Jumping1()
  669.    {
  670.       if(this.mcRef.Etat._currentframe >= this.FR_JUMPING1)
  671.       {
  672.          this.JumpingEnd();
  673.       }
  674.       else
  675.       {
  676.          this.MoveJump();
  677.       }
  678.    }
  679.    function Jumping2()
  680.    {
  681.       if(this.mcRef.Etat._currentframe >= this.FR_JUMPING2)
  682.       {
  683.          this.JumpingEnd();
  684.       }
  685.       else
  686.       {
  687.          this.MoveJump();
  688.       }
  689.    }
  690.    function Jumping3()
  691.    {
  692.       if(this.mcRef.Etat._currentframe >= this.FR_JUMPING3)
  693.       {
  694.          this.JumpingEnd(true);
  695.          _global.C[_global.C.G_vanAi].UnPause();
  696.          _global.C[_global.C.G_van].UnPause();
  697.       }
  698.    }
  699.    function JumpingEnd(l_specialJumping)
  700.    {
  701.       var _loc3_ = this.GetStageCoord();
  702.       this.stateLocked = false;
  703.       _global.C.KeyPressL = false;
  704.       _global.C.KeyPressR = false;
  705.       if(_global.C._parent.ScrollMap.Items.Map.HitContainer.Roads.hitTest(_loc3_.x,_loc3_.y,true))
  706.       {
  707.          if(!l_specialJumping)
  708.          {
  709.             this.Fall();
  710.          }
  711.       }
  712.       else
  713.       {
  714.          if(Math.floor(this.speed) >= this.ANIM_SPEED_ACC)
  715.          {
  716.             this.mcRef.gotoAndPlay("MoveFast");
  717.          }
  718.          else
  719.          {
  720.             this.mcRef.gotoAndPlay("MoveForw");
  721.          }
  722.          this.HandleAnim();
  723.       }
  724.    }
  725.    function Left2Idle()
  726.    {
  727.       if(_global.C.G_forwPressed)
  728.       {
  729.          this.MoveForw();
  730.       }
  731.       else
  732.       {
  733.          this.MoveIdle();
  734.       }
  735.    }
  736.    function Idle2Right()
  737.    {
  738.       if(_global.C.G_forwPressed)
  739.       {
  740.          this.MoveForw();
  741.       }
  742.       else
  743.       {
  744.          this.MoveIdle();
  745.       }
  746.    }
  747.    function MoveHandbrake()
  748.    {
  749.       this.SetSpeed(this.GetSpeed() * this.SPEED_DECEL);
  750.       this.MoveVeh();
  751.    }
  752.    function MoveForw()
  753.    {
  754.       if(!this.bounce)
  755.       {
  756.          var _loc2_ = this.GetSpeed();
  757.          _loc2_ += this.SPEED_ACCEL * this.powerUpAccelFactor;
  758.          this.SetSpeed(_loc2_);
  759.          this.MoveVeh();
  760.       }
  761.       else
  762.       {
  763.          this.SetSpeed(this.GetSpeed() * this.SPEED_DECEL);
  764.          this.MoveVeh();
  765.       }
  766.    }
  767.    function MoveJump()
  768.    {
  769.       if(this.speed != 0)
  770.       {
  771.          this.SetSpeed(this.GetSpeed() * this.SPEED_JUMP);
  772.          this.MoveVeh();
  773.       }
  774.       else
  775.       {
  776.          this.SetCommand("Idle");
  777.       }
  778.    }
  779.    function MoveLeft()
  780.    {
  781.       if(_global.C.G_forwPressed)
  782.       {
  783.          this.MoveForw();
  784.       }
  785.       else
  786.       {
  787.          this.MoveIdle();
  788.       }
  789.    }
  790.    function Idle()
  791.    {
  792.       if(this.changeDir == "Left")
  793.       {
  794.          this.RotateVeh(- this.STEERING);
  795.       }
  796.       else if(this.changeDir == "Right")
  797.       {
  798.          this.RotateVeh(this.STEERING);
  799.       }
  800.       this.CheckHit();
  801.    }
  802.    function MoveRight()
  803.    {
  804.       if(_global.C.G_forwPressed)
  805.       {
  806.          this.MoveForw();
  807.       }
  808.       else
  809.       {
  810.          this.MoveIdle();
  811.       }
  812.    }
  813.    function Right2Idle()
  814.    {
  815.       if(_global.C.G_forwPressed)
  816.       {
  817.          this.MoveForw();
  818.       }
  819.       else
  820.       {
  821.          this.MoveIdle();
  822.       }
  823.    }
  824.    function MoveVeh()
  825.    {
  826.       var _loc3_ = new Number();
  827.       var _loc6_ = false;
  828.       if(!_global.C.KeyPressL && !_global.C.KeyPressR)
  829.       {
  830.          if(this.GetPropRotation() > 45 && this.GetPropRotation() < 90)
  831.          {
  832.             this.changeDir = "Right";
  833.             _loc3_ = 90 - this.GetPropRotation();
  834.          }
  835.          else if(this.GetPropRotation() > 90 && this.GetPropRotation() < 135)
  836.          {
  837.             this.changeDir = "Left";
  838.             _loc3_ = this.GetPropRotation() - 90;
  839.          }
  840.          else if(this.GetPropRotation() > 135 && this.GetPropRotation() < 180)
  841.          {
  842.             this.changeDir = "Right";
  843.             _loc3_ = 180 - this.GetPropRotation();
  844.          }
  845.          else if(this.GetPropRotation() > -180 && this.GetPropRotation() < -135)
  846.          {
  847.             this.changeDir = "Left";
  848.             _loc3_ = this.GetPropRotation() + 180;
  849.          }
  850.          else if(this.GetPropRotation() < -45 && this.GetPropRotation() > -90)
  851.          {
  852.             this.changeDir = "Left";
  853.             _loc3_ = this.GetPropRotation() + 90;
  854.          }
  855.          else if(this.GetPropRotation() < -90 && this.GetPropRotation() > -135)
  856.          {
  857.             this.changeDir = "Right";
  858.             _loc3_ = -90 - this.GetPropRotation();
  859.          }
  860.          else if(this.GetPropRotation() > -45 && this.GetPropRotation() < 0)
  861.          {
  862.             this.changeDir = "Right";
  863.             _loc3_ = - this.GetPropRotation();
  864.          }
  865.          else if(this.GetPropRotation() > 0 && this.GetPropRotation() < 45)
  866.          {
  867.             this.changeDir = "Left";
  868.             _loc3_ = this.GetPropRotation() - 0;
  869.          }
  870.          _loc6_ = true;
  871.       }
  872.       if(_loc6_)
  873.       {
  874.          if(this.changeDir == "Left")
  875.          {
  876.             this.RotateVeh(- _loc3_);
  877.          }
  878.          else if(this.changeDir == "Right")
  879.          {
  880.             this.RotateVeh(_loc3_);
  881.          }
  882.          this.changeDir = null;
  883.       }
  884.       else if(this.changeDir == "Left")
  885.       {
  886.          this.RotateVeh(- this.STEERING);
  887.       }
  888.       else if(this.changeDir == "Right")
  889.       {
  890.          this.RotateVeh(this.STEERING);
  891.       }
  892.       if(this.etat != "Falling" && this.etat != "Jumping1" && this.etat != "Jumping2")
  893.       {
  894.          this.noFrame = this.noFrame + 1;
  895.          if(this.noFrame == 30)
  896.          {
  897.             this.oldPosX = _global.C._parent.ScrollMap.Items.Map._x;
  898.             this.oldPosY = _global.C._parent.ScrollMap.Items.Map._y;
  899.             this.noFrame = 0;
  900.          }
  901.       }
  902.       if(!this.bounce)
  903.       {
  904.          var _loc5_ = Math.sin(this.GetRotation() * 0.017453292519943295) * this.GetSpeed();
  905.          var _loc4_ = Math.cos(this.GetRotation() * 0.017453292519943295) * this.GetSpeed() * -1;
  906.          _global.C._parent.ScrollMap.Items.Map._x -= _loc5_;
  907.          _global.C._parent.ScrollMap.Items.Map._y -= _loc4_;
  908.          _global.C._parent.ScrollMap.Items.Front._x -= _loc5_;
  909.          _global.C._parent.ScrollMap.Items.Front._y -= _loc4_;
  910.          _global.C._parent.ScrollMap.Items.Parallax._x -= _loc5_ * 2.1;
  911.          _global.C._parent.ScrollMap.Items.Parallax._y -= _loc4_ * 2.1;
  912.       }
  913.       else
  914.       {
  915.          this.SetSpeed(this.GetSpeed() * 0.92);
  916.          _loc5_ = Math.sin(this.GetRotation() * 0.017453292519943295) * (this.GetSpeed() * this.SPEED_BRAKE);
  917.          _loc4_ = Math.cos(this.GetRotation() * 0.017453292519943295) * (this.GetSpeed() * this.SPEED_BRAKE) * -1;
  918.          _global.C._parent.ScrollMap.Items.Map._x += _loc5_;
  919.          _global.C._parent.ScrollMap.Items.Map._y += _loc4_;
  920.          _global.C._parent.ScrollMap.Items.Front._x += _loc5_;
  921.          _global.C._parent.ScrollMap.Items.Front._y += _loc4_;
  922.          _global.C._parent.ScrollMap.Items.Parallax._x += _loc5_ * 2.1;
  923.          _global.C._parent.ScrollMap.Items.Parallax._y += _loc4_ * 2.1;
  924.          if(Math.abs(this.speed) < 1)
  925.          {
  926.             this.bounce = false;
  927.          }
  928.       }
  929.       this.CheckHit();
  930.       if(!_global.C.G_backPressed && !this.stateLocked)
  931.       {
  932.          if(Math.floor(this.speed) == this.ANIM_SPEED_ACC)
  933.          {
  934.             if(this.oldSpeed < this.speed)
  935.             {
  936.                if(this.changeDir == null)
  937.                {
  938.                   this.mcRef.gotoAndPlay("MoveAcc");
  939.                }
  940.                this.nextAnimToPlay = "MoveFast";
  941.             }
  942.             else if(this.oldSpeed > this.speed)
  943.             {
  944.                if(this.changeDir == null)
  945.                {
  946.                   this.mcRef.gotoAndPlay("MoveDecc");
  947.                }
  948.                this.nextAnimToPlay = "MoveForw";
  949.             }
  950.          }
  951.       }
  952.    }
  953.    function ReceivePackage()
  954.    {
  955.       this.stateLocked = false;
  956.       this.pack.AttachToDropZone();
  957.       _global.C[_global.C.G_interface].UpdateEdFace("Happy");
  958.       this.vanAi.SetState("Explode");
  959.       this.HandleAnim();
  960.    }
  961.    function SetSpeed(l_speed)
  962.    {
  963.       if(l_speed <= this.SPEED_MAX * this.powerUpSpeedFactor && l_speed >= this.SPEED_MIN)
  964.       {
  965.          this.oldSpeed = this.speed;
  966.          this.speed = l_speed;
  967.       }
  968.       else if(l_speed > this.SPEED_MAX * this.powerUpSpeedFactor)
  969.       {
  970.          this.oldSpeed = this.speed;
  971.          this.speed *= 0.9;
  972.       }
  973.       if(Math.abs(this.speed) < 1 && Math.abs(this.speed) > 0)
  974.       {
  975.          this.speed = 0;
  976.       }
  977.    }
  978.    function ThrowForw()
  979.    {
  980.       if(this.mcRef.Etat._currentframe >= this.FR_THROW_FORW)
  981.       {
  982.          this.ReceivePackage();
  983.       }
  984.       if(_global.C.G_forwPressed)
  985.       {
  986.          this.MoveForw();
  987.       }
  988.       else
  989.       {
  990.          this.MoveIdle();
  991.       }
  992.    }
  993.    function ThrowLeft()
  994.    {
  995.       if(this.mcRef.Etat._currentframe >= this.FR_THROW_LEFT)
  996.       {
  997.          this.ReceivePackage();
  998.       }
  999.       this.MoveLeft();
  1000.    }
  1001.    function ThrowRight()
  1002.    {
  1003.       if(this.mcRef.Etat._currentframe >= this.FR_THROW_RIGHT)
  1004.       {
  1005.          this.ReceivePackage();
  1006.       }
  1007.       this.MoveRight();
  1008.    }
  1009.    function ShowPowerUp(l_powerUp, l_start)
  1010.    {
  1011.       if(l_start)
  1012.       {
  1013.          this.mcRef.PU[l_powerUp].gotoAndPlay("Idle");
  1014.       }
  1015.       else
  1016.       {
  1017.          this.mcRef.PU[l_powerUp].gotoAndStop("PasLa");
  1018.       }
  1019.    }
  1020.    function SetInvisible()
  1021.    {
  1022.       this.mcRef._visible = false;
  1023.       this.mcRef._parent.Hud_Fleche._visible = false;
  1024.    }
  1025.    function SetVisible()
  1026.    {
  1027.       this.mcRef._parent.Hud_Fleche._visible = true;
  1028.       this.mcRef._visible = true;
  1029.    }
  1030.    function SetPowerUpSpeedFactor(l_factorSpeedMax, l_factorAccel)
  1031.    {
  1032.       this.powerUpSpeedFactor = l_factorSpeedMax;
  1033.       this.powerUpAccelFactor = l_factorAccel;
  1034.    }
  1035.    function SetState(l_newState)
  1036.    {
  1037.       if(l_newState != undefined && l_newState != this.etat && !this.stateLocked)
  1038.       {
  1039.          this.oldEtat = this.etat;
  1040.          this.etat = l_newState;
  1041.          this.mcRef.gotoAndPlay(l_newState);
  1042.          if(this.etat === "Idle")
  1043.          {
  1044.             this.oldTrajectory = null;
  1045.             if(this.changeDir == "Left")
  1046.             {
  1047.                this.mcRef.gotoAndPlay("Left2Idle");
  1048.             }
  1049.             else if(this.changeDir == "Right")
  1050.             {
  1051.                this.mcRef.gotoAndPlay("Right2Idle");
  1052.             }
  1053.             this.bounce = false;
  1054.          }
  1055.       }
  1056.    }
  1057.    function SetTrajectory(l_TurnTo)
  1058.    {
  1059.       if(!this.stateLocked)
  1060.       {
  1061.          if(this.changeDir != l_TurnTo && (l_TurnTo == "Left" || l_TurnTo == "Right" || l_TurnTo == null))
  1062.          {
  1063.             this.oldTrajectory = this.changeDir;
  1064.             this.changeDir = l_TurnTo;
  1065.          }
  1066.       }
  1067.    }
  1068.    function UnSetPowerUpSpeedFactor()
  1069.    {
  1070.       this.powerUpSpeedFactor = 1;
  1071.       this.powerUpAccelFactor = 1;
  1072.    }
  1073.    function ExtractFromHole()
  1074.    {
  1075.       _global.C._parent.ScrollMap.Items.Map._x = _global.C._parent.ScrollMap.Items.Front._x = _global.C._parent.ScrollMap.Items.Parallax._x = this.oldPosX;
  1076.       _global.C._parent.ScrollMap.Items.Map._y = _global.C._parent.ScrollMap.Items.Front._y = _global.C._parent.ScrollMap.Items.Parallax._y = this.oldPosY;
  1077.    }
  1078. }
  1079.