home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Aventura / lightsprites.swf / scripts / __Packages / LightSpriteGame.as < prev    next >
Encoding:
Text File  |  2007-09-27  |  58.8 KB  |  1,868 lines

  1. class LightSpriteGame
  2. {
  3.    var lineDepth;
  4.    var popUpDepth;
  5.    var arrOrbs;
  6.    var arrOrbsFired;
  7.    var arrTargetObjects;
  8.    var arrCleanup;
  9.    var arrRelease;
  10.    var arrSets;
  11.    var arrSetCounter;
  12.    var arrPopUpFlags;
  13.    var popUpCounter;
  14.    var orbDepth;
  15.    var objectDepth;
  16.    var pointDepth;
  17.    var effectDepth;
  18.    var orbSpeed;
  19.    var orbMaxSpeed;
  20.    var windResistance;
  21.    var numGroundSpeed;
  22.    var gameTargets;
  23.    var blnHolding;
  24.    var blnLeftSide;
  25.    var keyCounter;
  26.    var engineTimer;
  27.    var difficultyPeopleCounter;
  28.    var difficultyTimer;
  29.    var refillType;
  30.    var score;
  31.    var numRelease;
  32.    var setIndex;
  33.    var targetCounter;
  34.    var modeCounter;
  35.    var blnMulti;
  36.    var rainbowHold;
  37.    var statCorrect;
  38.    var statMissed;
  39.    var statWrong;
  40.    var statThrown;
  41.    var statFull;
  42.    var numEnergyMax;
  43.    var numEnergy;
  44.    var backAnimCounter;
  45.    var backAnimMin;
  46.    var backAnimMax;
  47.    var blnArrows1;
  48.    var blnArrows2;
  49.    var multiOrbPointCounter;
  50.    var mouseListener;
  51.    var gameMode;
  52.    var currentSet;
  53.    function LightSpriteGame()
  54.    {
  55.       this.lineDepth = _root.lines.getDepth();
  56.       _root.lines.swapDepths(600);
  57.       this.popUpDepth = _root.popUp.getDepth();
  58.       _root.popUp.swapDepths(11001);
  59.       this.arrOrbs = new Array();
  60.       this.arrOrbsFired = new Array();
  61.       this.arrTargetObjects = new Array();
  62.       this.arrCleanup = new Array();
  63.       this.arrRelease = new Array();
  64.       this.arrSets = new Array();
  65.       if(_global.gameDifficulty == 1)
  66.       {
  67.          this.arrSetCounter = new Array(25,50,75,100,125,150,175);
  68.       }
  69.       else if(_global.gameDifficulty == 2)
  70.       {
  71.          this.arrSetCounter = new Array(30,60,90,120,150,180,210,240,270);
  72.       }
  73.       else if(_global.gameDifficulty == 3)
  74.       {
  75.          this.arrSetCounter = new Array(30,60,90,120,150,180,210,240,270,300,335,370);
  76.       }
  77.       else if(_global.gameDifficulty == 4)
  78.       {
  79.          this.arrSetCounter = new Array(30,60,90,120,150,180,210,240,270,300,335,370,400,430,460,490,510,540,570,600,630,660,690,720,750,780,910,940,1000,1100,1200);
  80.       }
  81.       else if(_global.gameDifficulty == 5)
  82.       {
  83.          this.arrSetCounter = new Array(30,60,90,120,150,180,210,240,270,300,335,370,400,430,460,490,510,540,570,600,630,660,690,720,750,780,910,940,1000,1100,1200);
  84.       }
  85.       this.arrPopUpFlags = new Array(false,false,false,false,false,false,false);
  86.       this.popUpCounter = 0;
  87.       this.orbDepth = 5000;
  88.       this.objectDepth = 4000;
  89.       this.pointDepth = 9000;
  90.       this.effectDepth = 10000;
  91.       this.orbSpeed = 0.4;
  92.       this.orbMaxSpeed = 16;
  93.       this.windResistance = 0;
  94.       if(_global.gameDifficulty == 1)
  95.       {
  96.          this.numGroundSpeed = 0.6;
  97.          this.gameTargets = 200;
  98.          _root.energy._visible = false;
  99.       }
  100.       else if(_global.gameDifficulty == 2)
  101.       {
  102.          this.numGroundSpeed = 0.7;
  103.          this.gameTargets = 300;
  104.          _root.energy._visible = false;
  105.       }
  106.       else if(_global.gameDifficulty == 3)
  107.       {
  108.          this.numGroundSpeed = 0.7;
  109.          this.gameTargets = 400;
  110.          _root.energy._visible = false;
  111.       }
  112.       else if(_global.gameDifficulty == 4)
  113.       {
  114.          this.numGroundSpeed = 0.65;
  115.          _root.energy._visible = true;
  116.          this.UpdateEnergy();
  117.       }
  118.       else if(_global.gameDifficulty == 5)
  119.       {
  120.          this.numGroundSpeed = 0.75;
  121.          this.gameTargets = 400;
  122.          _root.energy._visible = false;
  123.       }
  124.       this.blnHolding = false;
  125.       this.blnLeftSide = true;
  126.       this.keyCounter = 0;
  127.       this.engineTimer = 50;
  128.       this.difficultyPeopleCounter = 0;
  129.       this.difficultyTimer = -1;
  130.       this.refillType = 1;
  131.       this.score = 0;
  132.       this.numRelease = 1;
  133.       this.setIndex = 0;
  134.       this.targetCounter = 0;
  135.       this.modeCounter = -1;
  136.       this.blnMulti = false;
  137.       this.rainbowHold = false;
  138.       this.statCorrect = 0;
  139.       this.statMissed = 0;
  140.       this.statWrong = 0;
  141.       this.statThrown = 0;
  142.       this.statFull = 0;
  143.       this.numEnergyMax = 20;
  144.       this.numEnergy = 10;
  145.       this.backAnimCounter = 500;
  146.       this.backAnimMin = 400;
  147.       this.backAnimMax = 1500;
  148.       this.blnArrows1 = false;
  149.       this.blnArrows2 = false;
  150.       this.multiOrbPointCounter = 9999;
  151.       this.mouseListener = new Object();
  152.       this.mouseListener.onMouseDown = function()
  153.       {
  154.          _root.OrbHold();
  155.       };
  156.       this.mouseListener.onMouseUp = function()
  157.       {
  158.          _root.OrbRelease();
  159.       };
  160.       Mouse.addListener(this.mouseListener);
  161.       this.Setup();
  162.       this.gameMode = 1;
  163.       _global.gamePaused = true;
  164.    }
  165.    function Run()
  166.    {
  167.       if(_global.gameDifficulty == 4)
  168.       {
  169.          if(this.gameMode == 1 || _global.gamePaused == false)
  170.          {
  171.             this.UpdateEnergy();
  172.          }
  173.       }
  174.       if(this.gameMode == 2)
  175.       {
  176.          if(this.modeCounter == 0)
  177.          {
  178.             _root.paused.gotoAndStop(4);
  179.             this.gameMode = 3;
  180.             this.modeCounter = 20;
  181.          }
  182.          else
  183.          {
  184.             this.modeCounter = this.modeCounter - 1;
  185.          }
  186.       }
  187.       else if(this.gameMode == 3)
  188.       {
  189.          if(this.modeCounter == 0)
  190.          {
  191.             _root.paused.gotoAndStop(1);
  192.             this.gameMode = 4;
  193.             this.modeCounter = -1;
  194.             _global.gamePaused = false;
  195.          }
  196.          else
  197.          {
  198.             this.modeCounter = this.modeCounter - 1;
  199.          }
  200.       }
  201.       this.CheckKeyPress();
  202.       if(_global.gamePaused == false)
  203.       {
  204.          this.ManageHolding();
  205.          this.ManageFiredOrbs();
  206.          this.ManageObjects();
  207.          this.ControlDifficultyAndSurroundings();
  208.          this.OrbsFall();
  209.          this.UpdateScore();
  210.          this.UpdateBackAnim();
  211.          this.UpdateMultiOrb();
  212.       }
  213.       this.DoCleanup();
  214.       _global.danceSync = _global.danceSync + 1;
  215.       if(_global.danceSync == 69)
  216.       {
  217.          _global.danceSync = 20;
  218.       }
  219.    }
  220.    function Setup()
  221.    {
  222.       _root.arrow1.stop();
  223.       _root.arrow2.stop();
  224.       _root.arrow3.stop();
  225.       _root.arrow4.stop();
  226.       _root.arrow5.stop();
  227.       _root.startPlayText.stop();
  228.       this.BuildSets();
  229.       this.SelectSet();
  230.       this.AddObject(this.currentSet.GetPiece());
  231.       this.engineTimer = 10;
  232.       this.DropOrb(1);
  233.       this.DropOrb(2);
  234.       this.DropOrb(3);
  235.       this.DropOrb(4);
  236.       this.DropOrb(5);
  237.       this.UpdateScore();
  238.    }
  239.    function BeginGame()
  240.    {
  241.       this.gameMode = 2;
  242.       _root.paused.gotoAndStop(3);
  243.       this.modeCounter = 70;
  244.    }
  245.    function GameOver(blnCompleted)
  246.    {
  247.       _global.gamePaused = true;
  248.       this.gameMode = 5;
  249.       trace(blnCompleted);
  250.       if(_global.gameDifficulty == 4)
  251.       {
  252.          _root.paused.gotoAndStop(6);
  253.          _root.paused.completed_txt.text = "Game Over!";
  254.       }
  255.       else
  256.       {
  257.          _root.paused.gotoAndStop(5);
  258.          if(blnCompleted == false)
  259.          {
  260.             _root.paused.completed_txt.text = "Game Completed!";
  261.          }
  262.          else
  263.          {
  264.             _root.paused.completed_txt.text = "Game Over!";
  265.          }
  266.       }
  267.       _root.paused.total_txt.text = this.targetCounter;
  268.       _root.paused.thrown_txt.text = this.statThrown;
  269.       _root.paused.correct_txt.text = this.statCorrect;
  270.       _root.paused.wrong_txt.text = this.statWrong;
  271.       _root.paused.missed_txt.text = this.statMissed;
  272.       if(this.statThrown == 0)
  273.       {
  274.          _root.paused.accuracy_txt.text = "0%";
  275.       }
  276.       else
  277.       {
  278.          _root.paused.accuracy_txt.text = Math.round(this.statCorrect / this.statThrown * 100) + "%";
  279.       }
  280.       _root.paused.full_txt.text = this.statFull;
  281.       _root.paused.score_txt.text = this.score;
  282.       _global.lastScore = this.score;
  283.    }
  284.    function EndGame()
  285.    {
  286.       _root.paused.removeMovieClip();
  287.       var _loc4_ = 0;
  288.       while(_loc4_ < this.arrOrbsFired.length)
  289.       {
  290.          _root[this.arrOrbsFired[_loc4_].name].removeMovieClip();
  291.          _loc4_ = _loc4_ + 1;
  292.       }
  293.       _loc4_ = 0;
  294.       while(_loc4_ < this.arrOrbs.length)
  295.       {
  296.          _root[this.arrOrbs[_loc4_].name].removeMovieClip();
  297.          _loc4_ = _loc4_ + 1;
  298.       }
  299.       _loc4_ = 0;
  300.       while(_loc4_ < this.arrTargetObjects.length)
  301.       {
  302.          _root[this.arrTargetObjects[_loc4_].name].removeMovieClip();
  303.          _loc4_ = _loc4_ + 1;
  304.       }
  305.       _root.transition2.gotoAndStop(1);
  306.       _root.lines.swapDepths(this.lineDepth);
  307.       _root.popUp.swapDepths(this.popUpDepth);
  308.       _global.gamePaused = false;
  309.       if(_global.gameDifficulty == 4)
  310.       {
  311.          _root.gotoAndPlay("submitScores");
  312.       }
  313.       else
  314.       {
  315.          _root.gotoAndPlay("title");
  316.       }
  317.    }
  318.    function ControlDifficultyAndSurroundings()
  319.    {
  320.       if(_global.gameDifficulty == 1)
  321.       {
  322.          this.ControlEasy();
  323.       }
  324.       else if(_global.gameDifficulty == 2)
  325.       {
  326.          this.ControlMedium();
  327.       }
  328.       else if(_global.gameDifficulty == 3)
  329.       {
  330.          this.ControlHard();
  331.       }
  332.       else if(_global.gameDifficulty == 4)
  333.       {
  334.          this.ControlChallenge();
  335.       }
  336.       else if(_global.gameDifficulty == 5)
  337.       {
  338.          this.ControlInsane();
  339.       }
  340.    }
  341.    function ControlEasy()
  342.    {
  343.       switch(_global.difficulty)
  344.       {
  345.          case 1:
  346.             if(this.difficultyPeopleCounter > 50)
  347.             {
  348.                this.difficultyPeopleCounter = 0;
  349.                _global.difficulty = 2;
  350.                this.AddButton("purple");
  351.             }
  352.             break;
  353.          case 2:
  354.             if(this.difficultyPeopleCounter > 50)
  355.             {
  356.                this.difficultyPeopleCounter = 0;
  357.                _global.difficulty = 3;
  358.             }
  359.       }
  360.    }
  361.    function ControlMedium()
  362.    {
  363.       switch(_global.difficulty)
  364.       {
  365.          case 1:
  366.             if(this.difficultyPeopleCounter > 10)
  367.             {
  368.                this.difficultyPeopleCounter = 0;
  369.                _global.difficulty = 2;
  370.                this.AddButton("purple");
  371.             }
  372.             break;
  373.          case 2:
  374.             if(this.difficultyPeopleCounter > 10)
  375.             {
  376.                this.difficultyPeopleCounter = 0;
  377.                _global.difficulty = 3;
  378.             }
  379.             break;
  380.          case 3:
  381.             if(this.difficultyPeopleCounter > 10)
  382.             {
  383.                this.difficultyPeopleCounter = 0;
  384.                _global.difficulty = 5;
  385.                this.AddButton("blue");
  386.             }
  387.             break;
  388.          case 5:
  389.             if(this.difficultyPeopleCounter > 10)
  390.             {
  391.                this.difficultyPeopleCounter = 0;
  392.                _global.difficulty = 6;
  393.             }
  394.             break;
  395.          case 6:
  396.             if(this.difficultyPeopleCounter > 10)
  397.             {
  398.                this.difficultyPeopleCounter = 0;
  399.                _global.difficulty = 7;
  400.             }
  401.             break;
  402.          case 7:
  403.             if(this.difficultyPeopleCounter > 10)
  404.             {
  405.                this.difficultyPeopleCounter = 0;
  406.                _global.difficulty = 8;
  407.                this.AddButton("green");
  408.             }
  409.             break;
  410.          case 8:
  411.             if(this.difficultyPeopleCounter > 10)
  412.             {
  413.                this.difficultyPeopleCounter = 0;
  414.                _global.difficulty = 9;
  415.             }
  416.             break;
  417.          case 9:
  418.             if(this.difficultyPeopleCounter > 25)
  419.             {
  420.                this.difficultyPeopleCounter = 0;
  421.                _global.difficulty = 10;
  422.             }
  423.             break;
  424.          case 10:
  425.             if(this.difficultyPeopleCounter > 25)
  426.             {
  427.                this.difficultyPeopleCounter = 0;
  428.                _global.difficulty = 11;
  429.             }
  430.       }
  431.    }
  432.    function ControlHard()
  433.    {
  434.       switch(_global.difficulty)
  435.       {
  436.          case 1:
  437.             if(this.difficultyPeopleCounter > 10)
  438.             {
  439.                this.difficultyPeopleCounter = 0;
  440.                _global.difficulty = 2;
  441.                this.AddButton("purple");
  442.             }
  443.             break;
  444.          case 2:
  445.             if(this.difficultyPeopleCounter > 10)
  446.             {
  447.                this.difficultyPeopleCounter = 0;
  448.                _global.difficulty = 3;
  449.             }
  450.             break;
  451.          case 3:
  452.             if(this.difficultyPeopleCounter > 10)
  453.             {
  454.                this.difficultyPeopleCounter = 0;
  455.                _global.difficulty = 5;
  456.                this.AddButton("blue");
  457.             }
  458.             break;
  459.          case 5:
  460.             if(this.difficultyPeopleCounter > 10)
  461.             {
  462.                this.difficultyPeopleCounter = 0;
  463.                _global.difficulty = 6;
  464.             }
  465.             break;
  466.          case 6:
  467.             if(this.difficultyPeopleCounter > 10)
  468.             {
  469.                this.difficultyPeopleCounter = 0;
  470.                _global.difficulty = 7;
  471.             }
  472.             break;
  473.          case 7:
  474.             if(this.difficultyPeopleCounter > 10)
  475.             {
  476.                this.difficultyPeopleCounter = 0;
  477.                _global.difficulty = 8;
  478.                this.AddButton("green");
  479.             }
  480.             break;
  481.          case 8:
  482.             if(this.difficultyPeopleCounter > 10)
  483.             {
  484.                this.difficultyPeopleCounter = 0;
  485.                _global.difficulty = 9;
  486.             }
  487.             break;
  488.          case 9:
  489.             if(this.difficultyPeopleCounter > 10)
  490.             {
  491.                this.difficultyPeopleCounter = 0;
  492.                _global.difficulty = 10;
  493.             }
  494.             break;
  495.          case 10:
  496.             if(this.difficultyPeopleCounter > 15)
  497.             {
  498.                this.difficultyPeopleCounter = 0;
  499.                _global.difficulty = 11;
  500.             }
  501.             break;
  502.          case 11:
  503.             if(this.difficultyPeopleCounter > 30)
  504.             {
  505.                this.difficultyPeopleCounter = 0;
  506.                _global.difficulty = 13;
  507.                this.AddButton("yellow");
  508.             }
  509.             break;
  510.          case 13:
  511.             if(this.difficultyPeopleCounter > 10)
  512.             {
  513.                this.difficultyPeopleCounter = 0;
  514.                _global.difficulty = 14;
  515.             }
  516.             break;
  517.          case 14:
  518.             if(this.difficultyPeopleCounter > 10)
  519.             {
  520.                this.difficultyPeopleCounter = 0;
  521.                _global.difficulty = 15;
  522.             }
  523.             break;
  524.          case 15:
  525.             if(this.difficultyPeopleCounter > 10)
  526.             {
  527.                this.difficultyPeopleCounter = 0;
  528.                _global.difficulty = 16;
  529.             }
  530.             break;
  531.          case 16:
  532.             if(this.difficultyPeopleCounter > 30)
  533.             {
  534.                this.difficultyPeopleCounter = 0;
  535.                _global.difficulty = 17;
  536.                this.AddButton("orange");
  537.             }
  538.             break;
  539.          case 17:
  540.             if(this.difficultyPeopleCounter > 10)
  541.             {
  542.                this.difficultyPeopleCounter = 0;
  543.                _global.difficulty = 18;
  544.             }
  545.             break;
  546.          case 18:
  547.             if(this.difficultyPeopleCounter > 10)
  548.             {
  549.                this.difficultyPeopleCounter = 0;
  550.                _global.difficulty = 19;
  551.             }
  552.             break;
  553.          case 19:
  554.             if(this.difficultyPeopleCounter > 20)
  555.             {
  556.                this.difficultyPeopleCounter = 0;
  557.                _global.difficulty = 20;
  558.             }
  559.             break;
  560.          case 20:
  561.             if(this.difficultyPeopleCounter > 50)
  562.             {
  563.                this.difficultyPeopleCounter = 0;
  564.                _global.difficulty = 21;
  565.             }
  566.       }
  567.    }
  568.    function ControlInsane()
  569.    {
  570.       switch(_global.difficulty)
  571.       {
  572.          case 1:
  573.             if(this.difficultyPeopleCounter > 5)
  574.             {
  575.                this.difficultyPeopleCounter = 0;
  576.                _global.difficulty = 2;
  577.                this.AddButton("purple");
  578.             }
  579.             break;
  580.          case 2:
  581.             if(this.difficultyPeopleCounter > 5)
  582.             {
  583.                this.difficultyPeopleCounter = 0;
  584.                _global.difficulty = 5;
  585.                this.AddButton("blue");
  586.             }
  587.             break;
  588.          case 5:
  589.             if(this.difficultyPeopleCounter > 5)
  590.             {
  591.                this.difficultyPeopleCounter = 0;
  592.                _global.difficulty = 8;
  593.                this.AddButton("green");
  594.             }
  595.             break;
  596.          case 8:
  597.             if(this.difficultyPeopleCounter > 5)
  598.             {
  599.                this.difficultyPeopleCounter = 0;
  600.                _global.difficulty = 13;
  601.                this.AddButton("yellow");
  602.             }
  603.             break;
  604.          case 13:
  605.             if(this.difficultyPeopleCounter > 5)
  606.             {
  607.                this.difficultyPeopleCounter = 0;
  608.                _global.difficulty = 17;
  609.                this.AddButton("orange");
  610.             }
  611.             break;
  612.          case 17:
  613.             if(this.difficultyPeopleCounter > 10)
  614.             {
  615.                this.difficultyPeopleCounter = 0;
  616.                _global.difficulty = 19;
  617.             }
  618.             break;
  619.          case 19:
  620.             if(this.difficultyPeopleCounter > 100)
  621.             {
  622.                this.difficultyPeopleCounter = 0;
  623.                _global.difficulty = 20;
  624.             }
  625.             break;
  626.          case 20:
  627.             if(this.difficultyPeopleCounter > 100)
  628.             {
  629.                this.difficultyPeopleCounter = 0;
  630.                _global.difficulty = 21;
  631.             }
  632.             break;
  633.          case 21:
  634.             if(this.difficultyPeopleCounter > 100)
  635.             {
  636.                this.difficultyPeopleCounter = 0;
  637.                _global.difficulty = 22;
  638.             }
  639.             break;
  640.          case 22:
  641.             if(this.difficultyPeopleCounter > 50)
  642.             {
  643.                this.difficultyPeopleCounter = 0;
  644.                this.numGroundSpeed += 0.05;
  645.             }
  646.       }
  647.    }
  648.    function ControlChallenge()
  649.    {
  650.       switch(_global.difficulty)
  651.       {
  652.          case 1:
  653.             if(this.difficultyPeopleCounter > 10)
  654.             {
  655.                this.difficultyPeopleCounter = 0;
  656.                _global.difficulty = 2;
  657.                this.AddButton("purple");
  658.             }
  659.             break;
  660.          case 2:
  661.             if(this.difficultyPeopleCounter > 10)
  662.             {
  663.                this.difficultyPeopleCounter = 0;
  664.                _global.difficulty = 3;
  665.             }
  666.             break;
  667.          case 3:
  668.             if(this.difficultyPeopleCounter > 20)
  669.             {
  670.                this.difficultyPeopleCounter = 0;
  671.                _global.difficulty = 4;
  672.                this.AddButton("blue");
  673.             }
  674.             break;
  675.          case 4:
  676.             this.numGroundSpeed += 0.05;
  677.             _global.difficulty = 5;
  678.          case 5:
  679.             if(this.difficultyPeopleCounter > 10)
  680.             {
  681.                this.difficultyPeopleCounter = 0;
  682.                _global.difficulty = 6;
  683.             }
  684.             break;
  685.          case 6:
  686.             if(this.difficultyPeopleCounter > 10)
  687.             {
  688.                this.difficultyPeopleCounter = 0;
  689.                _global.difficulty = 7;
  690.             }
  691.             break;
  692.          case 7:
  693.             if(this.difficultyPeopleCounter > 10)
  694.             {
  695.                this.difficultyPeopleCounter = 0;
  696.                _global.difficulty = 8;
  697.                this.AddButton("green");
  698.             }
  699.             break;
  700.          case 8:
  701.             if(this.difficultyPeopleCounter > 10)
  702.             {
  703.                this.difficultyPeopleCounter = 0;
  704.                _global.difficulty = 9;
  705.             }
  706.             break;
  707.          case 9:
  708.             if(this.difficultyPeopleCounter > 10)
  709.             {
  710.                this.difficultyPeopleCounter = 0;
  711.                _global.difficulty = 10;
  712.             }
  713.             break;
  714.          case 10:
  715.             if(this.difficultyPeopleCounter > 10)
  716.             {
  717.                this.difficultyPeopleCounter = 0;
  718.                _global.difficulty = 11;
  719.             }
  720.             break;
  721.          case 11:
  722.             if(this.difficultyPeopleCounter > 10)
  723.             {
  724.                this.difficultyPeopleCounter = 0;
  725.                _global.difficulty = 12;
  726.                this.AddButton("yellow");
  727.             }
  728.             break;
  729.          case 12:
  730.             this.numGroundSpeed += 0.05;
  731.             _global.difficulty = 13;
  732.          case 13:
  733.             if(this.difficultyPeopleCounter > 10)
  734.             {
  735.                this.difficultyPeopleCounter = 0;
  736.                _global.difficulty = 14;
  737.             }
  738.             break;
  739.          case 14:
  740.             if(this.difficultyPeopleCounter > 10)
  741.             {
  742.                this.difficultyPeopleCounter = 0;
  743.                _global.difficulty = 15;
  744.             }
  745.             break;
  746.          case 15:
  747.             if(this.difficultyPeopleCounter > 10)
  748.             {
  749.                this.difficultyPeopleCounter = 0;
  750.                _global.difficulty = 16;
  751.             }
  752.             break;
  753.          case 16:
  754.             if(this.difficultyPeopleCounter > 10)
  755.             {
  756.                this.difficultyPeopleCounter = 0;
  757.                _global.difficulty = 17;
  758.                this.AddButton("orange");
  759.             }
  760.             break;
  761.          case 17:
  762.             if(this.difficultyPeopleCounter > 10)
  763.             {
  764.                this.difficultyPeopleCounter = 0;
  765.                _global.difficulty = 18;
  766.             }
  767.             break;
  768.          case 18:
  769.             if(this.difficultyPeopleCounter > 20)
  770.             {
  771.                this.difficultyPeopleCounter = 0;
  772.                _global.difficulty = 19;
  773.             }
  774.             break;
  775.          case 19:
  776.             if(this.difficultyPeopleCounter > 20)
  777.             {
  778.                this.difficultyPeopleCounter = 0;
  779.                _global.difficulty = 20;
  780.             }
  781.             break;
  782.          case 20:
  783.             if(this.difficultyPeopleCounter > 100)
  784.             {
  785.                this.difficultyPeopleCounter = 0;
  786.                _global.difficulty = 21;
  787.             }
  788.             break;
  789.          case 21:
  790.             if(this.difficultyPeopleCounter > 100)
  791.             {
  792.                this.difficultyPeopleCounter = 0;
  793.                _global.difficulty = 22;
  794.             }
  795.             break;
  796.          case 22:
  797.             if(this.difficultyPeopleCounter > 50)
  798.             {
  799.                this.numGroundSpeed += 0.05;
  800.                this.difficultyPeopleCounter = 0;
  801.                break;
  802.             }
  803.       }
  804.    }
  805.    function BuildSets()
  806.    {
  807.       var _loc2_ = undefined;
  808.       _loc2_ = new Set();
  809.       _loc2_.AddPiece("hill_1",60,60,100);
  810.       _loc2_.AddPiece("hill_2",40,60,100);
  811.       this.arrSets.push(_loc2_);
  812.       _loc2_ = new Set();
  813.       _loc2_.AddPiece("island_1",80,60,100);
  814.       _loc2_.AddPiece("pirate_boat_1",20,60,100);
  815.       this.arrSets.push(_loc2_);
  816.       _loc2_ = new Set();
  817.       _loc2_.AddPiece("egypt_1",40,100,140);
  818.       _loc2_.AddPiece("egypt_2",60,40,80);
  819.       this.arrSets.push(_loc2_);
  820.       _loc2_ = new Set();
  821.       _loc2_.AddPiece("china_1",30,120,140);
  822.       _loc2_.AddPiece("china_2",70,60,100);
  823.       this.arrSets.push(_loc2_);
  824.       _loc2_ = new Set();
  825.       _loc2_.AddPiece("grass_1",100,80,100);
  826.       this.arrSets.push(_loc2_);
  827.       _loc2_ = new Set();
  828.       _loc2_.AddPiece("arctic_1",40,80,100);
  829.       _loc2_.AddPiece("arctic_2",20,80,100);
  830.       _loc2_.AddPiece("arctic_3",20,60,100);
  831.       _loc2_.AddPiece("arctic_4",30,60,100);
  832.       this.arrSets.push(_loc2_);
  833.       _loc2_ = new Set();
  834.       _loc2_.AddPiece("city_1",100,80,100);
  835.       this.arrSets.push(_loc2_);
  836.       _loc2_ = new Set();
  837.       _loc2_.AddPiece("jungle_1",50,80,100);
  838.       _loc2_.AddPiece("jungle_2",50,80,100);
  839.       this.arrSets.push(_loc2_);
  840.       _loc2_ = new Set();
  841.       _loc2_.AddPiece("savannah_1",50,80,100);
  842.       _loc2_.AddPiece("savannah_2",50,80,100);
  843.       this.arrSets.push(_loc2_);
  844.       _loc2_ = new Set();
  845.       _loc2_.AddPiece("western_1",70,80,120);
  846.       _loc2_.AddPiece("western_2",30,80,120);
  847.       this.arrSets.push(_loc2_);
  848.       _loc2_ = new Set();
  849.       _loc2_.AddPiece("india_1",30,100,140);
  850.       _loc2_.AddPiece("india_2",70,80,100);
  851.       this.arrSets.push(_loc2_);
  852.       _loc2_ = new Set();
  853.       _loc2_.AddPiece("japan_1",30,100,120);
  854.       _loc2_.AddPiece("japan_2",45,100,120);
  855.       _loc2_.AddPiece("japan_3",25,120,150);
  856.       this.arrSets.push(_loc2_);
  857.    }
  858.    function SelectSet()
  859.    {
  860.       if(this.arrSets.length > 0)
  861.       {
  862.          var _loc2_ = Math.round(Math.random() * (this.arrSets.length - 1));
  863.          this.currentSet = this.arrSets[_loc2_];
  864.          this.arrSets.splice(_loc2_,1);
  865.       }
  866.       else
  867.       {
  868.          this.BuildSets();
  869.          _loc2_ = Math.round(Math.random() * (this.arrSets.length - 1));
  870.          this.currentSet = this.arrSets[_loc2_];
  871.          this.arrSets.splice(_loc2_,1);
  872.       }
  873.    }
  874.    function ResumeThisGame()
  875.    {
  876.       if(this.gameMode == 4)
  877.       {
  878.          _global.gamePaused = false;
  879.          _root.paused.gotoAndStop(1);
  880.       }
  881.    }
  882.    function CheckKeyPress()
  883.    {
  884.       if(this.keyCounter <= 0)
  885.       {
  886.          if(Key.isDown(39))
  887.          {
  888.             this.keyCounter = 20;
  889.             this.SelectSet();
  890.          }
  891.          else if(Key.isDown(80) || Key.isDown(27))
  892.          {
  893.             if(this.gameMode == 4)
  894.             {
  895.                this.keyCounter = 20;
  896.                if(_global.gamePaused == false)
  897.                {
  898.                   _global.gamePaused = true;
  899.                   _root.paused.gotoAndStop(2);
  900.                   if(_global.gameDifficulty == 1)
  901.                   {
  902.                      _root.paused.through_txt.text = Math.round((200 - this.gameTargets) / 200 * 100) + "% Through Game";
  903.                   }
  904.                   else if(_global.gameDifficulty == 2)
  905.                   {
  906.                      _root.paused.through_txt.text = Math.round((300 - this.gameTargets) / 300 * 100) + "% Through Game";
  907.                   }
  908.                   else if(_global.gameDifficulty == 3 || _global.gameDifficulty == 5)
  909.                   {
  910.                      _root.paused.through_txt.text = Math.round((400 - this.gameTargets) / 400 * 100) + "% Through Game";
  911.                   }
  912.                   else
  913.                   {
  914.                      _root.paused.through_txt.text = "";
  915.                   }
  916.                }
  917.                else
  918.                {
  919.                   _global.gamePaused = false;
  920.                   _root.paused.gotoAndStop(1);
  921.                }
  922.             }
  923.          }
  924.          if(this.gameMode == 4)
  925.          {
  926.             if(Key.isDown(_global.hotKey_red))
  927.             {
  928.                this.ChangeOrbs(1);
  929.             }
  930.             else if(Key.isDown(_global.hotKey_purple))
  931.             {
  932.                if(_global.difficulty >= 2)
  933.                {
  934.                   this.ChangeOrbs(2);
  935.                }
  936.             }
  937.             else if(Key.isDown(_global.hotKey_blue))
  938.             {
  939.                if(_global.difficulty >= 5)
  940.                {
  941.                   this.ChangeOrbs(3);
  942.                }
  943.             }
  944.             else if(Key.isDown(_global.hotKey_green))
  945.             {
  946.                if(_global.difficulty >= 8)
  947.                {
  948.                   this.ChangeOrbs(4);
  949.                }
  950.             }
  951.             else if(Key.isDown(_global.hotKey_yellow))
  952.             {
  953.                if(_global.difficulty >= 13)
  954.                {
  955.                   this.ChangeOrbs(5);
  956.                }
  957.             }
  958.             else if(Key.isDown(_global.hotKey_orange))
  959.             {
  960.                if(_global.difficulty >= 17)
  961.                {
  962.                   this.ChangeOrbs(6);
  963.                }
  964.             }
  965.             else if(Key.isDown(_global.hotKey_multi))
  966.             {
  967.                if(this.blnMulti == true)
  968.                {
  969.                   this.ChangeOrbs(7);
  970.                }
  971.             }
  972.          }
  973.       }
  974.       else
  975.       {
  976.          this.keyCounter = this.keyCounter - 1;
  977.       }
  978.    }
  979.    function UpdateEnergy()
  980.    {
  981.       if(this.gameMode == 4)
  982.       {
  983.          if(this.numEnergy <= 0)
  984.          {
  985.             this.GameOver(true);
  986.          }
  987.       }
  988.       if(this.numEnergy > this.numEnergyMax)
  989.       {
  990.          this.numEnergy = this.numEnergyMax;
  991.       }
  992.       var _loc3_ = Math.round(this.numEnergy / this.numEnergyMax * 100);
  993.       _root.energy.inside._yscale = _loc3_;
  994.       if(_loc3_ <= 25)
  995.       {
  996.          _root.energy.inside.gotoAndStop(2);
  997.       }
  998.       else
  999.       {
  1000.          _root.energy.inside.gotoAndStop(1);
  1001.       }
  1002.    }
  1003.    function DropOrb(orbSlot)
  1004.    {
  1005.       if(this.blnMulti == false && this.refillType == 7)
  1006.       {
  1007.          this.refillType = 1;
  1008.       }
  1009.       var _loc3_ = "Orb_" + this.orbDepth;
  1010.       _root.attachMovie("orb red",_loc3_,this.orbDepth);
  1011.       _root[_loc3_].gotoAndStop(this.refillType);
  1012.       _root[_loc3_]._y = _root.drop1._y;
  1013.       switch(orbSlot)
  1014.       {
  1015.          case 1:
  1016.             _root[_loc3_]._x = _root.drop1._x;
  1017.             break;
  1018.          case 2:
  1019.             _root[_loc3_]._x = _root.drop2._x;
  1020.             break;
  1021.          case 3:
  1022.             _root[_loc3_]._x = _root.drop3._x;
  1023.             break;
  1024.          case 4:
  1025.             _root[_loc3_]._x = _root.drop4._x;
  1026.             break;
  1027.          case 5:
  1028.             _root[_loc3_]._x = _root.drop5._x;
  1029.       }
  1030.       this.arrOrbs.push({name:_loc3_,speed:0.5,hold:false,startX:_root[_loc3_]._x,startY:0,slot:orbSlot,type:this.refillType});
  1031.       this.orbDepth = this.orbDepth + 1;
  1032.       if(this.orbDepth > 6000)
  1033.       {
  1034.          this.orbDepth = 5000;
  1035.       }
  1036.    }
  1037.    function OrbsFall()
  1038.    {
  1039.       var _loc3_ = 0;
  1040.       while(_loc3_ < this.arrOrbs.length)
  1041.       {
  1042.          if(_root[this.arrOrbs[_loc3_].name]._y < _root.land._y && this.arrOrbs[_loc3_].hold == false)
  1043.          {
  1044.             if(_root[this.arrOrbs[_loc3_].name]._y + this.arrOrbs[_loc3_].speed >= _root.land._y)
  1045.             {
  1046.                _root[this.arrOrbs[_loc3_].name]._y = _root.land._y;
  1047.                if(this.blnArrows1 == false)
  1048.                {
  1049.                   this.blnArrows1 = true;
  1050.                   _root.arrow1.play();
  1051.                   _root.arrow2.play();
  1052.                   _root.arrow3.play();
  1053.                   _root.arrow4.play();
  1054.                   _root.arrow5.play();
  1055.                   _root.startPlayText.play();
  1056.                }
  1057.             }
  1058.             else
  1059.             {
  1060.                _root[this.arrOrbs[_loc3_].name]._y += this.arrOrbs[_loc3_].speed;
  1061.                this.arrOrbs[_loc3_].speed += this.orbSpeed;
  1062.             }
  1063.          }
  1064.          _loc3_ = _loc3_ + 1;
  1065.       }
  1066.    }
  1067.    function ManageFiredOrbs()
  1068.    {
  1069.       var _loc11_ = new Array();
  1070.       var _loc12_ = 0;
  1071.       while(_loc12_ < this.arrOrbsFired.length)
  1072.       {
  1073.          _root[this.arrOrbsFired[_loc12_].name]._y += this.arrOrbsFired[_loc12_].moveY;
  1074.          this.arrOrbsFired[_loc12_].moveY += this.orbSpeed;
  1075.          if(this.arrOrbsFired[_loc12_].moveY > this.orbMaxSpeed)
  1076.          {
  1077.             this.arrOrbsFired[_loc12_].moveY = this.orbMaxSpeed;
  1078.          }
  1079.          if(_root[this.arrOrbsFired[_loc12_].name]._y - _root[this.arrOrbsFired[_loc12_].name]._height / 2 > Stage.height)
  1080.          {
  1081.             _loc11_.push(this.arrOrbsFired[_loc12_].name);
  1082.          }
  1083.          _root[this.arrOrbsFired[_loc12_].name]._x += this.arrOrbsFired[_loc12_].moveX;
  1084.          if(this.arrOrbsFired[_loc12_].moveX < 0)
  1085.          {
  1086.             this.arrOrbsFired[_loc12_].moveX += this.windResistance;
  1087.             if(this.arrOrbsFired[_loc12_].moveX > 0.1)
  1088.             {
  1089.                this.arrOrbsFired[_loc12_].moveX = 0;
  1090.             }
  1091.          }
  1092.          else if(this.arrOrbsFired[_loc12_].moveX > 0)
  1093.          {
  1094.             this.arrOrbsFired[_loc12_].moveX -= this.windResistance;
  1095.             if(this.arrOrbsFired[_loc12_].moveX < 0.1)
  1096.             {
  1097.                this.arrOrbsFired[_loc12_].moveX = 0;
  1098.             }
  1099.          }
  1100.          if(_global.trailOn == true)
  1101.          {
  1102.             var _loc9_ = "effect" + this.effectDepth;
  1103.             if(this.arrOrbsFired[_loc12_].type == 1)
  1104.             {
  1105.                _root.attachMovie("redEffect",_loc9_,this.effectDepth);
  1106.             }
  1107.             else if(this.arrOrbsFired[_loc12_].type == 2)
  1108.             {
  1109.                _root.attachMovie("purpleEffect",_loc9_,this.effectDepth);
  1110.             }
  1111.             else if(this.arrOrbsFired[_loc12_].type == 3)
  1112.             {
  1113.                _root.attachMovie("blueEffect",_loc9_,this.effectDepth);
  1114.             }
  1115.             else if(this.arrOrbsFired[_loc12_].type == 4)
  1116.             {
  1117.                _root.attachMovie("greenEffect",_loc9_,this.effectDepth);
  1118.             }
  1119.             else if(this.arrOrbsFired[_loc12_].type == 5)
  1120.             {
  1121.                _root.attachMovie("yellowEffect",_loc9_,this.effectDepth);
  1122.             }
  1123.             else if(this.arrOrbsFired[_loc12_].type == 6)
  1124.             {
  1125.                _root.attachMovie("orangeEffect",_loc9_,this.effectDepth);
  1126.             }
  1127.             else if(this.arrOrbsFired[_loc12_].type == 7)
  1128.             {
  1129.                _root.attachMovie("multiEffect",_loc9_,this.effectDepth);
  1130.             }
  1131.             _root[_loc9_]._x = _root[this.arrOrbsFired[_loc12_].name]._x;
  1132.             _root[_loc9_]._y = _root[this.arrOrbsFired[_loc12_].name]._y;
  1133.             this.effectDepth = this.effectDepth + 1;
  1134.             if(this.effectDepth > 11000)
  1135.             {
  1136.                this.effectDepth = 10000;
  1137.             }
  1138.          }
  1139.          _loc12_ = _loc12_ + 1;
  1140.       }
  1141.       var _loc8_ = undefined;
  1142.       _loc12_ = 0;
  1143.       while(_loc12_ < this.arrOrbsFired.length)
  1144.       {
  1145.          var _loc7_ = 0;
  1146.          while(_loc7_ < this.arrTargetObjects.length)
  1147.          {
  1148.             if(this.arrTargetObjects[_loc7_].down == true)
  1149.             {
  1150.                if(_root[this.arrOrbsFired[_loc12_].name].hitTest(_root[this.arrTargetObjects[_loc7_].name]))
  1151.                {
  1152.                   _loc8_ = _root[this.arrTargetObjects[_loc7_].name].CheckHits(this.arrOrbsFired[_loc12_].name,this.arrOrbsFired[_loc12_].type);
  1153.                   if(_loc8_._hit == true)
  1154.                   {
  1155.                      _loc11_.push(this.arrOrbsFired[_loc12_].name);
  1156.                      this.difficultyPeopleCounter = this.difficultyPeopleCounter + 1;
  1157.                      if(_loc8_._correctColor == true)
  1158.                      {
  1159.                         var _loc4_ = 0;
  1160.                         this.statCorrect = this.statCorrect + 1;
  1161.                         this.popUpCounter = this.popUpCounter + 1;
  1162.                         if(this.popUpCounter >= 10 && this.arrPopUpFlags[0] == false)
  1163.                         {
  1164.                            this.arrPopUpFlags[0] = true;
  1165.                            _root.popUp.gotoAndPlay(2);
  1166.                            _loc4_ = 100;
  1167.                         }
  1168.                         else if(this.popUpCounter >= 25 && this.arrPopUpFlags[1] == false)
  1169.                         {
  1170.                            this.arrPopUpFlags[1] = true;
  1171.                            _root.popUp.gotoAndPlay(3);
  1172.                            _loc4_ = 250;
  1173.                         }
  1174.                         else if(this.popUpCounter >= 50 && this.arrPopUpFlags[2] == false)
  1175.                         {
  1176.                            this.arrPopUpFlags[2] = true;
  1177.                            _root.popUp.gotoAndPlay(4);
  1178.                            _loc4_ = 500;
  1179.                         }
  1180.                         else if(this.popUpCounter >= 75 && this.arrPopUpFlags[3] == false)
  1181.                         {
  1182.                            this.arrPopUpFlags[3] = true;
  1183.                            _root.popUp.gotoAndPlay(5);
  1184.                            _loc4_ = 750;
  1185.                         }
  1186.                         else if(this.popUpCounter >= 100 && this.arrPopUpFlags[4] == false)
  1187.                         {
  1188.                            this.arrPopUpFlags[4] = true;
  1189.                            _root.popUp.gotoAndPlay(6);
  1190.                            _loc4_ = 1000;
  1191.                         }
  1192.                         else if(this.popUpCounter >= 150 && this.arrPopUpFlags[5] == false)
  1193.                         {
  1194.                            this.arrPopUpFlags[5] = true;
  1195.                            _root.popUp.gotoAndPlay(7);
  1196.                            _loc4_ = 1500;
  1197.                         }
  1198.                         else if(this.popUpCounter >= 200 && this.arrPopUpFlags[6] == false)
  1199.                         {
  1200.                            this.arrPopUpFlags[6] = true;
  1201.                            _root.popUp.gotoAndPlay(8);
  1202.                            _loc4_ = 2000;
  1203.                         }
  1204.                         this.score = _loc4_ + this.score;
  1205.                         if(this.multiOrbPointCounter != 9999)
  1206.                         {
  1207.                            this.multiOrbPointCounter -= _loc4_;
  1208.                         }
  1209.                         _loc4_ = 0;
  1210.                         var _loc10_ = Math.round(Math.random() * 100);
  1211.                         if(_loc10_ < 90)
  1212.                         {
  1213.                            _global.SoundManager.PlayHitSound("hit");
  1214.                         }
  1215.                         else
  1216.                         {
  1217.                            _loc10_ = Math.round(Math.random() * 7) + 1;
  1218.                            switch(_loc10_)
  1219.                            {
  1220.                               case 1:
  1221.                                  _global.SoundManager.PlayVoiceSound("funny1");
  1222.                                  break;
  1223.                               case 2:
  1224.                                  _global.SoundManager.PlayVoiceSound("funny2");
  1225.                                  break;
  1226.                               case 3:
  1227.                                  _global.SoundManager.PlayVoiceSound("funny3");
  1228.                                  break;
  1229.                               case 4:
  1230.                                  _global.SoundManager.PlayVoiceSound("funny4");
  1231.                                  break;
  1232.                               case 5:
  1233.                                  _global.SoundManager.PlayVoiceSound("funny5");
  1234.                                  break;
  1235.                               case 6:
  1236.                                  _global.SoundManager.PlayVoiceSound("funny6");
  1237.                                  break;
  1238.                               case 7:
  1239.                                  _global.SoundManager.PlayVoiceSound("funny7");
  1240.                                  break;
  1241.                               case 8:
  1242.                                  _global.SoundManager.PlayVoiceSound("funny8");
  1243.                            }
  1244.                         }
  1245.                         var _loc6_ = 0;
  1246.                         while(_loc6_ < this.arrRelease.length)
  1247.                         {
  1248.                            if(this.arrRelease[_loc6_].id == this.arrOrbsFired[_loc12_].id)
  1249.                            {
  1250.                               this.arrRelease[_loc6_].count = this.arrRelease[_loc6_].count + 1;
  1251.                               _loc4_ = 10 * this.arrRelease[_loc6_].count;
  1252.                               break;
  1253.                            }
  1254.                            _loc6_ = _loc6_ + 1;
  1255.                         }
  1256.                         if(this.arrOrbsFired[_loc12_].type == 7)
  1257.                         {
  1258.                            if(this.rainbowHold == false)
  1259.                            {
  1260.                               _root.rainbow.gotoAndPlay(2);
  1261.                               this.rainbowHold = true;
  1262.                            }
  1263.                         }
  1264.                         this.score = _loc4_ + this.score;
  1265.                         this.AddPointMarker(_loc4_,_loc8_._x,_loc8_._y,false);
  1266.                         if(this.multiOrbPointCounter != 9999)
  1267.                         {
  1268.                            this.multiOrbPointCounter -= _loc4_;
  1269.                         }
  1270.                         if(_loc8_._allCorrect == true)
  1271.                         {
  1272.                            _loc4_ = 50 * _loc8_._numTargets;
  1273.                            this.score = _loc4_ + this.score;
  1274.                            this.numEnergy = this.numEnergy + 1;
  1275.                            if(this.multiOrbPointCounter != 9999)
  1276.                            {
  1277.                               this.multiOrbPointCounter -= _loc4_;
  1278.                            }
  1279.                            var _loc5_ = new Object();
  1280.                            _loc5_.x = _root[this.arrTargetObjects[_loc7_].name].score._x;
  1281.                            _loc5_.y = _root[this.arrTargetObjects[_loc7_].name].score._y;
  1282.                            _root[this.arrTargetObjects[_loc7_].name].localToGlobal(_loc5_);
  1283.                            if(_loc5_.x - 20 < 0)
  1284.                            {
  1285.                               _loc5_.x = 30;
  1286.                            }
  1287.                            if(_loc5_.x + 20 > Stage.width)
  1288.                            {
  1289.                               _loc5_.x = Stage.width - 30;
  1290.                            }
  1291.                            this.AddPointMarker(_loc4_,_loc5_.x,_loc5_.y,true);
  1292.                            this.statFull = this.statFull + 1;
  1293.                         }
  1294.                      }
  1295.                      else
  1296.                      {
  1297.                         this.statWrong = this.statWrong + 1;
  1298.                         this.numEnergy -= 2;
  1299.                         this.popUpCounter = 0;
  1300.                         this.arrPopUpFlags[0] = false;
  1301.                         this.arrPopUpFlags[1] = false;
  1302.                         this.arrPopUpFlags[2] = false;
  1303.                         this.arrPopUpFlags[3] = false;
  1304.                         this.arrPopUpFlags[4] = false;
  1305.                         this.arrPopUpFlags[5] = false;
  1306.                         this.arrPopUpFlags[6] = false;
  1307.                      }
  1308.                      break;
  1309.                   }
  1310.                }
  1311.             }
  1312.             _loc7_ = _loc7_ + 1;
  1313.          }
  1314.          _loc12_ = _loc12_ + 1;
  1315.       }
  1316.       _loc12_ = 0;
  1317.       while(_loc12_ < _loc11_.length)
  1318.       {
  1319.          this.CleanupFiredOrb(_loc11_[_loc12_]);
  1320.          _loc12_ = _loc12_ + 1;
  1321.       }
  1322.    }
  1323.    function CleanupFiredOrb(strName)
  1324.    {
  1325.       var _loc3_ = 0;
  1326.       while(_loc3_ < this.arrOrbsFired.length)
  1327.       {
  1328.          if(strName == this.arrOrbsFired[_loc3_].name)
  1329.          {
  1330.             _root[this.arrOrbsFired[_loc3_].name].removeMovieClip();
  1331.             this.arrOrbsFired.splice(_loc3_,1);
  1332.             break;
  1333.          }
  1334.          _loc3_ = _loc3_ + 1;
  1335.       }
  1336.    }
  1337.    function HoldOrbs()
  1338.    {
  1339.       var _loc3_ = 0;
  1340.       while(_loc3_ < this.arrOrbs.length)
  1341.       {
  1342.          if(_root[this.arrOrbs[_loc3_].name].hitTest(_xmouse,_ymouse,true))
  1343.          {
  1344.             this.blnHolding = true;
  1345.             this.arrOrbs[_loc3_].hold = true;
  1346.             this.arrOrbs[_loc3_].startY = _root[this.arrOrbs[_loc3_].name]._y;
  1347.          }
  1348.          _loc3_ = _loc3_ + 1;
  1349.       }
  1350.    }
  1351.    function ChangeOrbs(numType)
  1352.    {
  1353.       var _loc3_ = 0;
  1354.       while(_loc3_ < this.arrOrbs.length)
  1355.       {
  1356.          _root[this.arrOrbs[_loc3_].name].gotoAndStop(numType);
  1357.          this.arrOrbs[_loc3_].type = numType;
  1358.          _loc3_ = _loc3_ + 1;
  1359.       }
  1360.       this.refillType = numType;
  1361.    }
  1362.    function ChangeHeldOrbs(numType)
  1363.    {
  1364.       var _loc3_ = 0;
  1365.       while(_loc3_ < this.arrOrbs.length)
  1366.       {
  1367.          if(this.arrOrbs[_loc3_].hold == true)
  1368.          {
  1369.             _root[this.arrOrbs[_loc3_].name].gotoAndStop(numType);
  1370.             this.arrOrbs[_loc3_].type = numType;
  1371.          }
  1372.          _loc3_ = _loc3_ + 1;
  1373.       }
  1374.    }
  1375.    function ReleaseOrbs()
  1376.    {
  1377.       if(_global.lockHold == false)
  1378.       {
  1379.          _global.lockRelease = true;
  1380.          this.blnHolding = false;
  1381.          _root.lines.clear();
  1382.          var _loc5_ = new Array();
  1383.          var _loc4_ = 0;
  1384.          while(_loc4_ < this.arrOrbs.length)
  1385.          {
  1386.             if(this.arrOrbs[_loc4_].hold == true)
  1387.             {
  1388.                _loc5_.push(this.arrOrbs[_loc4_].name);
  1389.             }
  1390.             _loc4_ = _loc4_ + 1;
  1391.          }
  1392.          this.arrRelease.push({id:this.numRelease,count:0});
  1393.          _loc4_ = 0;
  1394.          while(_loc4_ < _loc5_.length)
  1395.          {
  1396.             this.FireOrb(_loc5_[_loc4_],this.numRelease);
  1397.             _loc4_ = _loc4_ + 1;
  1398.          }
  1399.          if(this.numRelease > 2)
  1400.          {
  1401.             this.arrRelease.shift();
  1402.          }
  1403.          this.numRelease = this.numRelease + 1;
  1404.          _global.lockRelease = false;
  1405.       }
  1406.    }
  1407.    function FireOrb(strName, releaseNum)
  1408.    {
  1409.       var _loc4_ = 0;
  1410.       while(_loc4_ < this.arrOrbs.length)
  1411.       {
  1412.          if(strName == this.arrOrbs[_loc4_].name)
  1413.          {
  1414.             var _loc8_ = this.arrOrbs[_loc4_].startX - _root[this.arrOrbs[_loc4_].name]._x;
  1415.             var _loc7_ = this.arrOrbs[_loc4_].startY - _root[this.arrOrbs[_loc4_].name]._y;
  1416.             var _loc6_ = Math.sqrt(_loc8_ * _loc8_ + _loc7_ * _loc7_);
  1417.             var _loc5_ = _loc6_ / 200;
  1418.             if(_loc5_ > 1)
  1419.             {
  1420.                _loc5_ = 1;
  1421.             }
  1422.             _loc5_ = Math.round(_loc5_ * 12);
  1423.             var _loc10_ = 0;
  1424.             var _loc9_ = 0;
  1425.             if(_loc6_ != 0)
  1426.             {
  1427.                _loc10_ = _loc8_ / _loc6_ * _loc5_;
  1428.                _loc9_ = _loc7_ / _loc6_ * _loc5_;
  1429.             }
  1430.             this.arrOrbsFired.push({name:strName,moveX:_loc10_,moveY:_loc9_,type:this.arrOrbs[_loc4_].type,id:releaseNum});
  1431.             if(this.arrOrbs[_loc4_].type == 7)
  1432.             {
  1433.                if(this.blnMulti == true)
  1434.                {
  1435.                   if(_global.gameDifficulty == 1)
  1436.                   {
  1437.                      this.blnMulti = false;
  1438.                      this.AddButton("easyMultiGone");
  1439.                   }
  1440.                   else if(_global.gameDifficulty == 2)
  1441.                   {
  1442.                      this.blnMulti = false;
  1443.                      this.AddButton("medMultiGone");
  1444.                   }
  1445.                   else if(_global.gameDifficulty == 3)
  1446.                   {
  1447.                      this.blnMulti = false;
  1448.                      this.AddButton("multiGone");
  1449.                   }
  1450.                   else if(_global.gameDifficulty == 4)
  1451.                   {
  1452.                      this.blnMulti = false;
  1453.                      this.AddButton("multiGone");
  1454.                   }
  1455.                   else if(_global.gameDifficulty == 5)
  1456.                   {
  1457.                      this.blnMulti = false;
  1458.                      this.AddButton("multiGone");
  1459.                   }
  1460.                }
  1461.             }
  1462.             this.DropOrb(this.arrOrbs[_loc4_].slot);
  1463.             this.arrOrbs.splice(_loc4_,1);
  1464.             this.statThrown = this.statThrown + 1;
  1465.             break;
  1466.          }
  1467.          _loc4_ = _loc4_ + 1;
  1468.       }
  1469.    }
  1470.    function ManageHolding()
  1471.    {
  1472.       if(_global.lockRelease == false)
  1473.       {
  1474.          _global.lockHold = true;
  1475.          if(this.blnHolding == true)
  1476.          {
  1477.             var _loc4_ = 0;
  1478.             while(_loc4_ < this.arrOrbs.length)
  1479.             {
  1480.                if(this.arrOrbs[_loc4_].hold == false)
  1481.                {
  1482.                   if(_root[this.arrOrbs[_loc4_].name].hitTest(_xmouse,_ymouse,true))
  1483.                   {
  1484.                      this.arrOrbs[_loc4_].hold = true;
  1485.                      this.arrOrbs[_loc4_].startY = _root[this.arrOrbs[_loc4_].name]._y;
  1486.                   }
  1487.                }
  1488.                else
  1489.                {
  1490.                   _root[this.arrOrbs[_loc4_].name]._x = _xmouse;
  1491.                   if(_ymouse < _root.farthest._y)
  1492.                   {
  1493.                      _root[this.arrOrbs[_loc4_].name]._y = _ymouse;
  1494.                   }
  1495.                   else
  1496.                   {
  1497.                      _root[this.arrOrbs[_loc4_].name]._y = _root.farthest._y;
  1498.                   }
  1499.                }
  1500.                _loc4_ = _loc4_ + 1;
  1501.             }
  1502.             var _loc5_ = new Object();
  1503.             _loc5_.x = _xmouse;
  1504.             _loc5_.y = _ymouse;
  1505.             var _loc6_ = undefined;
  1506.             if(_global.difficulty >= 2)
  1507.             {
  1508.                if(_root.select.cover1.hitTest(_loc5_.x,_loc5_.y,true))
  1509.                {
  1510.                   this.ChangeHeldOrbs(1);
  1511.                }
  1512.                else if(_root.select.cover2.hitTest(_loc5_.x,_loc5_.y,true))
  1513.                {
  1514.                   this.ChangeHeldOrbs(2);
  1515.                }
  1516.             }
  1517.             if(_global.difficulty >= 5)
  1518.             {
  1519.                if(_root.select.cover3.hitTest(_loc5_.x,_loc5_.y,true))
  1520.                {
  1521.                   this.ChangeHeldOrbs(3);
  1522.                }
  1523.             }
  1524.             if(_global.difficulty >= 8)
  1525.             {
  1526.                if(_root.select.cover4.hitTest(_loc5_.x,_loc5_.y,true))
  1527.                {
  1528.                   this.ChangeHeldOrbs(4);
  1529.                }
  1530.             }
  1531.             if(_global.difficulty >= 13)
  1532.             {
  1533.                if(_root.select.cover5.hitTest(_loc5_.x,_loc5_.y,true))
  1534.                {
  1535.                   this.ChangeHeldOrbs(5);
  1536.                }
  1537.             }
  1538.             if(_global.difficulty >= 17)
  1539.             {
  1540.                if(_root.select.cover6.hitTest(_loc5_.x,_loc5_.y,true))
  1541.                {
  1542.                   this.ChangeHeldOrbs(6);
  1543.                }
  1544.             }
  1545.             if(this.blnMulti == true)
  1546.             {
  1547.                if(_root.select.cover7.hitTest(_loc5_.x,_loc5_.y,true))
  1548.                {
  1549.                   this.ChangeHeldOrbs(7);
  1550.                }
  1551.             }
  1552.             this.DrawLines();
  1553.          }
  1554.          _global.lockHold = false;
  1555.       }
  1556.    }
  1557.    function CheckChangeType(numType)
  1558.    {
  1559.       if(this.blnHolding == true)
  1560.       {
  1561.          this.ChangeOrbs(numType);
  1562.       }
  1563.    }
  1564.    function DrawLines()
  1565.    {
  1566.       _root.lines.clear();
  1567.       _root.lines.lineStyle(1,0,50);
  1568.       var _loc4_ = new Object();
  1569.       var _loc5_ = new Object();
  1570.       var _loc3_ = 0;
  1571.       while(_loc3_ < this.arrOrbs.length)
  1572.       {
  1573.          if(this.arrOrbs[_loc3_].hold == true)
  1574.          {
  1575.             _loc4_.x = this.arrOrbs[_loc3_].startX;
  1576.             _loc4_.y = this.arrOrbs[_loc3_].startY;
  1577.             _loc5_.x = _root[this.arrOrbs[_loc3_].name]._x;
  1578.             _loc5_.y = _root[this.arrOrbs[_loc3_].name]._y;
  1579.             _root.lines.globalToLocal(_loc4_);
  1580.             _root.lines.globalToLocal(_loc5_);
  1581.             _root.lines.moveTo(_loc4_.x,_loc4_.y);
  1582.             _root.lines.lineTo(_loc5_.x,_loc5_.y);
  1583.          }
  1584.          _loc3_ = _loc3_ + 1;
  1585.       }
  1586.    }
  1587.    function AddObject(linkID)
  1588.    {
  1589.       var _loc3_ = "obj" + this.objectDepth;
  1590.       _root.attachMovie(linkID,_loc3_,this.objectDepth);
  1591.       this.arrTargetObjects.push({name:_loc3_,down:false});
  1592.       if(this.blnLeftSide == true)
  1593.       {
  1594.          var _loc5_ = Math.round(Math.random() * 100) - 100;
  1595.          this.blnLeftSide = false;
  1596.       }
  1597.       else
  1598.       {
  1599.          _loc5_ = Math.round(Math.random() * 200) + 100;
  1600.          this.blnLeftSide = true;
  1601.       }
  1602.       _root[_loc3_]._x = _loc5_;
  1603.       _root[_loc3_]._y = Stage.height + _root[_loc3_]._height;
  1604.       var _loc4_ = _root[_loc3_].AdjustTargets();
  1605.       this.targetCounter += _loc4_;
  1606.       this.gameTargets -= _loc4_;
  1607.       if(this.setIndex != this.arrSetCounter.length)
  1608.       {
  1609.          if(this.targetCounter >= this.arrSetCounter[this.setIndex])
  1610.          {
  1611.             this.setIndex = this.setIndex + 1;
  1612.             var _loc7_ = this.currentSet.GetMinNext();
  1613.             var _loc6_ = this.currentSet.GetMaxNext();
  1614.             this.SelectSet();
  1615.             this.currentSet.SetMinMax(_loc7_,_loc6_);
  1616.          }
  1617.       }
  1618.       this.objectDepth = this.objectDepth - 1;
  1619.       if(this.objectDepth < 1000)
  1620.       {
  1621.          this.objectDepth = 4000;
  1622.       }
  1623.    }
  1624.    function ManageObjects()
  1625.    {
  1626.       var _loc6_ = new Array();
  1627.       var _loc4_ = 0;
  1628.       while(_loc4_ < this.arrTargetObjects.length)
  1629.       {
  1630.          if(this.arrTargetObjects[_loc4_].down == true)
  1631.          {
  1632.             _root[this.arrTargetObjects[_loc4_].name]._y += this.numGroundSpeed;
  1633.             if(_root[this.arrTargetObjects[_loc4_].name]._y - _root[this.arrTargetObjects[_loc4_].name]._height > Stage.height)
  1634.             {
  1635.                _loc6_.push(this.arrTargetObjects[_loc4_].name);
  1636.                this.statMissed += _root[this.arrTargetObjects[_loc4_].name].GetTargetsLeft();
  1637.                this.numEnergy -= Math.round(_root[this.arrTargetObjects[_loc4_].name].GetTargetsLeft() * 1.5);
  1638.             }
  1639.          }
  1640.          else
  1641.          {
  1642.             var _loc5_ = 0.15 * (_root[this.arrTargetObjects[_loc4_].name]._y - _root.start._y);
  1643.             if(_loc5_ <= 1)
  1644.             {
  1645.                _root[this.arrTargetObjects[_loc4_].name]._y = _root.start._y;
  1646.                this.arrTargetObjects[_loc4_].down = true;
  1647.             }
  1648.             else
  1649.             {
  1650.                _root[this.arrTargetObjects[_loc4_].name]._y -= _loc5_;
  1651.             }
  1652.          }
  1653.          _loc4_ = _loc4_ + 1;
  1654.       }
  1655.       _loc4_ = 0;
  1656.       while(_loc4_ < _loc6_.length)
  1657.       {
  1658.          this.RemoveObjects(_loc6_[_loc4_]);
  1659.          _loc4_ = _loc4_ + 1;
  1660.       }
  1661.       if(this.gameTargets > 0 || _global.gameDifficulty == 4)
  1662.       {
  1663.          this.engineTimer -= this.numGroundSpeed;
  1664.          if(this.engineTimer <= 0)
  1665.          {
  1666.             this.AddObject(this.currentSet.GetPiece());
  1667.             this.engineTimer = Math.round(Math.random() * (this.currentSet.GetMaxNext() - this.currentSet.GetMinNext())) + this.currentSet.GetMinNext();
  1668.          }
  1669.       }
  1670.       else if(this.arrTargetObjects.length == 0)
  1671.       {
  1672.          this.GameOver(false);
  1673.       }
  1674.    }
  1675.    function RemoveObjects(strName)
  1676.    {
  1677.       var _loc3_ = 0;
  1678.       while(_loc3_ < this.arrTargetObjects.length)
  1679.       {
  1680.          if(strName == this.arrTargetObjects[_loc3_].name)
  1681.          {
  1682.             _root[this.arrTargetObjects[_loc3_].name].removeMovieClip();
  1683.             this.arrTargetObjects.splice(_loc3_,1);
  1684.             break;
  1685.          }
  1686.          _loc3_ = _loc3_ + 1;
  1687.       }
  1688.    }
  1689.    function AddButton(strName)
  1690.    {
  1691.       _root.select.gotoAndPlay(strName);
  1692.    }
  1693.    function UpdateScore()
  1694.    {
  1695.       _root.score_txt.text = this.score;
  1696.    }
  1697.    function AddToCleanup(myName)
  1698.    {
  1699.       this.arrCleanup.push({name:myName,counter:40});
  1700.    }
  1701.    function DoCleanup()
  1702.    {
  1703.       var _loc4_ = new Array();
  1704.       var _loc3_ = 0;
  1705.       while(_loc3_ < this.arrCleanup.length)
  1706.       {
  1707.          this.arrCleanup[_loc3_].counter--;
  1708.          if(this.arrCleanup[_loc3_].counter == 0)
  1709.          {
  1710.             _loc4_.push(this.arrCleanup[_loc3_].name);
  1711.          }
  1712.          _loc3_ = _loc3_ + 1;
  1713.       }
  1714.       _loc3_ = 0;
  1715.       while(_loc3_ < _loc4_.length)
  1716.       {
  1717.          _root[_loc4_[_loc3_]].removeMovieClip();
  1718.          this.RemoveCleanupItem(_loc4_[_loc3_]);
  1719.          _loc3_ = _loc3_ + 1;
  1720.       }
  1721.    }
  1722.    function RemoveCleanupItem(strName)
  1723.    {
  1724.       var _loc2_ = 0;
  1725.       while(_loc2_ < this.arrCleanup.length)
  1726.       {
  1727.          if(strName == this.arrCleanup[_loc2_].name)
  1728.          {
  1729.             this.arrCleanup.splice(_loc2_,1);
  1730.             break;
  1731.          }
  1732.          _loc2_ = _loc2_ + 1;
  1733.       }
  1734.    }
  1735.    function AddPointMarker(points, xLoc, yLoc, blnObject)
  1736.    {
  1737.       var _loc3_ = "points" + this.pointDepth;
  1738.       _root.attachMovie("points",_loc3_,this.pointDepth);
  1739.       _root[_loc3_]._y = yLoc - 20;
  1740.       _root[_loc3_]._x = xLoc;
  1741.       var _loc4_ = undefined;
  1742.       if(blnObject == false)
  1743.       {
  1744.          _loc4_ = points / 10;
  1745.       }
  1746.       else
  1747.       {
  1748.          _loc4_ = points / 50 + 5;
  1749.       }
  1750.       _root[_loc3_].inside.gotoAndStop(_loc4_);
  1751.       this.AddToCleanup(_loc3_);
  1752.       this.pointDepth = this.pointDepth + 1;
  1753.       if(this.pointDepth > 9050)
  1754.       {
  1755.          this.pointDepth = 9000;
  1756.       }
  1757.    }
  1758.    function OverAnim()
  1759.    {
  1760.       this.rainbowHold = false;
  1761.    }
  1762.    function UpdateBackAnim()
  1763.    {
  1764.       if(this.backAnimCounter <= 0)
  1765.       {
  1766.          var _loc3_ = Math.round(Math.random() * 5) + 2;
  1767.          var _loc4_ = Math.round(Math.random() * (this.backAnimMax - this.backAnimMin)) + this.backAnimMin;
  1768.          trace("Playing: " + _loc3_ + "   Next: " + _loc4_);
  1769.          _root.backanim.gotoAndPlay(_loc3_);
  1770.          this.backAnimCounter = _loc4_;
  1771.       }
  1772.       else
  1773.       {
  1774.          this.backAnimCounter = this.backAnimCounter - 1;
  1775.       }
  1776.    }
  1777.    function UpdateMultiOrb()
  1778.    {
  1779.       if(this.multiOrbPointCounter <= 0)
  1780.       {
  1781.          if(_global.gameDifficulty == 1)
  1782.          {
  1783.             if(_global.difficulty >= 2 && this.blnMulti == false)
  1784.             {
  1785.                this.blnMulti = true;
  1786.                this.AddButton("easyMulti");
  1787.                this.multiOrbPointCounter = 4000;
  1788.             }
  1789.          }
  1790.          else if(_global.gameDifficulty == 2)
  1791.          {
  1792.             if(_global.difficulty >= 8 && this.blnMulti == false)
  1793.             {
  1794.                this.blnMulti = true;
  1795.                this.AddButton("medMulti");
  1796.                this.multiOrbPointCounter = 4000;
  1797.             }
  1798.          }
  1799.          else if(_global.gameDifficulty == 3)
  1800.          {
  1801.             if(_global.difficulty >= 17 && this.blnMulti == false)
  1802.             {
  1803.                this.blnMulti = true;
  1804.                this.AddButton("multi");
  1805.                this.multiOrbPointCounter = 4000;
  1806.             }
  1807.          }
  1808.          else if(_global.gameDifficulty == 4)
  1809.          {
  1810.             if(_global.difficulty >= 17 && this.blnMulti == false)
  1811.             {
  1812.                this.blnMulti = true;
  1813.                this.AddButton("multi");
  1814.                this.multiOrbPointCounter = 4000;
  1815.             }
  1816.          }
  1817.          else if(_global.gameDifficulty == 5)
  1818.          {
  1819.             if(_global.difficulty >= 17 && this.blnMulti == false)
  1820.             {
  1821.                this.blnMulti = true;
  1822.                this.AddButton("multi");
  1823.                this.multiOrbPointCounter = 4000;
  1824.             }
  1825.          }
  1826.          this.multiOrbPointCounter = 4000;
  1827.       }
  1828.       else if(this.multiOrbPointCounter == 9999)
  1829.       {
  1830.          if(_global.gameDifficulty == 1)
  1831.          {
  1832.             if(_global.difficulty >= 2)
  1833.             {
  1834.                this.multiOrbPointCounter = 1000;
  1835.             }
  1836.          }
  1837.          else if(_global.gameDifficulty == 2)
  1838.          {
  1839.             if(_global.difficulty >= 8)
  1840.             {
  1841.                this.multiOrbPointCounter = 1000;
  1842.             }
  1843.          }
  1844.          else if(_global.gameDifficulty == 3)
  1845.          {
  1846.             if(_global.difficulty >= 17)
  1847.             {
  1848.                this.multiOrbPointCounter = 1000;
  1849.             }
  1850.          }
  1851.          else if(_global.gameDifficulty == 4)
  1852.          {
  1853.             if(_global.difficulty >= 17)
  1854.             {
  1855.                this.multiOrbPointCounter = 1000;
  1856.             }
  1857.          }
  1858.          else if(_global.gameDifficulty == 5)
  1859.          {
  1860.             if(_global.difficulty >= 17)
  1861.             {
  1862.                this.multiOrbPointCounter = 1000;
  1863.             }
  1864.          }
  1865.       }
  1866.    }
  1867. }
  1868.