home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / staticshock.swf / scripts / frame_23 / DoAction_5.as < prev    next >
Encoding:
Text File  |  2005-11-09  |  10.5 KB  |  375 lines

  1. function init()
  2. {
  3.    _global.scroller = new scrollerEngine();
  4.    scroller.init(map1Parameters);
  5.    totalPlayFieldWidth = 4592;
  6.    coverMC.onEnterFrame = function()
  7.    {
  8.       coverMC._alpha -= 20;
  9.       if(coverMC._alpha < 0)
  10.       {
  11.          coverMC.unloadMovie();
  12.       }
  13.    };
  14.    loadingHolder = 1;
  15.    loadLevel();
  16. }
  17. function loadLevel()
  18. {
  19.    artplayField["container" + loadingHolder].loadMovie(fileNameStorage[loadingHolder - 1]);
  20.    artplayField.preloaderDelay = 0;
  21.    artplayField.onEnterFrame = function()
  22.    {
  23.       if(++this.preloaderDelay == 5)
  24.       {
  25.          this.onEnterFrame = preloadLevel;
  26.       }
  27.    };
  28. }
  29. function preloadLevel()
  30. {
  31.    var _loc1_ = Math.floor(artplayField["container" + loadingHolder].getBytesLoaded() / artplayField["container" + loadingHolder].getBytesTotal() * 100);
  32.    if(_loc1_ == 100)
  33.    {
  34.       delete this.onEnterFrame;
  35.       levelsLoaded[loadingHolder - 1] = true;
  36.       artplayField["container" + loadingHolder]._visible = false;
  37.       if(++loadingHolder != fileNameStorage.length + 1)
  38.       {
  39.          loadLevel();
  40.       }
  41.    }
  42. }
  43. function tracking()
  44. {
  45.    var _loc1_ = new Date().getTime();
  46.    loadMovieNum("http://www.gamezhero.com/online/staticShock/tracker.swf?" + _loc1_,10000);
  47. }
  48. function attract()
  49. {
  50.    radarSurround._visible = infoBar._visible = infoBar2._visible = false;
  51.    playerHide();
  52.    tellTarget(attractMode)
  53.    {
  54.       gotoAndPlay(2);
  55.    }
  56. }
  57. function startGame()
  58. {
  59.    score = 0;
  60.    infoBar.scoreText.text = score;
  61.    level = 1;
  62.    lives = 3;
  63.    infoBar.livesText.text = lives;
  64.    xtraLifeArrays = new Array(0,0,0,0,0,0,0,0,0);
  65.    livesOffset = 0;
  66.    cheated = false;
  67.    stamina = 200;
  68.    infoBar.staminaBar.gotoAndStop(1);
  69.    staticNRG = 200;
  70.    infoBar.staticEnergy.gotoAndStop(1);
  71.    backGroundOffset = numberOfCollectedCircuits = 0;
  72.    smartBombs = 3;
  73.    if(difficulty == "Hard")
  74.    {
  75.       numberOfCircuits = 5;
  76.    }
  77.    else
  78.    {
  79.       numberOfCircuits = 3;
  80.    }
  81.    numberOfAttempts = 1;
  82.    infoBar2.circuitsText.text = numberOfCollectedCircuits + "/" + numberOfCircuits;
  83.    infoBar.zapCap.text = smartBombs;
  84.    currentIntroFrame = 1;
  85.    artplayField.container1._visible = artplayField.container2._visible = artplayField.container3._visible = false;
  86.    this.onEnterFrame = function()
  87.    {
  88.       if(attractMode.wipe._currentframe == 15)
  89.       {
  90.          delete this.onEnterFrame;
  91.          attractMode.gotoAndPlay("getReady");
  92.          attractMode.wipe.gotoAndPlay("out");
  93.       }
  94.    };
  95. }
  96. function preContinueGame()
  97. {
  98.    attractMode.gotoAndPlay(1);
  99.    bgNumber = backgroundStorage[backGroundOffset][0];
  100.    backgroundMC.gotoAndStop(backgroundStorage[backGroundOffset][0]);
  101.    radarSurround._visible = infoBar._visible = infoBar2._visible = true;
  102.    scroller.resetScroller();
  103.    lampPostFrame = backgroundStorage[backGroundOffset][1];
  104.    continueGame();
  105. }
  106. function continueGame()
  107. {
  108.    arrowIndicator._visible = false;
  109.    arrowIndicatorCnt = 0;
  110.    arrowIndicatorFunc = null;
  111.    backgroundMC.gotoAndStop(backgroundStorage[backGroundOffset][0]);
  112.    backgroundMC.skyLine._x = -300;
  113.    artplayField.container1._visible = artplayField.container2._visible = artplayField.container3._visible = false;
  114.    if(bgNumber != 1)
  115.    {
  116.       var _loc1_ = undefined;
  117.       for(_loc1_ in artplayField)
  118.       {
  119.          artplayField[_loc1_]._visible = false;
  120.       }
  121.       artplayField["container" + (bgNumber - 1)]._visible = true;
  122.    }
  123.    else
  124.    {
  125.       artplayField._visible = true;
  126.    }
  127.    lampPostFrame = backgroundStorage[backGroundOffset][1];
  128.    scroller.startXPos = 44;
  129.    scroller.resetScroller();
  130.    scroller.xUpdate = scroller.xBoundary = false;
  131.    artplayField._x = radarMap._x = 0;
  132.    artBasedHandler();
  133.    staticNRG = 200;
  134.    infoBar.staticEnergy.gotoAndStop(1);
  135.    if(stamina == 200)
  136.    {
  137.       infoBar.staminaBar.gotoAndStop(1);
  138.    }
  139.    else
  140.    {
  141.       infoBar.staminaBar.gotoAndStop(20 - int(stamina / 10));
  142.    }
  143.    numberOfCollectedCircuits = 0;
  144.    infoBar2.circuitsText.text = numberOfCollectedCircuits + "/" + numberOfCircuits;
  145.    playerInit();
  146.    killAllBaddies();
  147.    humanInit();
  148.    baddieInit();
  149.    if(wipeRunningFlag == true)
  150.    {
  151.       wipeRunningFlag = false;
  152.       tellTarget(attractMode.wipe)
  153.       {
  154.          gotoAndStop("out");
  155.          play();
  156.       }
  157.       var wipeCnt = 0;
  158.       this.onEnterFrame = function()
  159.       {
  160.          if(++wipeCnt == 28)
  161.          {
  162.             attractMode.initInGameMusic();
  163.             plotStartLevelMessageBar();
  164.          }
  165.       };
  166.    }
  167.    else
  168.    {
  169.       this.onEnterFrame = master;
  170.    }
  171. }
  172. function plotStartLevelMessageBar()
  173. {
  174.    var _loc1_ = this;
  175.    messageBar.messageTextField.text = "";
  176.    messageBar.messageTextField._x = 52;
  177.    messageBar._visible = true;
  178.    messageBar.gotoAndPlay(1);
  179.    var cnt = 0;
  180.    var textPos = 0;
  181.    var textToPlot = "COLLECT " + numberOfCircuits + " CIRCUIT PARTS TO DEACTIVATE MICROBOTS";
  182.    _loc1_.onEnterFrame = function()
  183.    {
  184.       var _loc1_ = this;
  185.       if(++cnt == 15)
  186.       {
  187.          _loc1_.onEnterFrame = function()
  188.          {
  189.             cnt = 0;
  190.             messageBar.messageTextField.text += textToPlot.charAt(textPos++);
  191.             messageBar.messageTextField.text += textToPlot.charAt(textPos++);
  192.             if(textPos >= textToPlot.length)
  193.             {
  194.                this.onEnterFrame = function()
  195.                {
  196.                   if(++cnt == 35)
  197.                   {
  198.                      messageBar.play();
  199.                   }
  200.                   else if(cnt == 45)
  201.                   {
  202.                      this.onEnterFrame = master;
  203.                   }
  204.                };
  205.             }
  206.          };
  207.       }
  208.    };
  209. }
  210. function gameOver()
  211. {
  212.    var _loc1_ = this;
  213.    messageBar.messageTextField.text = "";
  214.    messageBar.messageTextField._x = 252;
  215.    messageBar._visible = true;
  216.    messageBar.gotoAndPlay(1);
  217.    var cnt = 0;
  218.    var textPos = 0;
  219.    var textToPlot = "GAME OVER";
  220.    gameOverMod.start();
  221.    _loc1_.onEnterFrame = function()
  222.    {
  223.       var _loc1_ = this;
  224.       if(++cnt == 15)
  225.       {
  226.          _loc1_.onEnterFrame = function()
  227.          {
  228.             cnt = 0;
  229.             messageBar.messageTextField.text += textToPlot.charAt(textPos++);
  230.             if(textPos == textToPlot.length)
  231.             {
  232.                this.onEnterFrame = function()
  233.                {
  234.                   if(++cnt == frameRate * 2)
  235.                   {
  236.                      messageBar.play();
  237.                   }
  238.                   else if(cnt == frameRate * 2 + 10)
  239.                   {
  240.                      killAllBaddies();
  241.                      delete this.onEnterFrame;
  242.                      attract();
  243.                   }
  244.                };
  245.             }
  246.          };
  247.       }
  248.    };
  249. }
  250. function bumpLevel()
  251. {
  252.    level++;
  253.    if(numberOfCircuits != 9)
  254.    {
  255.       numberOfCircuits++;
  256.    }
  257.    numberOfAttempts = 1;
  258.    infoBar2.circuitsText.text = numberOfCollectedCircuits + "/" + numberOfCircuits;
  259.    if(++backGroundOffset > backgroundStorage.length - 1)
  260.    {
  261.       backGroundOffset = 0;
  262.    }
  263.    currentIntroFrame = introFrames[backGroundOffset];
  264.    attractMode.gotoAndPlay("getReady");
  265. }
  266. function bumpLevel2()
  267. {
  268.    level++;
  269.    if(numberOfCircuits != 9)
  270.    {
  271.       numberOfCircuits++;
  272.    }
  273.    infoBar2.circuitsText.text = numberOfCollectedCircuits + "/" + numberOfCircuits;
  274.    if(++backGroundOffset > backgroundStorage.length - 1)
  275.    {
  276.       backGroundOffset = 0;
  277.    }
  278.    currentIntroFrame = introFrames[backGroundOffset];
  279.    attractMode.gotoAndPlay("getReady3");
  280. }
  281. function displayArrow()
  282. {
  283.    if(++arrowIndicatorCnt == frameRate * 2)
  284.    {
  285.       arrowIndicatorCnt = 0;
  286.       arrowIndicatorFunc = null;
  287.       arrowIndicator._visible = false;
  288.    }
  289. }
  290. function pauseCheck()
  291. {
  292.    var _loc3_ = this;
  293.    if(pausedKeyCheckDelay == 0)
  294.    {
  295.       if(inkey(80))
  296.       {
  297.          pausedKeyCheckDelay = 10;
  298.          if(pauseFlag == false)
  299.          {
  300.             pauseFlag = pauseText._visible = true;
  301.             pausedFunc = _loc3_.onEnterFrame;
  302.             _loc3_.onEnterFrame = pauseCheck;
  303.             tellTarget(player)
  304.             {
  305.                anim.gotoAndStop(anim._currentframe);
  306.             }
  307.             var _loc1_ = undefined;
  308.             var _loc2_ = 0;
  309.             for(_loc2_ in spritePlayField)
  310.             {
  311.                if(typeof spritePlayField[_loc2_] == "movieclip")
  312.                {
  313.                   _loc1_ = spritePlayField[_loc2_];
  314.                   _loc1_.anim.baddieAnim.gotoAndStop(_loc1_.anim.baddieAnim._currentframe);
  315.                   if(_loc1_.anim.baddieAnim.wings != undefined)
  316.                   {
  317.                      _loc1_.anim.baddieAnim.body.gotoAndStop(_loc1_.anim.baddieAnim.body._currentframe);
  318.                      _loc1_.anim.baddieAnim.wings.gotoAndStop(_loc1_.anim.baddieAnim.wings._currentframe);
  319.                   }
  320.                }
  321.             }
  322.          }
  323.          else
  324.          {
  325.             pauseFlag = pauseText._visible = false;
  326.             _loc2_ = 0;
  327.             for(_loc2_ in spritePlayField)
  328.             {
  329.                if(typeof spritePlayField[_loc2_] == "movieclip")
  330.                {
  331.                   _loc1_ = spritePlayField[_loc2_];
  332.                   if(_loc1_.animDelay == undefined)
  333.                   {
  334.                      _loc1_.anim.baddieAnim.gotoAndPlay(_loc1_.anim.baddieAnim._currentframe);
  335.                   }
  336.                   if(_loc1_.anim.baddieAnim.wings != undefined)
  337.                   {
  338.                      _loc1_.anim.baddieAnim.body.gotoAndPlay(_loc1_.anim.baddieAnim.body._currentframe);
  339.                      _loc1_.anim.baddieAnim.wings.gotoAndPlay(_loc1_.anim.baddieAnim.wings._currentframe);
  340.                   }
  341.                }
  342.             }
  343.             tellTarget(player)
  344.             {
  345.                anim.gotoAndPlay(anim._currentframe);
  346.             }
  347.             _loc3_.onEnterFrame = pausedFunc;
  348.          }
  349.       }
  350.       else if(inkey(81))
  351.       {
  352.          if(pauseFlag == true)
  353.          {
  354.             pauseFlag = pauseText._visible = false;
  355.             delete _loc3_.onEnterFrame;
  356.             killAllBaddies();
  357.             playerHide();
  358.             if(score > bestScore)
  359.             {
  360.                bestScore = score;
  361.                bestScoreString = insertZeros(bestScore);
  362.                saveData();
  363.             }
  364.             arrowIndicator._visible = false;
  365.             infoBar.extraLifeText._visible = false;
  366.             attract();
  367.          }
  368.       }
  369.    }
  370.    else
  371.    {
  372.       pausedKeyCheckDelay--;
  373.    }
  374. }
  375.