home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Aventura / tall-ships.swf / scripts / frame_9 / DoAction.as
Encoding:
Text File  |  2005-09-29  |  6.9 KB  |  254 lines

  1. function restartLeg()
  2. {
  3.    if(Key.isDown(32))
  4.    {
  5.       gotoAndStop("restartSlideShow3");
  6.    }
  7. }
  8. function moveBG(target, bg)
  9. {
  10.    bg._x -= Math.cos(target.radians) * target.speed + Math.cos(target.momentumRad) * target.momentumSpeed;
  11.    bg._y -= Math.sin(target.radians) * target.speed + Math.sin(target.momentumRad) * target.momentumSpeed;
  12. }
  13. function moveClouds(target, bg)
  14. {
  15.    bg._x -= (Math.cos(target.radians) * target.speed + Math.cos(target.momentumRad) * target.momentumSpeed) * 2;
  16.    bg._y -= (Math.sin(target.radians) * target.speed + Math.sin(target.momentumRad) * target.momentumSpeed) * 2;
  17. }
  18. function hitDock(target, dock)
  19. {
  20.    if(tutorialMap_mc.tutorialDocks_mc.hitTest(target._x,target._y,true) && target.speed < 0.5 && target.momentumSpeed < 0.5)
  21.    {
  22.       target.finished = true;
  23.       grats_txt.text = "Congratulations, you\'ve completed the tutorial.  You\'re now rady to sail!";
  24.    }
  25. }
  26. function turnIt(target)
  27. {
  28.    if(Key.isDown(37))
  29.    {
  30.       target._rotation -= target.turning;
  31.       target.degrees -= target.turning;
  32.       if(target.degrees < 0)
  33.       {
  34.          target.degrees += 360;
  35.       }
  36.       tutorialShipLayer_mc.ship3d_mc.gotoAndStop(Math.floor(target.degrees / 12));
  37.    }
  38.    if(Key.isDown(39))
  39.    {
  40.       target._rotation += target.turning;
  41.       target.degrees += target.turning;
  42.       if(target.degrees > 360)
  43.       {
  44.          target.degrees -= 360;
  45.       }
  46.       tutorialShipLayer_mc.ship3d_mc.gotoAndStop(Math.floor(target.degrees / 12));
  47.    }
  48.    if(target.hitStorm)
  49.    {
  50.       target._rotation += target.turning * 2;
  51.       target.degrees += target.turning * 2;
  52.       if(target.degrees > 360)
  53.       {
  54.          target.degrees -= 360;
  55.       }
  56.       tutorialShipLayer_mc.ship3d_mc.gotoAndStop(Math.floor(target.degrees / 12));
  57.    }
  58.    target.radians = (target._rotation + 30) * 3.141592653589793 / 180;
  59. }
  60. function changeSpeed(target)
  61. {
  62.    target.momentumSpeed *= 0.97;
  63.    if(target.momentumSpeed < 0.05)
  64.    {
  65.       target.momentumSpeed = 0;
  66.    }
  67.    if(Key.isDown(38) && target.speed < target.maxSpeed)
  68.    {
  69.       target.speed += target.acceleration;
  70.       if(target.speed > target.maxSpeed)
  71.       {
  72.          target.speed = target.maxSpeed;
  73.       }
  74.       if(target.momentumSpeed < target.speed)
  75.       {
  76.          target.momentumSpeed = target.speed;
  77.       }
  78.       target.momentumRad = target.radians;
  79.    }
  80.    else
  81.    {
  82.       target.speed *= 0.96;
  83.    }
  84.    if(Key.isDown(40) && target.speed > 0)
  85.    {
  86.       target.speed -= target.braking;
  87.       if(target.speed < 0.05)
  88.       {
  89.          target.speed = 0;
  90.       }
  91.    }
  92.    if(target.speed < 0.05)
  93.    {
  94.       target.speed = 0;
  95.    }
  96.    if(target.hitLand)
  97.    {
  98.       target.speed = 0.5;
  99.       target.momentumSpeed = 0;
  100.       if(pointsMinus_mc._currentframe == 1)
  101.       {
  102.          pointsMinus_mc.displayText = "4";
  103.          pointsMinus_mc.gotoAndPlay("start");
  104.          if(timer.seconds >= 4)
  105.          {
  106.             timer.seconds -= 4;
  107.          }
  108.          else
  109.          {
  110.             timer.seconds = 0;
  111.          }
  112.       }
  113.    }
  114.    else if(target.hitIceBerg)
  115.    {
  116.       target.speed = 0.5;
  117.       target.momentumSpeed = 0;
  118.       if(pointsMinus_mc._currentframe == 1)
  119.       {
  120.          pointsMinus_mc.displayText = "3";
  121.          pointsMinus_mc.gotoAndPlay("start");
  122.          if(timer.seconds >= 3)
  123.          {
  124.             timer.seconds -= 3;
  125.          }
  126.          else
  127.          {
  128.             timer.seconds = 0;
  129.          }
  130.       }
  131.    }
  132.    else if(target.hitRock)
  133.    {
  134.       target.speed = 0.5;
  135.       target.momentumSpeed = 0;
  136.       if(pointsMinus_mc._currentframe == 1)
  137.       {
  138.          pointsMinus_mc.displayText = "2";
  139.          pointsMinus_mc.gotoAndPlay("start");
  140.          if(timer.seconds >= 2)
  141.          {
  142.             timer.seconds -= 2;
  143.          }
  144.          else
  145.          {
  146.             timer.seconds = 0;
  147.          }
  148.       }
  149.    }
  150.    else if(target.hitWhale)
  151.    {
  152.       target.speed = 0.5;
  153.       target.momentumSpeed = 0;
  154.       if(pointsMinus_mc._currentframe == 1)
  155.       {
  156.          pointsMinus_mc.displayText = "3";
  157.          pointsMinus_mc.gotoAndPlay("start");
  158.          if(timer.seconds >= 3)
  159.          {
  160.             timer.seconds -= 3;
  161.          }
  162.          else
  163.          {
  164.             timer.seconds = 0;
  165.          }
  166.       }
  167.    }
  168. }
  169. stop();
  170. _quality = "HIGH";
  171. detailToggle_mc._visible = false;
  172. soundToggle_mc._visible = false;
  173. tutorialShip_mc._rotation = _global.shipRotation;
  174. switch(_global.shipClass)
  175. {
  176.    case "A":
  177.       tutorialShipLayer_mc.attachMovie("shipA","ship3d_mc",1);
  178.       tutorialShipLayer_mc.ship3d_mc._x = 231;
  179.       tutorialShipLayer_mc.ship3d_mc._y = 178;
  180.       tutorialShip_mc.radians = (tutorialShip_mc._rotation + 30) * 3.141592653589793 / 180;
  181.       tutorialShip_mc.maxSpeed = 6;
  182.       tutorialShip_mc.acceleration = 0.1;
  183.       tutorialShip_mc.braking = 2;
  184.       tutorialShip_mc.turning = 12;
  185.       break;
  186.    case "B":
  187.       tutorialShipLayer_mc.attachMovie("shipB","ship3d_mc",1);
  188.       tutorialShipLayer_mc.ship3d_mc._x = 231;
  189.       tutorialShipLayer_mc.ship3d_mc._y = 178;
  190.       tutorialShip_mc.radians = (tutorialShip_mc._rotation + 30) * 3.141592653589793 / 180;
  191.       tutorialShip_mc.maxSpeed = 5.5;
  192.       tutorialShip_mc.acceleration = 0.2;
  193.       tutorialShip_mc.braking = 2;
  194.       tutorialShip_mc.turning = 12;
  195.       break;
  196.    case "C":
  197.       tutorialShipLayer_mc.attachMovie("shipC","ship3d_mc",1);
  198.       tutorialShipLayer_mc.ship3d_mc._x = 231;
  199.       tutorialShipLayer_mc.ship3d_mc._y = 178;
  200.       tutorialShip_mc.radians = (tutorialShip_mc._rotation + 30) * 3.141592653589793 / 180;
  201.       tutorialShip_mc.maxSpeed = 5;
  202.       tutorialShip_mc.acceleration = 0.5;
  203.       tutorialShip_mc.braking = 2;
  204.       tutorialShip_mc.turning = 12;
  205. }
  206. tutorialShip_mc.degrees = _global.shipRotation;
  207. tutorialShipLayer_mc.ship3d_mc.gotoAndStop(Math.floor(tutorialShip_mc.degrees / 12));
  208. tutorialShip_mc.momentumRad = tutorialShip_mc.radians;
  209. tutorialShip_mc.momentumSpeed = 0;
  210. tutorialShip_mc.speed = 0;
  211. tutorialShip_mc.waterTrail = 0;
  212. tutorialShip_mc.orangeBuoys = 0;
  213. tutorialShip_mc.hitLand = false;
  214. tutorialShip_mc.hitIceBerg = false;
  215. tutorialShip_mc.hitRock = false;
  216. tutorialShip_mc.hitStorm = false;
  217. tutorialShip_mc.finished = false;
  218. tutorialShip_mc.onEnterFrame = function()
  219. {
  220.    if(!tutorialShip_mc.finished)
  221.    {
  222.       moveBG(this,tutorialMap_mc);
  223.       changeSpeed(this);
  224.       turnIt(this);
  225.       hitDock(this,_global.nextDock);
  226.       restartLeg();
  227.    }
  228.    else
  229.    {
  230.       restartLeg();
  231.    }
  232. };
  233. tutorialFadeToBlack_mc.onEnterFrame = function()
  234. {
  235.    if(tutorialShip_mc.finished && this._alpha < 65)
  236.    {
  237.       this._alpha += 5;
  238.    }
  239.    if(tutorialShip_mc.finished && gratsText_mc._alpha < 100)
  240.    {
  241.       gratsText_mc._alpha += 10;
  242.    }
  243. };
  244. btnNext_mc.onRelease = function()
  245. {
  246.    gotoAndStop("selectBoat");
  247.    play();
  248. };
  249. btnBack_mc.onRelease = function()
  250. {
  251.    gotoAndStop("slideShow2");
  252.    play();
  253. };
  254.