Files
DiamondHollowII/research/inner_decompiled/scripts/com/arc/dh/state/PlayMode.as
T

2142 lines
80 KiB
ActionScript

package com.arc.dh.state
{
import Playtomic.Log;
import com.arc.dh.Color;
import com.arc.dh.Gun;
import com.arc.dh.entities.Entity;
import com.arc.dh.entities.Player;
import com.arc.dh.menu.CompleteWindow;
import com.arc.dh.menu.Menu;
import com.arc.dh.objects.*;
import com.arc.dh.objects.enemies.Bird;
import com.arc.dh.objects.enemies.Blade;
import com.arc.dh.objects.enemies.Blob;
import com.arc.dh.objects.enemies.Boss;
import com.arc.dh.objects.enemies.BouncingSlime;
import com.arc.dh.objects.enemies.CeilingPlant;
import com.arc.dh.objects.enemies.ClimbingSlime;
import com.arc.dh.objects.enemies.Enemy;
import com.arc.dh.objects.enemies.FloorPlant;
import com.arc.dh.objects.enemies.Laser;
import com.arc.dh.objects.enemies.LaserBeam;
import com.arc.dh.objects.enemies.Plant;
import com.arc.dh.objects.enemies.Professor;
import com.arc.dh.objects.enemies.ProfessorShade;
import com.arc.dh.objects.enemies.Seed;
import com.arc.dh.objects.enemies.Slime;
import com.arc.dh.objects.enemies.SlimeKing;
import com.arc.dh.objects.enemies.Snail;
import com.arc.dh.objects.enemies.SnailKing;
import com.arc.dh.objects.enemies.Snake;
import com.arc.dh.objects.enemies.Spider;
import com.arc.dh.objects.enemies.Spike;
import com.arc.dh.objects.enemies.StoneBird;
import com.arc.dh.objects.enemies.Tadpole;
import com.arc.dh.objects.powerups.HeartCrystal;
import com.arc.dh.objects.powerups.Powerup;
import com.arc.dh.objects.powerups.PowerupEquipment;
import com.arc.dh.objects.powerups.PowerupFire;
import com.arc.dh.objects.powerups.PowerupHeart;
import com.arc.dh.objects.powerups.PowerupMagnet;
import com.arc.dh.objects.powerups.PowerupShield;
import com.arc.dh.objects.powerups.RedDiamond;
import com.arc.dh.util.AchievementSystem;
import com.arc.dh.util.AchievementWindow;
import com.arc.dh.util.Config;
import com.arc.dh.util.Data;
import com.arc.dh.util.ParticleSystem;
import com.arc.dh.util.Sound;
import com.arc.dh.util.SoundSystem;
import com.arc.dh.util.text.Avatar;
import com.arc.dh.util.text.TextSystem;
import com.arc.flixel.ArcGroup;
import com.arc.flixel.ArcParticleSystem;
import com.arc.flixel.ArcSprite;
import com.arc.flixel.ArcU;
import com.arc.flixel.Profiler;
import flash.display.BitmapData;
import flash.ui.Mouse;
import org.flixel.FlxBasic;
import org.flixel.FlxG;
import org.flixel.FlxGroup;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
import org.flixel.FlxSprite;
import org.flixel.FlxState;
import org.flixel.FlxTilemap;
public class PlayMode extends FlxState
{
protected static const BITMAP_SPRITE:Class = PlayMode_BITMAP_SPRITE;
protected static const CONTROLS_SPRITE:Class = PlayMode_CONTROLS_SPRITE;
protected static const MENU_TIP_SPRITE:Class = PlayMode_MENU_TIP_SPRITE;
protected static const UPGRADE_TIP_SPRITE:Class = PlayMode_UPGRADE_TIP_SPRITE;
protected static const T1:Class = PlayMode_T1;
protected static const BG3_1:Class = PlayMode_BG3_1;
protected static const BG2_1:Class = PlayMode_BG2_1;
protected static const BG1_1:Class = PlayMode_BG1_1;
protected static const T2:Class = PlayMode_T2;
protected static const BG3_2:Class = PlayMode_BG3_2;
protected static const BG2_2:Class = PlayMode_BG2_2;
protected static const BG1_2:Class = PlayMode_BG1_2;
protected static const T3:Class = PlayMode_T3;
protected static const BG3_3:Class = PlayMode_BG3_3;
protected static const BG2_3:Class = PlayMode_BG2_3;
protected static const BG1_3:Class = PlayMode_BG1_3;
protected static const T4:Class = PlayMode_T4;
protected static const BG3_4:Class = PlayMode_BG3_4;
protected static const BG2_4:Class = PlayMode_BG2_4;
protected static const BG1_4:Class = PlayMode_BG1_4;
protected static const T5:Class = PlayMode_T5;
protected static const BG3_5:Class = PlayMode_BG3_5;
protected static const BG2_5:Class = PlayMode_BG2_5;
protected static const BG1_5:Class = PlayMode_BG1_5;
protected static const T6:Class = PlayMode_T6;
protected static const BG3_6:Class = PlayMode_BG3_6;
protected static const BG2_6:Class = PlayMode_BG2_6;
protected static const BG1_6:Class = PlayMode_BG1_6;
protected static const T7:Class = PlayMode_T7;
protected static const BG3_7:Class = PlayMode_BG3_7;
protected static const BG2_7:Class = PlayMode_BG2_7;
protected static const BG1_7:Class = PlayMode_BG1_7;
private static const xraySprite:Class = PlayMode_xraySprite;
protected static const START_ROW:int = 999999;
public static const BULLET_TIME:Number = 0.4;
public static const STORY_MODE:int = 0;
public static const BOSS_MODE:int = 1;
public static const ESCAPE_MODE:int = 2;
public static const RUN_MODE:int = 3;
public static const TADPOLE_MODE:int = 3;
public static var mode:int = STORY_MODE;
protected static const DIAMOND_VALUES:Array = [1,2,3,4,5,10];
public var pixels:BitmapData;
public var mpixels:BitmapData;
public var overpixels:BitmapData;
protected var segments:Array = new Array();
protected var row:uint = 999999;
public var tilemap:FlxTilemap;
protected var _ch:int = 6;
public var checkpoints:Array = new Array();
protected var objectCounter:int = 2;
protected var messages:Array = new Array();
public var ui:UI;
public var player:Player;
public var underblocks:FlxGroup = new FlxGroup();
public var overblocks:FlxGroup = new FlxGroup();
public var bullets:FlxGroup = new FlxGroup();
public var enemies:FlxGroup = new FlxGroup();
public var penemies:FlxGroup = new FlxGroup();
public var diamonds:FlxGroup = new FlxGroup();
public var particles:ArcGroup = new ArcGroup();
public var emitters:ArcGroup = new ArcGroup();
public var friendly:ArcGroup = new ArcGroup();
public var powerups:ArcGroup = new ArcGroup();
public var damagetexts:ArcGroup = new ArcGroup();
public var healthbars:ArcGroup = new ArcGroup();
public var objects:ArcGroup = new ArcGroup();
public var cobjects:ArcGroup = new ArcGroup();
public var colliders:ArcGroup = new ArcGroup();
public var lavagroup:ArcGroup = new ArcGroup();
public var xray:ArcSprite;
protected var entities:FlxGroup = new FlxGroup();
protected var hittable:FlxGroup = new FlxGroup();
protected var bulletcollide:FlxGroup = new FlxGroup();
public var bulletTimer:Number = 0.4;
public var cameraSpeed:Number = 3;
protected var starty:int;
protected var scrolling:Boolean = false;
protected var startHeight:int = 0;
protected var _garbage:Number = 2;
protected var _menu:Menu;
public var inMenu:Boolean;
public var cdiamonds:int = 0;
public var cenemies:int = 0;
protected var _start:Number;
protected var _dieTimer:Number = 0;
protected var bg3:Background;
protected var bg2:Background;
protected var bg1:Background;
protected var i:int;
protected var j:int;
public var spawnTop:int = 0;
public var spawnBottom:int = 0;
public var despawnTop:int = 0;
public var despawnBottom:int = 0;
public var spawner:Object = new Object();
public var spawnChance:int = 100;
protected var fader:ArcSprite;
public var whitefader:ArcSprite;
protected var faderStatus:int = 0;
public var bossHeight:int = -1;
protected var _complete:Boolean = false;
protected var _completeWindow:CompleteWindow;
protected var _red:int = 0;
protected var _redLocations:Object = new Object();
public var controls:ArcSprite;
public var worldAllFuckedUp:Boolean = false;
public var controlCharacter:Boolean = true;
public var boss:int = 0;
protected const GRASS:uint = 5228053;
protected const GRASS2:uint = 2652672;
protected const DIRT:uint = 10052885;
protected const WATER:uint = 32511;
protected const LAVA:uint = 14045513;
protected const WOODEN_CRATE:uint = 7028992;
protected const STEEL_CRATE:uint = 1579032;
protected const RED_DIAMOND:uint = 16711932;
protected const tiles:Array = [this.GRASS,this.GRASS2,this.DIRT,this.WATER,this.LAVA];
protected const objectTiles:Array = [this.WOODEN_CRATE,this.STEEL_CRATE];
public function PlayMode()
{
super();
TextSystem.reset();
}
override public function create() : void
{
Data.state = this;
Log.Play();
this.bg3 = new Background(0,0,PlayMode["BG3_" + this._ch]);
this.bg3.scrollFactor.x = this.bg3.scrollFactor.y = 0.4;
this.add(this.bg3);
this.bg2 = new Background(0,0,PlayMode["BG2_" + this._ch]);
this.bg2.scrollFactor.x = this.bg2.scrollFactor.y = 0.6;
this.add(this.bg2);
this.bg1 = new Background(0,0,PlayMode["BG1_" + this._ch]);
this.bg1.scrollFactor.x = this.bg1.scrollFactor.y = 0.8;
this.add(this.bg1);
this.createLevel();
this.player = new Player(128,this.tilemap.height - 36);
FlxG.camera.follow(this.player);
FlxG.camera.update();
FlxG.worldBounds.width = Config.WIDTH;
FlxG.worldBounds.height = Config.HEIGHT + (Config.DESPAWN_PADDING * 2 + Config.SPAWN_PADDING * 2) * Config.BLOCK_SIZE;
this.add(this.underblocks);
this.add(this.particles);
this.add(this.emitters);
this.add(this.player);
this.add(this.diamonds);
this.add(this.bullets);
this.add(this.powerups);
this.add(this.objects);
this.add(this.cobjects);
this.add(this.penemies);
this.add(this.enemies);
this.add(this.lavagroup);
this.add(this.tilemap);
this.add(this.healthbars);
this.add(this.overblocks);
this.add(this.damagetexts);
this.entities.add(this.player);
this.entities.add(this.enemies);
this.entities.add(this.diamonds);
this.entities.add(this.bullets);
this.hittable.add(this.enemies);
this.hittable.add(this.diamonds);
this.hittable.add(this.powerups);
this.hittable.add(this.objects);
this.hittable.add(this.cobjects);
this.hittable.add(this.penemies);
this.colliders.add(this.tilemap);
this.colliders.add(this.cobjects);
this.friendly.add(this.player);
this.friendly.add(this.bullets);
this.bulletcollide.add(this.enemies);
this.bulletcollide.add(this.tilemap);
this.xray = new ArcSprite(0,0);
this.xray.offset.y = 512;
this.xray.offset.x = 512;
this.xray.loadGraphic(xraySprite,false,false,1024,1024);
this.xray.blend = "overlay";
this.add(this.xray);
this.fader = new ArcSprite(0,0);
this.fader.makeGraphic(FlxG.width,FlxG.height,4278190080);
this.fader.scrollFactor.x = this.fader.scrollFactor.y = 0;
this.add(this.fader);
this.faderStatus = 2;
this.ui = new UI();
this.add(this.ui);
this._menu = new Menu();
if(!(this is BossMode && this._ch != 1 && !(this as BossMode).isPractice()))
{
Data.hp = Data.hpm;
Data.ctime = 0;
}
this._start = new Date().getTime();
this.cdiamonds = 0;
this.cenemies = 0;
var _loc1_:int = this.getStartX();
this.checkpoints.push([_loc1_ / Config.BLOCK_SIZE,(this.tilemap.height - this.getStartY()) / Config.BLOCK_SIZE]);
this.restart();
if(_loc1_ > 200)
{
this.player.facing = FlxObject.LEFT;
}
if(this._ch == 1 && this is StoryMode)
{
this.add(new BeginnerTip(133,this.tilemap.height - 240 + 86,CONTROLS_SPRITE));
this.add(new BeginnerTip(20,this.tilemap.height - 533,MENU_TIP_SPRITE,50));
this.add(new BeginnerTip(58,this.tilemap.height - 960,UPGRADE_TIP_SPRITE,40));
}
ParticleSystem.initialize();
this.emitters.add(ArcParticleSystem.emitters);
this.add(TextSystem.instance);
super.create();
}
protected function getStartX() : int
{
return 128;
}
protected function getStartY() : int
{
return 60;
}
protected function createLevel() : void
{
}
public function restart() : void
{
}
public function get caveLevel() : int
{
return this.caveHeight / 50 + 1;
}
public function get caveHeight() : int
{
if(this.player.maxHeight + this.startHeight > Data.maxheight && this is EscapeMode)
{
Data.maxheight = this.player.maxHeight + this.startHeight;
}
return this.player.maxHeight + this.startHeight;
}
public function get duration() : String
{
return Data.duration(0,Math.ceil(Data.ctime) * 1000);
}
protected function garbageCollect(param1:FlxGroup) : void
{
var _loc5_:FlxBasic = null;
var _loc2_:Array = param1.members;
var _loc3_:Array = [];
var _loc4_:int = 0;
while(_loc4_ < _loc2_.length)
{
_loc5_ = _loc2_[_loc4_] as FlxBasic;
if(_loc5_ != null && _loc5_.alive && _loc5_.exists)
{
_loc3_.push(_loc5_);
}
_loc4_++;
}
param1.members = _loc3_;
}
public function get over() : Boolean
{
return this._dieTimer > 0;
}
public function setMenu(param1:Boolean) : void
{
this.inMenu = param1;
}
public function get chapter() : int
{
return this._ch;
}
protected function updateSpawn() : void
{
this.spawnTop = this.calcTop(Config.SPAWN_PADDING);
if(this.spawnTop < this.despawnTop)
{
while(this.spawnTop < this.despawnTop)
{
this.spawn(this.despawnTop);
--this.despawnTop;
}
}
else if(this.spawnTop - this.despawnTop > Config.DESPAWN_PADDING)
{
this.despawnTop = this.spawnTop - Config.DESPAWN_PADDING;
}
this.spawnBottom = this.calcBottom(Config.SPAWN_PADDING);
if(this.spawnBottom > this.despawnBottom)
{
while(this.spawnBottom > this.despawnBottom)
{
this.spawn(this.despawnBottom);
++this.despawnBottom;
}
this.despawnBottom = this.spawnBottom;
}
else if(this.despawnBottom - this.spawnBottom > Config.DESPAWN_PADDING)
{
this.despawnBottom = this.spawnBottom + Config.DESPAWN_PADDING;
}
}
override public function update() : void
{
var p9:Profiler;
var p7:Profiler;
var message:StoryDialog = null;
var enemy:Enemy = null;
Mouse.hide();
FlxG.mouse.show();
Data.time += FlxG.elapsed;
Data.ctime += FlxG.elapsed;
this.updateSpawn();
FlxG.worldBounds.x = FlxG.camera.scroll.x;
FlxG.worldBounds.y = FlxG.camera.scroll.y - (this is HorizontalMode ? 0 : (Config.SPAWN_PADDING + Config.DESPAWN_PADDING) * Config.BLOCK_SIZE);
if(Data.hp > 0 && (FlxG.keys.justPressed("ESCAPE") || FlxG.keys.justPressed("P") || FlxG.keys.justPressed("TAB")) && !this._menu.inConfirmation && !this._menu.inOptions)
{
this._menu.fade(!this.inMenu);
}
if(Data.hp > 0 && FlxG.keys.justPressed("M") && !this.inMenu)
{
this._menu.fade(true,3);
}
if(this._dieTimer > 0 && !(this is HorizontalMode))
{
this._dieTimer -= FlxG.elapsed;
this.player.alpha -= FlxG.elapsed;
if(this._dieTimer <= 0)
{
this.player.alpha = 0;
this.reset();
}
}
this.showAchievement();
if(this.inMenu)
{
this._menu.update();
return;
}
this.parallax();
this.gc();
this.shootBullet();
if(this.faderStatus == 1)
{
this.fader.alpha += FlxG.elapsed * 3;
if(this.fader.alpha >= 1)
{
this.fader.alpha = 1;
this.restart();
this.faderStatus = 2;
}
return;
}
if(this.faderStatus == 2)
{
this.fader.alpha -= FlxG.elapsed * 3;
if(this.fader.alpha <= 0)
{
this.faderStatus = 0;
}
return;
}
SoundSystem.update();
super.update();
p9 = new Profiler("overlap2");
FlxG.overlap(this.friendly,this.hittable,function(param1:FlxObject, param2:FlxObject):void
{
var _loc3_:FlxObject = null;
var _loc6_:Boolean = false;
var _loc7_:Boolean = false;
var _loc8_:int = 0;
var _loc9_:int = 0;
var _loc10_:int = 0;
var _loc11_:Number = NaN;
var _loc4_:Player = param1 is Player ? param1 as Player : param2 as Player;
if(_loc4_ != null)
{
_loc3_ = param1 is Player ? param2 : param1;
_loc6_ = _loc3_ is Enemy && (_loc3_ as Enemy).pierce;
if(_loc3_ is Enemy && (player.invulnerable <= 0 || _loc6_ && !player.isHit || _loc3_ is LaserBeam) && (!player.shielded || _loc6_))
{
if(player.invulnerable <= 0)
{
if(_loc3_.x > player.x)
{
player.velocity.x = -160 + Data.recover * 5;
}
else
{
player.velocity.x = 160 - Data.recover * 5;
}
--player.y;
if(_loc3_ is LaserBeam && ((_loc3_ as LaserBeam).face == 1 || (_loc3_ as LaserBeam).face == 3))
{
if(player.y < _loc3_.y - 4)
{
player.velocity.y = -300;
player.velocity.x = 0;
}
else
{
player.velocity.y = 100;
player.velocity.x = 0;
}
}
else
{
player.velocity.y = -40;
}
}
if(Data.state is TadpoleMode)
{
(Data.state as TadpoleMode).predie();
}
_loc7_ = true;
if(_loc3_ is LaserBeam && player.invulnerable > 0)
{
_loc7_ = false;
}
player.hit((_loc3_ as Enemy).level,_loc6_,_loc7_);
if(_loc3_ is Seed)
{
_loc3_.exists = false;
_loc3_.alive = false;
}
return;
}
if(_loc3_ is Diamond)
{
Data.diamonds += (_loc3_ as Diamond).value;
Data.totaldiamonds += (_loc3_ as Diamond).value;
AchievementSystem.diamonds();
cdiamonds += (_loc3_ as Diamond).value;
(_loc3_ as Diamond).despawn();
_loc3_.kill();
ArcParticleSystem.emit(Data.state.particles,(_loc3_ as Diamond).diamondColor,_loc3_.x + _loc3_.width / 2,_loc3_.y + _loc3_.width / 2,3,1,0.5,0,-30,30,-30,30);
switch(ArcU.rand(1,5))
{
case 1:
SoundSystem.play(Sound.DIAMOND1);
break;
case 2:
SoundSystem.play(Sound.DIAMOND2);
break;
case 3:
SoundSystem.play(Sound.DIAMOND3);
break;
case 4:
SoundSystem.play(Sound.DIAMOND4);
break;
case 5:
SoundSystem.play(Sound.DIAMOND5);
}
return;
}
if(_loc3_ is Powerup)
{
(_loc3_ as Powerup).activate();
}
}
var _loc5_:Bullet = param1 is Bullet ? param1 as Bullet : param2 as Bullet;
if(_loc5_ != null)
{
_loc3_ = param1 is Bullet ? param2 : param1;
if(_loc3_ is Enemy && !(_loc3_ as Enemy).killable && !(_loc3_ is LaserBeam) && !(_loc3_ is Seed) && (_loc3_ as FlxSprite).alpha == 1)
{
SoundSystem.play(Sound.PLINK,0.1);
}
if(_loc3_ is Enemy && (_loc3_ as Enemy).killable)
{
if(_loc5_ is BulletRebound && Data.reboundgun[Gun.SPECIAL_TWO] == 1)
{
_loc5_.setCollider(_loc3_);
if((_loc5_ as BulletRebound).solidTimer <= 0)
{
_loc5_.kill();
}
}
else
{
_loc5_.kill();
}
if(_loc5_ is BulletRebound)
{
if(_loc3_ == (_loc5_ as BulletRebound).lastEnemy)
{
return;
}
(_loc5_ as BulletRebound).lastEnemy = _loc3_ as Enemy;
}
if(_loc5_ is Missile)
{
(_loc3_ as Enemy).hit(_loc5_.velocity.x > 0 ? int(FlxObject.RIGHT) : int(FlxObject.LEFT));
if(Data.missilegun[Gun.SPECIAL_TWO] == 1)
{
_loc9_ = _loc5_.getMidpoint().x;
_loc10_ = _loc5_.getMidpoint().y;
_loc11_ = 0.3926;
while(_loc11_ < 6.28318)
{
Data.state.bullets.add(BulletFactory.create(_loc9_,_loc10_,Gun.REBOUNDER_SPEED,_loc11_,BulletFragment));
_loc11_ += 0.78539;
}
}
}
_loc8_ = _loc5_.damage;
if(_loc5_ is BulletPrime && Data.primegun[Gun.SPECIAL_ONE] == 1 && ArcU.rand(1,10) <= 3)
{
_loc8_ *= 1.5;
ArcParticleSystem.emit(Data.state.particles,Color.WHITE,_loc5_.x,_loc5_.y,5,1,1,0,-100,100,-100,100,_loc5_.width,_loc5_.height);
}
(_loc3_ as Enemy).damage(_loc8_,_loc5_);
}
else if(_loc3_ is Seed && _loc5_ is Missile && Data.missilegun[Gun.SPECIAL_ONE] == 1)
{
_loc3_.exists = false;
_loc3_.alive = false;
}
else if(_loc3_ is LaserBeam)
{
_loc5_.mark(0.01);
}
else if(_loc3_ is Pot)
{
ArcParticleSystem.emit(Data.state.particles,"pot",_loc3_.x,_loc3_.y,10,1,5,400,-50,50,-100,-40,_loc3_.width,_loc3_.height);
_loc3_.kill();
_loc5_.kill();
}
else if(_loc3_ is WoodenCrate)
{
ArcParticleSystem.emit(Data.state.particles,"wooden_crate",_loc3_.x,_loc3_.y,10,1,5,400,-100,100,-100,-40,_loc3_.width,_loc3_.height);
_loc3_.kill();
_loc5_.kill();
}
else if(_loc3_ is SteelCrate)
{
if(_loc5_ is Missile)
{
ArcParticleSystem.emit(Data.state.particles,"steel_crate",_loc3_.x,_loc3_.y,10,1,5,800,-100,100,-200,-80,_loc3_.width,_loc3_.height);
_loc3_.kill();
}
_loc5_.setCollider(_loc3_);
_loc5_.kill();
}
else if(_loc3_ is BossDoor)
{
_loc5_.kill();
}
else if(_loc3_ is Blade && _loc5_ is Missile)
{
_loc3_.kill();
_loc5_.kill();
}
}
});
p9.end();
p7 = new Profiler("collide");
FlxG.collide(this.entities,this.colliders,function(param1:FlxObject, param2:FlxObject):void
{
var _loc4_:FlxObject = null;
var _loc5_:int = 0;
var _loc6_:int = 0;
var _loc7_:Number = NaN;
var _loc3_:Bullet = param1 is Bullet ? param1 as Bullet : param2 as Bullet;
if(_loc3_ != null)
{
_loc4_ = param1 is Bullet ? param2 : param1;
if(_loc4_ is FlxTilemap)
{
if(_loc3_ is Missile && Data.missilegun[Gun.SPECIAL_TWO] == 1)
{
_loc5_ = _loc3_.getMidpoint().x;
_loc6_ = _loc3_.getMidpoint().y;
_loc7_ = 0.3926;
while(_loc7_ < 6.28318)
{
Data.state.bullets.add(BulletFactory.create(_loc5_,_loc6_,Gun.REBOUNDER_SPEED,_loc7_,BulletFragment));
_loc7_ += 0.78539;
}
}
_loc3_.setCollider(_loc4_);
_loc3_.kill();
}
return;
}
if(Data.state is TadpoleMode && (param1 is Player || param2 is Player))
{
(Data.state as TadpoleMode).predie();
}
if(param1 is Entity)
{
(param1 as Entity).handleCollision(param2);
}
else if(param2 is Entity)
{
(param2 as Entity).handleCollision(param1);
}
});
p7.end();
if(FlxG.keys.justPressed("F") && Boolean(Data.autofirer))
{
Data.autofire = !Data.autofire;
}
if(ArcU.rand(1,50) == 2)
{
}
if(FlxG.keys.justPressed("ONE") && Data.prime == 1)
{
Data.gun = this.player.gun = Gun.PRIME;
this.ui.showGuns();
}
else if(FlxG.keys.justPressed("TWO") && Data.spreader == 1)
{
Data.gun = this.player.gun = Gun.SPREADER;
this.ui.showGuns();
}
else if(FlxG.keys.justPressed("THREE") && Data.missile == 1)
{
Data.gun = this.player.gun = Gun.MISSILE;
this.ui.showGuns();
}
else if(FlxG.keys.justPressed("FOUR") && Data.rebound == 1)
{
Data.gun = this.player.gun = Gun.REBOUNDER;
this.ui.showGuns();
}
if(FlxG.mouse.wheel < 0 || FlxG.keys.justPressed("E"))
{
switch(Data.gun)
{
case Gun.PRIME:
if(Data.spreader == 1)
{
Data.gun = this.player.gun = Gun.SPREADER;
this.ui.showGuns();
}
break;
case Gun.SPREADER:
if(Data.missile == 1)
{
Data.gun = this.player.gun = Gun.MISSILE;
this.ui.showGuns();
}
else
{
Data.gun = this.player.gun = Gun.PRIME;
this.ui.showGuns();
}
break;
case Gun.MISSILE:
if(Data.rebound == 1)
{
Data.gun = this.player.gun = Gun.REBOUNDER;
this.ui.showGuns();
}
else
{
Data.gun = this.player.gun = Gun.PRIME;
this.ui.showGuns();
}
break;
case Gun.REBOUNDER:
if(Data.prime == 1)
{
Data.gun = this.player.gun = Gun.PRIME;
this.ui.showGuns();
}
}
}
else if(FlxG.mouse.wheel > 0 || FlxG.keys.justPressed("Q"))
{
switch(Data.gun)
{
case Gun.PRIME:
if(Data.rebound == 1)
{
Data.gun = this.player.gun = Gun.REBOUNDER;
this.ui.showGuns();
}
else if(Data.missile == 1)
{
Data.gun = this.player.gun = Gun.MISSILE;
this.ui.showGuns();
}
else if(Data.spreader == 1)
{
Data.gun = this.player.gun = Gun.SPREADER;
this.ui.showGuns();
}
break;
case Gun.SPREADER:
if(Data.prime == 1)
{
Data.gun = this.player.gun = Gun.PRIME;
this.ui.showGuns();
}
break;
case Gun.MISSILE:
if(Data.spreader == 1)
{
Data.gun = this.player.gun = Gun.SPREADER;
this.ui.showGuns();
}
break;
case Gun.REBOUNDER:
if(Data.missile == 1)
{
Data.gun = this.player.gun = Gun.MISSILE;
this.ui.showGuns();
}
}
}
if(this.boss == 1)
{
FlxG.camera.scroll.y -= FlxG.elapsed * 50;
if(FlxG.camera.scroll.y <= 0)
{
FlxG.camera.scroll.y = 0;
this.boss = 2;
for each(enemy in this.enemies.members)
{
if(!(enemy is Boss || enemy.bossenemy || enemy is Spike))
{
enemy.silentKill();
}
}
}
}
for each(message in this.messages)
{
message.activate(this.player.x,this.player.y);
}
}
protected function parallax() : void
{
var _loc1_:ArcSprite = null;
var _loc2_:int = 0;
for each(_loc1_ in [this.bg1,this.bg2,this.bg3])
{
_loc2_ = _loc1_.getScreenXY().y;
if(_loc2_ < -420)
{
_loc1_.y = FlxG.camera.scroll.y * _loc1_.scrollFactor.y + (_loc2_ > 0 && _loc2_ < 1000 ? _loc2_ : 0);
}
else if(_loc2_ > 0)
{
_loc1_.y = FlxG.camera.scroll.y * _loc1_.scrollFactor.y - 420 + (_loc2_ > 0 && _loc2_ < 1000 ? _loc2_ : 0);
}
}
}
protected function showAchievement() : void
{
var _loc1_:AchievementWindow = AchievementSystem.achievementWindow;
if(_loc1_ != null)
{
_loc1_.update();
_loc1_.timer -= FlxG.elapsed;
if(_loc1_.timer < 0)
{
_loc1_.alpha = 1 + _loc1_.timer;
if(_loc1_.alpha <= 0)
{
AchievementSystem.achievementWindow = null;
}
}
}
}
public function toggleMenu() : void
{
this._menu.fade(!this.inMenu);
}
protected function gc() : void
{
this._garbage -= FlxG.elapsed;
if(this._garbage <= 0)
{
this.garbageCollect(this.underblocks);
this.garbageCollect(this.overblocks);
this.garbageCollect(this.bullets);
this.garbageCollect(this.enemies);
this.garbageCollect(this.diamonds);
this.garbageCollect(this.particles);
this.garbageCollect(this.healthbars);
this._garbage = 5;
}
}
protected function shootBullet() : void
{
var _loc2_:Number = NaN;
var _loc3_:Bullet = null;
var _loc4_:Bullet = null;
var _loc5_:Bullet = null;
if(Data.hp <= 0 || Data.state.xraying)
{
return;
}
this.bulletTimer -= FlxG.elapsed;
var _loc1_:Boolean = (Data.control == Data.CONTROL_MOUSE && (Data.autofire || FlxG.mouse.pressed()) || Data.control == Data.CONTROL_KEYBOARD && (Data.autofire || FlxG.keys.LEFT || FlxG.keys.RIGHT || FlxG.keys.UP || FlxG.keys.DOWN) || Data.control == Data.CONTROL_KEYBOARDI && (Data.autofire || FlxG.keys.A || FlxG.keys.D || FlxG.keys.W || FlxG.keys.S)) && this.bulletTimer <= 0 && this.player.controllable && Data.prime == 1;
if(_loc1_)
{
if(Data.control == Data.CONTROL_MOUSE)
{
_loc2_ = Math.atan2(FlxG.mouse.y - (this.player.y + this.player.height / 2),FlxG.mouse.x - (this.player.x + this.player.width / 2));
}
else if(Data.control == Data.CONTROL_KEYBOARD)
{
if(FlxG.keys.LEFT && FlxG.keys.UP)
{
_loc2_ = 5 * Math.PI / 4;
}
else if(FlxG.keys.LEFT && FlxG.keys.DOWN)
{
_loc2_ = 3 * Math.PI / 4;
}
else if(FlxG.keys.LEFT)
{
_loc2_ = 4 * Math.PI / 4;
}
else if(FlxG.keys.RIGHT && FlxG.keys.UP)
{
_loc2_ = 7 * Math.PI / 4;
}
else if(FlxG.keys.RIGHT && FlxG.keys.DOWN)
{
_loc2_ = 1 * Math.PI / 4;
}
else if(FlxG.keys.RIGHT)
{
_loc2_ = 0;
}
else if(FlxG.keys.DOWN)
{
_loc2_ = 2 * Math.PI / 4;
}
else if(FlxG.keys.UP)
{
_loc2_ = 6 * Math.PI / 4;
}
else if(this.player.facing == FlxObject.LEFT)
{
_loc2_ = 4 * Math.PI / 4;
}
else if(this.player.facing == FlxObject.RIGHT)
{
_loc2_ = 0;
}
}
else if(Data.control == Data.CONTROL_KEYBOARDI)
{
if(FlxG.keys.A && FlxG.keys.W)
{
_loc2_ = 5 * Math.PI / 4;
}
else if(FlxG.keys.A && FlxG.keys.S)
{
_loc2_ = 3 * Math.PI / 4;
}
else if(FlxG.keys.A)
{
_loc2_ = 4 * Math.PI / 4;
}
else if(FlxG.keys.D && FlxG.keys.W)
{
_loc2_ = 7 * Math.PI / 4;
}
else if(FlxG.keys.D && FlxG.keys.S)
{
_loc2_ = 1 * Math.PI / 4;
}
else if(FlxG.keys.D)
{
_loc2_ = 0;
}
else if(FlxG.keys.S)
{
_loc2_ = 2 * Math.PI / 4;
}
else if(FlxG.keys.W)
{
_loc2_ = 6 * Math.PI / 4;
}
else if(this.player.facing == FlxObject.LEFT)
{
_loc2_ = 4 * Math.PI / 4;
}
else if(this.player.facing == FlxObject.RIGHT)
{
_loc2_ = 0;
}
}
}
if(this.player.gun == Gun.PRIME && _loc1_ && Data.prime == 1)
{
this.bulletTimer = Gun.PRIME_DELAY[Data.primegun[1]];
if(Data.primegun[Gun.SPECIAL_TWO] == 1)
{
this.bullets.add(BulletFactory.create(this.player.x + this.player.width / 2,this.player.y + this.player.height / 2,Gun.PRIME_SPEED,_loc2_,BulletPrime).shift(0.008));
this.bullets.add(BulletFactory.create(this.player.x + this.player.width / 2,this.player.y + this.player.height / 2,Gun.PRIME_SPEED,_loc2_,BulletPrime).shift(0.008,-1));
}
else
{
this.bullets.add(BulletFactory.create(this.player.x + this.player.width / 2,this.player.y + this.player.height / 2,Gun.PRIME_SPEED,_loc2_,BulletPrime));
}
}
else if(this.player.gun == Gun.SPREADER && _loc1_)
{
this.bulletTimer = Gun.SPREADER_DELAY[Data.spreadergun[1]];
if(Data.spreadergun[Gun.SPECIAL_TWO] == 1)
{
_loc3_ = BulletFactory.create(this.player.x + this.player.width / 2,this.player.y + this.player.height / 2,Gun.SPREADER_SPEED,_loc2_,BulletSpreader);
(_loc3_ as BulletSpreader).green();
this.bullets.add(_loc3_);
}
else
{
this.bullets.add(BulletFactory.create(this.player.x + this.player.width / 2,this.player.y + this.player.height / 2,Gun.SPREADER_SPEED,_loc2_,BulletSpreader));
}
this.bullets.add(BulletFactory.create(this.player.x + this.player.width / 2,this.player.y + this.player.height / 2,Gun.SPREADER_SPEED,_loc2_ + 0.15,BulletSpreader));
this.bullets.add(BulletFactory.create(this.player.x + this.player.width / 2,this.player.y + this.player.height / 2,Gun.SPREADER_SPEED,_loc2_ - 0.15,BulletSpreader));
if(Data.spreadergun[Gun.SPECIAL_ONE] == 1)
{
this.bullets.add(BulletFactory.create(this.player.x + this.player.width / 2,this.player.y + this.player.height / 2,Gun.SPREADER_SPEED,_loc2_ + 0.3,BulletSpreader));
this.bullets.add(BulletFactory.create(this.player.x + this.player.width / 2,this.player.y + this.player.height / 2,Gun.SPREADER_SPEED,_loc2_ - 0.3,BulletSpreader));
}
}
else if(this.player.gun == Gun.REBOUNDER && _loc1_)
{
this.bulletTimer = Gun.REBOUND_DELAY[Data.reboundgun[1]];
_loc4_ = BulletFactory.create(this.player.x,this.player.y + 4,Gun.REBOUNDER_SPEED,_loc2_,BulletRebound);
this.bullets.add(_loc4_);
}
else if(this.player.gun == Gun.MISSILE && _loc1_)
{
this.bulletTimer = Gun.MISSILE_DELAY[Data.missilegun[1]];
_loc5_ = BulletFactory.create(this.player.x,this.player.y + 4,Gun.MISSILE_SPEED,_loc2_,Missile);
this.bullets.add(_loc5_);
}
if(_loc1_)
{
SoundSystem.play(Sound.SHOOT_SMALL,0.3);
}
}
public function addDiamonds(param1:int, param2:int, param3:int, param4:int = -1) : void
{
var _loc8_:int = 0;
var _loc9_:int = 0;
var _loc10_:int = 0;
var _loc11_:int = 0;
var _loc12_:* = 0;
var _loc13_:int = 0;
var _loc14_:Diamond = null;
var _loc5_:int = ArcU.rand(3,8);
var _loc6_:int = param3;
var _loc7_:Array = [];
if(param4 == -1)
{
loop1:
while(_loc6_ > 0)
{
if(_loc7_.length < _loc5_)
{
_loc7_.push(DIAMOND_VALUES[0]);
_loc6_ -= DIAMOND_VALUES[0];
}
else
{
_loc9_ = ArcU.rand(0,_loc7_.length - 1);
_loc10_ = int(_loc7_[_loc9_]);
_loc11_ = 0;
_loc12_ = 0;
while(_loc11_ <= _loc10_)
{
if(_loc12_ >= DIAMOND_VALUES.length)
{
_loc7_[_loc9_] = _loc11_;
break loop1;
}
_loc11_ = int(DIAMOND_VALUES[_loc12_++]);
}
_loc7_[_loc9_] = _loc11_;
_loc6_ = _loc6_ + _loc10_ - _loc11_;
}
}
}
else
{
_loc13_ = 0;
while(_loc13_ < _loc6_)
{
_loc7_.push(10);
_loc13_++;
}
}
for each(_loc8_ in _loc7_)
{
_loc14_ = new Diamond(param1,param2,_loc8_);
if(ArcU.rand(0,1) == 1)
{
_loc14_.velocity.x = ArcU.rand(-50,-20);
}
else
{
_loc14_.velocity.x = ArcU.rand(20,50);
}
_loc14_.velocity.y = ArcU.rand(-100,-50);
_loc14_.drag.x = _loc14_.drag.y = 60;
_loc14_.acceleration.y = 400;
_loc14_.pullDelay = 0.3;
_loc14_.solid = true;
this.diamonds.add(_loc14_);
}
}
public function createHeart(param1:int, param2:int) : void
{
if(this is TadpoleMode)
{
return;
}
var _loc3_:int = ArcU.rand(1,100);
if(this is StoryMode && _loc3_ < 20 || this is EscapeMode && _loc3_ < 75)
{
return;
}
var _loc4_:Powerup = new PowerupHeart(param1 / Config.BLOCK_SIZE,param2 / Config.BLOCK_SIZE);
this.powerups.add(_loc4_);
}
public function die() : void
{
}
public function despawn(param1:int, param2:int) : void
{
this.pixels.setPixel(param1,param2,16777215);
}
public function checkpoint() : void
{
var _loc1_:StoryDialog = null;
this.mpixels = this.pixels.clone();
for each(_loc1_ in this.messages)
{
_loc1_.save();
}
}
public function complete() : void
{
}
public function setBoss(param1:int) : void
{
}
protected function getLayerTile(param1:int, param2:int, param3:Boolean = false) : uint
{
var _loc6_:uint = 0;
var _loc4_:uint = this.pixels.getPixel(param1,param2);
var _loc5_:uint = this.overpixels.getPixel(param1,param2);
for each(_loc6_ in this.tiles)
{
if(_loc4_ == _loc6_ || _loc5_ == _loc6_)
{
return _loc6_;
}
}
if(param3)
{
for each(_loc6_ in this.objectTiles)
{
if(_loc4_ == _loc6_ || _loc5_ == _loc6_)
{
return _loc6_;
}
}
}
return 0;
}
protected function markRedDiamond(param1:int, param2:int) : void
{
this._redLocations[param1 + "-" + param2] = this._red++;
}
protected function colorToTileID(param1:uint, param2:int, param3:int, param4:Boolean = false) : int
{
var _loc50_:Boolean = false;
var _loc51_:Boolean = false;
var _loc5_:int = 0;
if(!param4 && this.isTile(this.overpixels.getPixel(param2,param3)) != 0)
{
return 0;
}
var _loc6_:uint = this.getLayerTile(param2,param3 - 1);
var _loc7_:uint = this.getLayerTile(param2 + 1,param3);
var _loc8_:uint = this.getLayerTile(param2,param3 + 1);
var _loc9_:uint = this.getLayerTile(param2 - 1,param3);
var _loc10_:uint = this.getLayerTile(param2 + 1,param3 + 1);
var _loc11_:uint = this.getLayerTile(param2 - 1,param3 + 1);
var _loc12_:uint = this.getLayerTile(param2 + 1,param3 - 1);
var _loc13_:uint = this.getLayerTile(param2 - 1,param3 - 1);
var _loc14_:Boolean = _loc9_ != 0 || param2 == 0;
var _loc15_:Boolean = _loc7_ != 0 || param2 == Config.BLOCK_WIDTH - 1;
var _loc16_:Boolean = _loc6_ != 0;
var _loc17_:Boolean = _loc8_ != 0 || param3 == this.pixels.height - 1;
var _loc18_:Boolean = _loc10_ != 0 || param3 == this.pixels.height - 1 || param2 == Config.BLOCK_WIDTH - 1;
var _loc19_:Boolean = _loc11_ != 0 || param3 == this.pixels.height - 1 || param2 == 0;
var _loc20_:Boolean = _loc9_ == this.WATER;
var _loc21_:Boolean = _loc7_ == this.WATER;
var _loc22_:Boolean = _loc13_ == this.WATER;
var _loc23_:Boolean = _loc12_ == this.WATER;
var _loc24_:Boolean = _loc11_ == this.WATER;
var _loc25_:Boolean = _loc10_ == this.WATER;
var _loc26_:Boolean = _loc8_ == this.WATER;
var _loc27_:Boolean = _loc8_ == this.WATER;
var _loc28_:Boolean = _loc9_ == this.LAVA;
var _loc29_:Boolean = _loc7_ == this.LAVA;
var _loc30_:Boolean = _loc13_ == this.LAVA;
var _loc31_:Boolean = _loc12_ == this.LAVA;
var _loc32_:Boolean = _loc11_ == this.LAVA;
var _loc33_:Boolean = _loc10_ == this.LAVA;
var _loc34_:Boolean = _loc8_ == this.LAVA;
var _loc35_:Boolean = _loc8_ == this.LAVA;
var _loc36_:Boolean = _loc20_ || _loc28_;
var _loc37_:Boolean = _loc21_ || _loc29_;
var _loc38_:Boolean = _loc22_ || _loc30_;
var _loc39_:Boolean = _loc23_ || _loc31_;
var _loc40_:Boolean = _loc24_ || _loc32_;
var _loc41_:Boolean = _loc25_ || _loc33_;
var _loc42_:Boolean = _loc26_ || _loc34_;
var _loc43_:Boolean = _loc27_ || _loc35_;
var _loc44_:Boolean = _loc14_ && !_loc36_;
var _loc45_:Boolean = _loc15_ && !_loc37_;
var _loc46_:Boolean = _loc16_ && !_loc43_;
var _loc47_:Boolean = _loc17_ && !_loc42_;
var _loc48_:Boolean = _loc19_ && !_loc40_;
var _loc49_:Boolean = _loc18_ && !_loc41_;
switch(param1)
{
case this.DIRT:
if(_loc44_ && _loc45_ && _loc47_ && _loc48_ && _loc49_)
{
if(_loc9_ == this.GRASS)
{
_loc5_ = 132;
}
else if(_loc7_ == this.GRASS)
{
_loc5_ = 133;
}
else if(_loc9_ == this.GRASS2)
{
_loc5_ = 134;
}
else if(_loc7_ == this.GRASS2)
{
_loc5_ = 135;
}
else
{
_loc5_ = ArcU.rand(88 + 48,95 + 48 + 16);
}
}
else if(_loc44_ && _loc45_ && _loc47_ && _loc48_ && _loc41_)
{
if(_loc25_)
{
_loc5_ = 101;
}
else if(_loc33_)
{
_loc5_ = 103;
}
}
else if(_loc44_ && _loc45_ && _loc47_ && _loc49_ && _loc40_)
{
if(_loc24_)
{
_loc5_ = 100;
}
else if(_loc32_)
{
_loc5_ = 102;
}
}
else if(_loc44_ && _loc45_ && _loc47_ && _loc19_ && !_loc18_)
{
if(_loc21_)
{
_loc5_ = 117;
}
else if(_loc29_)
{
_loc5_ = 119;
}
else
{
_loc5_ = 86;
}
}
else if(_loc44_ && _loc45_ && _loc47_ && !_loc19_ && _loc18_)
{
if(_loc20_)
{
_loc5_ = 116;
}
else if(_loc28_)
{
_loc5_ = 118;
}
else
{
_loc5_ = 85;
}
}
else if(_loc44_ && _loc47_)
{
if(_loc21_)
{
if(_loc23_)
{
_loc5_ = 117;
}
else
{
_loc5_ = 129;
}
}
else if(_loc29_)
{
if(_loc31_)
{
_loc5_ = 119;
}
else
{
_loc5_ = 131;
}
}
else
{
_loc5_ = 87;
}
}
else if(_loc45_ && _loc47_)
{
if(_loc20_)
{
if(_loc22_)
{
_loc5_ = 116;
}
else
{
_loc5_ = 128;
}
}
else if(_loc28_)
{
if(_loc30_)
{
_loc5_ = 118;
}
else
{
_loc5_ = 130;
}
}
else
{
_loc5_ = 84;
}
}
else if(_loc44_ && _loc45_)
{
if(_loc26_)
{
_loc5_ = ArcU.rand(21,22);
}
else if(_loc34_)
{
_loc5_ = ArcU.rand(25,26);
}
else
{
_loc5_ = ArcU.rand(5,6);
}
}
else if(_loc44_)
{
if(_loc26_)
{
_loc5_ = 23;
}
else if(_loc34_)
{
_loc5_ = 27;
}
else
{
_loc5_ = 7;
}
}
else if(_loc45_)
{
if(_loc26_)
{
_loc5_ = 20;
}
else if(_loc34_)
{
_loc5_ = 24;
}
else
{
_loc5_ = 4;
}
}
break;
case this.GRASS:
if(_loc14_ && _loc15_ && !_loc36_ && !_loc37_)
{
_loc5_ = ArcU.rand(81,82);
}
else if(_loc14_ && !_loc36_)
{
if(_loc23_)
{
_loc5_ = 109;
}
else if(_loc31_)
{
_loc5_ = 111;
}
else if(_loc21_)
{
_loc5_ = 113;
}
else if(_loc29_)
{
_loc5_ = 115;
}
else
{
_loc5_ = 83;
}
}
else if(_loc22_)
{
_loc5_ = 108;
}
else if(_loc30_)
{
_loc5_ = 110;
}
else if(_loc20_)
{
_loc5_ = 112;
}
else if(_loc28_)
{
_loc5_ = 114;
}
else
{
_loc5_ = 80;
}
break;
case this.GRASS2:
if(_loc14_ && _loc15_ && !_loc36_ && !_loc37_)
{
_loc5_ = ArcU.rand(97,98);
}
else if(_loc14_ && !_loc36_)
{
if(_loc23_)
{
_loc5_ = 109 + 12;
}
else if(_loc31_)
{
_loc5_ = 111 + 12;
}
else if(_loc21_)
{
_loc5_ = 113 + 12;
}
else if(_loc29_)
{
_loc5_ = 115 + 12;
}
else
{
_loc5_ = 99;
}
}
else if(_loc22_)
{
_loc5_ = 108 + 12;
}
else if(_loc30_)
{
_loc5_ = 110 + 12;
}
else if(_loc20_)
{
_loc5_ = 112 + 12;
}
else if(_loc28_)
{
_loc5_ = 114 + 12;
}
else
{
_loc5_ = 96;
}
break;
case this.WATER:
_loc50_ = this.overpixels.getPixel(param2,param3 - 1) == 16777215;
if((_loc50_) && this.pixels.getPixel(param2,param3 - 1) != this.DIRT)
{
_loc5_ = 8;
}
else
{
_loc5_ = 12;
}
break;
case this.LAVA:
_loc51_ = this.overpixels.getPixel(param2,param3 - 1) == 16777215;
if((_loc51_) && this.pixels.getPixel(param2,param3 - 1) != this.DIRT)
{
_loc5_ = 9;
}
else
{
_loc5_ = 13;
}
break;
case this.WOODEN_CRATE:
_loc5_ = 52;
break;
case this.STEEL_CRATE:
_loc5_ = 53;
break;
default:
_loc5_ = 0;
}
if(this.pixels.getPixel(param2,param3) == 16777215 && _loc5_ == 0 && !param4 && (_loc8_ == this.DIRT || _loc8_ == this.GRASS))
{
--this.objectCounter;
if(this.objectCounter <= 0 && _loc11_ != 0 && _loc10_ != 0)
{
_loc5_ = ArcU.rand(68,75);
this.objectCounter = ArcU.rand(5,11);
}
}
return _loc5_;
}
protected function isTile(param1:uint) : Boolean
{
return param1 == this.GRASS || param1 == this.DIRT;
}
protected function addMessages(param1:int) : void
{
switch(param1)
{
case 1:
if(Data.prime == 0)
{
this.messages.push(new StoryDialog(15,355,20,20,Avatar.SAGA,"Hey kid, over here to the left! Help me out here!",true));
}
this.messages.push(new StoryDialog(23,345,3,3,Avatar.SAGA,"I was built by The Professor to help him protect this cave. He tossed me down here when I refused to continue my duty."));
this.messages.push(new StoryDialog(26,330,1,1,Avatar.SAGA,"That crystal was a Matrix Distortion Time Crystal. You\'ll find that if anything happens to you, you\'ll be able to safely return to that spot. It also fully heals you when you touch it. Think of it as a checkpoint."));
this.messages.push(new StoryDialog(15,135,3,3,Avatar.SAGA,"It\'s no wonder the monsters are drawn to these diamonds. Their power should be able to enhance my abilities."));
this.messages.push(new StoryDialog(10,204,3,3,Avatar.SAGA,"Be on the lookout for hidden areas carved into the cave by the monsters. They like to hoard the treasures they find in the areas so the other monsters won\'t steal them."));
this.messages.push(new StoryDialog(20,204,3,3,Avatar.SAGA,"Those heart crystals were created by The Professor by condensing diamonds under a heated laser. Be on the look out for them as they will enhance your vitality."));
this.messages.push(new StoryDialog(20,204,3,3,Avatar.SAGA,"Be careful, I sense a strong presence ahead."));
break;
case 2:
this.messages.push(new StoryDialog(15,300,3,3,Avatar.PROFESSOR,"Why do you bother trying to escape? You\'re so far underground you\'ll never again see the light of day."));
this.messages.push(new StoryDialog(20,220,3,3,Avatar.SAGA,"You don\'t remember how you got down here? When dealing with The Professor there\'s rarely a reason for anything."));
this.messages.push(new StoryDialog(20,140,3,3,Avatar.PROFESSOR,"The silly gun is right. You\'re only here because you happened to wander into my path. And now you\'ll die down in that cave like everyone else who has laid eyes on my experiments."));
this.messages.push(new StoryDialog(20,80,3,3,Avatar.SAGA,"We\'re making good progress. Be on the look out for more extension chips to boost my power. We\'re going to need all the help we can get the closer to the surface we climb."));
break;
case 3:
this.messages.push(new StoryDialog(14,160,20,3,Avatar.SAGA,"These monsters are the result of The Professor\'s terrible experiments. While they may look cute on the outside, don\'t be fooled."));
this.messages.push(new StoryDialog(15,270,20,3,Avatar.SAGA,"As we climb higher, you\'ll find we must pass through a variety of environments, each one a test from The Professor to see how his mutants react."));
break;
case 4:
this.messages.push(new StoryDialog(14,250,20,3,Avatar.PROFESSOR,"You\'re a persistent little one, aren\'t you?"));
this.messages.push(new StoryDialog(14,100,20,3,Avatar.PROFESSOR,"Why don\'t you give up while you\'re ahead? Starvation is a much better death than what awaits you ahead."));
break;
case 5:
this.messages.push(new StoryDialog(14,300,20,3,Avatar.SAGA,"I can\'t wait to see The Professor\'s face when we show up at his laboratory."));
this.messages.push(new StoryDialog(14,300,20,3,Avatar.PROFESSOR,"You\'ll never make it here alive you worthless gun."));
break;
case 6:
this.messages.push(new StoryDialog(14,355,20,19,Avatar.SAGA,"To be honest, the reason The Professor left me down there was because I refused to kill any more humans. I\'m glad you didn\'t come along sooner or you might have been another victim of my ruthless killing."));
this.messages.push(new StoryDialog(14,300,20,3,Avatar.SAGA,"Don\'t think I won\'t help you defeat these mutants though. These abominations are simply The Professor\'s experiments."));
this.messages.push(new StoryDialog(14,180,20,3,Avatar.SAGA,"I wonder what an existence without violence would be like. I can\'t wait to get out of this cave and start my new life."));
break;
case 7:
this.messages.push(new StoryDialog(14,630,20,20,Avatar.PROFESSOR,"Eh heh heh... I\'ve got you right where I want you."));
this.messages.push(new StoryDialog(14,630,20,20,Avatar.SAGA,"Don\'t be afraid. He never expected us to make it this far and he\'s running out of plans."));
this.messages.push(new StoryDialog(14,400,20,10,Avatar.SAGA,"Don\'t give up, we\'re almost there. I can see the light of our new lives already..."));
this.messages.push(new StoryDialog(14,200,20,10,Avatar.SAGA,"Almost there..."));
}
}
public function get level() : int
{
if(this is StoryMode)
{
return (1 - this.player.y / this.tilemap.height) * 10 + 1 + (this._ch - 1) * 10;
}
return this.caveHeight / 25 + 1;
}
protected function spawn(param1:int) : void
{
var _loc2_:Enemy = null;
var _loc3_:Powerup = null;
var _loc5_:int = 0;
var _loc8_:int = 0;
var _loc9_:int = 0;
var _loc10_:int = 0;
var _loc11_:int = 0;
var _loc12_:uint = 0;
var _loc13_:uint = 0;
var _loc14_:int = 0;
var _loc15_:Boolean = false;
var _loc16_:uint = 0;
var _loc17_:Wall = null;
var _loc18_:Wall = null;
var _loc19_:BossDoor = null;
var _loc20_:int = 0;
var _loc21_:int = 0;
var _loc22_:int = 0;
var _loc23_:FlxPoint = null;
var _loc24_:int = 0;
var _loc25_:int = 0;
var _loc26_:int = 0;
var _loc27_:Diamond = null;
var _loc28_:Checkpoint = null;
var _loc29_:int = 0;
var _loc30_:Pot = null;
var _loc4_:Boolean = false;
if(!(this is HorizontalMode) && param1 > this.pixels.height - 15 && this.spawnChance < 100)
{
return;
}
_loc5_ = this.level;
var _loc6_:int = this is HorizontalMode ? this.pixels.height : this.pixels.width;
var _loc7_:int = 0;
for(; _loc7_ < _loc6_; _loc7_++)
{
_loc8_ = this is HorizontalMode ? param1 : _loc7_;
_loc9_ = this is HorizontalMode ? _loc7_ : param1;
if(Data.state.spawner[_loc8_ + "," + _loc9_] == null)
{
_loc10_ = _loc8_ * Config.BLOCK_SIZE;
_loc11_ = _loc9_ * Config.BLOCK_SIZE;
_loc12_ = this.pixels.getPixel(_loc8_,_loc9_);
_loc13_ = this.overpixels.getPixel(_loc8_,_loc9_);
_loc14_ = this.colorToTileID(_loc13_,_loc8_,_loc9_,true);
_loc15_ = false;
if(_loc14_ > 0 && _loc13_ != this.WATER && _loc13_ != this.LAVA)
{
_loc17_ = new Wall(_loc8_ * Config.BLOCK_SIZE,_loc9_ * Config.BLOCK_SIZE,_loc14_,PlayMode["T" + this._ch],true);
this.overblocks.add(_loc17_);
_loc18_ = new Wall(_loc8_ * Config.BLOCK_SIZE,_loc9_ * Config.BLOCK_SIZE,_loc14_,PlayMode["T" + this._ch]);
_loc18_.color = 3355443;
this.underblocks.add(_loc18_);
_loc15_ = true;
}
if(ArcU.rand(1,100) <= this.spawnChance)
{
switch(_loc12_)
{
case 16711680:
_loc2_ = new Slime(_loc8_,_loc9_,_loc5_);
this.enemies.add(_loc2_);
break;
case 9699328:
_loc2_ = new BouncingSlime(_loc8_,_loc9_,_loc5_);
this.enemies.add(_loc2_);
break;
case 7340032:
_loc2_ = new ClimbingSlime(_loc8_,_loc9_,_loc5_);
this.enemies.add(_loc2_);
break;
case 7766374:
_loc2_ = new Plant(_loc8_,_loc9_,_loc5_,_loc4_ ? int(FlxObject.LEFT) : int(FlxObject.RIGHT));
this.enemies.add(_loc2_);
break;
case 5069370:
_loc2_ = new Plant(_loc8_,_loc9_,_loc5_,_loc4_ ? int(FlxObject.RIGHT) : int(FlxObject.LEFT));
this.enemies.add(_loc2_);
break;
case 1427036:
_loc2_ = new CeilingPlant(_loc8_,_loc9_,_loc5_);
this.enemies.add(_loc2_);
break;
case 3207347:
_loc2_ = new FloorPlant(_loc8_,_loc9_,_loc5_);
this.enemies.add(_loc2_);
break;
case 7929600:
_loc2_ = new Bird(_loc8_,_loc9_,_loc5_);
this.enemies.add(_loc2_);
break;
case 9517164:
_loc2_ = new Snail(_loc8_,_loc9_,_loc5_);
this.enemies.add(_loc2_);
break;
case 12221184:
_loc2_ = new Spider(_loc8_,_loc9_,_loc5_);
this.enemies.add(_loc2_);
break;
case 12500670:
_loc2_ = new Spike(_loc8_,_loc9_,_loc5_);
this.enemies.add(_loc2_);
break;
case 7500402:
_loc2_ = new Blade(_loc8_,_loc9_,_loc5_);
this.penemies.add(_loc2_);
break;
case 15763712:
_loc2_ = new Tadpole(_loc8_,_loc9_,_loc5_);
this.enemies.add(_loc2_);
break;
case 8750469:
_loc19_ = new BossDoor(_loc8_,_loc9_,_loc5_);
this.cobjects.add(_loc19_);
break;
case 3289650:
_loc20_ = 0;
_loc21_ = 0;
_loc22_ = 0;
if(this.isTile(this.pixels.getPixel(_loc8_,_loc9_ - 1)) != 0)
{
_loc20_ = 0;
_loc21_ = 0;
_loc22_ = 1;
}
else if(this.isTile(this.pixels.getPixel(_loc8_ + 1,_loc9_)) != 0)
{
_loc20_ = 1;
_loc21_ = -1;
_loc22_ = 0;
}
else if(this.isTile(this.pixels.getPixel(_loc8_,_loc9_ + 1)) != 0)
{
_loc20_ = 2;
_loc21_ = 0;
_loc22_ = -1;
}
else if(this.isTile(this.pixels.getPixel(_loc8_ - 1,_loc9_)) != 0)
{
_loc20_ = 3;
_loc21_ = 1;
_loc22_ = 0;
}
_loc23_ = new FlxPoint(0,0);
_loc24_ = _loc8_ + _loc21_;
_loc25_ = _loc9_ + _loc22_;
while(_loc23_.y == 0)
{
if(this.isTile(this.pixels.getPixel(_loc24_,_loc25_)))
{
_loc23_.y = _loc25_;
_loc23_.x = _loc24_;
}
else
{
_loc24_ += _loc21_;
_loc25_ += _loc22_;
}
}
_loc2_ = new Laser(_loc10_,_loc11_,1,_loc20_,_loc23_);
this.enemies.add(_loc2_);
break;
case 16763904:
_loc26_ = Diamond.valueFromLevel(_loc5_ * (this is EscapeMode ? 1 : 1) * (this is TadpoleMode ? 3 : 1));
_loc27_ = new Diamond(_loc8_ * Config.BLOCK_SIZE + 1,_loc9_ * Config.BLOCK_SIZE + 1,ArcU.rand(1,_loc26_),_loc15_,_loc8_,_loc9_);
this.diamonds.add(_loc27_);
break;
case 16747367:
if(!(this is EscapeMode && ArcU.rand(0,99) < 50))
{
_loc3_ = new PowerupFire(_loc8_,_loc9_);
this.powerups.add(_loc3_);
break;
}
continue;
case 6473198:
if(!(this is EscapeMode && ArcU.rand(0,99) < 30))
{
_loc3_ = new PowerupMagnet(_loc8_,_loc9_);
this.powerups.add(_loc3_);
break;
}
continue;
case 6746111:
if(!(this is EscapeMode && ArcU.rand(0,99) < 50))
{
_loc3_ = new PowerupShield(_loc8_,_loc9_);
this.powerups.add(_loc3_);
break;
}
continue;
case 8171970:
_loc28_ = new Checkpoint(_loc8_,_loc9_);
this.objects.add(_loc28_);
break;
case 2949120:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,0));
break;
case 2949121:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,1));
break;
case 2949122:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,2));
break;
case 2949123:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,3));
break;
case 2949124:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,4));
break;
case 2949125:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,5));
break;
case 2949126:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,6));
break;
case 2949127:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,7));
break;
case 2949128:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,8));
break;
case 2949129:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,9));
break;
case 2949136:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,10));
break;
case 2949137:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,11));
break;
case 2949138:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,12));
break;
case 2949139:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,13));
break;
case 2949140:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,14));
break;
case 2949141:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,15));
break;
case 2949142:
this.powerups.add(new HeartCrystal(_loc8_,_loc9_,16));
break;
case 255:
if(Data.autofirer == 0)
{
this.powerups.add(new PowerupEquipment(_loc8_,_loc9_,0));
}
break;
case 65791:
if(Data.lasersight == 0)
{
this.powerups.add(new PowerupEquipment(_loc8_,_loc9_,1));
}
break;
case 131327:
if(Data.skyboots == 0)
{
this.powerups.add(new PowerupEquipment(_loc8_,_loc9_,2));
}
break;
case 327935:
if(Data.moltensuit == 0)
{
this.powerups.add(new PowerupEquipment(_loc8_,_loc9_,3));
}
break;
case 459007:
if(Data.moonboots == 0)
{
this.powerups.add(new PowerupEquipment(_loc8_,_loc9_,4));
}
break;
case 590079:
if(Data.prime == 0)
{
this.powerups.add(new PowerupEquipment(_loc8_,_loc9_,5));
}
break;
case 196863:
if(Data.spreader == 0)
{
this.powerups.add(new PowerupEquipment(_loc8_,_loc9_,6));
}
break;
case 262399:
if(Data.missile == 0)
{
this.powerups.add(new PowerupEquipment(_loc8_,_loc9_,7));
}
break;
case 393471:
if(Data.rebound == 0)
{
this.powerups.add(new PowerupEquipment(_loc8_,_loc9_,8));
}
break;
case 524543:
if(Data.xrayscope == 0)
{
this.powerups.add(new PowerupEquipment(_loc8_,_loc9_,9));
}
break;
case 16711932:
this.powerups.add(new RedDiamond(_loc8_,_loc9_,this._redLocations[_loc8_ + "-" + _loc9_]));
break;
case 13369599:
_loc2_ = new SlimeKing(_loc8_,_loc9_);
this.enemies.add(_loc2_);
break;
case 13369855:
_loc2_ = new StoneBird(_loc8_,_loc9_);
this.enemies.add(_loc2_);
break;
case 13370111:
_loc2_ = new SnailKing(_loc8_,_loc9_);
this.enemies.add(_loc2_);
break;
case 13370367:
_loc2_ = new Blob(_loc8_,_loc9_);
this.enemies.add(_loc2_);
break;
case 13370623:
_loc2_ = new Snake(_loc8_,_loc9_);
this.enemies.add(_loc2_);
break;
case 13370879:
_loc2_ = new ProfessorShade(_loc8_,_loc9_);
this.enemies.add(_loc2_);
break;
case 13371135:
_loc2_ = new Professor(_loc8_,_loc9_);
this.enemies.add(_loc2_);
}
}
_loc16_ = this.pixels.getPixel(_loc8_,_loc9_ + 1);
if(_loc16_ == 5228053 && _loc12_ == 16777215 && this.tilemap.getTile(_loc8_,_loc9_) == 0)
{
_loc29_ = ArcU.rand(0,100);
if(_loc29_ < 3)
{
_loc30_ = new Pot(_loc10_,_loc11_,1);
this.objects.add(_loc30_);
}
}
}
}
}
override public function draw() : void
{
super.draw();
this.xray.visible = this.xraying;
if(this._complete && this._completeWindow != null)
{
this._completeWindow.draw();
}
if(this.inMenu)
{
this._menu.draw();
}
var _loc1_:AchievementWindow = AchievementSystem.achievementWindow;
if(_loc1_ != null)
{
_loc1_.draw();
}
if(this.whitefader != null)
{
this.whitefader.draw();
}
}
protected function calcTop(param1:int) : int
{
return FlxG.camera.scroll.y / Config.BLOCK_SIZE - param1;
}
protected function calcBottom(param1:int) : int
{
return (FlxG.camera.scroll.y + FlxG.height) / Config.BLOCK_SIZE + param1;
}
public function reset() : void
{
}
public function isComplete() : Boolean
{
return this._complete;
}
public function get xraying() : Boolean
{
return FlxG.keys.SHIFT && this.player.controllable && Data.xrayscope == 1 && !Data.state.isComplete() && !Data.state.inMenu && Data.hp > 0 && (Data.state is StoryMode || Data.state is EscapeMode);
}
public function get menu() : Menu
{
return this._menu;
}
}
}