home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Acao / 3FootNinja.swf / scripts / frame_222 / DoAction.as
Encoding:
Text File  |  2007-05-31  |  14.5 KB  |  566 lines

  1. function initGame()
  2. {
  3.    pickedUpScroll = false;
  4.    madeContact = false;
  5.    allDone = false;
  6.    nextScreen = false;
  7.    healthAmount = 20;
  8.    ninjaHit = false;
  9.    ninjaMove = 1;
  10.    ninjaLeft = false;
  11.    ninjaCrouch = false;
  12.    ninjaHealth._xscale = 100;
  13.    ninjaSwing = false;
  14.    ninjaStrength = power;
  15.    jump = false;
  16.    starCount = 10;
  17.    keyTouch = 1;
  18.    nextStarTime = 0;
  19.    nextStar = 0;
  20.    stars = [];
  21.    enemyLeft = false;
  22.    enemyHit = false;
  23.    enemySwing = false;
  24.    enemyStrength = 3;
  25.    enemyHealth._xscale = 100;
  26.    enemyBlock = false;
  27.    nextfireBall = 0;
  28.    fireBalls = [];
  29.    fireBallCount = 30;
  30.    nextIceBall = 0;
  31.    iceBalls = [];
  32.    iceBallCount = 30;
  33.    nextSuperF = 0;
  34.    superFs = [];
  35.    superFCount = 30;
  36.    swordSound = new Sound();
  37.    swordSound.attachSound("swordsClank");
  38.    gameSound = new Sound();
  39.    gameSound.attachSound("soundtrack");
  40. }
  41. function throwIceball()
  42. {
  43.    attachMovie("iceball","ice" + nextIceBall,nextIceBall + 10000);
  44.    if(enemyLeft == false)
  45.    {
  46.       _root["ice" + nextIceBall]._x = warrior._x - 50;
  47.    }
  48.    if(enemyLeft == true)
  49.    {
  50.       _root["ice" + nextIceBall]._x = warrior._x + 50;
  51.    }
  52.    _root["Ice" + nextIceBall]._y = warrior._y - 40;
  53.    iceBalls.push(nextIceBall);
  54.    nextIceBall++;
  55.    iceBallCount--;
  56. }
  57. function moveIceball()
  58. {
  59.    c = iceBalls.length - 1;
  60.    while(c >= 0)
  61.    {
  62.       i_Ball = _root["ice" + iceBalls[c]];
  63.       if(i_Ball._x < 0 || i_Ball._x > 550)
  64.       {
  65.          i_Ball.removeMovieClip();
  66.          iceBalls.splice(c,1);
  67.       }
  68.       else if(i_Ball.hitTest(ninja) && jump != true && ninjaCrouch != true)
  69.       {
  70.          i_Ball.gotoAndPlay(10);
  71.          ninjaHit = true;
  72.          ninja.gotoAndPlay(14);
  73.          ninjaHealth._xscale -= 10;
  74.       }
  75.       else if(i_Ball.hitTest(ninja) && jump != true && ninjaCrouch == true)
  76.       {
  77.          i_Ball.gotoAndPlay(10);
  78.       }
  79.       c--;
  80.    }
  81. }
  82. function throwFireball()
  83. {
  84.    attachMovie("fireball","fire" + nextfireBall,nextfireBall + 10000);
  85.    if(enemyLeft == false)
  86.    {
  87.       _root["fire" + nextfireBall]._x = warrior._x - 50;
  88.    }
  89.    if(enemyLeft == true)
  90.    {
  91.       _root["fire" + nextfireBall]._x = warrior._x + 50;
  92.    }
  93.    _root["fire" + nextfireBall]._y = warrior._y - 40;
  94.    fireBalls.push(nextfireBall);
  95.    nextfireBall++;
  96.    fireBallCount--;
  97. }
  98. function moveFireball()
  99. {
  100.    f = fireBalls.length - 1;
  101.    while(f >= 0)
  102.    {
  103.       f_Ball = _root["fire" + fireBalls[f]];
  104.       if(f_Ball._x < 0 || f_Ball._x > 550)
  105.       {
  106.          f_Ball.removeMovieClip();
  107.          fireBalls.splice(f,1);
  108.       }
  109.       else if(f_Ball.hitTest(ninja) && jump != true && ninjaCrouch != true)
  110.       {
  111.          f_Ball.gotoAndPlay(10);
  112.          ninjaHit = true;
  113.          ninja.gotoAndPlay(14);
  114.          ninjaHealth._xscale -= 10;
  115.       }
  116.       else if(f_Ball.hitTest(ninja) && jump != true && ninjaCrouch == true)
  117.       {
  118.          f_Ball.gotoAndPlay(10);
  119.       }
  120.       f--;
  121.    }
  122. }
  123. function throwStars()
  124. {
  125.    if(getTimer() > nextStarTime)
  126.    {
  127.       attachMovie("star","star" + nextStar,nextStar + 9999);
  128.       if(ninjaLeft == true)
  129.       {
  130.          _root["star" + nextStar]._x = ninja._x - 50;
  131.       }
  132.       if(ninjaLeft == false)
  133.       {
  134.          _root["star" + nextStar]._x = ninja._x + 50;
  135.       }
  136.       _root["star" + nextStar]._y = ninja._y - 40;
  137.       stars.push(nextStar);
  138.       nextStar++;
  139.       nextStarTime = getTimer() + 500;
  140.       starCount--;
  141.    }
  142. }
  143. function moveStars()
  144. {
  145.    n = stars.length - 1;
  146.    while(n >= 0)
  147.    {
  148.       star = _root["star" + stars[n]];
  149.       if(star._x < 0 || star._x > 550)
  150.       {
  151.          star.removeMovieClip();
  152.          stars.splice(n,1);
  153.       }
  154.       else if(star.hitTest(warrior))
  155.       {
  156.          warrior.gotoAndStop(3);
  157.          star.removeMovieClip();
  158.          enemyHealth._xscale -= 5;
  159.       }
  160.       n--;
  161.    }
  162. }
  163. function superFlash()
  164. {
  165.    attachMovie("superFlash","superF" + nextSuperF,nextSuperF + 9999);
  166.    if(enemyLeft == false)
  167.    {
  168.       _root["superF" + nextSuperF]._x = enemyFloat._x - 30;
  169.    }
  170.    if(enemyLeft == true)
  171.    {
  172.       _root["superF" + nextSuperF]._x = enemyFloat._x + 30;
  173.    }
  174.    _root["superF" + nextSuperF]._y = enemyFloat._y - 60;
  175.    superFs.push(nextSuperF);
  176.    nextSuperF++;
  177.    superFCount--;
  178. }
  179. function resetBonus()
  180. {
  181.    if(town._currentframe == 1 or town._currentframe == 14)
  182.    {
  183.       scrollsAvailable = false;
  184.    }
  185.    else if(town._currentframe == 2 or town._currentframe == 15)
  186.    {
  187.       _root.healthBottle();
  188.    }
  189.    else if(town._currentframe == 3 or town._currentframe == 16)
  190.    {
  191.       scrollsAvailable = true;
  192.       _root.oldScrolls();
  193.    }
  194.    else if(town._currentframe == 4 or town._currentframe == 17)
  195.    {
  196.       pickedUpScroll = false;
  197.       scrollsAvailable = false;
  198.       _root.healthBottle();
  199.    }
  200.    else if(town._currentframe == 5 or town._currentframe == 18)
  201.    {
  202.       pickedUpScroll = false;
  203.       scrollsAvailable = true;
  204.       _root.healthBottle();
  205.       _root.oldScrolls();
  206.    }
  207.    else if(town._currentframe == 6 or town._currentframe == 19)
  208.    {
  209.       pickedUpScroll = false;
  210.       scrollsAvailable = true;
  211.       _root.oldScrolls();
  212.       _root.healthBottle();
  213.    }
  214.    else if(town._currentframe == 7 or town._currentframe == 20)
  215.    {
  216.       pickedUpScroll = false;
  217.       scrollsAvailable = false;
  218.       _root.healthBottle();
  219.    }
  220.    else if(town._currentframe == 8 or town._currentframe == 21)
  221.    {
  222.       pickedUpScroll = false;
  223.       scrollsAvailable = true;
  224.       _root.healthBottle();
  225.       _root.oldScrolls();
  226.    }
  227.    else if(town._currentframe == 9 or town._currentframe == 22)
  228.    {
  229.       pickedUpScroll = false;
  230.       scrollsAvailable = false;
  231.       if(myXtraLife == 0)
  232.       {
  233.          _root.extraLife();
  234.       }
  235.    }
  236.    else if(town._currentframe == 10 or town._currentframe == 23)
  237.    {
  238.       _root.scrollsAvailable = false;
  239.       _root.healthBottle();
  240.    }
  241.    else if(town._currentframe == 11 or town._currentframe == 24)
  242.    {
  243.       _root.scrollsAvailable = false;
  244.       _root.healthBottle();
  245.    }
  246.    else if(town._currentframe == 12 or town._currentframe == 25)
  247.    {
  248.       _root.scrollsAvailable = false;
  249.       _root.healthBottle();
  250.    }
  251.    else if(town._currentframe == 13 or town._currentframe == 26)
  252.    {
  253.       _root.scrollsAvailable = true;
  254.       _root.healthBottle();
  255.       _root.oldScrolls();
  256.    }
  257. }
  258. function extraLife()
  259. {
  260.    myXtraLife = 1;
  261.    _root.attachMovie("life","life",100);
  262.    life._x = Math.random() * 400 + 100;
  263.    life._y = 145;
  264. }
  265. function healthBottle()
  266. {
  267.    if(ninjaHealth._xscale < 50)
  268.    {
  269.       _root.attachMovie("Health","Health",100);
  270.       Health._x = Math.random() * 400 + 100;
  271.       if(paperScroll.hitTest(Health._x,Health._y,true) == true)
  272.       {
  273.          Health._x = Math.random() * 400 + 100;
  274.       }
  275.       Health._y = 145;
  276.    }
  277. }
  278. function oldScrolls()
  279. {
  280.    _root.attachMovie("paperScroll","paperScroll",200);
  281.    paperScroll._x = Math.random() * 400 + 60;
  282.    paperScroll._y = 145;
  283.    scrollTaken = false;
  284.    scrollsAvailable = true;
  285. }
  286. function moveNinja()
  287. {
  288.    if(Key.isDown(39) && _root.keyTouch == 1 && ninjaCrouch != true)
  289.    {
  290.       ninjaLeft = false;
  291.       dx = 9;
  292.       ninja._xscale = Math.abs(ninja._xscale);
  293.    }
  294.    else if(Key.isDown(37) && _root.keyTouch == 1 && ninjaCrouch != true)
  295.    {
  296.       ninjaLeft = true;
  297.       dx = -9;
  298.       ninja._xscale = - Math.abs(ninja._xscale);
  299.    }
  300.    else
  301.    {
  302.       dx = 0;
  303.    }
  304.    if(ninjaMove == 1)
  305.    {
  306.       ninja._x += dx;
  307.    }
  308.    if(dx != 0 && ninja.swing.ninjaLegs._currentframe == 1)
  309.    {
  310.       ninja.swing.ninjaLegs.gotoAndPlay(2);
  311.    }
  312.    else if(dx == 0 && ninja.swing.ninjaLegs._currentframe != 1)
  313.    {
  314.       ninja.swing.ninjaLegs.gotoAndStop(1);
  315.    }
  316. }
  317. function ninjaFight()
  318. {
  319.    if(enemySwing != true && enemyBlock != true && ninjaSwing == true && enemyHit == false)
  320.    {
  321.       warrior.gotoAndStop(3);
  322.       enemyHealth._xscale -= ninjaStrength;
  323.    }
  324.    else if(enemyBlock == true && ninjaSwing == true)
  325.    {
  326.       warrior.Eswing.Esparks.gotoAndPlay(2);
  327.       if(ninjaLeft != true)
  328.       {
  329.          ninja._x -= 5;
  330.       }
  331.       else
  332.       {
  333.          ninja._x += 5;
  334.       }
  335.    }
  336.    else if(ninja._x < warrior._x && ninjaLeft != true && enemySwing == true && ninjaSwing != true && ninjaCrouch != true)
  337.    {
  338.       ninjaHit = true;
  339.       ninja.gotoAndPlay(14);
  340.       ninja._x -= 40;
  341.       ninjaHealth._xscale -= enemyStrength;
  342.    }
  343.    else if(ninja._x < warrior._x && ninjaLeft == true && enemySwing == true && ninjaSwing != true && ninjaCrouch != true)
  344.    {
  345.       ninjaHit = true;
  346.       ninja.gotoAndPlay(14);
  347.       ninja._x -= 40;
  348.       ninjaHealth._xscale -= enemyStrength;
  349.    }
  350.    else if(ninja._x > warrior._x && ninjaLeft != true && enemySwing == true && ninjaSwing != true && ninjaCrouch != true)
  351.    {
  352.       ninjaHit = true;
  353.       ninja.gotoAndPlay(14);
  354.       ninja._x += 40;
  355.       ninjaHealth._xscale -= enemyStrength;
  356.    }
  357.    else if(ninja._x > warrior._x && ninjaLeft == true && enemySwing == true && ninjaSwing != true && ninjaCrouch != true)
  358.    {
  359.       ninjaHit = true;
  360.       ninja.gotoAndPlay(14);
  361.       ninja._x += 40;
  362.       ninjaHealth._xscale -= enemyStrength;
  363.    }
  364. }
  365. function gameTime()
  366. {
  367.    time = new Date();
  368.    hours = time.getHours();
  369.    if(hours >= 0)
  370.    {
  371.       town.gotoAndStop("Nighttime");
  372.       frontStuff.gotoAndStop("stuffNight");
  373.       _root.sky.sky_red.gotoAndStop(4);
  374.       _root.sky.gotoAndStop(2);
  375.       _root.sky.moon.gotoAndStop(4);
  376.    }
  377.    if(hours >= 1)
  378.    {
  379.       town.gotoAndStop("Nighttime");
  380.       frontStuff.gotoAndStop("stuffNight");
  381.       _root.sky.sky_red.gotoAndStop(4);
  382.       _root.sky.gotoAndStop(2);
  383.       _root.sky.moon.gotoAndStop(5);
  384.    }
  385.    if(hours >= 2)
  386.    {
  387.       town.gotoAndStop("Nighttime");
  388.       frontStuff.gotoAndStop("stuffNight");
  389.       _root.sky.sky_red.gotoAndStop(4);
  390.       _root.sky.gotoAndStop(2);
  391.       _root.sky.moon.gotoAndStop(6);
  392.    }
  393.    if(hours >= 3)
  394.    {
  395.       town.gotoAndStop("Nighttime");
  396.       frontStuff.gotoAndStop("stuffNight");
  397.       _root.sky.sky_red.gotoAndStop(4);
  398.       _root.sky.gotoAndStop(2);
  399.       _root.sky.moon.gotoAndStop(7);
  400.    }
  401.    if(hours >= 4)
  402.    {
  403.       town.gotoAndStop("Nighttime");
  404.       frontStuff.gotoAndStop("stuffNight");
  405.       _root.sky.sky_red.gotoAndStop(4);
  406.       _root.sky.gotoAndStop(2);
  407.       _root.sky.moon.gotoAndStop(8);
  408.    }
  409.    if(hours >= 5)
  410.    {
  411.       town.gotoAndStop("Nighttime");
  412.       frontStuff.gotoAndStop("stuffNight");
  413.       _root.sky.sky_red.gotoAndStop(4);
  414.       _root.sky.gotoAndStop(2);
  415.       _root.sky.moon.gotoAndStop(9);
  416.    }
  417.    if(hours >= 6)
  418.    {
  419.       town.gotoAndStop("Daytime");
  420.       frontStuff.gotoAndStop("stuffDay");
  421.       _root.sky.sky_red.gotoAndStop(2);
  422.       _root.sky.gotoAndStop(1);
  423.       _root.sky.sun.gotoAndStop(1);
  424.    }
  425.    if(hours >= 7)
  426.    {
  427.       town.gotoAndStop("Daytime");
  428.       frontStuff.gotoAndStop("stuffDay");
  429.       _root.sky.sky_red.gotoAndStop(3);
  430.       _root.sky.gotoAndStop(1);
  431.       _root.sky.sun.gotoAndStop(2);
  432.    }
  433.    if(hours >= 8)
  434.    {
  435.       town.gotoAndStop("Daytime");
  436.       frontStuff.gotoAndStop("stuffDay");
  437.       _root.sky.sky_red.gotoAndStop(1);
  438.       _root.sky.gotoAndStop(1);
  439.       _root.sky.sun.gotoAndStop(3);
  440.    }
  441.    if(hours >= 9)
  442.    {
  443.       town.gotoAndStop("Daytime");
  444.       frontStuff.gotoAndStop("stuffDay");
  445.       _root.sky.sky_red.gotoAndStop(1);
  446.       _root.sky.gotoAndStop(1);
  447.       _root.sky.sun.gotoAndStop(4);
  448.    }
  449.    if(hours >= 10)
  450.    {
  451.       town.gotoAndStop("Daytime");
  452.       frontStuff.gotoAndStop("stuffDay");
  453.       _root.sky.sky_red.gotoAndStop(1);
  454.       _root.sky.gotoAndStop(1);
  455.       _root.sky.sun.gotoAndStop(5);
  456.    }
  457.    if(hours >= 11)
  458.    {
  459.       town.gotoAndStop("Daytime");
  460.       frontStuff.gotoAndStop("stuffDay");
  461.       _root.sky.sky_red.gotoAndStop(1);
  462.       _root.sky.gotoAndStop(1);
  463.       _root.sky.sun.gotoAndStop(6);
  464.    }
  465.    if(hours >= 12)
  466.    {
  467.       town.gotoAndStop("Daytime");
  468.       frontStuff.gotoAndStop("stuffDay");
  469.       _root.sky.sky_red.gotoAndStop(1);
  470.       _root.sky.gotoAndStop(1);
  471.       _root.sky.sun.gotoAndStop(7);
  472.    }
  473.    if(hours >= 13)
  474.    {
  475.       town.gotoAndStop("Daytime");
  476.       frontStuff.gotoAndStop("stuffDay");
  477.       _root.sky.sky_red.gotoAndStop(1);
  478.       _root.sky.gotoAndStop(1);
  479.       _root.sky.sun.gotoAndStop(8);
  480.    }
  481.    if(hours >= 14)
  482.    {
  483.       town.gotoAndStop("Daytime");
  484.       frontStuff.gotoAndStop("stuffDay");
  485.       _root.sky.sky_red.gotoAndStop(1);
  486.       _root.sky.gotoAndStop(1);
  487.       _root.sky.sun.gotoAndStop(9);
  488.    }
  489.    if(hours >= 15)
  490.    {
  491.       town.gotoAndStop("Daytime");
  492.       frontStuff.gotoAndStop("stuffDay");
  493.       _root.sky.sky_red.gotoAndStop(1);
  494.       _root.sky.gotoAndStop(1);
  495.       _root.sky.sun.gotoAndStop(10);
  496.    }
  497.    if(hours >= 16)
  498.    {
  499.       town.gotoAndStop("Daytime");
  500.       frontStuff.gotoAndStop("stuffDay");
  501.       _root.sky.sky_red.gotoAndStop(1);
  502.       _root.sky.gotoAndStop(1);
  503.       _root.sky.sun.gotoAndStop(11);
  504.    }
  505.    if(hours >= 17)
  506.    {
  507.       town.gotoAndStop("Daytime");
  508.       frontStuff.gotoAndStop("stuffDay");
  509.       _root.sky.sky_red.gotoAndStop(1);
  510.       _root.sky.gotoAndStop(1);
  511.       _root.sky.sun.gotoAndStop(12);
  512.    }
  513.    if(hours >= 18)
  514.    {
  515.       town.gotoAndStop("Daytime");
  516.       frontStuff.gotoAndStop("stuffDay");
  517.       _root.sky.sky_red.gotoAndStop(1);
  518.       _root.sky.gotoAndStop(1);
  519.       _root.sky.sun.gotoAndStop(13);
  520.    }
  521.    if(hours >= 19)
  522.    {
  523.       town.gotoAndStop("Nighttime");
  524.       frontStuff.gotoAndStop("stuffNight");
  525.       _root.sky.sky_red.gotoAndStop(6);
  526.       _root.sky.gotoAndStop(2);
  527.       _root.sky.sun.gotoAndStop(14);
  528.    }
  529.    if(hours >= 20)
  530.    {
  531.       town.gotoAndStop("Nighttime");
  532.       frontStuff.gotoAndStop("stuffNight");
  533.       _root.sky.sky_red.gotoAndStop(5);
  534.       _root.sky.gotoAndStop(2);
  535.       _root.sky.sun.gotoAndStop(15);
  536.    }
  537.    if(hours >= 21)
  538.    {
  539.       town.gotoAndStop("Nighttime");
  540.       frontStuff.gotoAndStop("stuffNight");
  541.       _root.sky.sky_red.gotoAndStop(4);
  542.       _root.sky.gotoAndStop(2);
  543.       _root.sky.moon.gotoAndStop(1);
  544.    }
  545.    if(hours >= 22)
  546.    {
  547.       town.gotoAndStop("Nighttime");
  548.       frontStuff.gotoAndStop("stuffNight");
  549.       _root.sky.sky_red.gotoAndStop(4);
  550.       _root.sky.gotoAndStop(2);
  551.       _root.sky.moon.gotoAndStop(2);
  552.    }
  553.    if(hours >= 23)
  554.    {
  555.       town.gotoAndStop("Nighttime");
  556.       frontStuff.gotoAndStop("stuffNight");
  557.       _root.sky.sky_red.gotoAndStop(4);
  558.       _root.sky.gotoAndStop(2);
  559.       _root.sky.moon.gotoAndStop(3);
  560.    }
  561. }
  562. levelStart = true;
  563. levelEnd = false;
  564. myXtraLife = 0;
  565. stop();
  566.