Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.runouw.ll.engine
- {
- import com.runouw.Maths;
- import com.runouw.keyEngine.KeyEngine;
- import com.runouw.ll.Main;
- import com.runouw.ll.SavedData;
- import com.runouw.ll.character.Character;
- import com.runouw.ll.engine.backgrounds.BGFactory;
- import com.runouw.ll.engine.backgrounds.Background;
- import com.runouw.ll.engine.backgrounds.CloseBackground;
- import com.runouw.ll.engine.char.GravityStats;
- import com.runouw.ll.engine.core.Camera;
- import com.runouw.ll.engine.core.Course;
- import com.runouw.ll.engine.hero.HeroStats;
- import com.runouw.ll.engine.hero.delta.DeltaCircle;
- import com.runouw.ll.engine.hero.delta.DeltaCursor;
- import com.runouw.ll.engine.hero.delta.DeltaEffector;
- import com.runouw.ll.engine.hero.delta.DeltaWallHandler;
- import com.runouw.ll.engine.levelData.Colors;
- import com.runouw.ll.engine.levelData.enemies.Enemy;
- import com.runouw.ll.engine.levelData.items.core.Boulder;
- import com.runouw.ll.engine.levelData.items.core.DeltaModifier;
- import com.runouw.ll.engine.levelData.items.core.Item;
- import com.runouw.ll.engine.levelData.items.core.Spikes;
- import com.runouw.ll.engine.levelData.items.core.interfaces.GravityZone;
- import com.runouw.ll.engine.levelData.items.core.interfaces.ISynchronize;
- import com.runouw.ll.engine.levelData.items.core.interfaces.Platform_Cloud;
- import com.runouw.ll.engine.levelData.items.core.interfaces.Platform_Damage;
- import com.runouw.ll.engine.levelData.items.core.interfaces.Platform_Ground;
- import com.runouw.ll.engine.levelData.items.data.Item_ColorBox;
- import com.runouw.ll.engine.levelData.items.data.Item_DeltaNegate;
- import com.runouw.ll.engine.levelData.items.data.Item_Splitter_X;
- import com.runouw.ll.engine.levelData.items.data.Item_StartPosition;
- import com.runouw.ll.engine.levelData.items.data.trigger.FunctionSequence;
- import com.runouw.ll.engine.levelData.slices.LevelDataSlice;
- import com.runouw.ll.engine.levelData.tiles.Tile;
- import com.runouw.ll.engine.levelData.tiles.TileFactory;
- import com.runouw.ll.engine.levelData.tiles.TileHandler;
- import com.runouw.ll.engine.modes.CinemaEngine;
- import com.runouw.ll.engine.modes.GameplayEngine;
- import com.runouw.ll.engine.modes.LevelDesignerEngine;
- import com.runouw.ll.engine.particles.Particle;
- import com.runouw.ll.engine.projectiles.Projectile;
- import com.runouw.ll.engine.quality.QualityHandler;
- import com.runouw.ll.engine.text.TextHandler;
- import com.runouw.ll.engine.transition.Transition;
- import com.runouw.ll.engine.transition.Transition_Black;
- import com.runouw.ll.engine.water.WaterSurface;
- import com.runouw.ll.engine.weather.WeatherHandler;
- import com.runouw.ll.sounds.MusicHandler;
- import com.runouw.ll.sounds.SoundHandler;
- import com.runouw.ll.ui.BehaviorHandler;
- import com.runouw.ll.ui.gameplay.HUD_PauseMenu;
- import com.runouw.ll.ui.gameplay.HUD_Shell;
- import flash.display.Bitmap;
- import flash.display.BitmapData;
- import flash.display.DisplayObject;
- import flash.display.MovieClip;
- import flash.events.Event;
- import flash.filters.ColorMatrixFilter;
- import flash.geom.ColorTransform;
- import flash.geom.Matrix;
- import flash.geom.Point;
- import flash.geom.Rectangle;
- import flash.media.SoundChannel;
- import flash.media.SoundTransform;
- import flash.utils.getTimer;
- import net.hires.debug.Stats;
- public class GameEngine
- {
- public static var stats:GameEngineStats;
- public static var screenBuffer:BitmapData;
- public static var screenBufferBit:Bitmap;
- public static var enterFrameArray:Vector.<IEnterFrame>;
- public static var triggerArray:Vector.<FunctionSequence>;
- public static var deltaEffectorArray:Vector.<DeltaEffector>;
- public static var enemyArray:Vector.<Enemy>;
- public static var boulderArray:Vector.<Boulder>;
- public static var deltaModifierArray:Vector.<DeltaModifier>;
- public static var spikesArray:Vector.<Spikes>;
- public static var spliter_XArray:Vector.<Item_Splitter_X>;
- public static var platforms_Cloud:Vector.<Platform_Cloud>;
- public static var platforms_Ground:Vector.<Platform_Ground>;
- public static var platforms_Damage:Vector.<Platform_Damage>;
- public static var gravityZones:Vector.<GravityZone>;
- public static var projectileArray:Vector.<Projectile>;
- public static var particleArray:Vector.<Particle>;
- public static var camera:Camera;
- public static var top:MovieClip;
- public static var signLayer:MovieClip;
- public static var transitionLayer:MovieClip;
- public static var course:Course;
- public static var midbg_xoffset:Number;
- public static var midbg_yoffset:Number;
- public static var bg:Background;
- public static var closeBG:CloseBackground;
- public static var slice:LevelDataSlice;
- public static var removed:Boolean = true;
- private static var debugStats:Stats;
- private static var loading:DisplayObject;
- public static var loadingThreshold:int = 16;
- public static var deathPause:Boolean;
- public static var paused:Boolean;
- public static var trigger_cinemaMode:Boolean;
- public static var heroAnimation_cinemaMode:Boolean;
- public static var heroAnimation_wormholeCinema:Boolean;
- public static var runTriggerCount:Number = 0;
- public static var usingScreenBuffer:Boolean = false;
- public static var inTransition:Transition;
- public static var currentTransition:Transition;
- public static var pauseMenu:HUD_PauseMenu;
- public static var tempHeroStats:HeroStats;
- public static var gravityPoint:Point = new Point();
- public static var gravity_dir:Number = 0;
- private static var deathRespawnCue:c_PressAButtonToRespawn;
- public static var worldSpeed:Number = 1;
- public static var framerateMultiplier:Number = 1;
- private static var _worldSpeed:Number = 1;
- public static var delta:Boolean;
- public static var deltaLevel:Number;
- public static var deltaTime:Number;
- public static var deltaTransformed:Boolean;
- public static var deltaSFX:SoundChannel;
- public static var deltaBitmap:Bitmap;
- public static var deltaBitmapData:BitmapData = new BitmapData(Main.WIDTH,Main.HEIGHT,false);
- public static var deltaBitmapDataTemp:BitmapData = new BitmapData(Main.WIDTH,Main.HEIGHT,true);
- public static var deltaEffectContainer:MovieClip;
- public static var deltaCursor:DeltaCursor;
- public static var deltaCircle:DeltaCircle;
- public function GameEngine()
- {
- super();
- }
- public static function getSplitterXIndex() : int
- {
- var _loc1_:int = -1;
- while(_loc1_ + 1 < spliter_XArray.length && camera.camX > spliter_XArray[_loc1_ + 1].x)
- {
- _loc1_++;
- }
- return _loc1_;
- }
- public static function start(param1:GameEngineStats) : void
- {
- var gameStats:GameEngineStats = param1;
- deathPause = false;
- paused = false;
- trigger_cinemaMode = false;
- heroAnimation_cinemaMode = false;
- heroAnimation_wormholeCinema = false;
- loading = new LevelPreloader();
- loading.x = Main.visibleContent.x;
- loading.y = Main.visibleContent.y;
- loading.scaleX = Main.visibleContent.width / Main.WIDTH;
- loading.scaleY = Main.visibleContent.height / Main.HEIGHT;
- (loading as LevelPreloader)._bar._fill.scaleX = 0.001;
- Main.getStage().addChild(loading);
- stats = gameStats;
- tempHeroStats = null;
- pauseMenu = new HUD_PauseMenu();
- Main.callNextFrame(function nextFrame():void
- {
- if(stats.isPrepared())
- {
- runEngine();
- }
- else
- {
- stats.prepare(function onPrepared():void
- {
- runEngine();
- });
- }
- });
- }
- public static function runEngine() : void
- {
- var onDone:Function = null;
- var onDone2:Function = null;
- onDone = function():void
- {
- course.cameraStuff();
- setTilesColorData(onDone2);
- };
- onDone2 = function():void
- {
- delta = false;
- deltaLevel = 0;
- deltaTime = 0;
- deltaTransformed = false;
- TileHandler.redrawAllTiles();
- course.enterFrame();
- if(bg != null)
- {
- bg.attach();
- }
- if(closeBG != null)
- {
- closeBG.attach();
- }
- if(stats.showDebugger)
- {
- debugStats = new Stats();
- debugStats.x = Main.visibleContent.x;
- debugStats.y = Main.visibleContent.y;
- if(stats.mode == GameEngineStats.MODE_LEVELDESIGNER)
- {
- debugStats.y = debugStats.y + 20 * (Main.visibleContent.height / Main.HEIGHT);
- }
- if(stats.mode == GameEngineStats.MODE_GAMEPLAY)
- {
- debugStats.x = Main.visibleContent.x + Main.visibleContent.width - 70;
- }
- }
- if(stats.mode != GameEngineStats.MODE_LEVELDESIGNER)
- {
- }
- WeatherHandler.display();
- DeltaWallHandler.attach();
- TextHandler.attach();
- Main.getStage().addChild(course);
- Main.getStage().addChild(top);
- Main.getStage().addChild(signLayer);
- if(debugStats != null)
- {
- Main.getStage().addChild(debugStats);
- }
- GameEngine.stats.heroStats.countDelta();
- gravity_dir = stats.level.startgravity_dir;
- switch(stats.mode)
- {
- case GameEngineStats.MODE_LEVELDESIGNER:
- LevelDesignerEngine.start();
- break;
- case GameEngineStats.MODE_GAMEPLAY:
- GameplayEngine.start();
- break;
- case GameEngineStats.MODE_CINEMA:
- CinemaEngine.start();
- break;
- default:
- throw new Error("Unsupported game mode!");
- }
- Main.getStage().addChild(transitionLayer);
- Main.getStage().removeChild(loading);
- loading = null;
- if(Main.edges != null)
- {
- }
- Main.getStage().addEventListener(Event.ENTER_FRAME,enterFrame);
- Main.getStage().addEventListener(Event.DEACTIVATE,focusOut);
- Main.getStage().addEventListener(Event.ACTIVATE,focusIn);
- Main.getStage().stage.focus = null;
- removed = false;
- enterFrame(null);
- if(GameEngine.stats.mode != GameEngineStats.MODE_LEVELDESIGNER)
- {
- GameEngine.currentTransition = new Transition_Black(false,function finish():void
- {
- },10);
- GameEngine.currentTransition.attach();
- }
- };
- removed = false;
- slice = stats.getCurrentSlice();
- camera = new Camera();
- camera.camX = stats.heroStats.x;
- camera.camY = stats.heroStats.y;
- midbg_xoffset = slice.midbg_xoffset;
- midbg_yoffset = slice.midbg_yoffset;
- bg = BGFactory.createBG(slice.bg_num);
- closeBG = BGFactory.createCloseBG(slice.midbg_num);
- course = new Course();
- course.x = Main.visibleContent.x + Main.visibleContent.width / 2;
- course.y = Main.visibleContent.y + Main.visibleContent.height / 2;
- top = new MovieClip();
- top.x = Main.visibleContent.x;
- top.y = Main.visibleContent.y;
- top.scaleX = Main.visibleContent.width / Main.WIDTH;
- top.scaleY = Main.visibleContent.height / Main.HEIGHT;
- signLayer = new MovieClip();
- signLayer.x = Main.visibleContent.x;
- signLayer.y = Main.visibleContent.y;
- signLayer.scaleX = Main.visibleContent.width / Main.WIDTH;
- signLayer.scaleY = Main.visibleContent.height / Main.HEIGHT;
- transitionLayer = new MovieClip();
- transitionLayer.x = Main.visibleContent.x;
- transitionLayer.y = Main.visibleContent.y;
- transitionLayer.scaleX = Main.visibleContent.width / Main.WIDTH;
- transitionLayer.scaleY = Main.visibleContent.height / Main.HEIGHT;
- if(inTransition != null)
- {
- inTransition.attach();
- currentTransition = inTransition;
- }
- enterFrameArray = new Vector.<IEnterFrame>();
- triggerArray = new Vector.<FunctionSequence>();
- deltaEffectorArray = new Vector.<DeltaEffector>();
- enemyArray = new Vector.<Enemy>();
- boulderArray = new Vector.<Boulder>();
- deltaModifierArray = new Vector.<DeltaModifier>();
- spikesArray = new Vector.<Spikes>();
- spliter_XArray = new Vector.<Item_Splitter_X>();
- platforms_Cloud = new Vector.<Platform_Cloud>();
- platforms_Ground = new Vector.<Platform_Ground>();
- platforms_Damage = new Vector.<Platform_Damage>();
- gravityZones = new Vector.<GravityZone>();
- projectileArray = new Vector.<Projectile>();
- particleArray = new Vector.<Particle>();
- runTriggerCount = 0;
- TileHandler.start();
- WeatherHandler.start();
- new DeltaWallHandler();
- course.attachItems(onDone);
- }
- public static function saveHeroStatsToTemp() : void
- {
- tempHeroStats = course.hero.stats;
- }
- public static function triggerGameWin() : void
- {
- var _loc1_:GameWinStats = new GameWinStats();
- _loc1_.coins = getGlobalVar("g_COINS");
- _loc1_.endingHeroStats = tempHeroStats;
- _loc1_.levelNum = stats.levelnum;
- _loc1_.hardMode = stats.hardMode;
- _loc1_.largeCoins[0] = stats.collectedLargeSquares[0];
- _loc1_.largeCoins[1] = stats.collectedLargeSquares[1];
- _loc1_.largeCoins[2] = stats.collectedLargeSquares[2];
- _loc1_.time = stats.timeElasped;
- stats.onWin(_loc1_);
- }
- public static function triggerPrematureQuit() : void
- {
- var _loc1_:GameWinStats = new GameWinStats();
- _loc1_.coins = getGlobalVar("g_COINS");
- _loc1_.endingHeroStats = tempHeroStats;
- _loc1_.levelNum = stats.levelnum;
- _loc1_.hardMode = stats.hardMode;
- _loc1_.largeCoins[0] = stats.collectedLargeSquares[0];
- _loc1_.largeCoins[1] = stats.collectedLargeSquares[1];
- _loc1_.largeCoins[2] = stats.collectedLargeSquares[2];
- _loc1_.time = stats.timeElasped;
- stats.onQuit(_loc1_);
- }
- public static function generatePauseMenu(param1:int) : void
- {
- pauseMenu.generate(param1);
- }
- private static function removePauseMenu() : void
- {
- pauseMenu.remove();
- }
- private static function focusOut(param1:Event) : void
- {
- KeyEngine.forceAllKeysUnpressed();
- if(!pauseMenu.exists)
- {
- generatePauseMenu(HUD_Shell.MODE_MAIN);
- }
- }
- private static function focusIn(param1:Event) : void
- {
- KeyEngine.forceAllKeysUnpressed();
- if(stats.mode != GameEngineStats.MODE_GAMEPLAY)
- {
- paused = false;
- }
- }
- private static function pauseEnterFrame() : void
- {
- pauseMenu.enterFrame();
- }
- private static function enterFrame(param1:Event) : void
- {
- var i:int = 0;
- var zoom:Number = NaN;
- var e:Event = param1;
- BehaviorHandler.enterFrame();
- if(removed)
- {
- return;
- }
- if(paused)
- {
- pauseEnterFrame();
- return;
- }
- if(stats.mode == GameEngineStats.MODE_GAMEPLAY)
- {
- if(KeyEngine.ld("p") <= 1)
- {
- generatePauseMenu(HUD_Shell.MODE_MAIN);
- }
- else if(KeyEngine.ld("e") <= 1)
- {
- generatePauseMenu(HUD_Shell.MODE_INVENTORY);
- }
- }
- if(currentTransition != null)
- {
- if(currentTransition.exists == true)
- {
- currentTransition.enterFrame();
- }
- else
- {
- currentTransition.remove();
- currentTransition = null;
- }
- }
- if(removed)
- {
- return;
- }
- try
- {
- if(QualityHandler.frameRate == 60)
- {
- framerateMultiplier = 0.5;
- worldSpeed = _worldSpeed * 0.5;
- }
- else
- {
- framerateMultiplier = 1;
- worldSpeed = _worldSpeed;
- }
- if(deltaLevel > 1)
- {
- worldSpeed = worldSpeed / deltaLevel;
- }
- camera.beginFrame();
- WeatherHandler.enterFrame();
- TextHandler.enterFrame();
- if(WaterSurface.updateGraphics)
- {
- WaterSurface.updateWaterGFX();
- WaterSurface.updateGraphics = false;
- }
- switch(stats.mode)
- {
- case GameEngineStats.MODE_LEVELDESIGNER:
- LevelDesignerEngine.enterFrame();
- break;
- case GameEngineStats.MODE_GAMEPLAY:
- GameplayEngine.enterFrame();
- break;
- case GameEngineStats.MODE_CINEMA:
- CinemaEngine.enterFrame();
- break;
- default:
- throw new Error("Unsupported game mode!");
- }
- if(removed)
- {
- return;
- }
- DeltaWallHandler.handleDeltaWalls();
- deltaEnterFrame();
- usingScreenBuffer = deltaTransformed || (QualityHandler.useScreenBuffer || WeatherHandler.post != null);
- if((QualityHandler.useScreenBuffer || WeatherHandler.post != null) && deltaTransformed == false)
- {
- if(screenBuffer == null)
- {
- screenBuffer = new BitmapData(Main.WIDTH,Main.HEIGHT,false,0);
- }
- if(screenBufferBit == null)
- {
- screenBufferBit = new Bitmap(screenBuffer);
- Main.getStage().addChildAt(screenBufferBit,0);
- screenBufferBit.x = Main.visibleContent.x;
- screenBufferBit.y = Main.visibleContent.y;
- screenBufferBit.scaleX = Main.visibleContent.width / Main.WIDTH;
- screenBufferBit.scaleY = Main.visibleContent.height / Main.HEIGHT;
- if(bg != null)
- {
- bg.setVisible(false);
- }
- if(closeBG != null)
- {
- closeBG.setVisible(false);
- }
- }
- course.visible = false;
- top.visible = false;
- screenBuffer.lock();
- if(bg != null)
- {
- bg.drawTo(screenBuffer);
- }
- else
- {
- screenBuffer.fillRect(screenBuffer.rect,0);
- }
- if(closeBG != null)
- {
- closeBG.drawTo(screenBuffer);
- }
- zoom = camera.currentZoom / 100;
- if(QualityHandler.canZoom == false)
- {
- zoom = 1;
- }
- screenBuffer.draw(course,new Matrix(zoom,0,0,zoom,Main.WIDTH / 2,Main.HEIGHT / 2));
- screenBuffer.draw(top,new Matrix(1,0,0,1,0,0));
- if(WeatherHandler.post != null)
- {
- if(WeatherHandler.post.supportsOnlyColorTransform())
- {
- screenBuffer.colorTransform(screenBuffer.rect,WeatherHandler.post.getColorTransform());
- }
- else
- {
- screenBuffer.applyFilter(screenBuffer,screenBuffer.rect,new Point(),new ColorMatrixFilter(WeatherHandler.post.getMatrix()));
- }
- }
- screenBuffer.unlock();
- }
- else
- {
- if(screenBuffer != null)
- {
- if(deltaTransformed == false)
- {
- if(bg != null)
- {
- bg.setVisible(true);
- }
- if(closeBG != null)
- {
- closeBG.setVisible(true);
- }
- course.visible = true;
- top.visible = true;
- }
- screenBuffer.dispose();
- screenBuffer = null;
- }
- if(screenBufferBit != null)
- {
- Main.getStage().removeChild(screenBufferBit);
- screenBufferBit = null;
- }
- }
- if(WeatherHandler.weather_darkness != null)
- {
- if(WeatherHandler.weather_darkness.screenLocked == true)
- {
- WeatherHandler.weather_darkness.unlockScreen();
- }
- }
- MusicHandler.refreshVolume();
- if(trigger_cinemaMode == false && heroAnimation_cinemaMode == false && heroAnimation_wormholeCinema == false)
- {
- stats.timeElasped = stats.timeElasped + framerateMultiplier / 30;
- }
- return;
- }
- catch(ended:GameEndedException)
- {
- ended.close();
- return;
- }
- }
- public static function callEnterFrames() : void
- {
- var _loc1_:int = 0;
- if(course.attachingItems == false)
- {
- if(deathPause == false)
- {
- _loc1_ = 0;
- while(_loc1_ < enterFrameArray.length)
- {
- if(enterFrameArray[_loc1_].enterFrame())
- {
- if(removed)
- {
- throw new GameEndedException();
- }
- enterFrameArray[_loc1_].enterFrameRemoved();
- enterFrameArray.splice(_loc1_--,1);
- }
- _loc1_++;
- }
- if(heroAnimation_cinemaMode == false)
- {
- _loc1_ = 0;
- while(_loc1_ < projectileArray.length)
- {
- if(projectileArray[_loc1_].exists == true)
- {
- projectileArray[_loc1_].enterFrame();
- }
- else
- {
- projectileArray.splice(_loc1_--,1);
- }
- _loc1_++;
- }
- }
- _loc1_ = 0;
- while(_loc1_ < particleArray.length)
- {
- if(particleArray[_loc1_].exists == true)
- {
- particleArray[_loc1_].enterFrame();
- }
- else
- {
- particleArray.splice(_loc1_--,1);
- }
- _loc1_++;
- }
- _loc1_ = 0;
- while(_loc1_ < platforms_Cloud.length)
- {
- if(platforms_Cloud[_loc1_].exists_cloud() == false)
- {
- platforms_Cloud.splice(_loc1_--,1);
- }
- _loc1_++;
- }
- _loc1_ = 0;
- while(_loc1_ < platforms_Ground.length)
- {
- if(platforms_Ground[_loc1_].exists_ground() == false)
- {
- platforms_Ground.splice(_loc1_--,1);
- }
- _loc1_++;
- }
- _loc1_ = 0;
- while(_loc1_ < platforms_Damage.length)
- {
- if(platforms_Damage[_loc1_].exists_damage() == false)
- {
- platforms_Damage.splice(_loc1_--,1);
- }
- _loc1_++;
- }
- _loc1_ = 0;
- while(_loc1_ < gravityZones.length)
- {
- if(gravityZones[_loc1_].exists_gravityZone() == false)
- {
- gravityZones.splice(_loc1_--,1);
- }
- _loc1_++;
- }
- if(heroAnimation_cinemaMode == false)
- {
- if(QualityHandler.frameRate == 60)
- {
- runTriggerCount = runTriggerCount + 0.5;
- }
- else
- {
- runTriggerCount = runTriggerCount + 1;
- }
- if(runTriggerCount >= 1)
- {
- _loc1_ = 0;
- while(_loc1_ < triggerArray.length)
- {
- if(triggerArray[_loc1_].run())
- {
- triggerArray[_loc1_].removedFromList();
- triggerArray.splice(_loc1_--,1);
- }
- _loc1_++;
- }
- runTriggerCount = runTriggerCount - 1;
- }
- trigger_cinemaMode = false;
- _loc1_ = 0;
- while(_loc1_ < triggerArray.length)
- {
- if(triggerArray[_loc1_].playing)
- {
- triggerArray[_loc1_].apply();
- }
- _loc1_++;
- }
- _loc1_ = 0;
- while(_loc1_ < deltaEffectorArray.length)
- {
- if(deltaEffectorArray[_loc1_].enterFrame())
- {
- if(deltaEffectorArray[_loc1_].parent != null)
- {
- deltaEffectorArray[_loc1_].parent.removeChild(deltaEffectorArray[_loc1_]);
- }
- deltaEffectorArray.splice(_loc1_--,1);
- }
- _loc1_++;
- }
- _loc1_ = 0;
- while(_loc1_ < enemyArray.length)
- {
- if(enemyArray[_loc1_].exists == true)
- {
- enemyArray[_loc1_].enterFrame();
- }
- else
- {
- enemyArray.splice(_loc1_--,1);
- }
- _loc1_++;
- }
- _loc1_ = 0;
- while(_loc1_ < boulderArray.length)
- {
- if(boulderArray[_loc1_].exists == true)
- {
- boulderArray[_loc1_].enterFrame();
- }
- else
- {
- boulderArray.splice(_loc1_--,1);
- }
- _loc1_++;
- }
- }
- }
- }
- }
- public static function transitionTo(param1:int) : void
- {
- var newSlice:int = param1;
- stats.heroStats.x = course.hero.x;
- stats.heroStats.y = course.hero.y;
- stats.heroStats.xspeed = course.hero.xspeed;
- stats.heroStats.yspeed = course.hero.yspeed;
- stats.heroStats.direction = course.hero.Direction;
- stats.currentSlice = newSlice;
- remove();
- throw new GameEndedException(function go():void
- {
- start(stats);
- });
- }
- public static function door_transitionTo(param1:Number, param2:Number) : void
- {
- var _loc4_:int = 0;
- var _loc5_:* = null;
- if(course.hero == null)
- {
- return;
- }
- course.hero.x = param1;
- course.hero.y = param2;
- var _loc3_:int = -1;
- while(_loc4_ < stats.slices.length)
- {
- _loc5_ = stats.slices[_loc4_];
- if(param1 >= _loc5_.leftX && param1 < _loc5_.rightX && param2 >= _loc5_.upY && param2 < _loc5_.downY)
- {
- _loc3_ = _loc4_;
- break;
- }
- _loc4_++;
- }
- if(_loc3_ != -1)
- {
- transitionTo(_loc3_);
- }
- else
- {
- camera.camX = course.hero.centerX;
- camera.camY = course.hero.centerY;
- camera.zoom = 100;
- TileHandler.teleportCamera(camera.camX,camera.camY);
- GameEngine.currentTransition = new Transition_Black(false,null,10);
- GameEngine.currentTransition.attach();
- }
- }
- public static function setItemLoadingProgress(param1:Number) : void
- {
- if(loading != null)
- {
- if(loading is LevelPreloader)
- {
- (loading as LevelPreloader)._bar._fill.scaleX = param1;
- }
- }
- }
- public static function resetCameraPosition() : void
- {
- var _loc4_:* = null;
- var _loc1_:int = 0;
- var _loc2_:int = 0;
- var _loc3_:int = 0;
- _loc1_ = 0;
- while(_loc1_ < stats.level.itemLayers.allItems.length)
- {
- _loc4_ = stats.level.itemLayers.allItems[_loc1_];
- if(_loc4_.num == 0 && _loc4_.cl == Item_StartPosition)
- {
- _loc2_ = _loc4_.x;
- _loc3_ = _loc4_.y;
- break;
- }
- _loc1_++;
- }
- camera.camX = _loc2_;
- camera.camY = _loc3_;
- camera.zoom = 100;
- TileHandler.teleportCamera(camera.camX,camera.camY);
- }
- public static function clearTilesColorData() : void
- {
- slice.levelData.backTiles.clearColors();
- slice.levelData.frontTiles.clearColors();
- }
- public static function setTilesColorData(param1:Function) : void
- {
- var i:int = 0;
- var items:Vector.<Item> = null;
- var doItems:Function = null;
- var onComplete:Function = param1;
- doItems = function(param1:Event):void
- {
- var _loc3_:int = 0;
- var _loc4_:int = 0;
- var _loc5_:int = 0;
- var _loc6_:int = 0;
- var _loc7_:* = null;
- var _loc8_:* = null;
- var _loc9_:* = null;
- var _loc2_:int = getTimer();
- while(i < items.length)
- {
- _loc7_ = items[i];
- if(_loc7_.cl == Item_ColorBox)
- {
- _loc8_ = _loc7_ as Item_ColorBox;
- _loc3_ = (_loc8_.x - slice.leftX) / 32;
- _loc4_ = (_loc8_.y - slice.upY) / 32;
- _loc6_ = _loc4_;
- while(_loc6_ < _loc8_.height + _loc4_)
- {
- _loc5_ = _loc3_;
- while(_loc5_ < _loc8_.width + _loc3_)
- {
- if(_loc5_ >= 0 && _loc6_ >= 0)
- {
- if(_loc5_ >= slice.levelData.width)
- {
- _loc5_ = _loc8_.width + _loc3_;
- break;
- }
- if(_loc6_ >= slice.levelData.height)
- {
- _loc5_ = _loc8_.width + _loc3_;
- _loc6_ = _loc8_.height + _loc4_;
- break;
- }
- if(_loc8_.itemLayer.layerNum <= 1)
- {
- slice.levelData.backTiles.getTileAt(_loc5_,_loc6_).colors = _loc8_.colors;
- }
- else
- {
- slice.levelData.frontTiles.getTileAt(_loc5_,_loc6_).colors = _loc8_.colors;
- }
- }
- _loc5_++;
- }
- _loc6_++;
- }
- }
- if(_loc7_.cl == Item_DeltaNegate)
- {
- _loc9_ = _loc7_ as Item_DeltaNegate;
- _loc3_ = _loc9_.x / 32;
- _loc4_ = _loc9_.y / 32;
- _loc6_ = _loc4_;
- while(_loc6_ < _loc9_.height + _loc4_)
- {
- _loc5_ = _loc3_;
- while(_loc5_ < _loc9_.width + _loc3_)
- {
- if(_loc5_ >= 0 && _loc6_ >= 0)
- {
- if(_loc5_ >= slice.levelData.width)
- {
- _loc5_ = _loc9_.width + _loc3_;
- break;
- }
- if(_loc6_ >= slice.levelData.height)
- {
- _loc5_ = _loc9_.width + _loc3_;
- _loc6_ = _loc9_.height + _loc4_;
- break;
- }
- if(_loc9_.itemLayer.layerNum > 1)
- {
- slice.levelData.frontTiles.getTileAt(_loc5_,_loc6_).overwrite = _loc9_.overwrite;
- }
- }
- _loc5_++;
- }
- _loc6_++;
- }
- }
- i++;
- if(getTimer() - _loc2_ > loadingThreshold)
- {
- return;
- }
- }
- Main.getStage().removeEventListener(Event.ENTER_FRAME,doItems);
- onComplete();
- };
- items = slice.levelData.itemLayers.allItems;
- Main.getStage().addEventListener(Event.ENTER_FRAME,doItems);
- doItems(null);
- }
- public static function updateLinkage(param1:Item, param2:String) : void
- {
- if(param1.linkage != null && param1.linkage != "")
- {
- stats.level.itemLayers.removeLinkage(param1.linkage,param1);
- }
- param1.linkage = param2;
- if(param1.linkage != null && param1.linkage != "")
- {
- stats.level.itemLayers.addLinkage(param1.linkage,param1);
- }
- }
- public static function isValidTagName_Write(param1:String) : Boolean
- {
- var _loc2_:int = 0;
- var _loc3_:* = null;
- if(param1 == null)
- {
- return true;
- }
- if(param1 == "")
- {
- return true;
- }
- if(FunctionSequence.isSelfTag(param1))
- {
- return false;
- }
- if(param1.length >= 1)
- {
- _loc2_ = param1.charCodeAt(0);
- _loc3_ = param1.charAt(0);
- if(_loc2_ >= 48 && _loc2_ <= 57)
- {
- return false;
- }
- if(_loc3_ == ".")
- {
- return false;
- }
- return true;
- }
- return true;
- }
- public static function isValidTagName_Read(param1:String) : Boolean
- {
- var _loc2_:int = 0;
- var _loc3_:* = null;
- if(param1 == null)
- {
- return false;
- }
- if(param1 == "")
- {
- return false;
- }
- if(param1.length >= 1)
- {
- _loc2_ = param1.charCodeAt(0);
- _loc3_ = param1.charAt(0);
- if(_loc2_ >= 48 && _loc2_ <= 57)
- {
- return false;
- }
- if(_loc3_ == ".")
- {
- return false;
- }
- return true;
- }
- return true;
- }
- public static function isValidVarName(param1:String) : Boolean
- {
- var _loc2_:int = 0;
- var _loc3_:* = null;
- if(param1 == null)
- {
- return false;
- }
- if(param1.length >= 1)
- {
- _loc2_ = param1.charCodeAt(0);
- _loc3_ = param1.charAt(0);
- if(_loc2_ >= 48 && _loc2_ <= 57)
- {
- return false;
- }
- if(_loc3_ == ".")
- {
- return false;
- }
- return true;
- }
- return false;
- }
- public static function isVarANumber(param1:String) : Boolean
- {
- var _loc2_:int = 0;
- if(param1 == null)
- {
- return false;
- }
- if(param1.length >= 1)
- {
- _loc2_ = param1.charCodeAt(0);
- if(_loc2_ >= 48 && _loc2_ <= 57)
- {
- return true;
- }
- }
- return false;
- }
- public static function isStaticGlobalVar(param1:String) : Boolean
- {
- if(param1.slice(0,2) == "s_")
- {
- return true;
- }
- return false;
- }
- public static function getGlobalVar(param1:String) : int
- {
- var str:String = param1;
- var r:int = 0;
- if(isVarANumber(str))
- {
- try
- {
- r = parseInt(str);
- }
- catch(e:Error)
- {
- r = 0;
- }
- }
- else if(isStaticGlobalVar(str))
- {
- r = stats.staticVars[str];
- }
- else if(stats.level.globalVars[str] != null)
- {
- r = stats.level.globalVars[str];
- }
- return r;
- }
- public static function setVar(param1:String, param2:int) : void
- {
- if(isStaticGlobalVar(param1))
- {
- stats.staticVars[param1] = param2;
- }
- else
- {
- stats.level.globalVars[param1] = param2;
- }
- }
- public static function numberOfItemsWithThisTag(param1:String) : int
- {
- if(param1 == null)
- {
- return 0;
- }
- if(param1 == "")
- {
- return 0;
- }
- if(FunctionSequence.isSelfTag(param1))
- {
- return 1;
- }
- var _loc2_:Vector.<Item> = getLinkageFromGlobal(param1);
- if(_loc2_ == null)
- {
- return 0;
- }
- return _loc2_.length;
- }
- public static function getLinkage(param1:String) : Vector.<Item>
- {
- return slice.levelData.itemLayers.getLinkage(param1);
- }
- public static function getLinkageFromGlobal(param1:String) : Vector.<Item>
- {
- return stats.level.itemLayers.getLinkage(param1);
- }
- public static function findCenterOfVItem(param1:Vector.<Item>) : Point
- {
- var _loc5_:int = 0;
- if(param1 == null)
- {
- return new Point();
- }
- var _loc2_:* = 0;
- var _loc3_:* = 0;
- var _loc4_:int = param1.length;
- _loc5_ = 0;
- while(_loc5_ < _loc4_)
- {
- _loc2_ = Number(_loc2_ + param1[_loc5_].x);
- _loc3_ = Number(_loc3_ + param1[_loc5_].y);
- _loc5_++;
- }
- _loc2_ = Number(_loc2_ / _loc4_);
- _loc3_ = Number(_loc3_ / _loc4_);
- return new Point(_loc2_,_loc3_);
- }
- public static function resyncItems() : void
- {
- var _loc2_:int = 0;
- var _loc1_:Vector.<Item> = slice.levelData.itemLayers.allItems;
- _loc2_ = 0;
- while(_loc2_ < _loc1_.length)
- {
- if(_loc1_[_loc2_] is ISynchronize)
- {
- (_loc1_[_loc2_] as ISynchronize).resyncronize();
- }
- _loc2_++;
- }
- }
- public static function getGravityAt(param1:int, param2:int) : Point
- {
- var _loc5_:int = 0;
- var _loc6_:Number = NaN;
- var _loc3_:Number = Number.MAX_VALUE;
- var _loc4_:* = null;
- _loc5_ = 0;
- while(_loc5_ < gravityZones.length)
- {
- _loc6_ = gravityZones[_loc5_].hitTest_gravityZone(param1,param2);
- if(_loc6_ < _loc3_)
- {
- _loc3_ = _loc6_;
- _loc4_ = gravityZones[_loc5_];
- }
- _loc5_++;
- }
- if(_loc4_ != null)
- {
- gravityPoint = _loc4_.getGravityAt(param1,param2);
- }
- else
- {
- gravityPoint.x = Math.cos((gravity_dir + 90) * Math.PI / 180);
- gravityPoint.y = Math.sin((gravity_dir + 90) * Math.PI / 180);
- }
- return gravityPoint;
- }
- public static function setGravityStatsAt(param1:GravityStats) : void
- {
- var _loc4_:int = 0;
- var _loc5_:Number = NaN;
- var _loc2_:Number = Number.MAX_VALUE;
- var _loc3_:* = null;
- _loc4_ = 0;
- while(_loc4_ < gravityZones.length)
- {
- _loc5_ = gravityZones[_loc4_].hitTest_gravityZone(param1.x,param1.y);
- if(_loc5_ < _loc2_)
- {
- _loc2_ = _loc5_;
- _loc3_ = gravityZones[_loc4_];
- }
- _loc4_++;
- }
- param1.setZone(_loc3_);
- }
- public static function getGravityAngleAt(param1:int, param2:int) : Number
- {
- var _loc3_:Point = getGravityAt(param1,param2);
- return Math.atan2(_loc3_.x,_loc3_.y) * 180 / Math.PI;
- }
- public static function hitTestGroundOrPlatforms(param1:int, param2:int) : Boolean
- {
- return hitTestGround(param1,param2) || hitTestPlatforms(param1,param2);
- }
- public static function getNormalOnGround(param1:int, param2:int, param3:Number = 10) : Number
- {
- var _loc4_:* = 0;
- var _loc5_:Number = Math.PI / 8;
- while(_loc5_ > 0.01)
- {
- if(hitTestGroundOrPlatforms(param1 + Math.cos(_loc4_) * param3,param2 + Math.sin(_loc4_) * param3))
- {
- _loc4_ = Number(_loc4_ - _loc5_);
- }
- else
- {
- _loc4_ = Number(_loc4_ + _loc5_);
- }
- _loc5_ = _loc5_ / 1.1;
- }
- return _loc4_ - Math.PI / 2;
- }
- public static function hitTestGround(param1:int, param2:int) : Boolean
- {
- var _loc5_:int = 0;
- var _loc6_:* = 0;
- var _loc7_:int = 0;
- var _loc8_:int = 0;
- var _loc9_:int = 0;
- var _loc10_:Number = NaN;
- var _loc3_:int = param1 - TileHandler.mx * 32 + TileHandler.tx * 16 - slice.leftX;
- var _loc4_:int = param2 - TileHandler.my * 32 + TileHandler.ty * 16 - slice.upY;
- if(_loc3_ >= 0 && _loc4_ >= 0 && _loc3_ < course.groundTiles.width && _loc4_ < course.groundTiles.height)
- {
- _loc6_ = uint(course.groundTiles.getPixel(_loc3_,_loc4_));
- if((_loc6_ & 65280) == 65280)
- {
- return true;
- }
- }
- else
- {
- _loc7_ = TileHandler.mx + (_loc3_ - TileHandler.tx * 16) / 32;
- _loc8_ = TileHandler.my + (_loc4_ - TileHandler.ty * 16) / 32;
- _loc9_ = slice.levelData.frontTiles.getTileNumAt(_loc7_,_loc8_);
- if(_loc9_ >= 1 && _loc9_ != 1000)
- {
- return true;
- }
- }
- _loc5_ = 0;
- while(_loc5_ < platforms_Ground.length)
- {
- if(platforms_Ground[_loc5_].hitTest_ground(param1,param2))
- {
- return true;
- }
- _loc5_++;
- }
- if(GameEngine.stats.mode == GameEngineStats.MODE_GAMEPLAY)
- {
- if(slice.edgeDown == -1)
- {
- _loc10_ = Math.abs(Maths.subtractAngles(gravity_dir,0));
- if(param2 > slice.rightX && (_loc10_ > 45 && _loc10_ < 135))
- {
- return true;
- }
- }
- if(slice.edgeUp == -1)
- {
- _loc10_ = Math.abs(Maths.subtractAngles(gravity_dir,180));
- if(param2 < slice.upY && (_loc10_ > 45 && _loc10_ < 135))
- {
- return true;
- }
- }
- if(slice.edgeLeft == -1)
- {
- _loc10_ = Math.abs(Maths.subtractAngles(gravity_dir,90));
- if(param1 < slice.leftX && (_loc10_ > 45 && _loc10_ < 135))
- {
- return true;
- }
- }
- if(slice.edgeRight == -1)
- {
- _loc10_ = Math.abs(Maths.subtractAngles(gravity_dir,-90));
- if(param1 > slice.rightX && (_loc10_ > 45 && _loc10_ < 135))
- {
- return true;
- }
- }
- }
- else
- {
- if(param2 > slice.levelData.height * 32)
- {
- return true;
- }
- if(param2 < 0)
- {
- return true;
- }
- if(param1 < 0)
- {
- return true;
- }
- if(param1 > slice.levelData.width * 32)
- {
- return true;
- }
- }
- return false;
- }
- public static function hitTestPlatforms(param1:int, param2:int) : Boolean
- {
- var _loc5_:int = 0;
- var _loc6_:* = 0;
- var _loc3_:int = param1 - TileHandler.mx * 32 + TileHandler.tx * 16 - slice.leftX;
- var _loc4_:int = param2 - TileHandler.my * 32 + TileHandler.ty * 16 - slice.upY;
- if(_loc3_ >= 0 && _loc4_ >= 0 && _loc3_ < course.groundTiles.width && _loc4_ < course.groundTiles.height)
- {
- _loc6_ = uint(course.groundTiles.getPixel(_loc3_,_loc4_));
- if((_loc6_ & 65535) == 65535)
- {
- return true;
- }
- }
- _loc5_ = 0;
- while(_loc5_ < platforms_Cloud.length)
- {
- if(platforms_Cloud[_loc5_].hitTest_cloud(param1,param2))
- {
- return true;
- }
- _loc5_++;
- }
- return false;
- }
- public static function hitTestDamage(param1:int, param2:int) : int
- {
- var _loc5_:int = 0;
- var _loc6_:* = 0;
- var _loc7_:int = 0;
- var _loc3_:int = param1 - TileHandler.mx * 32 + TileHandler.tx * 16 - slice.leftX;
- var _loc4_:int = param2 - TileHandler.my * 32 + TileHandler.ty * 16 - slice.upY;
- if(_loc3_ >= 0 && _loc4_ >= 0 && _loc3_ < course.groundTiles.width && _loc4_ < course.groundTiles.height)
- {
- _loc6_ = uint(course.groundTiles.getPixel(_loc3_,_loc4_));
- return 0;
- }
- _loc5_ = 0;
- while(_loc5_ < platforms_Damage.length)
- {
- _loc7_ = platforms_Damage[_loc5_].hitTest_damage(param1,param2);
- if(_loc7_ != 0)
- {
- return _loc7_;
- }
- _loc5_++;
- }
- return 0;
- }
- public static function hitTestType(param1:int, param2:int) : int
- {
- var _loc5_:int = 0;
- var _loc6_:* = 0;
- var _loc3_:int = param1 - TileHandler.mx * 32 + TileHandler.tx * 16 - slice.leftX;
- var _loc4_:int = param2 - TileHandler.my * 32 + TileHandler.ty * 16 - slice.upY;
- _loc5_ = 0;
- while(_loc5_ < platforms_Ground.length)
- {
- if(platforms_Ground[_loc5_].hitTest_ground(param1,param2))
- {
- return platforms_Ground[_loc5_].hitTest_type(param1,param2);
- }
- _loc5_++;
- }
- _loc5_ = 0;
- while(_loc5_ < platforms_Cloud.length)
- {
- if(platforms_Cloud[_loc5_].hitTest_cloud(param1,param2))
- {
- return platforms_Cloud[_loc5_].hitTest_type(param1,param2);
- }
- _loc5_++;
- }
- if(_loc3_ >= 0 && _loc4_ >= 0 && _loc3_ < course.groundTiles.width && _loc4_ < course.groundTiles.height)
- {
- _loc6_ = uint(course.groundTiles.getPixel(_loc3_,_loc4_));
- return (_loc6_ & 16711680) >> 16;
- }
- return -1;
- }
- public static function playSound(param1:int, param2:Character, param3:Number = 1) : SoundChannel
- {
- return playSoundAt(param1,param2.centerX,param2.centerY,param3);
- }
- public static function playSoundAt(param1:int, param2:int, param3:int, param4:Number = 1) : SoundChannel
- {
- var _loc5_:Number = (param2 - camera.camX) * camera.currentZoom / 100;
- var _loc6_:Number = (param3 - camera.camY) * camera.currentZoom / 100;
- var _loc7_:Number = Math.sqrt(_loc5_ * _loc5_ + _loc6_ * _loc6_);
- var _loc10_:Number = 1 - Math.max(_loc7_ - 150,0) / 500;
- if(_loc10_ <= 0)
- {
- return null;
- }
- var _loc11_:Number = _loc5_ / 400;
- _loc11_ = Math.min(_loc11_,1);
- _loc11_ = Math.max(_loc11_,-1);
- if(_loc10_ < 0.05)
- {
- return null;
- }
- return SoundHandler.playSound(param1,0,0,_loc10_ * param4,_loc11_);
- }
- public static function triggerDeath() : void
- {
- var cueMenu:Function = null;
- var count:Number = NaN;
- var count2:Number = NaN;
- var triggerMusic:Boolean = false;
- cueMenu = function(param1:Event):void
- {
- if(pauseMenu != null)
- {
- pauseMenu.switchMode(HUD_Shell.MODE_REMOVED);
- }
- if(deathRespawnCue == null)
- {
- Main.getStage().removeEventListener(Event.ENTER_FRAME,cueMenu);
- return;
- }
- count = count + worldSpeed;
- count2 = count2 + worldSpeed;
- if(count > 1)
- {
- if(deathRespawnCue.currentFrame < deathRespawnCue.totalFrames)
- {
- deathRespawnCue.nextFrame();
- }
- count = count - 1;
- }
- if(count2 >= 91)
- {
- if(triggerMusic == false)
- {
- MusicHandler.playTheme(16);
- triggerMusic = true;
- }
- }
- if(deathRespawnCue == null)
- {
- Main.getStage().removeEventListener(Event.ENTER_FRAME,cueMenu);
- }
- 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)
- {
- KeyEngine.forceAllKeysUnpressed();
- Main.getStage().removeEventListener(Event.ENTER_FRAME,cueMenu);
- Main.getStage().removeChild(deathRespawnCue);
- deathRespawnCue = null;
- MusicHandler.stopMusic();
- remove();
- GameEngine.stats.heroStats.loadSpawnPoint();
- GameEngine.stats.startedMusicAlready = false;
- GameEngine.start(GameEngine.stats);
- }
- };
- if(stats.mode == GameEngineStats.MODE_LEVELDESIGNER)
- {
- return;
- }
- if(deathPause == false)
- {
- deathPause = true;
- MusicHandler.stopMusic();
- deathRespawnCue = new c_PressAButtonToRespawn();
- deathRespawnCue.x = Main.visibleContent.x;
- deathRespawnCue.y = Main.visibleContent.y;
- deathRespawnCue.scaleX = Main.visibleContent.width / Main.WIDTH;
- deathRespawnCue.scaleY = Main.visibleContent.height / Main.HEIGHT;
- Main.getStage().addChild(deathRespawnCue);
- deathRespawnCue.gotoAndStop(1);
- if(course.hero != null)
- {
- course.hero.remove();
- course.hero = null;
- }
- count = 0;
- count2 = 0;
- triggerMusic = false;
- Main.getStage().addEventListener(Event.ENTER_FRAME,cueMenu);
- }
- }
- public static function setWorldSpeed(param1:Number) : void
- {
- _worldSpeed = param1;
- }
- public static function friction(param1:Number) : Number
- {
- return Math.pow(1 - 1 / param1,worldSpeed);
- }
- public static function ease(param1:Number) : Number
- {
- return 1 / param1 * worldSpeed;
- }
- public static function deltaEnterFrame() : void
- {
- var _loc1_:int = 0;
- var _loc2_:* = null;
- var _loc3_:int = 0;
- var _loc4_:int = 0;
- var _loc5_:* = null;
- var _loc6_:* = null;
- var _loc7_:* = null;
- var _loc8_:* = null;
- var _loc9_:* = null;
- var _loc10_:int = 0;
- var _loc11_:int = 0;
- var _loc12_:* = null;
- var _loc13_:int = 0;
- var _loc14_:int = 0;
- MusicHandler.musicDynamicVolume = MusicHandler.musicDynamicVolume * (1 - 0.8 * (deltaLevel / 10));
- if(delta)
- {
- if(QualityHandler.frameRate == 60)
- {
- deltaTime = deltaTime + 0.5;
- }
- else
- {
- deltaTime = deltaTime + 1;
- }
- if(deltaLevel < 10)
- {
- if(QualityHandler.frameRate == 60)
- {
- deltaLevel = deltaLevel + 1;
- }
- else
- {
- deltaLevel = deltaLevel + 0.5;
- }
- }
- if(deltaTransformed == false)
- {
- course.visible = false;
- top.visible = false;
- deltaCircle = new DeltaCircle(course.hero);
- deltaCursor = new DeltaCursor(course.hero);
- if(bg != null)
- {
- bg.setVisible(false);
- }
- if(closeBG != null)
- {
- closeBG.setVisible(false);
- }
- deltaBitmap = new Bitmap(deltaBitmapData);
- deltaBitmapData.fillRect(deltaBitmapData.rect,16777215);
- Main.getStage().addChildAt(deltaBitmap,0);
- deltaEffectContainer = new MovieClip();
- _loc1_ = 0;
- while(_loc1_ < deltaEffectorArray.length)
- {
- deltaEffectContainer.addChild(deltaEffectorArray[_loc1_]);
- _loc1_++;
- }
- deltaEffectContainer.addChild(deltaCircle);
- deltaEffectContainer.addChild(deltaCursor);
- Main.getStage().addChildAt(deltaEffectContainer,1);
- if(debugStats != null)
- {
- Main.getStage().removeChild(debugStats);
- Main.getStage().addChild(debugStats);
- }
- deltaTransformed = true;
- deltaTime = Math.random() * 40000;
- if(deltaSFX == null)
- {
- deltaSFX = SoundHandler.playSound(SoundHandler.USE_DELTA,0,9999,deltaLevel / 10,0);
- }
- }
- }
- else if(deltaLevel > 0)
- {
- deltaLevel--;
- }
- else if(deltaTransformed)
- {
- Main.getStage().removeChild(deltaBitmap);
- deltaBitmap = null;
- Main.getStage().removeChild(deltaEffectContainer);
- deltaEffectContainer = null;
- deltaCircle = null;
- deltaCursor = null;
- course.visible = true;
- top.visible = true;
- if(bg != null)
- {
- bg.setVisible(true);
- }
- if(closeBG != null)
- {
- closeBG.setVisible(true);
- }
- deltaTransformed = false;
- if(deltaSFX != null)
- {
- deltaSFX.stop();
- deltaSFX = null;
- }
- }
- if(deltaEffectContainer != null)
- {
- deltaEffectContainer.alpha = deltaLevel / 10;
- }
- if(deltaTransformed)
- {
- if(deltaSFX != null)
- {
- deltaSFX.soundTransform = new SoundTransform(deltaLevel / 10 * SavedData.getSoundsVolume(),0);
- }
- deltaBitmap.x = Main.visibleContent.x;
- deltaBitmap.y = Main.visibleContent.y;
- deltaBitmap.width = Main.visibleContent.width;
- deltaBitmap.height = Main.visibleContent.height;
- deltaEffectContainer.transform.matrix = course.midGFX.transform.concatenatedMatrix;
- deltaCircle.enterFrame();
- deltaCursor.enterFrame();
- deltaBitmapData.lock();
- deltaBitmapDataTemp.lock();
- if(bg != null)
- {
- bg.drawTo(deltaBitmapDataTemp);
- }
- else
- {
- deltaBitmapDataTemp.fillRect(deltaBitmapDataTemp.rect,4278190080);
- }
- if(closeBG != null)
- {
- closeBG.drawTo(deltaBitmapDataTemp);
- }
- course.frontTilesGFX.transform.colorTransform = new ColorTransform(1,1,1,1,deltaLevel * 5,deltaLevel * 5,deltaLevel * 5,0);
- deltaBitmapDataTemp.draw(course,new Matrix(camera.currentZoom / 100,0,0,camera.currentZoom / 100,Main.WIDTH / 2,Main.HEIGHT / 2));
- deltaBitmapDataTemp.draw(top,new Matrix(1,0,0,1,0,0));
- course.frontTilesGFX.transform.colorTransform = new ColorTransform();
- if(WeatherHandler.post != null)
- {
- if(WeatherHandler.post.supportsOnlyColorTransform())
- {
- deltaBitmapDataTemp.colorTransform(deltaBitmapDataTemp.rect,WeatherHandler.post.getColorTransform());
- }
- else
- {
- deltaBitmapDataTemp.applyFilter(deltaBitmapDataTemp,deltaBitmapDataTemp.rect,new Point(),new ColorMatrixFilter(WeatherHandler.post.getMatrix()));
- }
- }
- _loc2_ = new Colors();
- _loc2_.saturation = deltaLevel * -6;
- _loc2_.hue = deltaLevel * (Math.sin(deltaTime / 400) * 18);
- _loc2_.alphaMultiplier = 100 * (1 - deltaLevel / 20);
- _loc2_.redOffset = 0;
- _loc2_.greenOffset = 0;
- _loc2_.blueOffset = 0;
- _loc2_.redMultiplier = 100 - 100 * (deltaLevel / 50);
- _loc2_.greenMultiplier = 100 - 100 * (deltaLevel / 50);
- _loc2_.blueMultiplier = 100 - 100 * (deltaLevel / 50);
- _loc5_ = new Rectangle();
- _loc6_ = new Point();
- _loc7_ = new ColorMatrixFilter(_loc2_.getMatrix());
- _loc8_ = new ColorTransform(1 - 0.4 * (deltaLevel / 10),1 - 0.4 * (deltaLevel / 10),1 - 0.4 * (deltaLevel / 10),1 - 0.4 * (deltaLevel / 10));
- _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));
- _loc3_ = 0;
- while(_loc3_ < TileHandler.tx)
- {
- _loc4_ = 0;
- while(_loc4_ < TileHandler.ty)
- {
- _loc10_ = TileHandler.mx + _loc3_ - TileHandler.tx / 2;
- _loc11_ = TileHandler.my + _loc4_ - TileHandler.ty / 2;
- _loc12_ = slice.levelData.frontTiles.getTileAt(_loc10_,_loc11_);
- _loc5_.x = (-TileHandler.tx * 16 + TileHandler.px + _loc3_ * 32) * camera.currentZoom / 100 + Main.WIDTH / 2;
- _loc5_.y = (-TileHandler.ty * 16 + TileHandler.py + _loc4_ * 32) * camera.currentZoom / 100 + Main.HEIGHT / 2;
- _loc6_.x = _loc5_.x;
- _loc6_.y = _loc5_.y;
- _loc5_.width = 32 * camera.currentZoom / 100 + 2;
- _loc5_.height = 32 * camera.currentZoom / 100 + 2;
- if(_loc5_.right >= 0 && _loc5_.bottom >= 0 && _loc5_.left < deltaBitmapDataTemp.width && _loc5_.top < deltaBitmapDataTemp.height)
- {
- if(_loc12_.overwrite != Tile.OVERWRITE_DELTANEGATE && deltaCursor.inRange(_loc10_ + slice.leftTile,_loc11_ + slice.upTile))
- {
- _loc13_ = getDeltaTileModifierValue(_loc10_,_loc11_);
- _loc14_ = 0;
- if(stats.level.deltaonbydefault)
- {
- _loc14_ = 1;
- }
- if(_loc13_ + _loc14_ <= 0)
- {
- if(getDeltaTileModifierNegativeValue(_loc10_,_loc11_) < 0)
- {
- _loc5_.width = 32 * camera.currentZoom / 100 + 0.1;
- _loc5_.height = 32 * camera.currentZoom / 100 + 0.1;
- deltaBitmapDataTemp.colorTransform(_loc5_,_loc9_);
- }
- else
- {
- _loc5_.width = 32 * camera.currentZoom / 100 + 0.1;
- _loc5_.height = 32 * camera.currentZoom / 100 + 0.1;
- deltaBitmapDataTemp.colorTransform(_loc5_,_loc8_);
- }
- }
- else
- {
- deltaBitmapDataTemp.applyFilter(deltaBitmapDataTemp,_loc5_,_loc6_,_loc7_);
- }
- }
- else
- {
- _loc5_.width = 32 * camera.currentZoom / 100 + 0.1;
- _loc5_.height = 32 * camera.currentZoom / 100 + 0.1;
- deltaBitmapDataTemp.colorTransform(_loc5_,_loc8_);
- }
- }
- _loc4_++;
- }
- _loc3_++;
- }
- deltaBitmapData.copyPixels(deltaBitmapDataTemp,deltaBitmapDataTemp.rect,new Point(),deltaBitmapDataTemp,new Point(),true);
- deltaBitmapDataTemp.unlock();
- deltaBitmapData.unlock();
- }
- }
- public static function isTileDeltaEnable(param1:int, param2:int) : Boolean
- {
- param1 = param1 - slice.leftTile;
- param2 = param2 - slice.upTile;
- var _loc3_:int = 0;
- if(stats.level.deltaonbydefault)
- {
- _loc3_ = 1;
- }
- return getDeltaTileModifierValue(param1,param2) + _loc3_ > 0;
- }
- public static function getDeltaTileModifierValue(param1:int, param2:int) : int
- {
- var _loc3_:Tile = stats.level.frontTiles.getTileAt(param1 + slice.leftTile,param2 + slice.upTile);
- if(TileFactory.isTileNumDeltaAble(_loc3_.num) == false)
- {
- return -100;
- }
- var _loc4_:int = 0;
- var _loc5_:int = 0;
- while(_loc5_ < deltaModifierArray.length)
- {
- if(deltaModifierArray[_loc5_].deltaModifier_exists())
- {
- _loc4_ = _loc4_ + deltaModifierArray[_loc5_].deltaModifier_getTile(param1,param2);
- }
- else
- {
- deltaModifierArray.splice(_loc5_--,1);
- }
- _loc5_++;
- }
- return _loc4_;
- }
- public static function getDeltaTileModifierPositiveValue(param1:int, param2:int) : int
- {
- var _loc6_:int = 0;
- var _loc3_:Tile = stats.level.frontTiles.getTileAt(param1 + slice.leftTile,param2 + slice.upTile);
- if(TileFactory.isTileNumDeltaAble(_loc3_.num) == false)
- {
- return 0;
- }
- var _loc4_:int = 0;
- var _loc5_:int = 0;
- while(_loc5_ < deltaModifierArray.length)
- {
- if(deltaModifierArray[_loc5_].deltaModifier_exists())
- {
- _loc6_ = deltaModifierArray[_loc5_].deltaModifier_getTile(param1,param2);
- if(_loc6_ > 0)
- {
- _loc4_ = _loc4_ + _loc6_;
- }
- }
- else
- {
- deltaModifierArray.splice(_loc5_--,1);
- }
- _loc5_++;
- }
- return _loc4_;
- }
- public static function getDeltaTileModifierNegativeValue(param1:int, param2:int) : int
- {
- var _loc6_:int = 0;
- var _loc3_:Tile = stats.level.frontTiles.getTileAt(param1 + slice.leftTile,param2 + slice.upTile);
- if(TileFactory.isTileNumDeltaAble(_loc3_.num) == false)
- {
- return 0;
- }
- var _loc4_:int = 0;
- var _loc5_:int = 0;
- while(_loc5_ < deltaModifierArray.length)
- {
- if(deltaModifierArray[_loc5_].deltaModifier_exists())
- {
- _loc6_ = deltaModifierArray[_loc5_].deltaModifier_getTile(param1,param2);
- if(_loc6_ < 0)
- {
- _loc4_ = _loc4_ + _loc6_;
- }
- }
- else
- {
- deltaModifierArray.splice(_loc5_--,1);
- }
- _loc5_++;
- }
- return _loc4_;
- }
- public static function isOnScreen(param1:Number, param2:Number) : Boolean
- {
- var _loc3_:Number = param1 - camera.camX;
- var _loc4_:Number = param2 - camera.camY;
- if(Math.abs(_loc3_) < Main.WIDTH * 2 && Math.abs(_loc4_) < Main.HEIGHT * 2)
- {
- return true;
- }
- return false;
- }
- public static function resized() : void
- {
- if(debugStats != null)
- {
- debugStats.x = Main.visibleContent.x;
- debugStats.y = Main.visibleContent.y;
- if(stats.mode == GameEngineStats.MODE_LEVELDESIGNER)
- {
- debugStats.y = debugStats.y + 20 * (Main.visibleContent.height / Main.HEIGHT);
- }
- if(stats.mode == GameEngineStats.MODE_GAMEPLAY)
- {
- debugStats.x = Main.visibleContent.x + Main.visibleContent.width - 70;
- }
- }
- if(bg != null)
- {
- bg.resized();
- }
- if(closeBG != null)
- {
- closeBG.resized();
- }
- if(course != null)
- {
- course.resized();
- }
- if(top != null)
- {
- top.x = Main.visibleContent.x;
- top.y = Main.visibleContent.y;
- top.scaleX = Main.visibleContent.width / Main.WIDTH;
- top.scaleY = Main.visibleContent.height / Main.HEIGHT;
- }
- if(signLayer != null)
- {
- signLayer.x = Main.visibleContent.x;
- signLayer.y = Main.visibleContent.y;
- signLayer.scaleX = Main.visibleContent.width / Main.WIDTH;
- signLayer.scaleY = Main.visibleContent.height / Main.HEIGHT;
- }
- if(transitionLayer != null)
- {
- transitionLayer.x = Main.visibleContent.x;
- transitionLayer.y = Main.visibleContent.y;
- transitionLayer.scaleX = Main.visibleContent.width / Main.WIDTH;
- transitionLayer.scaleY = Main.visibleContent.height / Main.HEIGHT;
- }
- if(screenBufferBit != null)
- {
- screenBufferBit.x = Main.visibleContent.x;
- screenBufferBit.y = Main.visibleContent.y;
- screenBufferBit.scaleX = Main.visibleContent.width / Main.WIDTH;
- screenBufferBit.scaleY = Main.visibleContent.height / Main.HEIGHT;
- }
- if(deltaTransformed)
- {
- deltaBitmap.x = Main.visibleContent.x;
- deltaBitmap.y = Main.visibleContent.y;
- deltaBitmap.width = Main.visibleContent.width;
- deltaBitmap.height = Main.visibleContent.height;
- }
- if(loading != null)
- {
- loading.x = Main.visibleContent.x;
- loading.y = Main.visibleContent.y;
- loading.scaleX = Main.visibleContent.width / Main.WIDTH;
- loading.scaleY = Main.visibleContent.height / Main.HEIGHT;
- }
- if(pauseMenu != null)
- {
- pauseMenu.resized();
- }
- if(deathRespawnCue != null)
- {
- deathRespawnCue.x = Main.visibleContent.x;
- deathRespawnCue.y = Main.visibleContent.y;
- deathRespawnCue.scaleX = Main.visibleContent.width / Main.WIDTH;
- deathRespawnCue.scaleY = Main.visibleContent.height / Main.HEIGHT;
- }
- if(stats != null && !removed)
- {
- switch(stats.mode)
- {
- case GameEngineStats.MODE_LEVELDESIGNER:
- LevelDesignerEngine.resized();
- break;
- case GameEngineStats.MODE_GAMEPLAY:
- GameplayEngine.resized();
- break;
- case GameEngineStats.MODE_CINEMA:
- CinemaEngine.resized();
- break;
- default:
- throw new Error("Unsupported game mode!");
- }
- }
- }
- public static function remove() : void
- {
- var _loc1_:int = 0;
- var _loc2_:Vector.<Item> = slice.levelData.itemLayers.allItems;
- _loc1_ = 0;
- while(_loc1_ < _loc2_.length)
- {
- if(_loc2_[_loc1_].attached)
- {
- _loc2_[_loc1_].remove();
- }
- _loc1_++;
- }
- _loc1_ = 0;
- while(_loc1_ < enterFrameArray.length)
- {
- enterFrameArray[_loc1_].enterFrameRemoved();
- _loc1_++;
- }
- enterFrameArray = null;
- _loc1_ = 0;
- while(_loc1_ < deltaEffectorArray.length)
- {
- deltaEffectorArray[_loc1_].undo_noEffect();
- _loc1_++;
- }
- deltaEffectorArray = null;
- boulderArray = null;
- enemyArray = null;
- deltaModifierArray = null;
- spikesArray = null;
- spliter_XArray = null;
- _loc1_ = 0;
- while(_loc1_ < triggerArray.length)
- {
- triggerArray[_loc1_].stop();
- triggerArray[_loc1_].removedFromList();
- _loc1_++;
- }
- triggerArray = null;
- WeatherHandler.remove();
- DeltaWallHandler.remove();
- TextHandler.remove();
- if(bg != null)
- {
- bg.remove();
- bg = null;
- }
- if(closeBG != null)
- {
- closeBG.remove();
- closeBG = null;
- }
- if(course != null)
- {
- Main.getStage().removeChild(course);
- course.remove();
- course = null;
- }
- if(top != null)
- {
- Main.getStage().removeChild(top);
- top = null;
- }
- if(signLayer != null)
- {
- Main.getStage().removeChild(signLayer);
- signLayer = null;
- }
- if(transitionLayer != null)
- {
- Main.getStage().removeChild(transitionLayer);
- transitionLayer = null;
- }
- switch(stats.mode)
- {
- case GameEngineStats.MODE_LEVELDESIGNER:
- LevelDesignerEngine.remove();
- break;
- case GameEngineStats.MODE_GAMEPLAY:
- GameplayEngine.remove();
- break;
- case GameEngineStats.MODE_CINEMA:
- CinemaEngine.remove();
- break;
- default:
- throw new Error("Unsupported game mode!");
- }
- usingScreenBuffer = false;
- if(screenBuffer != null)
- {
- screenBuffer.dispose();
- screenBuffer = null;
- }
- if(screenBufferBit != null)
- {
- Main.getStage().removeChild(screenBufferBit);
- screenBufferBit = null;
- }
- if(deltaBitmap != null)
- {
- Main.getStage().removeChild(deltaBitmap);
- }
- deltaBitmap = null;
- if(deltaEffectContainer != null)
- {
- Main.getStage().removeChild(deltaEffectContainer);
- }
- deltaEffectContainer = null;
- deltaCircle = null;
- deltaCursor = null;
- if(deltaSFX != null)
- {
- deltaSFX.stop();
- deltaSFX = null;
- }
- if(debugStats != null)
- {
- Main.getStage().removeChild(debugStats);
- }
- Main.getStage().removeEventListener(Event.ENTER_FRAME,enterFrame);
- Main.getStage().removeEventListener(Event.DEACTIVATE,focusOut);
- Main.getStage().removeEventListener(Event.ACTIVATE,focusIn);
- if(deathRespawnCue != null)
- {
- Main.getStage().removeChild(deathRespawnCue);
- deathRespawnCue = null;
- }
- if(currentTransition != null)
- {
- currentTransition.remove();
- currentTransition = null;
- }
- removePauseMenu();
- removed = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement