Advertisement
Guest User

Untitled

a guest
Dec 11th, 2012
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package
  2. {
  3.  
  4.     import flash.net.SharedObject;
  5.     import flash.display.MovieClip;
  6.     import flash.events.Event;
  7.     import flash.utils.Timer;
  8.     import flash.text.TextField;
  9.     import flash.events.MouseEvent;
  10.     import flash.text.TextFormat;
  11.     import flashx.textLayout.formats.BackgroundColor;
  12.     import flash.media.Sound;
  13.     import flash.media.SoundChannel;
  14.  
  15.  
  16.     public class Game extends MovieClip
  17.     {
  18.         public static var savedData:SharedObject;
  19.         static var list:Array = new Array();
  20.         static var timesdied:Number;
  21.         static var gametimer:Number;
  22.         static var achtimer:Number;
  23.         static var soundbutton:MovieClip;
  24.         static var ship:MovieClip;
  25.         static var enemyShipTimer:Timer;
  26.         static var specialShipTimer:Timer;
  27.         static var enemieskilled;
  28.         static var roundNumber:Number;
  29.         static var myTextField:TextField;
  30.         static var scoreText:TextField;
  31.         static var score:Number;
  32.         static var gameOverMenu:GameOverMenu;
  33.         static var mainMenu:MainMenu;
  34.         static var Story:story;
  35.         static var Background:Backgrounds;
  36.         static var shiphittests:MovieClip;
  37.         static var Paused:Boolean = false;
  38.         static var shopMenu:ShopMenu;
  39.         static var achMenu:AchMenu;
  40.         static var BulletLength:Number;
  41.         static var shrunk:Boolean = false;
  42.         static var grown:Boolean = false;
  43.         static var shieldactivate:Boolean = false;
  44.         static var doubleenemies:Boolean = false;
  45.         static var Instructions:instructions;
  46.         static var enemyShip2Timer:Timer;
  47.         static var enemyShip3Timer:Timer;
  48.         static var enemyShip4Timer:Timer;
  49.         static var enemyShip5Timer:Timer;
  50.         static var playthegameach:Boolean = false;//
  51.         static var asteroidkillerach:Boolean = false;//
  52.         static var asteroidkiller2ach:Boolean = false;//
  53.         static var asteroidkiller3ach:Boolean = false;//
  54.         static var asteroidkiller4ach:Boolean = false;//
  55.         static var a1minuteplayed:Boolean = false;//
  56.         static var a5minuteplayed:Boolean = false;//
  57.         static var a15minuteplayed:Boolean = false;//
  58.         static var a30minuteplayed:Boolean = false;//
  59.         static var a60minuteplayed:Boolean = false;//
  60.         static var died1time:Boolean = false;//
  61.         static var died10time:Boolean = false;//
  62.         static var died50time:Boolean = false;//
  63.         static var died100time:Boolean = false;//
  64.         static var teleported1time:Boolean = false;//
  65.         static var teleported100time:Boolean = false;//
  66.         static var teleported1000time:Boolean = false;//
  67.         static var randommax:Boolean = false;//
  68.         static var fireratemax:Boolean = false;//
  69.         static var shotpowermax:Boolean = false;//
  70.         static var shotdistancemax:Boolean = false;//
  71.         static var turnspeedmax:Boolean = false;//
  72.         static var brakesmax:Boolean = false;//
  73.         static var topspeedmax:Boolean = false;//
  74.         static var thrustmax:Boolean = false;//
  75.         static var duckyach:Boolean = false;//
  76.         static var nduckyach:Boolean = false;//
  77.         static var cantach:Boolean = false;//
  78.         static var tinyach:Boolean = false;//
  79.         static var miniach:Boolean = false;//
  80.         static var averageach:Boolean = false;//
  81.         static var largeach:Boolean = false;//
  82.         static var gigantoach:Boolean = false;//
  83.  
  84.  
  85.         function Game()
  86.         {
  87.  
  88.             if (Game.Paused == false)
  89.             {
  90.  
  91.  
  92.                 Key.initialize(stage);
  93.  
  94.                 ship = new Ship();
  95.                 ship.x = 200;
  96.                 ship.y = 150;
  97.  
  98.                 soundbutton = new soundButton();
  99.                 soundbutton.x = 650;
  100.                 soundbutton.y = 120;
  101.  
  102.                 Background = new Backgrounds();
  103.  
  104.                 addChild(Background);
  105.                 ship.visible = false;
  106.                 addChild(soundbutton);
  107.                 addChild(ship);
  108.                 myTextField= new TextField();
  109.                 addChild(myTextField);
  110.                 if (doubleenemies == false)
  111.                 {
  112.                     enemyShipTimer = new Timer(2000);
  113.  
  114.                 }
  115.                 if (doubleenemies == true)
  116.                 {
  117.                     enemyShipTimer = new Timer(1000);
  118.                 }
  119.                 enemyShipTimer.addEventListener("timer", sendEnemy);
  120.                 enemyShipTimer.stop();
  121.  
  122.                 if (doubleenemies == false)
  123.                 {
  124.                     enemyShip2Timer = new Timer(2000);
  125.  
  126.                 }
  127.                 if (doubleenemies == true)
  128.                 {
  129.                     enemyShip2Timer = new Timer(1000);
  130.                 }
  131.                 enemyShip2Timer.addEventListener("timer", sendEnemy2);
  132.                 enemyShip2Timer.stop();
  133.  
  134.                 if (doubleenemies == false)
  135.                 {
  136.                     enemyShip3Timer = new Timer(2000);
  137.  
  138.                 }
  139.                 if (doubleenemies == true)
  140.                 {
  141.                     enemyShip3Timer = new Timer(1000);
  142.                 }
  143.                 enemyShip3Timer.addEventListener("timer", sendEnemy3);
  144.                 enemyShip3Timer.stop();
  145.                 if (doubleenemies == false)
  146.                 {
  147.                     enemyShip4Timer = new Timer(4000);
  148.  
  149.                 }
  150.                 if (doubleenemies == true)
  151.                 {
  152.                     enemyShip4Timer = new Timer(2000);
  153.                 }
  154.                 enemyShip4Timer.addEventListener("timer", sendEnemy4);
  155.                 enemyShip4Timer.stop();
  156.                 if (doubleenemies == false)
  157.                 {
  158.                     enemyShip5Timer = new Timer(12000);
  159.  
  160.                 }
  161.                 if (doubleenemies == true)
  162.                 {
  163.                     enemyShip5Timer = new Timer(6000);
  164.                 }
  165.                 enemyShip5Timer.addEventListener("timer", sendEnemy5);
  166.                 enemyShip5Timer.stop();
  167.  
  168.                 if (doubleenemies == false)
  169.                 {
  170.  
  171.                     specialShipTimer = new Timer(1000);
  172.                 }
  173.                 if (doubleenemies == true)
  174.                 {
  175.                     specialShipTimer = new Timer(500);
  176.                 }
  177.                 specialShipTimer.addEventListener("timer", sendspecialEnemy);
  178.                 specialShipTimer.stop();
  179.  
  180.                 myTextField.text = String('');
  181.                 myTextField.width = 2500;
  182.                 myTextField.x = 25;
  183.                 myTextField.selectable = false;
  184.                 myTextField.y = 25;
  185.                 scoreText = new TextField();
  186.                 scoreText.x = 290;
  187.                 scoreText.y = 25;
  188.                 scoreText.text = String(0);
  189.                 addChild(scoreText);
  190.  
  191.                 resetScore();
  192.                 gameOverMenu = new GameOverMenu();
  193.  
  194.  
  195.                 addChild(gameOverMenu);
  196.                 gameOverMenu.visible = false;
  197.                 gameOverMenu.playAgainButton.addEventListener("mouseDown", showmainmenu);
  198.                 gameOverMenu.playAgainButton.addEventListener("mouseDown", save);
  199.                 gameOverMenu.playAgainButton.addEventListener("mouseDown", ship.saveg);
  200.  
  201.                 mainMenu = new MainMenu();
  202.                 addChild(mainMenu);
  203.                 mainMenu.visible = true;
  204.                 mainMenu.x = 300;
  205.                 mainMenu.y = 300;
  206.                 Story = new story();
  207.                 addChild(Story);
  208.                 Story.visible = false;
  209.                 Story.x = 300;
  210.                 Story.y = 500;
  211.                 mainMenu.startButton.addEventListener("mouseDown", newGame);
  212.                 mainMenu.achButton.addEventListener("mouseDown", showAch);
  213.                 mainMenu.shopButton.addEventListener("mouseDown", showShop);
  214.                 mainMenu.instructbutton.addEventListener("mouseDown", showInstruct);
  215.                 mainMenu.storybox.addEventListener("mouseDown", togglestory);
  216.                 shopMenu = new ShopMenu();
  217.                 achMenu = new AchMenu();
  218.  
  219.                 addChild(achMenu);
  220.                 Instructions = new instructions();
  221.                 addChild(Instructions);
  222.                 addChild(shopMenu);
  223.                 Instructions.visible = false;
  224.                 Instructions.x = 240;
  225.                 Instructions.y = 240;
  226.                 achMenu.visible = false;
  227.                 achMenu.x = 220;
  228.                 achMenu.y = 300;
  229.                 shopMenu.visible = false;
  230.                 shopMenu.x = 240;
  231.                 shopMenu.y = 240;
  232.                 achMenu.backbut.addEventListener("mouseDown", showmainmenu);
  233.                 shopMenu.BackButton.addEventListener("mouseDown", showmainmenu);
  234.                 shopMenu.BackButton.addEventListener("mouseDown", save);
  235.                 shopMenu.BackButton.addEventListener("mouseDown", ship.saveg);
  236.                 shopMenu.ShieldButton.Upgrade.gotoAndStop(1);
  237.                 shopMenu.ThrustButton.Upgrade.gotoAndStop(1);
  238.                 shopMenu.BulletLengthButton.Upgrade.gotoAndStop(1);
  239.                 shopMenu.FireRateButton.Upgrade.gotoAndStop(1);
  240.                 shopMenu.BrakesButton.Upgrade.gotoAndStop(1);
  241.                 shopMenu.TopSpeedButton.Upgrade.gotoAndStop(1);
  242.                 shopMenu.TurnSpeedButton.Upgrade.gotoAndStop(1);
  243.                 shopMenu.NumberOfShotsButton.Upgrade.gotoAndStop(1);
  244.  
  245.                 mainMenu.hardmodebox.addEventListener("mouseDown", togglehardmode);
  246.                 shopMenu.ShieldButton.addEventListener("mouseDown", UpgradeShield);
  247.                 shopMenu.ThrustButton.addEventListener("mouseDown", UpgradeThrust);
  248.                 shopMenu.BulletLengthButton.addEventListener("mouseDown", UpgradeBulletLength);
  249.                 shopMenu.FireRateButton.addEventListener("mouseDown", UpgradeFireRate);
  250.                 shopMenu.BrakesButton.addEventListener("mouseDown", UpgradeBrakes);
  251.                 shopMenu.TopSpeedButton.addEventListener("mouseDown", UpgradeTopSpeed);
  252.                 shopMenu.TurnSpeedButton.addEventListener("mouseDown", UpgradeTurnSpeed);
  253.                 shopMenu.NumberOfShotsButton.addEventListener("mouseDown", UpgradeNumberOfShots);
  254.  
  255.                 shopMenu.ShieldButton.addEventListener(MouseEvent.ROLL_OVER, ShieldButtonCost);
  256.                 shopMenu.ShieldButton.addEventListener(MouseEvent.ROLL_OUT, CostReset);
  257.                 shopMenu.ThrustButton.addEventListener(MouseEvent.ROLL_OVER, ThrustButtonCost);
  258.                 shopMenu.ThrustButton.addEventListener(MouseEvent.ROLL_OUT, CostReset);
  259.                 shopMenu.BulletLengthButton.addEventListener(MouseEvent.ROLL_OVER, BulletLengthButtonCost);
  260.                 shopMenu.BulletLengthButton.addEventListener(MouseEvent.ROLL_OUT, CostReset);
  261.                 shopMenu.FireRateButton.addEventListener(MouseEvent.ROLL_OVER, FireRateButtonCost);
  262.                 shopMenu.FireRateButton.addEventListener(MouseEvent.ROLL_OUT, CostReset);
  263.                 shopMenu.BrakesButton.addEventListener(MouseEvent.ROLL_OVER, BrakesButtonCost);
  264.                 shopMenu.BrakesButton.addEventListener(MouseEvent.ROLL_OUT, CostReset);
  265.                 shopMenu.TopSpeedButton.addEventListener(MouseEvent.ROLL_OVER, TopSpeedButtonCost);
  266.                 shopMenu.TopSpeedButton.addEventListener(MouseEvent.ROLL_OUT, CostReset);
  267.                 shopMenu.TurnSpeedButton.addEventListener(MouseEvent.ROLL_OVER, TurnSpeedButtonCost);
  268.                 shopMenu.TurnSpeedButton.addEventListener(MouseEvent.ROLL_OUT, CostReset);
  269.                 shopMenu.NumberOfShotsButton.addEventListener(MouseEvent.ROLL_OVER, NumberOfShotsButtonCost);
  270.                 shopMenu.NumberOfShotsButton.addEventListener(MouseEvent.ROLL_OUT, CostReset);
  271.                 mainMenu.ShipMode.addEventListener("mouseDown", toggleshipmode);
  272.                 Instructions.instructionsbutton.addEventListener("mouseDown", instructback);
  273.                 var scoreFormat = new TextFormat("Joystix",10,0x663300);
  274.                 var scoreFormat2 = new TextFormat("Joystix",15,0x663300);
  275.                 myTextField.defaultTextFormat = scoreFormat;
  276.                 scoreText.defaultTextFormat = scoreFormat2;
  277.  
  278.                 savedData = SharedObject.getLocal("newtest7");
  279.                 if (savedData.data.timesdied == undefined)
  280.                 {
  281.                     timesdied = 0;
  282.                     gametimer = 0;
  283.                     achtimer = 0;
  284.                     enemieskilled = 0;
  285.                     BulletLength = 1;
  286.                     score = 0;
  287.                 }
  288.                 else
  289.                 {
  290.                     score = savedData.data.score;
  291.                     timesdied = savedData.data.timesdied;
  292.                     died1time = savedData.data.died1time;
  293.                     gametimer = savedData.data.gametimer;
  294.  
  295.                     enemieskilled = savedData.data.enemieskilled;
  296.                     BulletLength = savedData.data.BulletLength;
  297.                     playthegameach = savedData.data.playthegameach;
  298.                     asteroidkillerach = savedData.data.asteroidkillerach;
  299.                     asteroidkiller2ach = savedData.data.asteroidkiller2ach;
  300.                     asteroidkiller3ach = savedData.data.asteroidkiller3ach;
  301.                     asteroidkiller4ach = savedData.data.asteroidkiller4ach;
  302.                     a1minuteplayed = savedData.data.a1minuteplayed;
  303.                     a5minuteplayed = savedData.data.a5minuteplayed;
  304.                     a15minuteplayed = savedData.data.a15minuteplayed;
  305.                     a30minuteplayed = savedData.data.a30minuteplayed;
  306.                     a60minuteplayed = savedData.data.a60minuteplayed;
  307.                     died10time = savedData.data.died10time;
  308.                     died50time = savedData.data.died50time;
  309.                     died100time = savedData.data.died100time;
  310.                     teleported1time = savedData.data.teleported1time;
  311.                     teleported100time = savedData.data.teleported100time;
  312.                     teleported1000time = savedData.data.teleported1000time;
  313.                     randommax = savedData.data.randommax;
  314.                     fireratemax = savedData.data.fireratemax;
  315.                     shotpowermax = savedData.data.shotpowermax;
  316.                     shotdistancemax = savedData.data.shotdistancemax;
  317.                     turnspeedmax = savedData.data.turnspeedmax;
  318.                     brakesmax = savedData.data.brakesmax;
  319.                     topspeedmax = savedData.data.topspeedmax;
  320.                     thrustmax = savedData.data.thrustmax;
  321.                     duckyach = savedData.data.duckyach;
  322.                     nduckyach = savedData.data.nduckyach;
  323.                     cantach = savedData.data.cantach;
  324.                     tinyach = savedData.data.tinyach;
  325.                     miniach = savedData.data.miniach;
  326.                     averageach = savedData.data.averageach;
  327.                     largeach = savedData.data.largeach;
  328.                     gigantoach = savedData.data.gigantoach;
  329.                    
  330.                    
  331.                    
  332.                     shopMenu.ShieldButton.Upgrade.gotoAndStop(ship.ShieldPower);
  333.                     shopMenu.ThrustButton.Upgrade.gotoAndStop(ship.thrustVar);
  334.                 shopMenu.BulletLengthButton.Upgrade.gotoAndStop(BulletLength -= 1);
  335.                 shopMenu.FireRateButton.Upgrade.gotoAndStop(ship.shootTimerVar);
  336.                 shopMenu.BrakesButton.Upgrade.gotoAndStop(ship.brakesVar);
  337.                 shopMenu.TopSpeedButton.Upgrade.gotoAndStop(ship.topSpeedVar);
  338.                 shopMenu.TurnSpeedButton.Upgrade.gotoAndStop(ship.turnSpeedVar);
  339.                 shopMenu.NumberOfShotsButton.Upgrade.gotoAndStop(ship.numberOfBulletsVar);
  340.                     if (died1time == true)
  341.                     {
  342.                         achMenu.die.gotoAndStop(2);
  343.                     }
  344.                     if (playthegameach == true)
  345.                     {
  346.                         achMenu.welc.gotoAndStop(2);
  347.                     }
  348.                     if (asteroidkillerach == true)
  349.                     {
  350.                         achMenu.akil.gotoAndStop(2);
  351.                     }
  352.                     if (asteroidkiller2ach == true)
  353.                     {
  354.                         achMenu.ahun.gotoAndStop(2);
  355.                     }
  356.                     if (asteroidkiller3ach == true)
  357.                     {
  358.                         achMenu.leet.gotoAndStop(2);
  359.                     }
  360.                     if (asteroidkiller4ach == true)
  361.                     {
  362.                         achMenu.over.gotoAndStop(2);
  363.                     }
  364.                     if (a1minuteplayed == true)
  365.                     {
  366.                         achMenu.wadi.gotoAndStop(2);
  367.                     }
  368.                     if (a5minuteplayed == true)
  369.                     {
  370.                         achMenu.bein.gotoAndStop(2);
  371.                     }
  372.                     if (a15minuteplayed == true)
  373.                     {
  374.                         achMenu.game.gotoAndStop(2);
  375.                     }
  376.                     if (a30minuteplayed == true)
  377.                     {
  378.                         achMenu.must.gotoAndStop(2);
  379.                     }
  380.                     if (a60minuteplayed == true)
  381.                     {
  382.                         achMenu.goou.gotoAndStop(2);
  383.                     }
  384.                     if (died10time == true)
  385.                     {
  386.                         achMenu.pers.gotoAndStop(2);
  387.                     }
  388.                     if (died50time == true)
  389.                     {
  390.                         achMenu.just.gotoAndStop(2);
  391.                     }
  392.                     if (died100time == true)
  393.                     {
  394.                         achMenu.suic.gotoAndStop(2);
  395.                     }
  396.                     if (teleported1time == true)
  397.                     {
  398.                         achMenu.ohha.gotoAndStop(2);
  399.                     }
  400.                     if (teleported100time == true)
  401.                     {
  402.                         achMenu.step.gotoAndStop(2);
  403.                     }
  404.                     if (teleported1000time == true)
  405.                     {
  406.                         achMenu.leap.gotoAndStop(2);
  407.                     }
  408.                     if (randommax == true)
  409.                     {
  410.                         achMenu.rand.gotoAndStop(2);
  411.                         achMenu.cant.gotoAndStop(2);
  412.                     }
  413.                     if (fireratemax == true)
  414.                     {
  415.                         achMenu.quic.gotoAndStop(2);
  416.                     }
  417.                     if (shotpowermax == true)
  418.                     {
  419.                         achMenu.shot.gotoAndStop(2);
  420.                     }
  421.                     if (shotdistancemax == true)
  422.                     {
  423.                         achMenu.snip.gotoAndStop(2);
  424.                     }
  425.                     if (turnspeedmax == true)
  426.                     {
  427.                         achMenu.turn.gotoAndStop(2);
  428.                     }
  429.                     if (brakesmax == true)
  430.                     {
  431.                         achMenu.brak.gotoAndStop(2);
  432.                     }
  433.                     if (topspeedmax == true)
  434.                     {
  435.                         achMenu.tops.gotoAndStop(2);
  436.                     }
  437.                     if (thrustmax == true)
  438.                     {
  439.                         achMenu.thru.gotoAndStop(2);
  440.                     }
  441.                     if (duckyach == true)
  442.                     {
  443.                         achMenu.duck.gotoAndStop(2);
  444.                     }
  445.                     if (nduckyach == true)
  446.                     {
  447.                         achMenu.ninj.gotoAndStop(2);
  448.                     }
  449.                     if (tinyach == true)
  450.                     {
  451.                         achMenu.tiny.gotoAndStop(2);
  452.                     }
  453.                     if (miniach == true)
  454.                     {
  455.                         achMenu.mini.gotoAndStop(2);
  456.                     }
  457.                     if (averageach == true)
  458.                     {
  459.                         achMenu.aver.gotoAndStop(2);
  460.                     }
  461.                     if (largeach == true)
  462.                     {
  463.                         achMenu.larg.gotoAndStop(2);
  464.                     }
  465.                     if (gigantoach == true)
  466.                     {
  467.                         achMenu.giga.gotoAndStop(2);
  468.                     }
  469.                 }
  470.  
  471.             }
  472.         }
  473.         function save(e:Event)
  474.         {
  475.             trace(died1time);
  476.             savedData.data.died1time = died1time;
  477.             savedData.data.timesdied = timesdied;
  478.  
  479.             savedData.data.score = score;
  480.  
  481.             savedData.data.gametimer = gametimer;
  482.  
  483.             savedData.data.enemieskilled = enemieskilled;
  484.             savedData.data.BulletLength = BulletLength;
  485.             savedData.data.playthegameach = playthegameach;
  486.             savedData.data.asteroidkillerach = asteroidkillerach;
  487.             savedData.data.asteroidkiller2ach = asteroidkiller2ach;
  488.             savedData.data.asteroidkiller3ach = asteroidkiller3ach;
  489.             savedData.data.asteroidkiller4ach = asteroidkiller4ach;
  490.             savedData.data.a1minuteplayed = a1minuteplayed;
  491.             savedData.data.a5minuteplayed = a5minuteplayed;
  492.             savedData.data.a15minuteplayed = a15minuteplayed;
  493.             savedData.data.a30minuteplayed = a30minuteplayed;
  494.             savedData.data.a60minuteplayed = a60minuteplayed;
  495.             savedData.data.died10time = died10time;
  496.             savedData.data.died50time = died50time;
  497.             savedData.data.died100time = died100time;
  498.             savedData.data.teleported1time = teleported1time;
  499.             savedData.data.teleported100time = teleported100time;
  500.             savedData.data.teleported1000time = teleported1000time;
  501.             savedData.data.randommax = randommax;
  502.             savedData.data.fireratemax = fireratemax;
  503.             savedData.data.shotpowermax = shotpowermax;
  504.             savedData.data.shotdistancemax = shotdistancemax;
  505.             savedData.data.turnspeedmax = turnspeedmax;
  506.             savedData.data.brakesmax = brakesmax;
  507.             savedData.data.topspeedmax = topspeedmax;
  508.             savedData.data.thrustmax = thrustmax;
  509.             savedData.data.duckyach = duckyach;
  510.             savedData.data.nduckyach = nduckyach;
  511.             savedData.data.cantach = cantach;
  512.             savedData.data.tinyach = tinyach;
  513.             savedData.data.miniach = miniach;
  514.             savedData.data.averageach = averageach;
  515.             savedData.data.largeach = largeach;
  516.             savedData.data.gigantoach = gigantoach;
  517.  
  518.  
  519.  
  520.         }
  521.         function instructback(e:Event)
  522.         {
  523.             Instructions.visible = false;
  524.             mainMenu.visible = true;
  525.         }
  526.         function toggleshipmode(e:Event)
  527.         {
  528.             if (ship.ShieldPower > 4)
  529.             {
  530.                 if (ship.isduck == false)
  531.                 {
  532.                     mainMenu.ShipMode.gotoAndStop(3);
  533.                     ship.isduck = true;
  534.  
  535.                 }
  536.                 else
  537.                 {
  538.                     mainMenu.ShipMode.gotoAndStop(2);
  539.                     ship.isduck = false;
  540.  
  541.                 }
  542.             }
  543.  
  544.         }
  545.         function togglestory(e:Event)
  546.         {
  547.             if (Game.ship.skipstory == false)
  548.             {
  549.                 Game.ship.skipstory = true;
  550.                 mainMenu.storybox.gotoAndStop(2);
  551.             }
  552.             else
  553.             {
  554.                 mainMenu.storybox.gotoAndStop(1);
  555.                 Game.ship.skipstory = false;
  556.             }
  557.         }
  558.         function togglehardmode(e:Event)
  559.         {
  560.             if (ship.ShieldPower > 6)
  561.             {
  562.                 if (doubleenemies == false)
  563.                 {
  564.                     mainMenu.hardmodebox.gotoAndStop(3);
  565.                     doubleenemies = true;
  566.                     trace('banana');
  567.  
  568.                 }
  569.                 else
  570.                 {
  571.                     mainMenu.hardmodebox.gotoAndStop(2);
  572.                     doubleenemies = false;
  573.  
  574.                 }
  575.             }
  576.         }
  577.         function ShieldButtonCost(e:Event)
  578.         {
  579.  
  580.             shopMenu.BackButton.UpgradeText.visible = true;
  581.             shopMenu.BackButton.UpgradeText.text = 1000 * ship.ShieldPower;
  582.         }
  583.         function ThrustButtonCost(e:Event)
  584.         {
  585.             shopMenu.BackButton.UpgradeText.visible = true;
  586.             shopMenu.BackButton.UpgradeText.text = 500 * ship.thrustVar;
  587.         }
  588.         function BulletLengthButtonCost(e:Event)
  589.         {
  590.             shopMenu.BackButton.UpgradeText.visible = true;
  591.             shopMenu.BackButton.UpgradeText.text = 750 * BulletLength;
  592.         }
  593.         function FireRateButtonCost(e:Event)
  594.         {
  595.             shopMenu.BackButton.UpgradeText.visible = true;
  596.             shopMenu.BackButton.UpgradeText.text = 750 * ship.shootTimerVar;
  597.         }
  598.         function BrakesButtonCost(e:Event)
  599.         {
  600.             shopMenu.BackButton.UpgradeText.visible = true;
  601.             shopMenu.BackButton.UpgradeText.text = 500 * ship.brakesVar;
  602.         }
  603.         function TopSpeedButtonCost(e:Event)
  604.         {
  605.             shopMenu.BackButton.UpgradeText.visible = true;
  606.             shopMenu.BackButton.UpgradeText.text = 500 * ship.topSpeedVar;
  607.         }
  608.         function TurnSpeedButtonCost(e:Event)
  609.         {
  610.             shopMenu.BackButton.UpgradeText.visible = true;
  611.             shopMenu.BackButton.UpgradeText.text = 500 * ship.turnSpeedVar;
  612.         }
  613.  
  614.         function NumberOfShotsButtonCost(e:Event)
  615.         {
  616.             shopMenu.BackButton.UpgradeText.visible = true;
  617.             shopMenu.BackButton.UpgradeText.text = 1000 * ship.numberOfBulletsVar;
  618.         }
  619.         function CostReset(e:Event)
  620.         {
  621.  
  622.             shopMenu.BackButton.UpgradeText.visible = false;
  623.         }
  624.  
  625.         static function gameOver()
  626.         {
  627.             if (timesdied == 1)
  628.             {
  629.                 if (died1time == false)
  630.                 {
  631.                     updateach("Achievement Unlocked: Die");
  632.                     updateScore(200);
  633.                     died1time = true;
  634.                     achMenu.die.gotoAndStop(2);
  635.                 }
  636.             }
  637.             if (timesdied == 10)
  638.             {
  639.                 if (died10time == false)
  640.                 {
  641.                     updateach("Achievement Unlocked: Persistent");
  642.                     updateScore(1000);
  643.                     died10time = true;
  644.                     achMenu.pers.gotoAndStop(2);
  645.                 }
  646.             }
  647.             if (timesdied == 50)
  648.             {
  649.                 if (died50time == false)
  650.                 {
  651.                     updateach("Achievement Unlocked: Just keep dieing");
  652.                     updateScore(3000);
  653.                     died50time = true;
  654.                     achMenu.just.gotoAndStop(2);
  655.                 }
  656.             }
  657.             if (timesdied == 100)
  658.             {
  659.                 if (died100time == false)
  660.                 {
  661.                     updateach("Achievement Unlocked: Suicidal");
  662.                     updateScore(5000);
  663.                     died100time = true;
  664.                     achMenu.suic.gotoAndStop(2);
  665.                 }
  666.             }
  667.             gameOverMenu.visible = true;
  668.             gameOverMenu.x = 300;
  669.             gameOverMenu.y = 300;
  670.             enemyShipTimer.stop();
  671.             enemyShip2Timer.stop();
  672.             enemyShip3Timer.stop();
  673.             enemyShip4Timer.stop();
  674.             enemyShip5Timer.stop();
  675.             specialShipTimer.stop();
  676.             ship.Round = 0;
  677.  
  678.             for (var i in list)
  679.             {
  680.                 list[i].gameoverdie();
  681.             }
  682.  
  683.         }
  684.  
  685.         function showmainmenu(e:Event)
  686.         {
  687.             trace(ship.roundtimer);
  688.             shopMenu.visible = false;
  689.             achMenu.visible = false;
  690.             mainMenu.visible = true;
  691.             gameOverMenu.visible = false;
  692.         }
  693.  
  694.         function newGame(e:Event)
  695.         {
  696.             if (playthegameach == false)
  697.             {
  698.                 updateach("Achievement Unlocked:Play the game");
  699.                 playthegameach = true;
  700.                 updateScore(200);
  701.                 achMenu.welc.gotoAndStop(2);
  702.             }
  703.             ship.changemode();
  704.             mainMenu.visible = false;
  705.             gameOverMenu.visible = false;
  706.             ship.visible = true;
  707.             ship.x = 200;
  708.             ship.y = 300;
  709.             ship.thrust = 0;
  710.             ship.addEventListener("enterFrame", ship.move);
  711.  
  712.             ship.Round = 1;
  713.  
  714.             specialShipTimer.start();
  715.             ship.invulnTimer = 0;
  716.             ship.invulnUsed = false;
  717.  
  718.  
  719.         }
  720.         function showShop(e:Event)
  721.         {
  722.             mainMenu.visible = false;
  723.             shopMenu.visible = true;
  724.         }
  725.         function showAch(e:Event)
  726.         {
  727.             mainMenu.visible = false;
  728.             achMenu.visible = true;
  729.         }
  730.         function showInstruct(e:Event)
  731.         {
  732.             mainMenu.visible = false;
  733.             Instructions.visible = true;
  734.         }
  735.         function showMainMenu(e:Event)
  736.         {
  737.             mainMenu.visible = true;
  738.             shopMenu.visible = false;
  739.         }
  740.         function sendEnemy(e:Event)
  741.         {
  742.             var enemy = new EnemyShip();
  743.             stage.addChild(enemy);
  744.  
  745.  
  746.         }
  747.         function sendEnemy2(e:Event)
  748.         {
  749.             var enemy2 = new EnemyShip2();
  750.             stage.addChild(enemy2);
  751.  
  752.         }
  753.         function sendEnemy3(e:Event)
  754.         {
  755.             var enemy3 = new EnemyShip3();
  756.             stage.addChild(enemy3);
  757.  
  758.         }
  759.         function sendEnemy4(e:Event)
  760.         {
  761.             var enemy4 = new EnemyShip4();
  762.             stage.addChild(enemy4);
  763.  
  764.         }
  765.         function sendEnemy5(e:Event)
  766.         {
  767.             var enemy5 = new EnemyShip5();
  768.             stage.addChild(enemy5);
  769.  
  770.         }
  771.         function sendspecialEnemy(e:Event)
  772.         {
  773.  
  774.             if (Math.random() < .001 && ship.ShieldPower > 8)
  775.             {
  776.                 var special = new SpecialShip();
  777.                 stage.addChild(special);
  778.             }
  779.         }
  780.         static function updateScore(points)
  781.         {
  782.             score +=  points;
  783.             scoreText.text = String(score);
  784.         }
  785.         static function updateach(ach)
  786.         {
  787.             achtimer = 0;
  788.             myTextField.text = String(ach);
  789.         }
  790.  
  791.         static function resetScore()
  792.         {
  793.             score = 0;
  794.             scoreText.text = String(score);
  795.  
  796.         }
  797.         function UpgradeShield(e:Event)
  798.         {
  799.             trace('banana');
  800.             if (ship.ShieldPower == 5)
  801.             {
  802.                 mainMenu.ShipMode.gotoAndStop(2);
  803.             }
  804.             if (ship.ShieldPower > 6)
  805.             {
  806.                 mainMenu.hardmodebox.gotoAndStop(2);
  807.             }
  808.             if (Game.ship.ShieldPower < 11)
  809.             {
  810.                 if (1000 * Game.ship.ShieldPower <= score)
  811.                 {
  812.  
  813.                     if (Game.ship.ShieldPower == 10)
  814.                     {
  815.                         if (randommax == false)
  816.                         {
  817.                             randommax = true;
  818.                             updateach("Achievement Unlocked: Randomizer, Cant Touch This");
  819.                             updateScore(1000);
  820.                             randommax = true;
  821.                             achMenu.rand.gotoAndStop(2);
  822.                             achMenu.cant.gotoAndStop(2);
  823.                         }
  824.  
  825.                     }
  826.                     updateScore(-1000*ship.ShieldPower);
  827.                     Game.ship.ShieldPower +=  1;
  828.                     shopMenu.ShieldButton.Upgrade.gotoAndStop(ship.ShieldPower);
  829.                     shopMenu.BackButton.UpgradeText.text = 1000 * ship.ShieldPower;
  830.                 }
  831.             }
  832.         }
  833.         function UpgradeThrust(e:Event)
  834.         {
  835.  
  836.             if (500 * Game.ship.thrustVar <= score)
  837.             {
  838.                 if (Game.ship.thrustVar == 10)
  839.                 {
  840.                     if (thrustmax == false)
  841.                     {
  842.                         thrustmax = true;
  843.                         updateach("Achievement Unlocked: Thrusters Primed");
  844.                         updateScore(1000);
  845.                         thrustmax = true;
  846.                         achMenu.thru.gotoAndStop(2);
  847.                     }
  848.  
  849.                 }
  850.                 if (Game.ship.thrustVar < 11)
  851.                 {
  852.                     updateScore(-500*ship.thrustVar);
  853.                     Game.ship.thrustVar +=  1;
  854.                     shopMenu.ThrustButton.Upgrade.gotoAndStop(ship.thrustVar);
  855.                     shopMenu.BackButton.UpgradeText.text = 500 * ship.thrustVar;
  856.                 }
  857.             }
  858.         }
  859.         function UpgradeFireRate(e:Event)
  860.         {
  861.  
  862.             if (750 * Game.ship.shootTimerVar <= score)
  863.             {
  864.                 if (Game.ship.shootTimerVar == 10)
  865.                 {
  866.                     if (fireratemax == false)
  867.                     {
  868.                         fireratemax = true;
  869.                         updateach("Achievement Unlocked: QuickDraw");
  870.                         updateScore(1000);
  871.                         fireratemax = true;
  872.                         achMenu.quic.gotoAndStop(2);
  873.                     }
  874.  
  875.                 }
  876.                 if (ship.shootTimerVar < 11)
  877.                 {
  878.                     updateScore(-750*ship.shootTimerVar);
  879.                     Game.ship.shootTimerVar +=  1;
  880.                     shopMenu.FireRateButton.Upgrade.gotoAndStop(ship.shootTimerVar);
  881.                     shopMenu.BackButton.UpgradeText.text = 750 * ship.shootTimerVar;
  882.                 }
  883.             }
  884.  
  885.         }
  886.  
  887.         function UpgradeBulletLength(e:Event)
  888.         {
  889.  
  890.             if (750 * BulletLength <= score)
  891.             {
  892.                 if (BulletLength == 10)
  893.                 {
  894.                     if (shotdistancemax == false)
  895.                     {
  896.                         shotdistancemax = true;
  897.                         updateach("Achievement Unlocked: Sniper");
  898.                         updateScore(1000);
  899.                         shotdistancemax = true;
  900.                         achMenu.snip.gotoAndStop(2);
  901.                     }
  902.  
  903.                 }
  904.                 if (BulletLength < 11)
  905.                 {
  906.                     updateScore(-750*BulletLength);
  907.                     BulletLength +=  1;
  908.                     shopMenu.BulletLengthButton.Upgrade.gotoAndStop(BulletLength);
  909.                     shopMenu.BackButton.UpgradeText.text = 750 * BulletLength;
  910.  
  911.                 }
  912.             }
  913.  
  914.         }
  915.         function UpgradeBrakes(e:Event)
  916.         {
  917.  
  918.             if (500 * Game.ship.brakesVar <= score)
  919.             {
  920.                 if (Game.ship.brakesVar == 10)
  921.                 {
  922.                     if (brakesmax == false)
  923.                     {
  924.                         brakesmax = true;
  925.                         updateach("Achievement Unlocked: STOP!");
  926.                         updateScore(1000);
  927.                         brakesmax = true;
  928.                         achMenu.brak.gotoAndStop(2);
  929.                     }
  930.  
  931.                 }
  932.                 if (Game.ship.brakesVar < 11)
  933.                 {
  934.                     updateScore(-500*ship.brakesVar);
  935.                     Game.ship.brakesVar +=  1;
  936.                     shopMenu.BrakesButton.Upgrade.gotoAndStop(Game.ship.brakesVar);
  937.                     shopMenu.BackButton.UpgradeText.text = 500 * ship.brakesVar;
  938.                 }
  939.             }
  940.  
  941.         }
  942.         function UpgradeTopSpeed(e:Event)
  943.         {
  944.             if (500 * Game.ship.topSpeedVar <= score)
  945.             {
  946.                 if (Game.ship.topSpeedVar == 10)
  947.                 {
  948.                     if (topspeedmax == false)
  949.                     {
  950.                         topspeedmax = true;
  951.                         updateach("Achievement Unlocked: Super Fast");
  952.                         updateScore(1000);
  953.                         topspeedmax = true;
  954.                         achMenu.tops.gotoAndStop(2);
  955.                     }
  956.  
  957.                 }
  958.                 if (Game.ship.topSpeedVar < 11)
  959.                 {
  960.                     updateScore(-500*ship.topSpeedVar);
  961.                     Game.ship.topSpeedVar +=  1;
  962.                     shopMenu.TopSpeedButton.Upgrade.gotoAndStop(Game.ship.topSpeedVar);
  963.                     shopMenu.BackButton.UpgradeText.text = 500 * ship.topSpeedVar;
  964.                 }
  965.             }
  966.  
  967.         }
  968.         function UpgradeTurnSpeed(e:Event)
  969.         {
  970.             if (500 * Game.ship.turnSpeedVar <= score)
  971.             {
  972.                 if (Game.ship.turnSpeedVar == 10)
  973.                 {
  974.                     if (turnspeedmax == false)
  975.                     {
  976.                         turnspeedmax = true;
  977.                         updateach("Achievement Unlocked: Spin Spin Spin");
  978.                         updateScore(1000);
  979.                         turnspeedmax = true;
  980.                         achMenu.turn.gotoAndStop(2);
  981.                     }
  982.  
  983.                 }
  984.                 if (ship.turnSpeedVar < 11)
  985.                 {
  986.                     updateScore(-500*ship.turnSpeedVar);
  987.                     Game.ship.turnSpeedVar +=  1;
  988.                     shopMenu.TurnSpeedButton.Upgrade.gotoAndStop(Game.ship.turnSpeedVar);
  989.                     shopMenu.BackButton.UpgradeText.text = 500 * ship.turnSpeedVar;
  990.                 }
  991.             }
  992.  
  993.         }
  994.         function UpgradeNumberOfShots(e:Event)
  995.         {
  996.             if (1000 * Game.ship.numberOfBulletsVar <= score)
  997.             {
  998.                 if (Game.ship.numberOfBulletsVar == 10)
  999.                 {
  1000.                     if (shotpowermax == false)
  1001.                     {
  1002.                         shotpowermax = true;
  1003.                         updateach("Achievement Unlocked: Shoot EVERYTHING!");
  1004.                         updateScore(1000);
  1005.                         shotpowermax = true;
  1006.                         achMenu.shot.gotoAndStop(2);
  1007.                     }
  1008.  
  1009.                 }
  1010.                 if (Game.ship.numberOfBulletsVar < 11)
  1011.                 {
  1012.                     updateScore(-1000*ship.numberOfBulletsVar);
  1013.                     Game.ship.numberOfBulletsVar +=  1;
  1014.                     shopMenu.NumberOfShotsButton.Upgrade.gotoAndStop(ship.numberOfBulletsVar);
  1015.                     shopMenu.BackButton.UpgradeText.text = 1000 * ship.numberOfBulletsVar;
  1016.                 }
  1017.             }
  1018.  
  1019.         }
  1020.  
  1021.     }
  1022.  
  1023. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement