Advertisement
Guest User

LL:NS game engine

a guest
Dec 3rd, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.runouw.ll.engine
  2. {
  3.    import com.runouw.Maths;
  4.    import com.runouw.keyEngine.KeyEngine;
  5.    import com.runouw.ll.Main;
  6.    import com.runouw.ll.SavedData;
  7.    import com.runouw.ll.character.Character;
  8.    import com.runouw.ll.engine.backgrounds.BGFactory;
  9.    import com.runouw.ll.engine.backgrounds.Background;
  10.    import com.runouw.ll.engine.backgrounds.CloseBackground;
  11.    import com.runouw.ll.engine.char.GravityStats;
  12.    import com.runouw.ll.engine.core.Camera;
  13.    import com.runouw.ll.engine.core.Course;
  14.    import com.runouw.ll.engine.hero.HeroStats;
  15.    import com.runouw.ll.engine.hero.delta.DeltaCircle;
  16.    import com.runouw.ll.engine.hero.delta.DeltaCursor;
  17.    import com.runouw.ll.engine.hero.delta.DeltaEffector;
  18.    import com.runouw.ll.engine.hero.delta.DeltaWallHandler;
  19.    import com.runouw.ll.engine.levelData.Colors;
  20.    import com.runouw.ll.engine.levelData.enemies.Enemy;
  21.    import com.runouw.ll.engine.levelData.items.core.Boulder;
  22.    import com.runouw.ll.engine.levelData.items.core.DeltaModifier;
  23.    import com.runouw.ll.engine.levelData.items.core.Item;
  24.    import com.runouw.ll.engine.levelData.items.core.Spikes;
  25.    import com.runouw.ll.engine.levelData.items.core.interfaces.GravityZone;
  26.    import com.runouw.ll.engine.levelData.items.core.interfaces.ISynchronize;
  27.    import com.runouw.ll.engine.levelData.items.core.interfaces.Platform_Cloud;
  28.    import com.runouw.ll.engine.levelData.items.core.interfaces.Platform_Damage;
  29.    import com.runouw.ll.engine.levelData.items.core.interfaces.Platform_Ground;
  30.    import com.runouw.ll.engine.levelData.items.data.Item_ColorBox;
  31.    import com.runouw.ll.engine.levelData.items.data.Item_DeltaNegate;
  32.    import com.runouw.ll.engine.levelData.items.data.Item_Splitter_X;
  33.    import com.runouw.ll.engine.levelData.items.data.Item_StartPosition;
  34.    import com.runouw.ll.engine.levelData.items.data.trigger.FunctionSequence;
  35.    import com.runouw.ll.engine.levelData.slices.LevelDataSlice;
  36.    import com.runouw.ll.engine.levelData.tiles.Tile;
  37.    import com.runouw.ll.engine.levelData.tiles.TileFactory;
  38.    import com.runouw.ll.engine.levelData.tiles.TileHandler;
  39.    import com.runouw.ll.engine.modes.CinemaEngine;
  40.    import com.runouw.ll.engine.modes.GameplayEngine;
  41.    import com.runouw.ll.engine.modes.LevelDesignerEngine;
  42.    import com.runouw.ll.engine.particles.Particle;
  43.    import com.runouw.ll.engine.projectiles.Projectile;
  44.    import com.runouw.ll.engine.quality.QualityHandler;
  45.    import com.runouw.ll.engine.text.TextHandler;
  46.    import com.runouw.ll.engine.transition.Transition;
  47.    import com.runouw.ll.engine.transition.Transition_Black;
  48.    import com.runouw.ll.engine.water.WaterSurface;
  49.    import com.runouw.ll.engine.weather.WeatherHandler;
  50.    import com.runouw.ll.sounds.MusicHandler;
  51.    import com.runouw.ll.sounds.SoundHandler;
  52.    import com.runouw.ll.ui.BehaviorHandler;
  53.    import com.runouw.ll.ui.gameplay.HUD_PauseMenu;
  54.    import com.runouw.ll.ui.gameplay.HUD_Shell;
  55.    import flash.display.Bitmap;
  56.    import flash.display.BitmapData;
  57.    import flash.display.DisplayObject;
  58.    import flash.display.MovieClip;
  59.    import flash.events.Event;
  60.    import flash.filters.ColorMatrixFilter;
  61.    import flash.geom.ColorTransform;
  62.    import flash.geom.Matrix;
  63.    import flash.geom.Point;
  64.    import flash.geom.Rectangle;
  65.    import flash.media.SoundChannel;
  66.    import flash.media.SoundTransform;
  67.    import flash.utils.getTimer;
  68.    import net.hires.debug.Stats;
  69.    
  70.    public class GameEngine
  71.    {
  72.      
  73.       public static var stats:GameEngineStats;
  74.      
  75.       public static var screenBuffer:BitmapData;
  76.      
  77.       public static var screenBufferBit:Bitmap;
  78.      
  79.       public static var enterFrameArray:Vector.<IEnterFrame>;
  80.      
  81.       public static var triggerArray:Vector.<FunctionSequence>;
  82.      
  83.       public static var deltaEffectorArray:Vector.<DeltaEffector>;
  84.      
  85.       public static var enemyArray:Vector.<Enemy>;
  86.      
  87.       public static var boulderArray:Vector.<Boulder>;
  88.      
  89.       public static var deltaModifierArray:Vector.<DeltaModifier>;
  90.      
  91.       public static var spikesArray:Vector.<Spikes>;
  92.      
  93.       public static var spliter_XArray:Vector.<Item_Splitter_X>;
  94.      
  95.       public static var platforms_Cloud:Vector.<Platform_Cloud>;
  96.      
  97.       public static var platforms_Ground:Vector.<Platform_Ground>;
  98.      
  99.       public static var platforms_Damage:Vector.<Platform_Damage>;
  100.      
  101.       public static var gravityZones:Vector.<GravityZone>;
  102.      
  103.       public static var projectileArray:Vector.<Projectile>;
  104.      
  105.       public static var particleArray:Vector.<Particle>;
  106.      
  107.       public static var camera:Camera;
  108.      
  109.       public static var top:MovieClip;
  110.      
  111.       public static var signLayer:MovieClip;
  112.      
  113.       public static var transitionLayer:MovieClip;
  114.      
  115.       public static var course:Course;
  116.      
  117.       public static var midbg_xoffset:Number;
  118.      
  119.       public static var midbg_yoffset:Number;
  120.      
  121.       public static var bg:Background;
  122.      
  123.       public static var closeBG:CloseBackground;
  124.      
  125.       public static var slice:LevelDataSlice;
  126.      
  127.       public static var removed:Boolean = true;
  128.      
  129.       private static var debugStats:Stats;
  130.      
  131.       private static var loading:DisplayObject;
  132.      
  133.       public static var loadingThreshold:int = 16;
  134.      
  135.       public static var deathPause:Boolean;
  136.      
  137.       public static var paused:Boolean;
  138.      
  139.       public static var trigger_cinemaMode:Boolean;
  140.      
  141.       public static var heroAnimation_cinemaMode:Boolean;
  142.      
  143.       public static var heroAnimation_wormholeCinema:Boolean;
  144.      
  145.       public static var runTriggerCount:Number = 0;
  146.      
  147.       public static var usingScreenBuffer:Boolean = false;
  148.      
  149.       public static var inTransition:Transition;
  150.      
  151.       public static var currentTransition:Transition;
  152.      
  153.       public static var pauseMenu:HUD_PauseMenu;
  154.      
  155.       public static var tempHeroStats:HeroStats;
  156.      
  157.       public static var gravityPoint:Point = new Point();
  158.      
  159.       public static var gravity_dir:Number = 0;
  160.      
  161.       private static var deathRespawnCue:c_PressAButtonToRespawn;
  162.      
  163.       public static var worldSpeed:Number = 1;
  164.      
  165.       public static var framerateMultiplier:Number = 1;
  166.      
  167.       private static var _worldSpeed:Number = 1;
  168.      
  169.       public static var delta:Boolean;
  170.      
  171.       public static var deltaLevel:Number;
  172.      
  173.       public static var deltaTime:Number;
  174.      
  175.       public static var deltaTransformed:Boolean;
  176.      
  177.       public static var deltaSFX:SoundChannel;
  178.      
  179.       public static var deltaBitmap:Bitmap;
  180.      
  181.       public static var deltaBitmapData:BitmapData = new BitmapData(Main.WIDTH,Main.HEIGHT,false);
  182.      
  183.       public static var deltaBitmapDataTemp:BitmapData = new BitmapData(Main.WIDTH,Main.HEIGHT,true);
  184.      
  185.       public static var deltaEffectContainer:MovieClip;
  186.      
  187.       public static var deltaCursor:DeltaCursor;
  188.      
  189.       public static var deltaCircle:DeltaCircle;
  190.        
  191.      
  192.       public function GameEngine()
  193.       {
  194.          super();
  195.       }
  196.      
  197.       public static function getSplitterXIndex() : int
  198.       {
  199.          var _loc1_:int = -1;
  200.          while(_loc1_ + 1 < spliter_XArray.length && camera.camX > spliter_XArray[_loc1_ + 1].x)
  201.          {
  202.             _loc1_++;
  203.          }
  204.          return _loc1_;
  205.       }
  206.      
  207.       public static function start(param1:GameEngineStats) : void
  208.       {
  209.          var gameStats:GameEngineStats = param1;
  210.          deathPause = false;
  211.          paused = false;
  212.          trigger_cinemaMode = false;
  213.          heroAnimation_cinemaMode = false;
  214.          heroAnimation_wormholeCinema = false;
  215.          loading = new LevelPreloader();
  216.          loading.x = Main.visibleContent.x;
  217.          loading.y = Main.visibleContent.y;
  218.          loading.scaleX = Main.visibleContent.width / Main.WIDTH;
  219.          loading.scaleY = Main.visibleContent.height / Main.HEIGHT;
  220.          (loading as LevelPreloader)._bar._fill.scaleX = 0.001;
  221.          Main.getStage().addChild(loading);
  222.          stats = gameStats;
  223.          tempHeroStats = null;
  224.          pauseMenu = new HUD_PauseMenu();
  225.          Main.callNextFrame(function nextFrame():void
  226.          {
  227.             if(stats.isPrepared())
  228.             {
  229.                runEngine();
  230.             }
  231.             else
  232.             {
  233.                stats.prepare(function onPrepared():void
  234.                {
  235.                   runEngine();
  236.                });
  237.             }
  238.          });
  239.       }
  240.      
  241.       public static function runEngine() : void
  242.       {
  243.          var onDone:Function = null;
  244.          var onDone2:Function = null;
  245.          onDone = function():void
  246.          {
  247.             course.cameraStuff();
  248.             setTilesColorData(onDone2);
  249.          };
  250.          onDone2 = function():void
  251.          {
  252.             delta = false;
  253.             deltaLevel = 0;
  254.             deltaTime = 0;
  255.             deltaTransformed = false;
  256.             TileHandler.redrawAllTiles();
  257.             course.enterFrame();
  258.             if(bg != null)
  259.             {
  260.                bg.attach();
  261.             }
  262.             if(closeBG != null)
  263.             {
  264.                closeBG.attach();
  265.             }
  266.             if(stats.showDebugger)
  267.             {
  268.                debugStats = new Stats();
  269.                debugStats.x = Main.visibleContent.x;
  270.                debugStats.y = Main.visibleContent.y;
  271.                if(stats.mode == GameEngineStats.MODE_LEVELDESIGNER)
  272.                {
  273.                   debugStats.y = debugStats.y + 20 * (Main.visibleContent.height / Main.HEIGHT);
  274.                }
  275.                if(stats.mode == GameEngineStats.MODE_GAMEPLAY)
  276.                {
  277.                   debugStats.x = Main.visibleContent.x + Main.visibleContent.width - 70;
  278.                }
  279.             }
  280.             if(stats.mode != GameEngineStats.MODE_LEVELDESIGNER)
  281.             {
  282.             }
  283.             WeatherHandler.display();
  284.             DeltaWallHandler.attach();
  285.             TextHandler.attach();
  286.             Main.getStage().addChild(course);
  287.             Main.getStage().addChild(top);
  288.             Main.getStage().addChild(signLayer);
  289.             if(debugStats != null)
  290.             {
  291.                Main.getStage().addChild(debugStats);
  292.             }
  293.             GameEngine.stats.heroStats.countDelta();
  294.             gravity_dir = stats.level.startgravity_dir;
  295.             switch(stats.mode)
  296.             {
  297.                case GameEngineStats.MODE_LEVELDESIGNER:
  298.                   LevelDesignerEngine.start();
  299.                   break;
  300.                case GameEngineStats.MODE_GAMEPLAY:
  301.                   GameplayEngine.start();
  302.                   break;
  303.                case GameEngineStats.MODE_CINEMA:
  304.                   CinemaEngine.start();
  305.                   break;
  306.                default:
  307.                   throw new Error("Unsupported game mode!");
  308.             }
  309.             Main.getStage().addChild(transitionLayer);
  310.             Main.getStage().removeChild(loading);
  311.             loading = null;
  312.             if(Main.edges != null)
  313.             {
  314.             }
  315.             Main.getStage().addEventListener(Event.ENTER_FRAME,enterFrame);
  316.             Main.getStage().addEventListener(Event.DEACTIVATE,focusOut);
  317.             Main.getStage().addEventListener(Event.ACTIVATE,focusIn);
  318.             Main.getStage().stage.focus = null;
  319.             removed = false;
  320.             enterFrame(null);
  321.             if(GameEngine.stats.mode != GameEngineStats.MODE_LEVELDESIGNER)
  322.             {
  323.                GameEngine.currentTransition = new Transition_Black(false,function finish():void
  324.                {
  325.                },10);
  326.                GameEngine.currentTransition.attach();
  327.             }
  328.          };
  329.          removed = false;
  330.          slice = stats.getCurrentSlice();
  331.          camera = new Camera();
  332.          camera.camX = stats.heroStats.x;
  333.          camera.camY = stats.heroStats.y;
  334.          midbg_xoffset = slice.midbg_xoffset;
  335.          midbg_yoffset = slice.midbg_yoffset;
  336.          bg = BGFactory.createBG(slice.bg_num);
  337.          closeBG = BGFactory.createCloseBG(slice.midbg_num);
  338.          course = new Course();
  339.          course.x = Main.visibleContent.x + Main.visibleContent.width / 2;
  340.          course.y = Main.visibleContent.y + Main.visibleContent.height / 2;
  341.          top = new MovieClip();
  342.          top.x = Main.visibleContent.x;
  343.          top.y = Main.visibleContent.y;
  344.          top.scaleX = Main.visibleContent.width / Main.WIDTH;
  345.          top.scaleY = Main.visibleContent.height / Main.HEIGHT;
  346.          signLayer = new MovieClip();
  347.          signLayer.x = Main.visibleContent.x;
  348.          signLayer.y = Main.visibleContent.y;
  349.          signLayer.scaleX = Main.visibleContent.width / Main.WIDTH;
  350.          signLayer.scaleY = Main.visibleContent.height / Main.HEIGHT;
  351.          transitionLayer = new MovieClip();
  352.          transitionLayer.x = Main.visibleContent.x;
  353.          transitionLayer.y = Main.visibleContent.y;
  354.          transitionLayer.scaleX = Main.visibleContent.width / Main.WIDTH;
  355.          transitionLayer.scaleY = Main.visibleContent.height / Main.HEIGHT;
  356.          if(inTransition != null)
  357.          {
  358.             inTransition.attach();
  359.             currentTransition = inTransition;
  360.          }
  361.          enterFrameArray = new Vector.<IEnterFrame>();
  362.          triggerArray = new Vector.<FunctionSequence>();
  363.          deltaEffectorArray = new Vector.<DeltaEffector>();
  364.          enemyArray = new Vector.<Enemy>();
  365.          boulderArray = new Vector.<Boulder>();
  366.          deltaModifierArray = new Vector.<DeltaModifier>();
  367.          spikesArray = new Vector.<Spikes>();
  368.          spliter_XArray = new Vector.<Item_Splitter_X>();
  369.          platforms_Cloud = new Vector.<Platform_Cloud>();
  370.          platforms_Ground = new Vector.<Platform_Ground>();
  371.          platforms_Damage = new Vector.<Platform_Damage>();
  372.          gravityZones = new Vector.<GravityZone>();
  373.          projectileArray = new Vector.<Projectile>();
  374.          particleArray = new Vector.<Particle>();
  375.          runTriggerCount = 0;
  376.          TileHandler.start();
  377.          WeatherHandler.start();
  378.          new DeltaWallHandler();
  379.          course.attachItems(onDone);
  380.       }
  381.      
  382.       public static function saveHeroStatsToTemp() : void
  383.       {
  384.          tempHeroStats = course.hero.stats;
  385.       }
  386.      
  387.       public static function triggerGameWin() : void
  388.       {
  389.          var _loc1_:GameWinStats = new GameWinStats();
  390.          _loc1_.coins = getGlobalVar("g_COINS");
  391.          _loc1_.endingHeroStats = tempHeroStats;
  392.          _loc1_.levelNum = stats.levelnum;
  393.          _loc1_.hardMode = stats.hardMode;
  394.          _loc1_.largeCoins[0] = stats.collectedLargeSquares[0];
  395.          _loc1_.largeCoins[1] = stats.collectedLargeSquares[1];
  396.          _loc1_.largeCoins[2] = stats.collectedLargeSquares[2];
  397.          _loc1_.time = stats.timeElasped;
  398.          stats.onWin(_loc1_);
  399.       }
  400.      
  401.       public static function triggerPrematureQuit() : void
  402.       {
  403.          var _loc1_:GameWinStats = new GameWinStats();
  404.          _loc1_.coins = getGlobalVar("g_COINS");
  405.          _loc1_.endingHeroStats = tempHeroStats;
  406.          _loc1_.levelNum = stats.levelnum;
  407.          _loc1_.hardMode = stats.hardMode;
  408.          _loc1_.largeCoins[0] = stats.collectedLargeSquares[0];
  409.          _loc1_.largeCoins[1] = stats.collectedLargeSquares[1];
  410.          _loc1_.largeCoins[2] = stats.collectedLargeSquares[2];
  411.          _loc1_.time = stats.timeElasped;
  412.          stats.onQuit(_loc1_);
  413.       }
  414.      
  415.       public static function generatePauseMenu(param1:int) : void
  416.       {
  417.          pauseMenu.generate(param1);
  418.       }
  419.      
  420.       private static function removePauseMenu() : void
  421.       {
  422.          pauseMenu.remove();
  423.       }
  424.      
  425.       private static function focusOut(param1:Event) : void
  426.       {
  427.          KeyEngine.forceAllKeysUnpressed();
  428.          if(!pauseMenu.exists)
  429.          {
  430.             generatePauseMenu(HUD_Shell.MODE_MAIN);
  431.          }
  432.       }
  433.      
  434.       private static function focusIn(param1:Event) : void
  435.       {
  436.          KeyEngine.forceAllKeysUnpressed();
  437.          if(stats.mode != GameEngineStats.MODE_GAMEPLAY)
  438.          {
  439.             paused = false;
  440.          }
  441.       }
  442.      
  443.       private static function pauseEnterFrame() : void
  444.       {
  445.          pauseMenu.enterFrame();
  446.       }
  447.      
  448.       private static function enterFrame(param1:Event) : void
  449.       {
  450.          var i:int = 0;
  451.          var zoom:Number = NaN;
  452.          var e:Event = param1;
  453.          BehaviorHandler.enterFrame();
  454.          if(removed)
  455.          {
  456.             return;
  457.          }
  458.          if(paused)
  459.          {
  460.             pauseEnterFrame();
  461.             return;
  462.          }
  463.          if(stats.mode == GameEngineStats.MODE_GAMEPLAY)
  464.          {
  465.             if(KeyEngine.ld("p") <= 1)
  466.             {
  467.                generatePauseMenu(HUD_Shell.MODE_MAIN);
  468.             }
  469.             else if(KeyEngine.ld("e") <= 1)
  470.             {
  471.                generatePauseMenu(HUD_Shell.MODE_INVENTORY);
  472.             }
  473.          }
  474.          if(currentTransition != null)
  475.          {
  476.             if(currentTransition.exists == true)
  477.             {
  478.                currentTransition.enterFrame();
  479.             }
  480.             else
  481.             {
  482.                currentTransition.remove();
  483.                currentTransition = null;
  484.             }
  485.          }
  486.          if(removed)
  487.          {
  488.             return;
  489.          }
  490.          try
  491.          {
  492.             if(QualityHandler.frameRate == 60)
  493.             {
  494.                framerateMultiplier = 0.5;
  495.                worldSpeed = _worldSpeed * 0.5;
  496.             }
  497.             else
  498.             {
  499.                framerateMultiplier = 1;
  500.                worldSpeed = _worldSpeed;
  501.             }
  502.             if(deltaLevel > 1)
  503.             {
  504.                worldSpeed = worldSpeed / deltaLevel;
  505.             }
  506.             camera.beginFrame();
  507.             WeatherHandler.enterFrame();
  508.             TextHandler.enterFrame();
  509.             if(WaterSurface.updateGraphics)
  510.             {
  511.                WaterSurface.updateWaterGFX();
  512.                WaterSurface.updateGraphics = false;
  513.             }
  514.             switch(stats.mode)
  515.             {
  516.                case GameEngineStats.MODE_LEVELDESIGNER:
  517.                   LevelDesignerEngine.enterFrame();
  518.                   break;
  519.                case GameEngineStats.MODE_GAMEPLAY:
  520.                   GameplayEngine.enterFrame();
  521.                   break;
  522.                case GameEngineStats.MODE_CINEMA:
  523.                   CinemaEngine.enterFrame();
  524.                   break;
  525.                default:
  526.                   throw new Error("Unsupported game mode!");
  527.             }
  528.             if(removed)
  529.             {
  530.                return;
  531.             }
  532.             DeltaWallHandler.handleDeltaWalls();
  533.             deltaEnterFrame();
  534.             usingScreenBuffer = deltaTransformed || (QualityHandler.useScreenBuffer || WeatherHandler.post != null);
  535.             if((QualityHandler.useScreenBuffer || WeatherHandler.post != null) && deltaTransformed == false)
  536.             {
  537.                if(screenBuffer == null)
  538.                {
  539.                   screenBuffer = new BitmapData(Main.WIDTH,Main.HEIGHT,false,0);
  540.                }
  541.                if(screenBufferBit == null)
  542.                {
  543.                   screenBufferBit = new Bitmap(screenBuffer);
  544.                   Main.getStage().addChildAt(screenBufferBit,0);
  545.                   screenBufferBit.x = Main.visibleContent.x;
  546.                   screenBufferBit.y = Main.visibleContent.y;
  547.                   screenBufferBit.scaleX = Main.visibleContent.width / Main.WIDTH;
  548.                   screenBufferBit.scaleY = Main.visibleContent.height / Main.HEIGHT;
  549.                   if(bg != null)
  550.                   {
  551.                      bg.setVisible(false);
  552.                   }
  553.                   if(closeBG != null)
  554.                   {
  555.                      closeBG.setVisible(false);
  556.                   }
  557.                }
  558.                course.visible = false;
  559.                top.visible = false;
  560.                screenBuffer.lock();
  561.                if(bg != null)
  562.                {
  563.                   bg.drawTo(screenBuffer);
  564.                }
  565.                else
  566.                {
  567.                   screenBuffer.fillRect(screenBuffer.rect,0);
  568.                }
  569.                if(closeBG != null)
  570.                {
  571.                   closeBG.drawTo(screenBuffer);
  572.                }
  573.                zoom = camera.currentZoom / 100;
  574.                if(QualityHandler.canZoom == false)
  575.                {
  576.                   zoom = 1;
  577.                }
  578.                screenBuffer.draw(course,new Matrix(zoom,0,0,zoom,Main.WIDTH / 2,Main.HEIGHT / 2));
  579.                screenBuffer.draw(top,new Matrix(1,0,0,1,0,0));
  580.                if(WeatherHandler.post != null)
  581.                {
  582.                   if(WeatherHandler.post.supportsOnlyColorTransform())
  583.                   {
  584.                      screenBuffer.colorTransform(screenBuffer.rect,WeatherHandler.post.getColorTransform());
  585.                   }
  586.                   else
  587.                   {
  588.                      screenBuffer.applyFilter(screenBuffer,screenBuffer.rect,new Point(),new ColorMatrixFilter(WeatherHandler.post.getMatrix()));
  589.                   }
  590.                }
  591.                screenBuffer.unlock();
  592.             }
  593.             else
  594.             {
  595.                if(screenBuffer != null)
  596.                {
  597.                   if(deltaTransformed == false)
  598.                   {
  599.                      if(bg != null)
  600.                      {
  601.                         bg.setVisible(true);
  602.                      }
  603.                      if(closeBG != null)
  604.                      {
  605.                         closeBG.setVisible(true);
  606.                      }
  607.                      course.visible = true;
  608.                      top.visible = true;
  609.                   }
  610.                   screenBuffer.dispose();
  611.                   screenBuffer = null;
  612.                }
  613.                if(screenBufferBit != null)
  614.                {
  615.                   Main.getStage().removeChild(screenBufferBit);
  616.                   screenBufferBit = null;
  617.                }
  618.             }
  619.             if(WeatherHandler.weather_darkness != null)
  620.             {
  621.                if(WeatherHandler.weather_darkness.screenLocked == true)
  622.                {
  623.                   WeatherHandler.weather_darkness.unlockScreen();
  624.                }
  625.             }
  626.             MusicHandler.refreshVolume();
  627.             if(trigger_cinemaMode == false && heroAnimation_cinemaMode == false && heroAnimation_wormholeCinema == false)
  628.             {
  629.                stats.timeElasped = stats.timeElasped + framerateMultiplier / 30;
  630.             }
  631.             return;
  632.          }
  633.          catch(ended:GameEndedException)
  634.          {
  635.             ended.close();
  636.             return;
  637.          }
  638.       }
  639.      
  640.       public static function callEnterFrames() : void
  641.       {
  642.          var _loc1_:int = 0;
  643.          if(course.attachingItems == false)
  644.          {
  645.             if(deathPause == false)
  646.             {
  647.                _loc1_ = 0;
  648.                while(_loc1_ < enterFrameArray.length)
  649.                {
  650.                   if(enterFrameArray[_loc1_].enterFrame())
  651.                   {
  652.                      if(removed)
  653.                      {
  654.                         throw new GameEndedException();
  655.                      }
  656.                      enterFrameArray[_loc1_].enterFrameRemoved();
  657.                      enterFrameArray.splice(_loc1_--,1);
  658.                   }
  659.                   _loc1_++;
  660.                }
  661.                if(heroAnimation_cinemaMode == false)
  662.                {
  663.                   _loc1_ = 0;
  664.                   while(_loc1_ < projectileArray.length)
  665.                   {
  666.                      if(projectileArray[_loc1_].exists == true)
  667.                      {
  668.                         projectileArray[_loc1_].enterFrame();
  669.                      }
  670.                      else
  671.                      {
  672.                         projectileArray.splice(_loc1_--,1);
  673.                      }
  674.                      _loc1_++;
  675.                   }
  676.                }
  677.                _loc1_ = 0;
  678.                while(_loc1_ < particleArray.length)
  679.                {
  680.                   if(particleArray[_loc1_].exists == true)
  681.                   {
  682.                      particleArray[_loc1_].enterFrame();
  683.                   }
  684.                   else
  685.                   {
  686.                      particleArray.splice(_loc1_--,1);
  687.                   }
  688.                   _loc1_++;
  689.                }
  690.                _loc1_ = 0;
  691.                while(_loc1_ < platforms_Cloud.length)
  692.                {
  693.                   if(platforms_Cloud[_loc1_].exists_cloud() == false)
  694.                   {
  695.                      platforms_Cloud.splice(_loc1_--,1);
  696.                   }
  697.                   _loc1_++;
  698.                }
  699.                _loc1_ = 0;
  700.                while(_loc1_ < platforms_Ground.length)
  701.                {
  702.                   if(platforms_Ground[_loc1_].exists_ground() == false)
  703.                   {
  704.                      platforms_Ground.splice(_loc1_--,1);
  705.                   }
  706.                   _loc1_++;
  707.                }
  708.                _loc1_ = 0;
  709.                while(_loc1_ < platforms_Damage.length)
  710.                {
  711.                   if(platforms_Damage[_loc1_].exists_damage() == false)
  712.                   {
  713.                      platforms_Damage.splice(_loc1_--,1);
  714.                   }
  715.                   _loc1_++;
  716.                }
  717.                _loc1_ = 0;
  718.                while(_loc1_ < gravityZones.length)
  719.                {
  720.                   if(gravityZones[_loc1_].exists_gravityZone() == false)
  721.                   {
  722.                      gravityZones.splice(_loc1_--,1);
  723.                   }
  724.                   _loc1_++;
  725.                }
  726.                if(heroAnimation_cinemaMode == false)
  727.                {
  728.                   if(QualityHandler.frameRate == 60)
  729.                   {
  730.                      runTriggerCount = runTriggerCount + 0.5;
  731.                   }
  732.                   else
  733.                   {
  734.                      runTriggerCount = runTriggerCount + 1;
  735.                   }
  736.                   if(runTriggerCount >= 1)
  737.                   {
  738.                      _loc1_ = 0;
  739.                      while(_loc1_ < triggerArray.length)
  740.                      {
  741.                         if(triggerArray[_loc1_].run())
  742.                         {
  743.                            triggerArray[_loc1_].removedFromList();
  744.                            triggerArray.splice(_loc1_--,1);
  745.                         }
  746.                         _loc1_++;
  747.                      }
  748.                      runTriggerCount = runTriggerCount - 1;
  749.                   }
  750.                   trigger_cinemaMode = false;
  751.                   _loc1_ = 0;
  752.                   while(_loc1_ < triggerArray.length)
  753.                   {
  754.                      if(triggerArray[_loc1_].playing)
  755.                      {
  756.                         triggerArray[_loc1_].apply();
  757.                      }
  758.                      _loc1_++;
  759.                   }
  760.                   _loc1_ = 0;
  761.                   while(_loc1_ < deltaEffectorArray.length)
  762.                   {
  763.                      if(deltaEffectorArray[_loc1_].enterFrame())
  764.                      {
  765.                         if(deltaEffectorArray[_loc1_].parent != null)
  766.                         {
  767.                            deltaEffectorArray[_loc1_].parent.removeChild(deltaEffectorArray[_loc1_]);
  768.                         }
  769.                         deltaEffectorArray.splice(_loc1_--,1);
  770.                      }
  771.                      _loc1_++;
  772.                   }
  773.                   _loc1_ = 0;
  774.                   while(_loc1_ < enemyArray.length)
  775.                   {
  776.                      if(enemyArray[_loc1_].exists == true)
  777.                      {
  778.                         enemyArray[_loc1_].enterFrame();
  779.                      }
  780.                      else
  781.                      {
  782.                         enemyArray.splice(_loc1_--,1);
  783.                      }
  784.                      _loc1_++;
  785.                   }
  786.                   _loc1_ = 0;
  787.                   while(_loc1_ < boulderArray.length)
  788.                   {
  789.                      if(boulderArray[_loc1_].exists == true)
  790.                      {
  791.                         boulderArray[_loc1_].enterFrame();
  792.                      }
  793.                      else
  794.                      {
  795.                         boulderArray.splice(_loc1_--,1);
  796.                      }
  797.                      _loc1_++;
  798.                   }
  799.                }
  800.             }
  801.          }
  802.       }
  803.      
  804.       public static function transitionTo(param1:int) : void
  805.       {
  806.          var newSlice:int = param1;
  807.          stats.heroStats.x = course.hero.x;
  808.          stats.heroStats.y = course.hero.y;
  809.          stats.heroStats.xspeed = course.hero.xspeed;
  810.          stats.heroStats.yspeed = course.hero.yspeed;
  811.          stats.heroStats.direction = course.hero.Direction;
  812.          stats.currentSlice = newSlice;
  813.          remove();
  814.          throw new GameEndedException(function go():void
  815.          {
  816.             start(stats);
  817.          });
  818.       }
  819.      
  820.       public static function door_transitionTo(param1:Number, param2:Number) : void
  821.       {
  822.          var _loc4_:int = 0;
  823.          var _loc5_:* = null;
  824.          if(course.hero == null)
  825.          {
  826.             return;
  827.          }
  828.          course.hero.x = param1;
  829.          course.hero.y = param2;
  830.          var _loc3_:int = -1;
  831.          while(_loc4_ < stats.slices.length)
  832.          {
  833.             _loc5_ = stats.slices[_loc4_];
  834.             if(param1 >= _loc5_.leftX && param1 < _loc5_.rightX && param2 >= _loc5_.upY && param2 < _loc5_.downY)
  835.             {
  836.                _loc3_ = _loc4_;
  837.                break;
  838.             }
  839.             _loc4_++;
  840.          }
  841.          if(_loc3_ != -1)
  842.          {
  843.             transitionTo(_loc3_);
  844.          }
  845.          else
  846.          {
  847.             camera.camX = course.hero.centerX;
  848.             camera.camY = course.hero.centerY;
  849.             camera.zoom = 100;
  850.             TileHandler.teleportCamera(camera.camX,camera.camY);
  851.             GameEngine.currentTransition = new Transition_Black(false,null,10);
  852.             GameEngine.currentTransition.attach();
  853.          }
  854.       }
  855.      
  856.       public static function setItemLoadingProgress(param1:Number) : void
  857.       {
  858.          if(loading != null)
  859.          {
  860.             if(loading is LevelPreloader)
  861.             {
  862.                (loading as LevelPreloader)._bar._fill.scaleX = param1;
  863.             }
  864.          }
  865.       }
  866.      
  867.       public static function resetCameraPosition() : void
  868.       {
  869.          var _loc4_:* = null;
  870.          var _loc1_:int = 0;
  871.          var _loc2_:int = 0;
  872.          var _loc3_:int = 0;
  873.          _loc1_ = 0;
  874.          while(_loc1_ < stats.level.itemLayers.allItems.length)
  875.          {
  876.             _loc4_ = stats.level.itemLayers.allItems[_loc1_];
  877.             if(_loc4_.num == 0 && _loc4_.cl == Item_StartPosition)
  878.             {
  879.                _loc2_ = _loc4_.x;
  880.                _loc3_ = _loc4_.y;
  881.                break;
  882.             }
  883.             _loc1_++;
  884.          }
  885.          camera.camX = _loc2_;
  886.          camera.camY = _loc3_;
  887.          camera.zoom = 100;
  888.          TileHandler.teleportCamera(camera.camX,camera.camY);
  889.       }
  890.      
  891.       public static function clearTilesColorData() : void
  892.       {
  893.          slice.levelData.backTiles.clearColors();
  894.          slice.levelData.frontTiles.clearColors();
  895.       }
  896.      
  897.       public static function setTilesColorData(param1:Function) : void
  898.       {
  899.          var i:int = 0;
  900.          var items:Vector.<Item> = null;
  901.          var doItems:Function = null;
  902.          var onComplete:Function = param1;
  903.          doItems = function(param1:Event):void
  904.          {
  905.             var _loc3_:int = 0;
  906.             var _loc4_:int = 0;
  907.             var _loc5_:int = 0;
  908.             var _loc6_:int = 0;
  909.             var _loc7_:* = null;
  910.             var _loc8_:* = null;
  911.             var _loc9_:* = null;
  912.             var _loc2_:int = getTimer();
  913.             while(i < items.length)
  914.             {
  915.                _loc7_ = items[i];
  916.                if(_loc7_.cl == Item_ColorBox)
  917.                {
  918.                   _loc8_ = _loc7_ as Item_ColorBox;
  919.                   _loc3_ = (_loc8_.x - slice.leftX) / 32;
  920.                   _loc4_ = (_loc8_.y - slice.upY) / 32;
  921.                   _loc6_ = _loc4_;
  922.                   while(_loc6_ < _loc8_.height + _loc4_)
  923.                   {
  924.                      _loc5_ = _loc3_;
  925.                      while(_loc5_ < _loc8_.width + _loc3_)
  926.                      {
  927.                         if(_loc5_ >= 0 && _loc6_ >= 0)
  928.                         {
  929.                            if(_loc5_ >= slice.levelData.width)
  930.                            {
  931.                               _loc5_ = _loc8_.width + _loc3_;
  932.                               break;
  933.                            }
  934.                            if(_loc6_ >= slice.levelData.height)
  935.                            {
  936.                               _loc5_ = _loc8_.width + _loc3_;
  937.                               _loc6_ = _loc8_.height + _loc4_;
  938.                               break;
  939.                            }
  940.                            if(_loc8_.itemLayer.layerNum <= 1)
  941.                            {
  942.                               slice.levelData.backTiles.getTileAt(_loc5_,_loc6_).colors = _loc8_.colors;
  943.                            }
  944.                            else
  945.                            {
  946.                               slice.levelData.frontTiles.getTileAt(_loc5_,_loc6_).colors = _loc8_.colors;
  947.                            }
  948.                         }
  949.                         _loc5_++;
  950.                      }
  951.                      _loc6_++;
  952.                   }
  953.                }
  954.                if(_loc7_.cl == Item_DeltaNegate)
  955.                {
  956.                   _loc9_ = _loc7_ as Item_DeltaNegate;
  957.                   _loc3_ = _loc9_.x / 32;
  958.                   _loc4_ = _loc9_.y / 32;
  959.                   _loc6_ = _loc4_;
  960.                   while(_loc6_ < _loc9_.height + _loc4_)
  961.                   {
  962.                      _loc5_ = _loc3_;
  963.                      while(_loc5_ < _loc9_.width + _loc3_)
  964.                      {
  965.                         if(_loc5_ >= 0 && _loc6_ >= 0)
  966.                         {
  967.                            if(_loc5_ >= slice.levelData.width)
  968.                            {
  969.                               _loc5_ = _loc9_.width + _loc3_;
  970.                               break;
  971.                            }
  972.                            if(_loc6_ >= slice.levelData.height)
  973.                            {
  974.                               _loc5_ = _loc9_.width + _loc3_;
  975.                               _loc6_ = _loc9_.height + _loc4_;
  976.                               break;
  977.                            }
  978.                            if(_loc9_.itemLayer.layerNum > 1)
  979.                            {
  980.                               slice.levelData.frontTiles.getTileAt(_loc5_,_loc6_).overwrite = _loc9_.overwrite;
  981.                            }
  982.                         }
  983.                         _loc5_++;
  984.                      }
  985.                      _loc6_++;
  986.                   }
  987.                }
  988.                i++;
  989.                if(getTimer() - _loc2_ > loadingThreshold)
  990.                {
  991.                   return;
  992.                }
  993.             }
  994.             Main.getStage().removeEventListener(Event.ENTER_FRAME,doItems);
  995.             onComplete();
  996.          };
  997.          items = slice.levelData.itemLayers.allItems;
  998.          Main.getStage().addEventListener(Event.ENTER_FRAME,doItems);
  999.          doItems(null);
  1000.       }
  1001.      
  1002.       public static function updateLinkage(param1:Item, param2:String) : void
  1003.       {
  1004.          if(param1.linkage != null && param1.linkage != "")
  1005.          {
  1006.             stats.level.itemLayers.removeLinkage(param1.linkage,param1);
  1007.          }
  1008.          param1.linkage = param2;
  1009.          if(param1.linkage != null && param1.linkage != "")
  1010.          {
  1011.             stats.level.itemLayers.addLinkage(param1.linkage,param1);
  1012.          }
  1013.       }
  1014.      
  1015.       public static function isValidTagName_Write(param1:String) : Boolean
  1016.       {
  1017.          var _loc2_:int = 0;
  1018.          var _loc3_:* = null;
  1019.          if(param1 == null)
  1020.          {
  1021.             return true;
  1022.          }
  1023.          if(param1 == "")
  1024.          {
  1025.             return true;
  1026.          }
  1027.          if(FunctionSequence.isSelfTag(param1))
  1028.          {
  1029.             return false;
  1030.          }
  1031.          if(param1.length >= 1)
  1032.          {
  1033.             _loc2_ = param1.charCodeAt(0);
  1034.             _loc3_ = param1.charAt(0);
  1035.             if(_loc2_ >= 48 && _loc2_ <= 57)
  1036.             {
  1037.                return false;
  1038.             }
  1039.             if(_loc3_ == ".")
  1040.             {
  1041.                return false;
  1042.             }
  1043.             return true;
  1044.          }
  1045.          return true;
  1046.       }
  1047.      
  1048.       public static function isValidTagName_Read(param1:String) : Boolean
  1049.       {
  1050.          var _loc2_:int = 0;
  1051.          var _loc3_:* = null;
  1052.          if(param1 == null)
  1053.          {
  1054.             return false;
  1055.          }
  1056.          if(param1 == "")
  1057.          {
  1058.             return false;
  1059.          }
  1060.          if(param1.length >= 1)
  1061.          {
  1062.             _loc2_ = param1.charCodeAt(0);
  1063.             _loc3_ = param1.charAt(0);
  1064.             if(_loc2_ >= 48 && _loc2_ <= 57)
  1065.             {
  1066.                return false;
  1067.             }
  1068.             if(_loc3_ == ".")
  1069.             {
  1070.                return false;
  1071.             }
  1072.             return true;
  1073.          }
  1074.          return true;
  1075.       }
  1076.      
  1077.       public static function isValidVarName(param1:String) : Boolean
  1078.       {
  1079.          var _loc2_:int = 0;
  1080.          var _loc3_:* = null;
  1081.          if(param1 == null)
  1082.          {
  1083.             return false;
  1084.          }
  1085.          if(param1.length >= 1)
  1086.          {
  1087.             _loc2_ = param1.charCodeAt(0);
  1088.             _loc3_ = param1.charAt(0);
  1089.             if(_loc2_ >= 48 && _loc2_ <= 57)
  1090.             {
  1091.                return false;
  1092.             }
  1093.             if(_loc3_ == ".")
  1094.             {
  1095.                return false;
  1096.             }
  1097.             return true;
  1098.          }
  1099.          return false;
  1100.       }
  1101.      
  1102.       public static function isVarANumber(param1:String) : Boolean
  1103.       {
  1104.          var _loc2_:int = 0;
  1105.          if(param1 == null)
  1106.          {
  1107.             return false;
  1108.          }
  1109.          if(param1.length >= 1)
  1110.          {
  1111.             _loc2_ = param1.charCodeAt(0);
  1112.             if(_loc2_ >= 48 && _loc2_ <= 57)
  1113.             {
  1114.                return true;
  1115.             }
  1116.          }
  1117.          return false;
  1118.       }
  1119.      
  1120.       public static function isStaticGlobalVar(param1:String) : Boolean
  1121.       {
  1122.          if(param1.slice(0,2) == "s_")
  1123.          {
  1124.             return true;
  1125.          }
  1126.          return false;
  1127.       }
  1128.      
  1129.       public static function getGlobalVar(param1:String) : int
  1130.       {
  1131.          var str:String = param1;
  1132.          var r:int = 0;
  1133.          if(isVarANumber(str))
  1134.          {
  1135.             try
  1136.             {
  1137.                r = parseInt(str);
  1138.             }
  1139.             catch(e:Error)
  1140.             {
  1141.                r = 0;
  1142.             }
  1143.          }
  1144.          else if(isStaticGlobalVar(str))
  1145.          {
  1146.             r = stats.staticVars[str];
  1147.          }
  1148.          else if(stats.level.globalVars[str] != null)
  1149.          {
  1150.             r = stats.level.globalVars[str];
  1151.          }
  1152.          return r;
  1153.       }
  1154.      
  1155.       public static function setVar(param1:String, param2:int) : void
  1156.       {
  1157.          if(isStaticGlobalVar(param1))
  1158.          {
  1159.             stats.staticVars[param1] = param2;
  1160.          }
  1161.          else
  1162.          {
  1163.             stats.level.globalVars[param1] = param2;
  1164.          }
  1165.       }
  1166.      
  1167.       public static function numberOfItemsWithThisTag(param1:String) : int
  1168.       {
  1169.          if(param1 == null)
  1170.          {
  1171.             return 0;
  1172.          }
  1173.          if(param1 == "")
  1174.          {
  1175.             return 0;
  1176.          }
  1177.          if(FunctionSequence.isSelfTag(param1))
  1178.          {
  1179.             return 1;
  1180.          }
  1181.          var _loc2_:Vector.<Item> = getLinkageFromGlobal(param1);
  1182.          if(_loc2_ == null)
  1183.          {
  1184.             return 0;
  1185.          }
  1186.          return _loc2_.length;
  1187.       }
  1188.      
  1189.       public static function getLinkage(param1:String) : Vector.<Item>
  1190.       {
  1191.          return slice.levelData.itemLayers.getLinkage(param1);
  1192.       }
  1193.      
  1194.       public static function getLinkageFromGlobal(param1:String) : Vector.<Item>
  1195.       {
  1196.          return stats.level.itemLayers.getLinkage(param1);
  1197.       }
  1198.      
  1199.       public static function findCenterOfVItem(param1:Vector.<Item>) : Point
  1200.       {
  1201.          var _loc5_:int = 0;
  1202.          if(param1 == null)
  1203.          {
  1204.             return new Point();
  1205.          }
  1206.          var _loc2_:* = 0;
  1207.          var _loc3_:* = 0;
  1208.          var _loc4_:int = param1.length;
  1209.          _loc5_ = 0;
  1210.          while(_loc5_ < _loc4_)
  1211.          {
  1212.             _loc2_ = Number(_loc2_ + param1[_loc5_].x);
  1213.             _loc3_ = Number(_loc3_ + param1[_loc5_].y);
  1214.             _loc5_++;
  1215.          }
  1216.          _loc2_ = Number(_loc2_ / _loc4_);
  1217.          _loc3_ = Number(_loc3_ / _loc4_);
  1218.          return new Point(_loc2_,_loc3_);
  1219.       }
  1220.      
  1221.       public static function resyncItems() : void
  1222.       {
  1223.          var _loc2_:int = 0;
  1224.          var _loc1_:Vector.<Item> = slice.levelData.itemLayers.allItems;
  1225.          _loc2_ = 0;
  1226.          while(_loc2_ < _loc1_.length)
  1227.          {
  1228.             if(_loc1_[_loc2_] is ISynchronize)
  1229.             {
  1230.                (_loc1_[_loc2_] as ISynchronize).resyncronize();
  1231.             }
  1232.             _loc2_++;
  1233.          }
  1234.       }
  1235.      
  1236.       public static function getGravityAt(param1:int, param2:int) : Point
  1237.       {
  1238.          var _loc5_:int = 0;
  1239.          var _loc6_:Number = NaN;
  1240.          var _loc3_:Number = Number.MAX_VALUE;
  1241.          var _loc4_:* = null;
  1242.          _loc5_ = 0;
  1243.          while(_loc5_ < gravityZones.length)
  1244.          {
  1245.             _loc6_ = gravityZones[_loc5_].hitTest_gravityZone(param1,param2);
  1246.             if(_loc6_ < _loc3_)
  1247.             {
  1248.                _loc3_ = _loc6_;
  1249.                _loc4_ = gravityZones[_loc5_];
  1250.             }
  1251.             _loc5_++;
  1252.          }
  1253.          if(_loc4_ != null)
  1254.          {
  1255.             gravityPoint = _loc4_.getGravityAt(param1,param2);
  1256.          }
  1257.          else
  1258.          {
  1259.             gravityPoint.x = Math.cos((gravity_dir + 90) * Math.PI / 180);
  1260.             gravityPoint.y = Math.sin((gravity_dir + 90) * Math.PI / 180);
  1261.          }
  1262.          return gravityPoint;
  1263.       }
  1264.      
  1265.       public static function setGravityStatsAt(param1:GravityStats) : void
  1266.       {
  1267.          var _loc4_:int = 0;
  1268.          var _loc5_:Number = NaN;
  1269.          var _loc2_:Number = Number.MAX_VALUE;
  1270.          var _loc3_:* = null;
  1271.          _loc4_ = 0;
  1272.          while(_loc4_ < gravityZones.length)
  1273.          {
  1274.             _loc5_ = gravityZones[_loc4_].hitTest_gravityZone(param1.x,param1.y);
  1275.             if(_loc5_ < _loc2_)
  1276.             {
  1277.                _loc2_ = _loc5_;
  1278.                _loc3_ = gravityZones[_loc4_];
  1279.             }
  1280.             _loc4_++;
  1281.          }
  1282.          param1.setZone(_loc3_);
  1283.       }
  1284.      
  1285.       public static function getGravityAngleAt(param1:int, param2:int) : Number
  1286.       {
  1287.          var _loc3_:Point = getGravityAt(param1,param2);
  1288.          return Math.atan2(_loc3_.x,_loc3_.y) * 180 / Math.PI;
  1289.       }
  1290.      
  1291.       public static function hitTestGroundOrPlatforms(param1:int, param2:int) : Boolean
  1292.       {
  1293.          return hitTestGround(param1,param2) || hitTestPlatforms(param1,param2);
  1294.       }
  1295.      
  1296.       public static function getNormalOnGround(param1:int, param2:int, param3:Number = 10) : Number
  1297.       {
  1298.          var _loc4_:* = 0;
  1299.          var _loc5_:Number = Math.PI / 8;
  1300.          while(_loc5_ > 0.01)
  1301.          {
  1302.             if(hitTestGroundOrPlatforms(param1 + Math.cos(_loc4_) * param3,param2 + Math.sin(_loc4_) * param3))
  1303.             {
  1304.                _loc4_ = Number(_loc4_ - _loc5_);
  1305.             }
  1306.             else
  1307.             {
  1308.                _loc4_ = Number(_loc4_ + _loc5_);
  1309.             }
  1310.             _loc5_ = _loc5_ / 1.1;
  1311.          }
  1312.          return _loc4_ - Math.PI / 2;
  1313.       }
  1314.      
  1315.       public static function hitTestGround(param1:int, param2:int) : Boolean
  1316.       {
  1317.          var _loc5_:int = 0;
  1318.          var _loc6_:* = 0;
  1319.          var _loc7_:int = 0;
  1320.          var _loc8_:int = 0;
  1321.          var _loc9_:int = 0;
  1322.          var _loc10_:Number = NaN;
  1323.          var _loc3_:int = param1 - TileHandler.mx * 32 + TileHandler.tx * 16 - slice.leftX;
  1324.          var _loc4_:int = param2 - TileHandler.my * 32 + TileHandler.ty * 16 - slice.upY;
  1325.          if(_loc3_ >= 0 && _loc4_ >= 0 && _loc3_ < course.groundTiles.width && _loc4_ < course.groundTiles.height)
  1326.          {
  1327.             _loc6_ = uint(course.groundTiles.getPixel(_loc3_,_loc4_));
  1328.             if((_loc6_ & 65280) == 65280)
  1329.             {
  1330.                return true;
  1331.             }
  1332.          }
  1333.          else
  1334.          {
  1335.             _loc7_ = TileHandler.mx + (_loc3_ - TileHandler.tx * 16) / 32;
  1336.             _loc8_ = TileHandler.my + (_loc4_ - TileHandler.ty * 16) / 32;
  1337.             _loc9_ = slice.levelData.frontTiles.getTileNumAt(_loc7_,_loc8_);
  1338.             if(_loc9_ >= 1 && _loc9_ != 1000)
  1339.             {
  1340.                return true;
  1341.             }
  1342.          }
  1343.          _loc5_ = 0;
  1344.          while(_loc5_ < platforms_Ground.length)
  1345.          {
  1346.             if(platforms_Ground[_loc5_].hitTest_ground(param1,param2))
  1347.             {
  1348.                return true;
  1349.             }
  1350.             _loc5_++;
  1351.          }
  1352.          if(GameEngine.stats.mode == GameEngineStats.MODE_GAMEPLAY)
  1353.          {
  1354.             if(slice.edgeDown == -1)
  1355.             {
  1356.                _loc10_ = Math.abs(Maths.subtractAngles(gravity_dir,0));
  1357.                if(param2 > slice.rightX && (_loc10_ > 45 && _loc10_ < 135))
  1358.                {
  1359.                   return true;
  1360.                }
  1361.             }
  1362.             if(slice.edgeUp == -1)
  1363.             {
  1364.                _loc10_ = Math.abs(Maths.subtractAngles(gravity_dir,180));
  1365.                if(param2 < slice.upY && (_loc10_ > 45 && _loc10_ < 135))
  1366.                {
  1367.                   return true;
  1368.                }
  1369.             }
  1370.             if(slice.edgeLeft == -1)
  1371.             {
  1372.                _loc10_ = Math.abs(Maths.subtractAngles(gravity_dir,90));
  1373.                if(param1 < slice.leftX && (_loc10_ > 45 && _loc10_ < 135))
  1374.                {
  1375.                   return true;
  1376.                }
  1377.             }
  1378.             if(slice.edgeRight == -1)
  1379.             {
  1380.                _loc10_ = Math.abs(Maths.subtractAngles(gravity_dir,-90));
  1381.                if(param1 > slice.rightX && (_loc10_ > 45 && _loc10_ < 135))
  1382.                {
  1383.                   return true;
  1384.                }
  1385.             }
  1386.          }
  1387.          else
  1388.          {
  1389.             if(param2 > slice.levelData.height * 32)
  1390.             {
  1391.                return true;
  1392.             }
  1393.             if(param2 < 0)
  1394.             {
  1395.                return true;
  1396.             }
  1397.             if(param1 < 0)
  1398.             {
  1399.                return true;
  1400.             }
  1401.             if(param1 > slice.levelData.width * 32)
  1402.             {
  1403.                return true;
  1404.             }
  1405.          }
  1406.          return false;
  1407.       }
  1408.      
  1409.       public static function hitTestPlatforms(param1:int, param2:int) : Boolean
  1410.       {
  1411.          var _loc5_:int = 0;
  1412.          var _loc6_:* = 0;
  1413.          var _loc3_:int = param1 - TileHandler.mx * 32 + TileHandler.tx * 16 - slice.leftX;
  1414.          var _loc4_:int = param2 - TileHandler.my * 32 + TileHandler.ty * 16 - slice.upY;
  1415.          if(_loc3_ >= 0 && _loc4_ >= 0 && _loc3_ < course.groundTiles.width && _loc4_ < course.groundTiles.height)
  1416.          {
  1417.             _loc6_ = uint(course.groundTiles.getPixel(_loc3_,_loc4_));
  1418.             if((_loc6_ & 65535) == 65535)
  1419.             {
  1420.                return true;
  1421.             }
  1422.          }
  1423.          _loc5_ = 0;
  1424.          while(_loc5_ < platforms_Cloud.length)
  1425.          {
  1426.             if(platforms_Cloud[_loc5_].hitTest_cloud(param1,param2))
  1427.             {
  1428.                return true;
  1429.             }
  1430.             _loc5_++;
  1431.          }
  1432.          return false;
  1433.       }
  1434.      
  1435.       public static function hitTestDamage(param1:int, param2:int) : int
  1436.       {
  1437.          var _loc5_:int = 0;
  1438.          var _loc6_:* = 0;
  1439.          var _loc7_:int = 0;
  1440.          var _loc3_:int = param1 - TileHandler.mx * 32 + TileHandler.tx * 16 - slice.leftX;
  1441.          var _loc4_:int = param2 - TileHandler.my * 32 + TileHandler.ty * 16 - slice.upY;
  1442.          if(_loc3_ >= 0 && _loc4_ >= 0 && _loc3_ < course.groundTiles.width && _loc4_ < course.groundTiles.height)
  1443.          {
  1444.             _loc6_ = uint(course.groundTiles.getPixel(_loc3_,_loc4_));
  1445.             return 0;
  1446.          }
  1447.          _loc5_ = 0;
  1448.          while(_loc5_ < platforms_Damage.length)
  1449.          {
  1450.             _loc7_ = platforms_Damage[_loc5_].hitTest_damage(param1,param2);
  1451.             if(_loc7_ != 0)
  1452.             {
  1453.                return _loc7_;
  1454.             }
  1455.             _loc5_++;
  1456.          }
  1457.          return 0;
  1458.       }
  1459.      
  1460.       public static function hitTestType(param1:int, param2:int) : int
  1461.       {
  1462.          var _loc5_:int = 0;
  1463.          var _loc6_:* = 0;
  1464.          var _loc3_:int = param1 - TileHandler.mx * 32 + TileHandler.tx * 16 - slice.leftX;
  1465.          var _loc4_:int = param2 - TileHandler.my * 32 + TileHandler.ty * 16 - slice.upY;
  1466.          _loc5_ = 0;
  1467.          while(_loc5_ < platforms_Ground.length)
  1468.          {
  1469.             if(platforms_Ground[_loc5_].hitTest_ground(param1,param2))
  1470.             {
  1471.                return platforms_Ground[_loc5_].hitTest_type(param1,param2);
  1472.             }
  1473.             _loc5_++;
  1474.          }
  1475.          _loc5_ = 0;
  1476.          while(_loc5_ < platforms_Cloud.length)
  1477.          {
  1478.             if(platforms_Cloud[_loc5_].hitTest_cloud(param1,param2))
  1479.             {
  1480.                return platforms_Cloud[_loc5_].hitTest_type(param1,param2);
  1481.             }
  1482.             _loc5_++;
  1483.          }
  1484.          if(_loc3_ >= 0 && _loc4_ >= 0 && _loc3_ < course.groundTiles.width && _loc4_ < course.groundTiles.height)
  1485.          {
  1486.             _loc6_ = uint(course.groundTiles.getPixel(_loc3_,_loc4_));
  1487.             return (_loc6_ & 16711680) >> 16;
  1488.          }
  1489.          return -1;
  1490.       }
  1491.      
  1492.       public static function playSound(param1:int, param2:Character, param3:Number = 1) : SoundChannel
  1493.       {
  1494.          return playSoundAt(param1,param2.centerX,param2.centerY,param3);
  1495.       }
  1496.      
  1497.       public static function playSoundAt(param1:int, param2:int, param3:int, param4:Number = 1) : SoundChannel
  1498.       {
  1499.          var _loc5_:Number = (param2 - camera.camX) * camera.currentZoom / 100;
  1500.          var _loc6_:Number = (param3 - camera.camY) * camera.currentZoom / 100;
  1501.          var _loc7_:Number = Math.sqrt(_loc5_ * _loc5_ + _loc6_ * _loc6_);
  1502.          var _loc10_:Number = 1 - Math.max(_loc7_ - 150,0) / 500;
  1503.          if(_loc10_ <= 0)
  1504.          {
  1505.             return null;
  1506.          }
  1507.          var _loc11_:Number = _loc5_ / 400;
  1508.          _loc11_ = Math.min(_loc11_,1);
  1509.          _loc11_ = Math.max(_loc11_,-1);
  1510.          if(_loc10_ < 0.05)
  1511.          {
  1512.             return null;
  1513.          }
  1514.          return SoundHandler.playSound(param1,0,0,_loc10_ * param4,_loc11_);
  1515.       }
  1516.      
  1517.       public static function triggerDeath() : void
  1518.       {
  1519.          var cueMenu:Function = null;
  1520.          var count:Number = NaN;
  1521.          var count2:Number = NaN;
  1522.          var triggerMusic:Boolean = false;
  1523.          cueMenu = function(param1:Event):void
  1524.          {
  1525.             if(pauseMenu != null)
  1526.             {
  1527.                pauseMenu.switchMode(HUD_Shell.MODE_REMOVED);
  1528.             }
  1529.             if(deathRespawnCue == null)
  1530.             {
  1531.                Main.getStage().removeEventListener(Event.ENTER_FRAME,cueMenu);
  1532.                return;
  1533.             }
  1534.             count = count + worldSpeed;
  1535.             count2 = count2 + worldSpeed;
  1536.             if(count > 1)
  1537.             {
  1538.                if(deathRespawnCue.currentFrame < deathRespawnCue.totalFrames)
  1539.                {
  1540.                   deathRespawnCue.nextFrame();
  1541.                }
  1542.                count = count - 1;
  1543.             }
  1544.             if(count2 >= 91)
  1545.             {
  1546.                if(triggerMusic == false)
  1547.                {
  1548.                   MusicHandler.playTheme(16);
  1549.                   triggerMusic = true;
  1550.                }
  1551.             }
  1552.             if(deathRespawnCue == null)
  1553.             {
  1554.                Main.getStage().removeEventListener(Event.ENTER_FRAME,cueMenu);
  1555.             }
  1556.             else if(KeyEngine.ld("up") == 1 || KeyEngine.ld("down") == 1 || KeyEngine.ld("left") == 1 || KeyEngine.ld("right") == 1 || KeyEngine.ld("z") == 1 || KeyEngine.ld("x") == 1 || KeyEngine.ld("c") == 1 || KeyEngine.ld("shift") == 1 || KeyEngine.ld("backspace") == 1 || KeyEngine.ld("delta") == 1 || KeyEngine.ld("mouse") == 1 || KeyEngine.ld("rightClick") == 1)
  1557.             {
  1558.                KeyEngine.forceAllKeysUnpressed();
  1559.                Main.getStage().removeEventListener(Event.ENTER_FRAME,cueMenu);
  1560.                Main.getStage().removeChild(deathRespawnCue);
  1561.                deathRespawnCue = null;
  1562.                MusicHandler.stopMusic();
  1563.                remove();
  1564.                GameEngine.stats.heroStats.loadSpawnPoint();
  1565.                GameEngine.stats.startedMusicAlready = false;
  1566.                GameEngine.start(GameEngine.stats);
  1567.             }
  1568.          };
  1569.          if(stats.mode == GameEngineStats.MODE_LEVELDESIGNER)
  1570.          {
  1571.             return;
  1572.          }
  1573.          if(deathPause == false)
  1574.          {
  1575.             deathPause = true;
  1576.             MusicHandler.stopMusic();
  1577.             deathRespawnCue = new c_PressAButtonToRespawn();
  1578.             deathRespawnCue.x = Main.visibleContent.x;
  1579.             deathRespawnCue.y = Main.visibleContent.y;
  1580.             deathRespawnCue.scaleX = Main.visibleContent.width / Main.WIDTH;
  1581.             deathRespawnCue.scaleY = Main.visibleContent.height / Main.HEIGHT;
  1582.             Main.getStage().addChild(deathRespawnCue);
  1583.             deathRespawnCue.gotoAndStop(1);
  1584.             if(course.hero != null)
  1585.             {
  1586.                course.hero.remove();
  1587.                course.hero = null;
  1588.             }
  1589.             count = 0;
  1590.             count2 = 0;
  1591.             triggerMusic = false;
  1592.             Main.getStage().addEventListener(Event.ENTER_FRAME,cueMenu);
  1593.          }
  1594.       }
  1595.      
  1596.       public static function setWorldSpeed(param1:Number) : void
  1597.       {
  1598.          _worldSpeed = param1;
  1599.       }
  1600.      
  1601.       public static function friction(param1:Number) : Number
  1602.       {
  1603.          return Math.pow(1 - 1 / param1,worldSpeed);
  1604.       }
  1605.      
  1606.       public static function ease(param1:Number) : Number
  1607.       {
  1608.          return 1 / param1 * worldSpeed;
  1609.       }
  1610.      
  1611.       public static function deltaEnterFrame() : void
  1612.       {
  1613.          var _loc1_:int = 0;
  1614.          var _loc2_:* = null;
  1615.          var _loc3_:int = 0;
  1616.          var _loc4_:int = 0;
  1617.          var _loc5_:* = null;
  1618.          var _loc6_:* = null;
  1619.          var _loc7_:* = null;
  1620.          var _loc8_:* = null;
  1621.          var _loc9_:* = null;
  1622.          var _loc10_:int = 0;
  1623.          var _loc11_:int = 0;
  1624.          var _loc12_:* = null;
  1625.          var _loc13_:int = 0;
  1626.          var _loc14_:int = 0;
  1627.          MusicHandler.musicDynamicVolume = MusicHandler.musicDynamicVolume * (1 - 0.8 * (deltaLevel / 10));
  1628.          if(delta)
  1629.          {
  1630.             if(QualityHandler.frameRate == 60)
  1631.             {
  1632.                deltaTime = deltaTime + 0.5;
  1633.             }
  1634.             else
  1635.             {
  1636.                deltaTime = deltaTime + 1;
  1637.             }
  1638.             if(deltaLevel < 10)
  1639.             {
  1640.                if(QualityHandler.frameRate == 60)
  1641.                {
  1642.                   deltaLevel = deltaLevel + 1;
  1643.                }
  1644.                else
  1645.                {
  1646.                   deltaLevel = deltaLevel + 0.5;
  1647.                }
  1648.             }
  1649.             if(deltaTransformed == false)
  1650.             {
  1651.                course.visible = false;
  1652.                top.visible = false;
  1653.                deltaCircle = new DeltaCircle(course.hero);
  1654.                deltaCursor = new DeltaCursor(course.hero);
  1655.                if(bg != null)
  1656.                {
  1657.                   bg.setVisible(false);
  1658.                }
  1659.                if(closeBG != null)
  1660.                {
  1661.                   closeBG.setVisible(false);
  1662.                }
  1663.                deltaBitmap = new Bitmap(deltaBitmapData);
  1664.                deltaBitmapData.fillRect(deltaBitmapData.rect,16777215);
  1665.                Main.getStage().addChildAt(deltaBitmap,0);
  1666.                deltaEffectContainer = new MovieClip();
  1667.                _loc1_ = 0;
  1668.                while(_loc1_ < deltaEffectorArray.length)
  1669.                {
  1670.                   deltaEffectContainer.addChild(deltaEffectorArray[_loc1_]);
  1671.                   _loc1_++;
  1672.                }
  1673.                deltaEffectContainer.addChild(deltaCircle);
  1674.                deltaEffectContainer.addChild(deltaCursor);
  1675.                Main.getStage().addChildAt(deltaEffectContainer,1);
  1676.                if(debugStats != null)
  1677.                {
  1678.                   Main.getStage().removeChild(debugStats);
  1679.                   Main.getStage().addChild(debugStats);
  1680.                }
  1681.                deltaTransformed = true;
  1682.                deltaTime = Math.random() * 40000;
  1683.                if(deltaSFX == null)
  1684.                {
  1685.                   deltaSFX = SoundHandler.playSound(SoundHandler.USE_DELTA,0,9999,deltaLevel / 10,0);
  1686.                }
  1687.             }
  1688.          }
  1689.          else if(deltaLevel > 0)
  1690.          {
  1691.             deltaLevel--;
  1692.          }
  1693.          else if(deltaTransformed)
  1694.          {
  1695.             Main.getStage().removeChild(deltaBitmap);
  1696.             deltaBitmap = null;
  1697.             Main.getStage().removeChild(deltaEffectContainer);
  1698.             deltaEffectContainer = null;
  1699.             deltaCircle = null;
  1700.             deltaCursor = null;
  1701.             course.visible = true;
  1702.             top.visible = true;
  1703.             if(bg != null)
  1704.             {
  1705.                bg.setVisible(true);
  1706.             }
  1707.             if(closeBG != null)
  1708.             {
  1709.                closeBG.setVisible(true);
  1710.             }
  1711.             deltaTransformed = false;
  1712.             if(deltaSFX != null)
  1713.             {
  1714.                deltaSFX.stop();
  1715.                deltaSFX = null;
  1716.             }
  1717.          }
  1718.          if(deltaEffectContainer != null)
  1719.          {
  1720.             deltaEffectContainer.alpha = deltaLevel / 10;
  1721.          }
  1722.          if(deltaTransformed)
  1723.          {
  1724.             if(deltaSFX != null)
  1725.             {
  1726.                deltaSFX.soundTransform = new SoundTransform(deltaLevel / 10 * SavedData.getSoundsVolume(),0);
  1727.             }
  1728.             deltaBitmap.x = Main.visibleContent.x;
  1729.             deltaBitmap.y = Main.visibleContent.y;
  1730.             deltaBitmap.width = Main.visibleContent.width;
  1731.             deltaBitmap.height = Main.visibleContent.height;
  1732.             deltaEffectContainer.transform.matrix = course.midGFX.transform.concatenatedMatrix;
  1733.             deltaCircle.enterFrame();
  1734.             deltaCursor.enterFrame();
  1735.             deltaBitmapData.lock();
  1736.             deltaBitmapDataTemp.lock();
  1737.             if(bg != null)
  1738.             {
  1739.                bg.drawTo(deltaBitmapDataTemp);
  1740.             }
  1741.             else
  1742.             {
  1743.                deltaBitmapDataTemp.fillRect(deltaBitmapDataTemp.rect,4278190080);
  1744.             }
  1745.             if(closeBG != null)
  1746.             {
  1747.                closeBG.drawTo(deltaBitmapDataTemp);
  1748.             }
  1749.             course.frontTilesGFX.transform.colorTransform = new ColorTransform(1,1,1,1,deltaLevel * 5,deltaLevel * 5,deltaLevel * 5,0);
  1750.             deltaBitmapDataTemp.draw(course,new Matrix(camera.currentZoom / 100,0,0,camera.currentZoom / 100,Main.WIDTH / 2,Main.HEIGHT / 2));
  1751.             deltaBitmapDataTemp.draw(top,new Matrix(1,0,0,1,0,0));
  1752.             course.frontTilesGFX.transform.colorTransform = new ColorTransform();
  1753.             if(WeatherHandler.post != null)
  1754.             {
  1755.                if(WeatherHandler.post.supportsOnlyColorTransform())
  1756.                {
  1757.                   deltaBitmapDataTemp.colorTransform(deltaBitmapDataTemp.rect,WeatherHandler.post.getColorTransform());
  1758.                }
  1759.                else
  1760.                {
  1761.                   deltaBitmapDataTemp.applyFilter(deltaBitmapDataTemp,deltaBitmapDataTemp.rect,new Point(),new ColorMatrixFilter(WeatherHandler.post.getMatrix()));
  1762.                }
  1763.             }
  1764.             _loc2_ = new Colors();
  1765.             _loc2_.saturation = deltaLevel * -6;
  1766.             _loc2_.hue = deltaLevel * (Math.sin(deltaTime / 400) * 18);
  1767.             _loc2_.alphaMultiplier = 100 * (1 - deltaLevel / 20);
  1768.             _loc2_.redOffset = 0;
  1769.             _loc2_.greenOffset = 0;
  1770.             _loc2_.blueOffset = 0;
  1771.             _loc2_.redMultiplier = 100 - 100 * (deltaLevel / 50);
  1772.             _loc2_.greenMultiplier = 100 - 100 * (deltaLevel / 50);
  1773.             _loc2_.blueMultiplier = 100 - 100 * (deltaLevel / 50);
  1774.             _loc5_ = new Rectangle();
  1775.             _loc6_ = new Point();
  1776.             _loc7_ = new ColorMatrixFilter(_loc2_.getMatrix());
  1777.             _loc8_ = new ColorTransform(1 - 0.4 * (deltaLevel / 10),1 - 0.4 * (deltaLevel / 10),1 - 0.4 * (deltaLevel / 10),1 - 0.4 * (deltaLevel / 10));
  1778.             _loc9_ = new ColorTransform(1.4 - 0.4 * (deltaLevel / 10),0.8 - 0.4 * (deltaLevel / 10),0.8 - 0.4 * (deltaLevel / 10),1 - 0.2 * (deltaLevel / 10));
  1779.             _loc3_ = 0;
  1780.             while(_loc3_ < TileHandler.tx)
  1781.             {
  1782.                _loc4_ = 0;
  1783.                while(_loc4_ < TileHandler.ty)
  1784.                {
  1785.                   _loc10_ = TileHandler.mx + _loc3_ - TileHandler.tx / 2;
  1786.                   _loc11_ = TileHandler.my + _loc4_ - TileHandler.ty / 2;
  1787.                   _loc12_ = slice.levelData.frontTiles.getTileAt(_loc10_,_loc11_);
  1788.                   _loc5_.x = (-TileHandler.tx * 16 + TileHandler.px + _loc3_ * 32) * camera.currentZoom / 100 + Main.WIDTH / 2;
  1789.                   _loc5_.y = (-TileHandler.ty * 16 + TileHandler.py + _loc4_ * 32) * camera.currentZoom / 100 + Main.HEIGHT / 2;
  1790.                   _loc6_.x = _loc5_.x;
  1791.                   _loc6_.y = _loc5_.y;
  1792.                   _loc5_.width = 32 * camera.currentZoom / 100 + 2;
  1793.                   _loc5_.height = 32 * camera.currentZoom / 100 + 2;
  1794.                   if(_loc5_.right >= 0 && _loc5_.bottom >= 0 && _loc5_.left < deltaBitmapDataTemp.width && _loc5_.top < deltaBitmapDataTemp.height)
  1795.                   {
  1796.                      if(_loc12_.overwrite != Tile.OVERWRITE_DELTANEGATE && deltaCursor.inRange(_loc10_ + slice.leftTile,_loc11_ + slice.upTile))
  1797.                      {
  1798.                         _loc13_ = getDeltaTileModifierValue(_loc10_,_loc11_);
  1799.                         _loc14_ = 0;
  1800.                         if(stats.level.deltaonbydefault)
  1801.                         {
  1802.                            _loc14_ = 1;
  1803.                         }
  1804.                         if(_loc13_ + _loc14_ <= 0)
  1805.                         {
  1806.                            if(getDeltaTileModifierNegativeValue(_loc10_,_loc11_) < 0)
  1807.                            {
  1808.                               _loc5_.width = 32 * camera.currentZoom / 100 + 0.1;
  1809.                               _loc5_.height = 32 * camera.currentZoom / 100 + 0.1;
  1810.                               deltaBitmapDataTemp.colorTransform(_loc5_,_loc9_);
  1811.                            }
  1812.                            else
  1813.                            {
  1814.                               _loc5_.width = 32 * camera.currentZoom / 100 + 0.1;
  1815.                               _loc5_.height = 32 * camera.currentZoom / 100 + 0.1;
  1816.                               deltaBitmapDataTemp.colorTransform(_loc5_,_loc8_);
  1817.                            }
  1818.                         }
  1819.                         else
  1820.                         {
  1821.                            deltaBitmapDataTemp.applyFilter(deltaBitmapDataTemp,_loc5_,_loc6_,_loc7_);
  1822.                         }
  1823.                      }
  1824.                      else
  1825.                      {
  1826.                         _loc5_.width = 32 * camera.currentZoom / 100 + 0.1;
  1827.                         _loc5_.height = 32 * camera.currentZoom / 100 + 0.1;
  1828.                         deltaBitmapDataTemp.colorTransform(_loc5_,_loc8_);
  1829.                      }
  1830.                   }
  1831.                   _loc4_++;
  1832.                }
  1833.                _loc3_++;
  1834.             }
  1835.             deltaBitmapData.copyPixels(deltaBitmapDataTemp,deltaBitmapDataTemp.rect,new Point(),deltaBitmapDataTemp,new Point(),true);
  1836.             deltaBitmapDataTemp.unlock();
  1837.             deltaBitmapData.unlock();
  1838.          }
  1839.       }
  1840.      
  1841.       public static function isTileDeltaEnable(param1:int, param2:int) : Boolean
  1842.       {
  1843.          param1 = param1 - slice.leftTile;
  1844.          param2 = param2 - slice.upTile;
  1845.          var _loc3_:int = 0;
  1846.          if(stats.level.deltaonbydefault)
  1847.          {
  1848.             _loc3_ = 1;
  1849.          }
  1850.          return getDeltaTileModifierValue(param1,param2) + _loc3_ > 0;
  1851.       }
  1852.      
  1853.       public static function getDeltaTileModifierValue(param1:int, param2:int) : int
  1854.       {
  1855.          var _loc3_:Tile = stats.level.frontTiles.getTileAt(param1 + slice.leftTile,param2 + slice.upTile);
  1856.          if(TileFactory.isTileNumDeltaAble(_loc3_.num) == false)
  1857.          {
  1858.             return -100;
  1859.          }
  1860.          var _loc4_:int = 0;
  1861.          var _loc5_:int = 0;
  1862.          while(_loc5_ < deltaModifierArray.length)
  1863.          {
  1864.             if(deltaModifierArray[_loc5_].deltaModifier_exists())
  1865.             {
  1866.                _loc4_ = _loc4_ + deltaModifierArray[_loc5_].deltaModifier_getTile(param1,param2);
  1867.             }
  1868.             else
  1869.             {
  1870.                deltaModifierArray.splice(_loc5_--,1);
  1871.             }
  1872.             _loc5_++;
  1873.          }
  1874.          return _loc4_;
  1875.       }
  1876.      
  1877.       public static function getDeltaTileModifierPositiveValue(param1:int, param2:int) : int
  1878.       {
  1879.          var _loc6_:int = 0;
  1880.          var _loc3_:Tile = stats.level.frontTiles.getTileAt(param1 + slice.leftTile,param2 + slice.upTile);
  1881.          if(TileFactory.isTileNumDeltaAble(_loc3_.num) == false)
  1882.          {
  1883.             return 0;
  1884.          }
  1885.          var _loc4_:int = 0;
  1886.          var _loc5_:int = 0;
  1887.          while(_loc5_ < deltaModifierArray.length)
  1888.          {
  1889.             if(deltaModifierArray[_loc5_].deltaModifier_exists())
  1890.             {
  1891.                _loc6_ = deltaModifierArray[_loc5_].deltaModifier_getTile(param1,param2);
  1892.                if(_loc6_ > 0)
  1893.                {
  1894.                   _loc4_ = _loc4_ + _loc6_;
  1895.                }
  1896.             }
  1897.             else
  1898.             {
  1899.                deltaModifierArray.splice(_loc5_--,1);
  1900.             }
  1901.             _loc5_++;
  1902.          }
  1903.          return _loc4_;
  1904.       }
  1905.      
  1906.       public static function getDeltaTileModifierNegativeValue(param1:int, param2:int) : int
  1907.       {
  1908.          var _loc6_:int = 0;
  1909.          var _loc3_:Tile = stats.level.frontTiles.getTileAt(param1 + slice.leftTile,param2 + slice.upTile);
  1910.          if(TileFactory.isTileNumDeltaAble(_loc3_.num) == false)
  1911.          {
  1912.             return 0;
  1913.          }
  1914.          var _loc4_:int = 0;
  1915.          var _loc5_:int = 0;
  1916.          while(_loc5_ < deltaModifierArray.length)
  1917.          {
  1918.             if(deltaModifierArray[_loc5_].deltaModifier_exists())
  1919.             {
  1920.                _loc6_ = deltaModifierArray[_loc5_].deltaModifier_getTile(param1,param2);
  1921.                if(_loc6_ < 0)
  1922.                {
  1923.                   _loc4_ = _loc4_ + _loc6_;
  1924.                }
  1925.             }
  1926.             else
  1927.             {
  1928.                deltaModifierArray.splice(_loc5_--,1);
  1929.             }
  1930.             _loc5_++;
  1931.          }
  1932.          return _loc4_;
  1933.       }
  1934.      
  1935.       public static function isOnScreen(param1:Number, param2:Number) : Boolean
  1936.       {
  1937.          var _loc3_:Number = param1 - camera.camX;
  1938.          var _loc4_:Number = param2 - camera.camY;
  1939.          if(Math.abs(_loc3_) < Main.WIDTH * 2 && Math.abs(_loc4_) < Main.HEIGHT * 2)
  1940.          {
  1941.             return true;
  1942.          }
  1943.          return false;
  1944.       }
  1945.      
  1946.       public static function resized() : void
  1947.       {
  1948.          if(debugStats != null)
  1949.          {
  1950.             debugStats.x = Main.visibleContent.x;
  1951.             debugStats.y = Main.visibleContent.y;
  1952.             if(stats.mode == GameEngineStats.MODE_LEVELDESIGNER)
  1953.             {
  1954.                debugStats.y = debugStats.y + 20 * (Main.visibleContent.height / Main.HEIGHT);
  1955.             }
  1956.             if(stats.mode == GameEngineStats.MODE_GAMEPLAY)
  1957.             {
  1958.                debugStats.x = Main.visibleContent.x + Main.visibleContent.width - 70;
  1959.             }
  1960.          }
  1961.          if(bg != null)
  1962.          {
  1963.             bg.resized();
  1964.          }
  1965.          if(closeBG != null)
  1966.          {
  1967.             closeBG.resized();
  1968.          }
  1969.          if(course != null)
  1970.          {
  1971.             course.resized();
  1972.          }
  1973.          if(top != null)
  1974.          {
  1975.             top.x = Main.visibleContent.x;
  1976.             top.y = Main.visibleContent.y;
  1977.             top.scaleX = Main.visibleContent.width / Main.WIDTH;
  1978.             top.scaleY = Main.visibleContent.height / Main.HEIGHT;
  1979.          }
  1980.          if(signLayer != null)
  1981.          {
  1982.             signLayer.x = Main.visibleContent.x;
  1983.             signLayer.y = Main.visibleContent.y;
  1984.             signLayer.scaleX = Main.visibleContent.width / Main.WIDTH;
  1985.             signLayer.scaleY = Main.visibleContent.height / Main.HEIGHT;
  1986.          }
  1987.          if(transitionLayer != null)
  1988.          {
  1989.             transitionLayer.x = Main.visibleContent.x;
  1990.             transitionLayer.y = Main.visibleContent.y;
  1991.             transitionLayer.scaleX = Main.visibleContent.width / Main.WIDTH;
  1992.             transitionLayer.scaleY = Main.visibleContent.height / Main.HEIGHT;
  1993.          }
  1994.          if(screenBufferBit != null)
  1995.          {
  1996.             screenBufferBit.x = Main.visibleContent.x;
  1997.             screenBufferBit.y = Main.visibleContent.y;
  1998.             screenBufferBit.scaleX = Main.visibleContent.width / Main.WIDTH;
  1999.             screenBufferBit.scaleY = Main.visibleContent.height / Main.HEIGHT;
  2000.          }
  2001.          if(deltaTransformed)
  2002.          {
  2003.             deltaBitmap.x = Main.visibleContent.x;
  2004.             deltaBitmap.y = Main.visibleContent.y;
  2005.             deltaBitmap.width = Main.visibleContent.width;
  2006.             deltaBitmap.height = Main.visibleContent.height;
  2007.          }
  2008.          if(loading != null)
  2009.          {
  2010.             loading.x = Main.visibleContent.x;
  2011.             loading.y = Main.visibleContent.y;
  2012.             loading.scaleX = Main.visibleContent.width / Main.WIDTH;
  2013.             loading.scaleY = Main.visibleContent.height / Main.HEIGHT;
  2014.          }
  2015.          if(pauseMenu != null)
  2016.          {
  2017.             pauseMenu.resized();
  2018.          }
  2019.          if(deathRespawnCue != null)
  2020.          {
  2021.             deathRespawnCue.x = Main.visibleContent.x;
  2022.             deathRespawnCue.y = Main.visibleContent.y;
  2023.             deathRespawnCue.scaleX = Main.visibleContent.width / Main.WIDTH;
  2024.             deathRespawnCue.scaleY = Main.visibleContent.height / Main.HEIGHT;
  2025.          }
  2026.          if(stats != null && !removed)
  2027.          {
  2028.             switch(stats.mode)
  2029.             {
  2030.                case GameEngineStats.MODE_LEVELDESIGNER:
  2031.                   LevelDesignerEngine.resized();
  2032.                   break;
  2033.                case GameEngineStats.MODE_GAMEPLAY:
  2034.                   GameplayEngine.resized();
  2035.                   break;
  2036.                case GameEngineStats.MODE_CINEMA:
  2037.                   CinemaEngine.resized();
  2038.                   break;
  2039.                default:
  2040.                   throw new Error("Unsupported game mode!");
  2041.             }
  2042.          }
  2043.       }
  2044.      
  2045.       public static function remove() : void
  2046.       {
  2047.          var _loc1_:int = 0;
  2048.          var _loc2_:Vector.<Item> = slice.levelData.itemLayers.allItems;
  2049.          _loc1_ = 0;
  2050.          while(_loc1_ < _loc2_.length)
  2051.          {
  2052.             if(_loc2_[_loc1_].attached)
  2053.             {
  2054.                _loc2_[_loc1_].remove();
  2055.             }
  2056.             _loc1_++;
  2057.          }
  2058.          _loc1_ = 0;
  2059.          while(_loc1_ < enterFrameArray.length)
  2060.          {
  2061.             enterFrameArray[_loc1_].enterFrameRemoved();
  2062.             _loc1_++;
  2063.          }
  2064.          enterFrameArray = null;
  2065.          _loc1_ = 0;
  2066.          while(_loc1_ < deltaEffectorArray.length)
  2067.          {
  2068.             deltaEffectorArray[_loc1_].undo_noEffect();
  2069.             _loc1_++;
  2070.          }
  2071.          deltaEffectorArray = null;
  2072.          boulderArray = null;
  2073.          enemyArray = null;
  2074.          deltaModifierArray = null;
  2075.          spikesArray = null;
  2076.          spliter_XArray = null;
  2077.          _loc1_ = 0;
  2078.          while(_loc1_ < triggerArray.length)
  2079.          {
  2080.             triggerArray[_loc1_].stop();
  2081.             triggerArray[_loc1_].removedFromList();
  2082.             _loc1_++;
  2083.          }
  2084.          triggerArray = null;
  2085.          WeatherHandler.remove();
  2086.          DeltaWallHandler.remove();
  2087.          TextHandler.remove();
  2088.          if(bg != null)
  2089.          {
  2090.             bg.remove();
  2091.             bg = null;
  2092.          }
  2093.          if(closeBG != null)
  2094.          {
  2095.             closeBG.remove();
  2096.             closeBG = null;
  2097.          }
  2098.          if(course != null)
  2099.          {
  2100.             Main.getStage().removeChild(course);
  2101.             course.remove();
  2102.             course = null;
  2103.          }
  2104.          if(top != null)
  2105.          {
  2106.             Main.getStage().removeChild(top);
  2107.             top = null;
  2108.          }
  2109.          if(signLayer != null)
  2110.          {
  2111.             Main.getStage().removeChild(signLayer);
  2112.             signLayer = null;
  2113.          }
  2114.          if(transitionLayer != null)
  2115.          {
  2116.             Main.getStage().removeChild(transitionLayer);
  2117.             transitionLayer = null;
  2118.          }
  2119.          switch(stats.mode)
  2120.          {
  2121.             case GameEngineStats.MODE_LEVELDESIGNER:
  2122.                LevelDesignerEngine.remove();
  2123.                break;
  2124.             case GameEngineStats.MODE_GAMEPLAY:
  2125.                GameplayEngine.remove();
  2126.                break;
  2127.             case GameEngineStats.MODE_CINEMA:
  2128.                CinemaEngine.remove();
  2129.                break;
  2130.             default:
  2131.                throw new Error("Unsupported game mode!");
  2132.          }
  2133.          usingScreenBuffer = false;
  2134.          if(screenBuffer != null)
  2135.          {
  2136.             screenBuffer.dispose();
  2137.             screenBuffer = null;
  2138.          }
  2139.          if(screenBufferBit != null)
  2140.          {
  2141.             Main.getStage().removeChild(screenBufferBit);
  2142.             screenBufferBit = null;
  2143.          }
  2144.          if(deltaBitmap != null)
  2145.          {
  2146.             Main.getStage().removeChild(deltaBitmap);
  2147.          }
  2148.          deltaBitmap = null;
  2149.          if(deltaEffectContainer != null)
  2150.          {
  2151.             Main.getStage().removeChild(deltaEffectContainer);
  2152.          }
  2153.          deltaEffectContainer = null;
  2154.          deltaCircle = null;
  2155.          deltaCursor = null;
  2156.          if(deltaSFX != null)
  2157.          {
  2158.             deltaSFX.stop();
  2159.             deltaSFX = null;
  2160.          }
  2161.          if(debugStats != null)
  2162.          {
  2163.             Main.getStage().removeChild(debugStats);
  2164.          }
  2165.          Main.getStage().removeEventListener(Event.ENTER_FRAME,enterFrame);
  2166.          Main.getStage().removeEventListener(Event.DEACTIVATE,focusOut);
  2167.          Main.getStage().removeEventListener(Event.ACTIVATE,focusIn);
  2168.          if(deathRespawnCue != null)
  2169.          {
  2170.             Main.getStage().removeChild(deathRespawnCue);
  2171.             deathRespawnCue = null;
  2172.          }
  2173.          if(currentTransition != null)
  2174.          {
  2175.             currentTransition.remove();
  2176.             currentTransition = null;
  2177.          }
  2178.          removePauseMenu();
  2179.          removed = true;
  2180.       }
  2181.    }
  2182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement