Frame 1
System.security.allowDomain("*");
this.createEmptyMovieClip("rectangle_mc", Camera3D.getNextDepth());
rectangle_mc._x = 0;
rectangle_mc._y = 0;
var xmouse = _xmouse;
var ymouse = _ymouse;
var lastxmouse = _xmouse;
var lastymouse = _ymouse;
var mouseStayTimer = 0;
var frames = 0;
var lastFPSTime = 0;
_root.createTextField("txtFPS", 1000, 5, 5, 300, 100);
txtFPS.multiline = true;
txtFPS.wordWrap = true;
var txtFmt = new TextFormat();
txtFmt.color = 16777215 /* 0xFFFFFF */;
txtFPS.text = "Frame Time: \nFPS: ";
txtFPS.setTextFormat(txtFmt);
txtFPS._visible = false;
var dt = 0;
var prevTime;
var curTime;
var dMouseWheel = 0;
var displayPlayerTarget = false;
var displayTextField = false;
var cheatMode = false;
var lastPressed = 0;
_root.createEmptyMovieClip("background_mc", Camera3D.getNextDepth());
var bgColor = new XColor(16777215);
var curLevel = 0;
var nextLevel = 0;
var switchLevel = 0;
var switchingLevels = false;
var gameLevels = new Array();
var totalLevel = 0;
var playerNum = 0;
var formerSelf;
var numPlayerBosses = 0;
var camera = new Camera3D();
var particleA;
var sndLoader = new SndLoader();
sndLoader.initialize();
var tStartZ = 0;
var tAccel = 0;
var tAccelDefault = -75;
var tSpeed = 0;
var toTop = false;
var curCampaign = -1;
var switchingCampaigns = false;
var cTransTime = 2;
var curCTransDelay = 1;
var curCTransTime = 0;
var loaded = false;
var levelLoader = new LevelLoader();
levelLoader.loadXML("levels.xml");
var currentObj = _root.createEmptyMovieClip("fish_player" + playerNum, Camera3D.getNextDepth());
currentObj._visible = false;
var player = new Snakefish(0, 0, 3, 16, 0, 15, 200, ((8 + random(3)) / 180) * Math.PI, false, currentObj, -1, "c1_");
camera.focalLength = 600;
camera.posX = (Stage.width / 2) - player.posX;
camera.posY = (Stage.height / 2) - player.posY;
camera.posZ = 0;
particleA = new Particle(10);
curTime = (prevTime = getTimer());
lastFPSTime = curTime;
lastPressed = curTime;
background_mc._x = 0;
background_mc._y = 0;
bgColor.baseColor = gameLevels[curLevel].bgColor.curColor;
bgColor.setBias(1);
_root.onMouseDown = function () {
player.pressed = true;
};
_root.onMouseUp = function () {
player.pressed = false;
};
Frame 3
function switchLevel(newLevel) {
if (((((newLevel < 0) || (newLevel > (gameLevels.length - 1))) || (newLevel == curLevel)) || (nextLevel != curLevel)) || (toTop)) {
return(undefined);
}
nextLevel = newLevel;
camera.targetZ = gameLevels[nextLevel].zDepth;
bgColor.targetColor = gameLevels[nextLevel].bgColor.curColor;
}
function transitionToLevel() {
switchingLevels = true;
if (nextLevel < curLevel) {
camera.posZ = camera.posZ + (((camera.targetZ - camera.posZ) * dt) * 6);
} else {
camera.posZ = camera.posZ + (((camera.targetZ - camera.posZ) * dt) * 2.5);
}
bgColor.setBias(Math.abs(camera.targetZ - camera.posZ) / GameLevel.zLevelGap);
if (Math.abs(camera.targetZ - camera.posZ) < 3) {
camera.posZ = camera.targetZ;
curLevel = nextLevel;
bgColor.baseColor = (bgColor.targetColor = gameLevels[curLevel].bgColor.curColor);
player.setBias(1);
bgColor.setBias(1);
player.assetPrefix = gameLevels[curLevel].assetPrefix;
switchingLevels = false;
}
player.posZ = camera.posZ;
}
function switchCampaign(num, ease) {
if (num != curCampaign) {
var _local1 = new XColor(16777215);
_local1.copy(bgColor);
levelLoader.spawnCampaign(num);
if (ease) {
gameLevels[1].setAlpha(0);
switchingCampaigns = true;
curCTransTime = 0;
curCTransDelay = 0.5;
bgColor.baseColor = _local1.curColor;
bgColor.targetColor = gameLevels[curLevel].bgColor.curColor;
bgColor.setBias(1);
} else {
bgColor.baseColor = (bgColor.targetColor = gameLevels[curLevel].bgColor.curColor);
bgColor.setBias(1);
}
player.color.copy(gameLevels[curLevel].fgColor);
player.color.setBias(1);
player.assetPrefix = gameLevels[curLevel].assetPrefix;
curCampaign = num;
}
}
function transitionToCampaign() {
if (curCTransDelay > 0) {
curCTransDelay = curCTransDelay - dt;
return(undefined);
}
curCTransTime = curCTransTime + dt;
var _local1 = (cTransTime - curCTransTime) / cTransTime;
var _local2 = (cTransTime - Math.max(curCTransTime - 0.5, 0)) / cTransTime;
bgColor.setBias(Math.min(_local1, 1));
gameLevels[1].setAlpha(Math.max(1 - _local2, 0));
if (curCTransTime >= cTransTime) {
bgColor.baseColor = bgColor.targetColor;
bgColor.setBias(1);
if (curCTransTime >= (cTransTime * 1.5)) {
gameLevels[1].setAlpha(1);
switchingCampaigns = false;
}
}
if (curCTransTime >= (cTransTime / 4)) {
PlayerXForm.hatchPlayer();
}
}
function floatToTop() {
if ((!toTop()) && (!switchingLevels)) {
toTop = true;
tStartZ = camera.posZ;
tSpeed = 0;
tAccel = tAccelDefault;
camera.targetZ = 0;
camera.targetX = (Stage.width / 2) - player.posX;
camera.targetY = (Stage.height / 2) - player.posY;
camera.toTarget = true;
camera.targetZ = 0;
var _local1 = 0;
while (_local1 < totalLevel) {
gameLevels[_local1].closeToCam = true;
_local1++;
}
player.toTarget = true;
player.targetX = 0;
player.targetY = 0;
}
}
function transitionToTop() {
if (!switchingLevels) {
if ((tStartZ - camera.posZ) > (tStartZ / 2)) {
var _local3 = ((camera.posZ + 150) / (tStartZ / 2)) * tSpeed;
_local3 = Math.max(_local3, 50);
camera.posZ = camera.posZ - (_local3 * dt);
} else {
tAccel = tAccel + (30 * dt);
if (tAccel >= 0) {
tSpeed = tSpeed + (tAccel * dt);
}
camera.posZ = camera.posZ - (tSpeed * dt);
}
var _local2 = camera.posZ / GameLevel.zLevelGap;
var _local5 = Math.ceil(_local2);
var _local4 = Math.floor(_local2);
bgColor.baseColor = gameLevels[_local5].bgColor.curColor;
bgColor.targetColor = gameLevels[_local4].bgColor.curColor;
bgColor.setBias(_local2 - _local4);
if (camera.posZ < 3) {
toTop = false;
camera.posZ = 0;
camera.toTarget = false;
player.toTarget = false;
curLevel = (nextLevel = 0);
var _local1 = 0;
while (_local1 < totalLevel) {
gameLevels[_local1].closeToCam = false;
_local1++;
}
if (curCampaign == 2) {
switchCampaign(1, true);
} else {
switchCampaign(2, true);
}
formerSelf.speed = formerSelf.defaultSpeed;
}
camera.targetX = (Stage.width / 2) - player.posX;
camera.targetY = (Stage.height / 2) - player.posY;
player.posZ = camera.posZ;
}
}
function redrawBackground() {
background_mc.clear();
Camera3D.drawRectangle(background_mc, Stage.width, Stage.height, bgColor.curColor, 100);
}
clear();
redrawBackground();
prevTime = curTime;
curTime = getTimer();
dt = (curTime - prevTime) / 1000;
frames++;
if (displayTextField) {
txtFPS._visible = true;
if ((curTime - lastFPSTime) > 100) {
var FPS = ((frames / (curTime - lastFPSTime)) * 1000);
var FrameTime = (1000 / FPS);
FPS = FPS * 10;
FPS = Math.round(FPS);
FPS = FPS / 10;
FrameTime = FrameTime * 10;
FrameTime = Math.round(FrameTime);
FrameTime = FrameTime / 10;
frames = 0;
lastFPSTime = curTime;
txtFPS.text = ((((((((("Frame Time:\t" + FrameTime) + " ms") + "\nFPS:\t\t\t") + FPS) + "\nx:") + int(player.posX)) + " y:") + int(player.posY)) + " z:") + int(player.posZ);
txtFPS.setTextFormat(txtFmt);
}
} else {
txtFPS._visible = false;
}
if ((lastxmouse == _xmouse) && (lastymouse == _ymouse)) {
mouseStayTimer = mouseStayTimer + dt;
if (mouseStayTimer > 3) {
xmouse = Stage.width * 0.5;
ymouse = Stage.height * 0.5;
}
} else {
lastxmouse = _xmouse;
lastymouse = _ymouse;
xmouse = _xmouse;
ymouse = _ymouse;
mouseStayTimer = 0;
}
if ((curLevel != -1) && (!toTop)) {
if (_xmouse < (Stage.width * 0.5)) {
camera.posX = camera.posX + ((player.currentSpeed * dt) * (1 - (xmouse / (Stage.width * 0.5))));
} else if (xmouse > (Stage.width * 0.5)) {
camera.posX = camera.posX - ((player.currentSpeed * dt) * ((xmouse / (Stage.width * 0.5)) - 1));
}
if (_ymouse < (Stage.height * 0.5)) {
camera.posY = camera.posY + ((player.currentSpeed * dt) * (1 - (ymouse / (Stage.height * 0.5))));
} else if (ymouse > (Stage.height * 0.5)) {
camera.posY = camera.posY - ((player.currentSpeed * dt) * ((ymouse / (Stage.height * 0.5)) - 1));
}
}
if (Key.isDown(192)) {
cheatMode = true;
}
if (cheatMode) {
if (Key.isDown(39)) {
camera.zOffset = camera.zOffset - 20;
} else if (Key.isDown(37)) {
camera.zOffset = camera.zOffset + 20;
}
if (Key.isDown(40)) {
switchLevel(curLevel - 1);
} else if (Key.isDown(38)) {
switchLevel(curLevel + 1);
}
if (Key.isDown(84) && ((curTime - lastPressed) > 250)) {
displayTextField = !displayTextField;
lastPressed = curTime;
}
if (Key.isDown(80) && ((curTime - lastPressed) > 250)) {
displayPlayerTarget = !displayPlayerTarget;
GameLevel.debugLines = !GameLevel.debugLines;
lastPressed = curTime;
}
if (Key.isDown(83)) {
camera.shake(0);
}
if (Key.isDown(82)) {
player.regeneration();
}
if (Key.isDown(71)) {
player.grow();
}
if (Key.isDown(69)) {
gameLevels[curLevel].spawnFoodAtLocation(0, player.posX, player.posY, 15, 10);
}
if (Key.isDown(68)) {
gameLevels[curLevel].spawnFoodAtLocation(99, player.posX, player.posY, 15, 10);
}
if (Key.isDown(70)) {
gameLevels[curLevel].spawnFoodAtLocation(1, player.posX, player.posY, 15, 10);
}
if (Key.isDown(67)) {
if (player.dieing == false) {
player.die();
}
}
if (Key.isDown(66)) {
var b = gameLevels[curLevel].spawnBulletAtLocation(50, player.posX, player.posY, 25, 60, 5, 8, 3);
b.movementMode = 2;
}
if (Key.isDown(65)) {
switchCampaign(2, true);
}
if (Key.isDown(72)) {
switchLevel(0);
}
if (Key.isDown(90)) {
switchLevel(19);
}
if (Key.isDown(73)) {
gameLevels[curLevel].fish[0].die();
}
if (Key.isDown(74)) {
gameLevels[curLevel].spawnFoodAtLocation(102, 0, 0, 25, 10);
}
if (Key.isDown(75)) {
var mc = _root.createEmptyMovieClip("b" + dt, Camera3D.getNextDepth());
var c = Creature.clone(player, mc, 111);
gameLevels[curLevel].fish[gameLevels[curLevel].fish.length] = c;
gameLevels[curLevel].fishLength++;
}
}
if ((!loaded) && (LevelLoader.isLoaded)) {
loaded = true;
switchCampaign(1, false);
}
if (curLevel != nextLevel) {
transitionToLevel();
}
if (toTop) {
transitionToTop();
}
if (switchingCampaigns) {
transitionToCampaign();
}
sndLoader.update();
PlayerXForm.update(dt);
camera.updateShake(dt);
camera.updateMovement(dt);
player.mc._visible = true;
player.updateScreenPos(camera);
player.update(dt, camera, this, gameLevels[curLevel].fish, gameLevels[curLevel].food);
if ((displayPlayerTarget && (player.hasTarget)) && (curLevel == nextLevel)) {
background_mc.lineStyle(1, 16777215, 128);
background_mc.moveTo(player.screenX + camera.screenX, player.screenY + camera.screenY);
background_mc.lineTo((player.targetX * (player.mc._xscale / 100)) + camera.screenX, (player.targetY * (player.mc._yscale / 100)) + camera.screenY);
}
var i = 0;
while (i < gameLevels.length) {
if (i == curLevel) {
gameLevels[i].update(dt, camera, player);
} else {
gameLevels[i].update(dt, camera, null);
}
i++;
}
particleA.update(dt, camera);
dMouseWheel = 0;
gotoAndPlay (2);
Symbol 12 MovieClip [c1_segbody1] Frame 1
stop();
Symbol 12 MovieClip [c1_segbody1] Frame 2
stop();
Symbol 19 MovieClip Frame 1
stop();
Symbol 24 MovieClip [c1_jellyhead1] Frame 1
stop();
Symbol 24 MovieClip [c1_jellyhead1] Frame 22
gotoAndPlay (20);
Symbol 24 MovieClip [c1_jellyhead1] Frame 29
gotoAndStop (1);
Symbol 32 MovieClip [c4_segbody1] Frame 1
stop();
Symbol 32 MovieClip [c4_segbody1] Frame 2
stop();
Symbol 32 MovieClip [c4_segbody1] Frame 3
stop();
Symbol 32 MovieClip [c4_segbody1] Frame 4
stop();
Symbol 32 MovieClip [c4_segbody1] Frame 5
stop();
Symbol 34 MovieClip [c4_jellybody1] Frame 1
stop();
Symbol 34 MovieClip [c4_jellybody1] Frame 2
stop();
Symbol 34 MovieClip [c4_jellybody1] Frame 3
stop();
Symbol 34 MovieClip [c4_jellybody1] Frame 4
stop();
Symbol 34 MovieClip [c4_jellybody1] Frame 5
stop();
Symbol 36 MovieClip [c3_jellybody1] Frame 1
stop();
Symbol 36 MovieClip [c3_jellybody1] Frame 2
stop();
Symbol 36 MovieClip [c3_jellybody1] Frame 3
stop();
Symbol 36 MovieClip [c3_jellybody1] Frame 4
stop();
Symbol 39 MovieClip [c3_segbody1] Frame 1
stop();
Symbol 39 MovieClip [c3_segbody1] Frame 2
stop();
Symbol 39 MovieClip [c3_segbody1] Frame 3
stop();
Symbol 39 MovieClip [c3_segbody1] Frame 4
stop();
Symbol 41 MovieClip [c2_jellybody1] Frame 1
stop();
Symbol 41 MovieClip [c2_jellybody1] Frame 2
stop();
Symbol 41 MovieClip [c2_jellybody1] Frame 3
stop();
Symbol 42 MovieClip [c2_segbody1] Frame 1
stop();
Symbol 42 MovieClip [c2_segbody1] Frame 2
stop();
Symbol 42 MovieClip [c2_segbody1] Frame 3
stop();
Symbol 43 MovieClip [c1_jellybody1] Frame 1
stop();
Symbol 43 MovieClip [c1_jellybody1] Frame 2
stop();
Symbol 166 MovieClip [c1_seghead1] Frame 1
stop();
Symbol 166 MovieClip [c1_seghead1] Frame 22
gotoAndPlay (20);
Symbol 166 MovieClip [c1_seghead1] Frame 29
gotoAndStop (1);
Symbol 192 MovieClip [__Packages.GameObject] Frame 0
class GameObject
{
var posX, posY, posZ, screenX, screenY, maxBlur, useEffect, blurFilter, colorTrans, colorTrans2, glowFilter, color, alpha, level, soundVolume, mc;
function GameObject () {
posX = (posY = (posZ = 0));
screenX = (screenY = 0);
maxBlur = 16;
useEffect = true;
blurFilter = new flash.filters.BlurFilter(0, 0, 1);
colorTrans = new flash.geom.ColorTransform();
colorTrans2 = new flash.geom.ColorTransform();
glowFilter = new flash.filters.GlowFilter(16777215, 1, 16, 16, 1.5, 1, false, false);
color = new XColor(16777215);
alpha = 1;
}
function updateScreenPos(camera) {
applyCamera(camera);
}
function applyCamera(camera) {
level = Math.round(posZ / GameLevel.zLevelGap);
var _local5 = (posZ - camera.posZ) + camera.zOffset;
var _local4 = camera.focalLength / (camera.focalLength + _local5);
var _local7 = 100 * _local4;
if (Math.abs(_local5) < GameLevel.zLevelGap) {
soundVolume = ((GameLevel.zLevelGap - Math.abs(_local5)) / GameLevel.zLevelGap) * 100;
var _local6 = dist(posX, posY, _root.player.posX, _root.player.posY);
if (_local6 < soundRange) {
soundVolume = soundVolume * ((soundRange - _local6) / soundRange);
} else {
soundVolume = 0;
}
} else {
soundVolume = 0;
}
_local5 = (posZ - camera.posZ) + camera.zOffset;
_local4 = camera.focalLength / (camera.focalLength + _local5);
mc._xscale = (mc._yscale = 100 * _local4);
mc._x = camera.posX;
mc._y = camera.posY;
screenX = posX * _local4;
screenY = posY * _local4;
camera.zScaleRatio = _local4;
camera.screenX = camera.posX;
camera.screenY = camera.posY;
if (!Camera3D.inWindow(screenX, screenY, camera)) {
mc._visible = false;
} else {
mc._visible = true;
}
if (useEffect && (mc._visible)) {
var _local8 = (posZ - camera.posZ) + camera.zOffset;
glowFilter.color = color.curColor;
shadeImage(_local8);
blurImage(_local7);
}
}
function blurImage(scale) {
var _local2;
if (mc.seg0._xscale <= 100) {
if (scale >= 100) {
_local2 = 0;
mc.filters = [glowFilter];
} else {
_local2 = (100 - scale) / 100;
blurFilter.blurX = _local2 * maxBlur;
blurFilter.blurY = _local2 * maxBlur;
mc.filters = [blurFilter, glowFilter];
}
} else {
mc.filters = [];
}
}
function shadeImage(dz) {
var _local2 = 0.3 + ((0.7 * (GameLevel.zLevelGap - dz)) / GameLevel.zLevelGap);
colorTrans.alphaMultiplier = Math.min(_local2, alpha);
colorTrans2.alphaMultiplier = Math.min(_local2 * 0.3, alpha);
colorTrans.redOffset = (colorTrans2.redOffset = -(255 - color.getRed()));
colorTrans.greenOffset = (colorTrans2.greenOffset = -(255 - color.getGreen()));
colorTrans.blueOffset = (colorTrans2.blueOffset = -(255 - color.getBlue()));
}
function dist(x1, y1, x2, y2) {
var _local1 = Math.sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
return(_local1);
}
var soundRange = 500;
}
Symbol 193 MovieClip [__Packages.XColor] Frame 0
class XColor
{
var defaultColor, baseColor, targetColor, curColor, bias;
function XColor (base) {
defaultColor = base;
baseColor = base;
targetColor = base;
curColor = base;
bias = 1;
}
function copy(color) {
defaultColor = color.defaultColor;
baseColor = color.baseColor;
targetColor = color.targetColor;
curColor = color.curColor;
}
function setBias(bias) {
var _local3 = (RED(baseColor) * bias) + (RED(targetColor) * (1 - bias));
var _local5 = (GREEN(baseColor) * bias) + (GREEN(targetColor) * (1 - bias));
var _local4 = (BLUE(baseColor) * bias) + (BLUE(targetColor) * (1 - bias));
curColor = RGB(_local3, _local5, _local4);
this.bias = bias;
}
function getRed() {
return(RED(curColor));
}
function getGreen() {
return(GREEN(curColor));
}
function getBlue() {
return(BLUE(curColor));
}
static function RED(rgb) {
return((rgb & 16711680) >> 16);
}
static function GREEN(rgb) {
return((rgb & 65280) >> 8);
}
static function BLUE(rgb) {
return(rgb & 255);
}
static function RGB(r, g, b) {
return(((r << 16) | (g << 8)) | b);
}
}
Symbol 194 MovieClip [__Packages.GameLevel] Frame 0
class GameLevel
{
var fish, fishLength, food, foodLength, effect, effectLength, billboard, billboardLength, level, levelSize, zDepth, isVisible, fgColor, bgColor, campaign, assetPrefix, bgMusic, bgMusicStarted, downMarker, upMarker, closeToCam, playerBoss, bgVolume, foodDown, foodUp;
function GameLevel (level, levelSize) {
init(level, levelSize);
}
function init(level, levelSize) {
fish = new Array();
fishLength = 0;
food = new Array();
foodLength = 0;
effect = new Array();
effectLength = 0;
billboard = new Array();
billboardLength = 0;
this.level = level;
this.levelSize = levelSize;
zDepth = level * zLevelGap;
isVisible = false;
fgColor = new XColor(16777215);
bgColor = new XColor(0);
campaign = 1;
if (campaign == 1) {
assetPrefix = "c1_";
} else if (campaign == 2) {
assetPrefix = "c2_";
} else if (campaign == 3) {
assetPrefix = "c3_";
} else if (campaign == 4) {
assetPrefix = "c4_";
}
bgMusic = _root.sndLoader.getSound(((assetPrefix + "Flow-lvl ") + level) + " drone");
bgMusicStarted = false;
downMarker = _root.createEmptyMovieClip(("level_" + level) + "_downMarker", Camera3D.getNextDepth());
downMarker.attachMovie("downMarker", "downMarker", 1);
downMarker._xscale = (downMarker._yscale = 100);
downMarker._visible = false;
upMarker = _root.createEmptyMovieClip(("level_" + level) + "_upMarker", Camera3D.getNextDepth());
upMarker.attachMovie("upMarker", "upMarker", 1);
upMarker._xscale = (upMarker._yscale = 100);
upMarker._visible = false;
closeToCam = false;
}
function eraseData() {
var _local3 = 0;
while (_local3 < fish.length) {
if (fish[_local3] != playerBoss) {
_root[fish[_local3].clipName].removeMovieClip();
delete fish[_local3];
fish[_local3] = null;
}
_local3++;
}
_local3 = 0;
while (_local3 < food.length) {
_root[food[_local3].clipName].removeMovieClip();
delete food[_local3];
food[_local3] = null;
_local3++;
}
_local3 = 0;
while (_local3 < effect.length) {
_root[effect[_local3].clipName].removeMovieClip();
delete effect[_local3];
effect[_local3] = null;
_local3++;
}
_local3 = 0;
while (_local3 < billboard.length) {
_root[billboard[_local3].clipName].removeMovieClip();
delete billboard[_local3];
billboard[_local3] = null;
_local3++;
}
fish = new Array();
fishLength = 0;
food = new Array();
foodLength = 0;
effect = new Array();
effectLength = 0;
billboard = new Array();
billboardLength = 0;
bgMusic.stop();
}
function update(dt, camera, player) {
var _local7;
var _local6 = zDepth - camera.posZ;
if (Math.abs(_local6) < zLevelGap) {
if ((!bgMusicStarted) && (SndLoader.isLoaded(bgMusic))) {
bgMusicStarted = true;
bgMusic.start(0, 99);
}
bgVolume = ((zLevelGap - Math.abs(_local6)) / zLevelGap) * 100;
bgMusic.setVolume(bgVolume);
} else if (Math.abs(_local6) < (2 * zLevelGap)) {
if (((!bgMusicStarted) && (bgMusic.getBytesTotal() > 0)) && (SndLoader.isLoaded(bgMusic))) {
bgMusicStarted = true;
bgMusic.start(0, 99);
bgMusic.setVolume(0);
}
} else {
bgMusic.setVolume(0);
bgMusic.stop();
bgMusicStarted = false;
}
var _local9 = 0.3;
if (closeToCam) {
_local9 = 0.9;
}
if ((_local6 < ((-zLevelGap) * _local9)) || (_local6 > (zLevelGap * 1.3))) {
setVisible(false);
} else {
setVisible(true);
}
_local7 = isVisible;
if (_local7) {
var _local4 = 0;
while (_local4 < fish.length) {
fish[_local4].updateScreenPos(camera);
fish[_local4].update(dt, camera, player, fish, food);
if (((_local6 == 0) && (fish[_local4].hasTarget)) && (debugLines)) {
_root.background_mc.lineStyle(1, 16777215, 128);
_root.background_mc.moveTo(fish[_local4].screenX + camera.screenX, fish[_local4].screenY + camera.screenY);
_root.background_mc.lineTo((fish[_local4].targetX * (fish[_local4].mc._xscale / 100)) + camera.screenX, (fish[_local4].targetY * (fish[_local4].mc._yscale / 100)) + camera.screenY);
}
if (fish[_local4].alive == false) {
delete fish[_local4];
fish[_local4] = null;
}
_local4++;
}
_local4 = 0;
while (_local4 < food.length) {
food[_local4].updateScreenPos(camera);
food[_local4].update(dt, camera);
if ((food[_local4].alive == false) && (food[_local4].respawnTime <= 0)) {
delete food[_local4];
food[_local4] = null;
}
_local4++;
}
_local4 = 0;
while (_local4 < effectLength) {
if (effect[_local4].alive) {
effect[_local4].updateScreenPos(camera);
if (_local7) {
effect[_local4].update(dt, camera);
}
}
_local4++;
}
_local4 = 0;
while (_local4 < billboard.length) {
billboard[_local4].updateScreenPos(camera);
billboard[_local4].update(camera);
_local4++;
}
if (foodDown != null) {
updateLevelMarker(foodDown, downMarker, player, camera);
}
if (foodUp != null) {
updateLevelMarker(foodUp, upMarker, player, camera);
}
} else {
if (_local6 > (-1.1 * zLevelGap)) {
var _local4 = 0;
while (_local4 < food.length) {
if (food[_local4].foodType > 99) {
food[_local4].update(dt, camera);
}
_local4++;
}
}
downMarker._visible = false;
upMarker._visible = false;
}
}
function setVisible(vis) {
if (isVisible == vis) {
return(undefined);
}
isVisible = vis;
var _local2 = 0;
while (_local2 < fish.length) {
fish[_local2].mc._visible = vis;
_local2++;
}
_local2 = 0;
while (_local2 < food.length) {
food[_local2].mc._visible = vis;
_local2++;
}
_local2 = 0;
while (_local2 < effectLength) {
effect[_local2].mc._visible = vis;
_local2++;
}
_local2 = 0;
while (_local2 < billboardLength) {
billboard[_local2].mc._visible = vis;
_local2++;
}
}
function setAlpha(a) {
var _local2 = 0;
while (_local2 < fish.length) {
fish[_local2].alpha = a;
_local2++;
}
_local2 = 0;
while (_local2 < food.length) {
food[_local2].alpha = a;
_local2++;
}
_local2 = 0;
while (_local2 < effectLength) {
effect[_local2].alpha = a;
_local2++;
}
}
function updateLevelMarker(food, marker, player, camera) {
if (player != null) {
if (!Camera3D.inWindow(food.screenX, food.screenY, camera)) {
var _local8 = (food.screenX + camera.screenX) - (Stage.width * 0.5);
var _local7 = (food.screenY + camera.screenY) - (Stage.height * 0.5);
var _local1 = Math.atan2(_local7, _local8);
var _local5 = Math.atan2(Stage.height, Stage.width);
var _local3;
if ((Math.abs(_local1) > _local5) && (Math.abs(_local1) < (Math.PI - _local5))) {
_local3 = Math.abs((Stage.height / 2) / Math.sin(_local1));
} else {
_local3 = Math.abs((Stage.width / 2) / Math.cos(_local1));
}
marker._x = (Stage.width / 2) + (_local3 * Math.cos(_local1));
marker._y = (Stage.height / 2) + (_local3 * Math.sin(_local1));
marker._visible = true;
} else {
marker._visible = false;
}
} else {
marker._visible = false;
}
}
function unspawnGoldEgg() {
var _local2 = 0;
while (_local2 < fish.length) {
fish[_local2].hasGoldEgg = false;
_local2++;
}
}
function spawnGoldEgg(fishNum) {
if ((fishNum > -1) && (fishNum < fishLength)) {
fish[fishNum].hasGoldEgg = true;
}
}
function clonePlayerBoss() {
var _local3 = _root.createEmptyMovieClip((("clonedBoss_" + level) + "_") + 0, Camera3D.getNextDepth());
clonedPlayerBoss = Creature.clone(playerBoss, _local3, 0);
clonedPlayerBoss.mc._visible = false;
}
function respawnPlayerBoss() {
if (clonedPlayerBoss != null) {
eraseData();
spawnFood(1, 101, 35, 0);
spawnFood(10, 5, 15, 10);
var _local3 = _root.createEmptyMovieClip((("bossClone_" + level) + "_") + fishLength, Camera3D.getNextDepth());
fish[fishLength] = Creature.clone(clonedPlayerBoss, _local3, fishLength);
fish[fishLength].spawnDownFood = true;
_local3._visible = false;
fishLength++;
}
}
function remPlayerBoss() {
var _local2 = 0;
while (_local2 < fish.length) {
if (fish[_local2] == playerBoss) {
fish[_local2] = null;
}
_local2++;
}
playerBoss = null;
}
function addPlayerAsFish(player) {
player.ID = fishLength;
fish[fishLength] = player;
fishLength++;
_root.playerNum++;
_root.numPlayerBosses++;
playerBoss = player;
}
function spawnFish(numFish, numSegs, maxSegs, randEvolve, segLength, speedMin, speedVar, turnSpeedMin, turnSpeedVar, panic) {
var _local4 = 0;
while (_local4 < numFish) {
var _local3;
_local3 = _root.createEmptyMovieClip((("fish_" + level) + "_") + fishLength, Camera3D.getNextDepth());
_local3._x = 0;
_local3._y = 0;
_local3._visible = false;
fish[fishLength] = new Snakefish(random(levelSize * 2) - levelSize, random(levelSize * 2) - levelSize, numSegs, maxSegs, randEvolve, segLength, speedMin + random(speedVar), ((turnSpeedMin + random(turnSpeedVar)) / 180) * Math.PI, panic, _local3, fishLength, assetPrefix);
fish[fishLength].posZ = zDepth;
fish[fishLength].color.copy(fgColor);
fish[fishLength].clipName = new String((("fish_" + level) + "_") + fishLength);
fishLength++;
_local4++;
}
}
function spawnJellyfish(numFish, numSegs, maxSegs, randEvolve, segLength, speedMin, speedVar, turnSpeedMin, turnSpeedVar, panic) {
var _local4 = 0;
while (_local4 < numFish) {
var _local3;
_local3 = _root.createEmptyMovieClip((("jellyfish_" + level) + "_") + fishLength, Camera3D.getNextDepth());
_local3._x = 0;
_local3._y = 0;
_local3._visible = false;
fish[fishLength] = new Jellyfish(random(levelSize * 2) - levelSize, random(levelSize * 2) - levelSize, numSegs, maxSegs, randEvolve, segLength, speedMin + random(speedVar), ((turnSpeedMin + random(turnSpeedVar)) / 180) * Math.PI, panic, _local3, fishLength, assetPrefix);
fish[fishLength].posZ = zDepth;
fish[fishLength].color.copy(fgColor);
fish[fishLength].clipName = new String((("jellyfish_" + level) + "_") + fishLength);
fishLength++;
_local4++;
}
}
function spawnFlockfish(numFish, numSegs, maxSegs, randEvolve, segLength, speedMin, speedVar, turnSpeedMin, turnSpeedVar, panic) {
var _local4 = 0;
while (_local4 < numFish) {
var _local3;
_local3 = _root.createEmptyMovieClip((("flockfish_" + level) + "_") + fishLength, Camera3D.getNextDepth());
_local3._x = 0;
_local3._y = 0;
_local3._visible = false;
fish[fishLength] = new Flockfish(random(levelSize * 2) - levelSize, random(levelSize * 2) - levelSize, numSegs, maxSegs, randEvolve, segLength, speedMin + random(speedVar), ((turnSpeedMin + random(turnSpeedVar)) / 180) * Math.PI, panic, _local3, fishLength, assetPrefix);
fish[fishLength].posZ = zDepth;
fish[fishLength].color.copy(fgColor);
fish[fishLength].clipName = new String((("flockfish_" + level) + "_") + fishLength);
fishLength++;
_local4++;
}
}
function spawnTelefish(numFish, numSegs, maxSegs, randEvolve, segLength, speedMin, speedVar, turnSpeedMin, turnSpeedVar, panic) {
var _local4 = 0;
while (_local4 < numFish) {
var _local3;
_local3 = _root.createEmptyMovieClip((("telefish_" + level) + "_") + fishLength, Camera3D.getNextDepth());
_local3._x = 0;
_local3._y = 0;
_local3._visible = false;
fish[fishLength] = new Jellyfish(random(levelSize * 2) - levelSize, random(levelSize * 2) - levelSize, numSegs, maxSegs, randEvolve, segLength, speedMin + random(speedVar), ((turnSpeedMin + random(turnSpeedVar)) / 180) * Math.PI, panic, _local3, fishLength, assetPrefix);
fish[fishLength].posZ = zDepth;
fish[fishLength].color.copy(fgColor);
fish[fishLength].clipName = new String((("telefish_" + level) + "_") + fishLength);
fishLength++;
_local4++;
}
}
function spawnBoss(numFish, numSegs, segLength, speedMin, speedVar, turnSpeedMin, turnSpeedVar) {
var _local4 = 0;
while (_local4 < numFish) {
var _local3;
_local3 = _root.createEmptyMovieClip((("boss_" + level) + "_") + fishLength, Camera3D.getNextDepth());
_local3._x = 0;
_local3._y = 0;
_local3._visible = false;
fish[fishLength] = new Boss(random(levelSize * 2) - levelSize, random(levelSize * 2) - levelSize, numSegs, segLength, speedMin + random(speedVar), ((turnSpeedMin + random(turnSpeedVar)) / 180) * Math.PI, _local3, fishLength, assetPrefix);
fish[fishLength].posZ = zDepth;
fish[fishLength].color.copy(fgColor);
fish[fishLength].clipName = new String((("boss_" + level) + "_") + fishLength);
fishLength++;
_local4++;
}
}
function spawnManta(numFish, numSegs, segLength, speedMin, speedVar, turnSpeedMin, turnSpeedVar) {
var _local4 = 0;
while (_local4 < numFish) {
var _local3;
_local3 = _root.createEmptyMovieClip((("manta_" + level) + "_") + fishLength, Camera3D.getNextDepth());
_local3._x = 0;
_local3._y = 0;
_local3._visible = false;
fish[fishLength] = new Manta(random(levelSize * 2) - levelSize, random(levelSize * 2) - levelSize, numSegs, segLength, speedMin + random(speedVar), ((turnSpeedMin + random(turnSpeedVar)) / 180) * Math.PI, _local3, fishLength, assetPrefix);
fish[fishLength].posZ = zDepth;
fish[fishLength].color.copy(fgColor);
fish[fishLength].clipName = new String((("manta_" + level) + "_") + fishLength);
fishLength++;
_local4++;
}
}
function spawnFood(numFood, foodType, hitPointsMin, hitPointsVar) {
var i = 0;
while (i < numFood) {
var currentObj;
_root.createEmptyMovieClip((("food_" + level) + "_") + foodLength, Camera3D.getNextDepth());
currentObj = eval ((("food_" + level) + "_") + foodLength);
currentObj._x = 0;
currentObj._y = 0;
currentObj._visible = false;
food[foodLength] = new Food(foodType, random(levelSize * 2) - levelSize, random(levelSize * 2) - levelSize, zDepth, hitPointsMin + random(hitPointsVar), currentObj, assetPrefix);
food[foodLength].color.copy(fgColor);
food[foodLength].clipName = new String((("food_" + level) + "_") + foodLength);
foodLength++;
if (foodType == 100) {
foodDown = food[foodLength - 1];
} else if (foodType == 101) {
foodUp = food[foodLength - 1];
}
i++;
}
}
function spawnBillboard(billName, posX, posY) {
var currentObj;
_root.createEmptyMovieClip((("Billboard_" + level) + "_") + 0, Camera3D.getNextDepth());
currentObj = eval ((("Billboard_" + level) + "_") + 0);
currentObj._x = posX;
currentObj._y = posY;
currentObj._visible = false;
billboard[billboardLength] = new Billboard(billName, zDepth, currentObj);
billboard[billboardLength].color = fgColor;
billboard[billboardLength].clipName = new String((("Billboard_" + level) + "_") + 0);
billboardLength++;
}
function spawnFoodAtLocation(foodType, xPos, yPos, hitPointsMin, hitPointsVar) {
var _local3;
_local3 = _root.createEmptyMovieClip((("food_" + level) + "_") + food.length, Camera3D.getNextDepth());
_local3._x = 0;
_local3._y = 0;
food[foodLength] = new Food(foodType, xPos, yPos, zDepth, hitPointsMin + random(hitPointsVar), _local3, assetPrefix);
food[foodLength].color.copy(fgColor);
food[foodLength].clipName = new String((("food_" + level) + "_") + food.length);
foodLength++;
}
function spawnBulletAtLocation(lifeTime, xPos, yPos, segLength, speedMin, speedVar, turnSpeedMin, turnSpeedVar) {
var _local3;
_local3 = _root.createEmptyMovieClip((("bullet_" + level) + "_") + fishLength, Camera3D.getNextDepth());
_local3._x = 0;
_local3._y = 0;
fish[fishLength] = new Bullet(lifeTime, xPos, yPos, segLength, speedMin + random(speedVar), ((turnSpeedMin + random(turnSpeedVar)) / 180) * Math.PI, _local3, fishLength, assetPrefix);
fish[fishLength].posZ = zDepth;
fish[fishLength].color.copy(fgColor);
fish[fishLength].clipName = new String((("bullet_" + level) + "_") + fishLength);
fishLength++;
return(fish[fishLength - 1]);
}
function killAllBulletFish() {
var _local2 = 0;
while (_local2 < fish.length) {
if (fish[_local2].clipName == ((("bullet_" + level) + "_") + _local2)) {
fish[_local2].die();
}
_local2++;
}
}
function spawnEffect(eType, eSize, eTime, eDelay, posX, posY, camera) {
if (Camera3D.inWindow(posX, posY, camera) && (level == _root.nextLevel)) {
var _local11;
var _local4 = false;
var _local3 = 0;
while (_local3 < effectLength) {
if (!effect[_local3].alive) {
effect[_local3].reset(eType, eSize, eTime, eDelay, posX, posY, zDepth);
_local4 = true;
break;
}
_local3++;
}
if ((!_local4) && (effectLength < 64)) {
_local11 = _root.createEmptyMovieClip((("effect_" + level) + "_") + effectLength, Camera3D.getNextDepth());
effect[effectLength] = new Effect(eType, eSize, eTime, eDelay, posX, posY, zDepth, _local11);
effect[effectLength].color.copy(fgColor);
effect[effectLength].clipName = new String((("effect_" + level) + "_") + effectLength);
effectLength++;
}
}
}
static var zLevelGap = 300;
static var debugLines = false;
var clonedPlayerBoss = null;
}
Symbol 195 MovieClip [__Packages.Food] Frame 0
class Food extends GameObject
{
var posX, posY, posZ, mc, foodType, gfxPrefix, alive, nutrition, timer, respawnTime, trans, headingX, headingY, colorTrans;
function Food (foodType, posX, posY, posZ, fSize, mc, prefix) {
super();
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
this.fSize = fSize;
this.mc = mc;
speed = fSize;
this.foodType = foodType;
gfxPrefix = prefix;
currentAim = random((Math.PI*2));
alive = true;
var _local4;
nutrition = foodType;
_local4 = mc.attachMovie((gfxPrefix + "food") + foodType, "dot", 0);
timer = 0;
respawnTime = 0;
if (foodType == 0) {
nutrition = 1;
respawnTime = 0;
} else if (foodType == 99) {
nutrition = 1;
respawnTime = 0;
} else if (foodType == 100) {
nutrition = 0;
respawnTime = 3;
} else if (foodType == 101) {
nutrition = 0;
respawnTime = 3;
} else if (foodType == 102) {
nutrition = 102;
respawnTime = 0;
}
_local4._xscale = fSize;
_local4._yscale = fSize;
_local4._x = posX;
_local4._y = posY;
trans = new flash.geom.Transform(_local4);
}
function update(dt, camera) {
if (!alive) {
var _local2 = mc.dot;
_local2._xscale = 0;
_local2._yscale = 0;
if (respawnTime > 0) {
timer = timer + dt;
if (timer > respawnTime) {
alive = true;
timer = 0;
_local2._x = posX;
_local2._y = posY;
_local2._xscale = fSize;
_local2._yscale = fSize;
}
}
} else {
var _local3 = (mc.dot._rotation * Math.PI) / 180;
headingX = Math.cos(_local3);
headingY = Math.sin(_local3);
turnRandom();
posX = posX + ((speed * Math.cos(currentAim)) * dt);
posY = posY + ((speed * Math.sin(currentAim)) * dt);
var _local2 = mc.dot;
_local2._rotation = (currentAim * 180) / Math.PI;
_local2._x = posX;
_local2._y = posY;
}
trans.colorTransform = colorTrans;
}
function turnRandom() {
var _local2 = random(3);
if (_local2 > 1.5) {
currentAim = currentAim + turnSpeed;
} else {
currentAim = currentAim - turnSpeed;
}
}
var fSize = 0;
var speed = 0.1;
var turnSpeed = 0.05;
var currentAim = 0;
}
Symbol 196 MovieClip [__Packages.Creature] Frame 0
class Creature extends GameObject
{
var posX, posY, defaultNumSegs, defaultSegLength, segLength, defaultSpeed, speed, currentSpeed, turnSpeed, panic, mc, ID, assetPrefix, segName, maxEvolveStates, maxSegs, mouthSize, aliveTime, behavior, lifeTime, alive, dieing, targets, hasChosenTarget, tempMin, tempMinDefault, tempFood, tempFish, tempWeak, hasTarget, headingX, headingY, level, transArray, segTag, segSounds, segTimes, weakPoints, weakPointsHit, numSegs, curNumSegs, glowID, targetX, targetY, tempTargetX, tempTargetY, weakLength, boss, panicTimer, dieExplosionRate, dieTimer, dieSeg, turnIntoFoodOnDeath, wounded, panicIntensity, panicIntensityDefault, panicRange, panicTimerDefault, defaultColorTransTime, colorTransTime, curTransTime, coward, toTarget, hasGoldEgg, spawnDownFood, color, colorTrans, colorTrans2, sounds, soundVolume, screenY, screenX;
function Creature (posX, posY, numSegs, maxSegs, randEvolve, segLength, speed, turnSpeed, panic, mc, ID, prefix) {
super();
this.posX = posX;
this.posY = posY;
defaultNumSegs = numSegs;
defaultSegLength = segLength;
this.segLength = segLength;
defaultSpeed = speed;
this.speed = speed;
currentSpeed = speed;
this.turnSpeed = turnSpeed;
this.panic = panic;
this.mc = mc;
this.ID = ID;
assetPrefix = prefix;
segName = "segbody1";
maxEvolveStates = 4;
this.maxSegs = maxSegs;
initializeVars();
initialize();
var _local3 = 0;
while (_local3 < randEvolve) {
evolveRandomSeg();
_local3++;
}
}
static function clone(c, mc, ID) {
var _local2;
if (c.creatureType == "Snakefish") {
_local2 = new Snakefish(0, 0, 0, 16, 0, 15, 200, ((8 + random(3)) / 180) * Math.PI, false, mc, ID, "c1_");
} else if (c.creatureType == "Jellyfish") {
_local2 = new Jellyfish(0, 0, 0, 16, 0, 15, 200, ((8 + random(3)) / 180) * Math.PI, false, mc, ID, "c1_");
}
_local2.posX = c.posX;
_local2.posY = c.posY;
_local2.posZ = c.posZ;
_local2.defaultNumSegs = c.defaultNumSegs;
_local2.defaultSegLength = c.defaultSegLength;
_local2.panic = c.panic;
_local2.panicRange = c.panicRange;
_local2.assetPrefix = c.assetPrefix;
_local2.maxEvolveStates = c.maxEvolveStates;
_local2.maxSegs = c.maxSegs;
var _local4 = 1;
while (_local4 < c.numSegs) {
_local2.grow();
_local4++;
}
var _local1 = 0;
while (_local1 < c.numSegs) {
while (c.mc["seg" + _local1].evolveState > _local2.mc["seg" + _local1].evolveState) {
_local2.evolveSegment(_local1);
}
_local1++;
}
_local2.segLength = c.segLength;
_local2.defaultSpeed = c.defaultSpeed;
_local2.speed = c.speed;
_local2.currentSpeed = c.currentSpeed;
_local2.turnSpeed = c.turnSpeed;
return(_local2);
}
function update(dt, camera, player, fish, food) {
mouthSize = mc.seg0._yscale;
aliveTime = aliveTime + dt;
if (boostTimer > 0) {
behavior.startBoost(this, boostTimer / boostMax, dt);
} else {
behavior.stopBoost(this);
}
if ((((aliveTime >= lifeTime) && (lifeTime >= 0)) && (alive)) && (!dieing)) {
die();
}
while (targets.length > 0) {
targets.pop();
}
if (!hasChosenTarget) {
tempMin = tempMinDefault;
tempFood = -1;
tempFish = -2;
tempWeak = -1;
hasTarget = false;
}
var _local4 = (mc.seg0._rotation * Math.PI) / 180;
headingX = Math.cos(_local4);
headingY = Math.sin(_local4);
if (dieing && (level == _root.nextLevel)) {
dieUpdate(dt);
} else {
chooseTarget(dt, player, fish, food);
collision(food);
eatingUpdate(dt, camera);
movementUpdate(dt, camera);
}
updateColor(dt);
hasChosenTarget = false;
}
function initializeVars() {
targets = new Array();
transArray = new Array();
segTag = new Array(64);
segSounds = new Array(64);
segTimes = new Array(64);
weakPoints = new Array(64);
weakPointsHit = new Array(64);
speed = defaultSpeed;
currentSpeed = speed * 0.2;
segLength = defaultSegLength;
numSegs = 0;
curNumSegs = 0;
glowID = 0;
targetX = posX;
targetY = posY;
tempTargetX = targetX;
tempTargetY = targetY;
weakLength = 0;
hasTarget = false;
boss = false;
panicTimer = 0;
alive = true;
dieing = false;
dieExplosionRate = 0;
dieTimer = 0;
dieSeg = 0;
turnIntoFoodOnDeath = true;
aliveTime = 0;
lifeTime = -1;
tempMinDefault = 15 * segLength;
behavior = new Behavior();
wounded = false;
panicIntensity = 0;
panicIntensityDefault = 4;
panicRange = Math.min((segLength * 3) + 200, 500);
panicTimerDefault = 3;
panicTimer = 0;
defaultColorTransTime = 0.66;
colorTransTime = defaultColorTransTime;
curTransTime = 0;
hasChosenTarget = false;
coward = false;
toTarget = false;
hasGoldEgg = false;
spawnDownFood = false;
}
function initialize() {
}
function chooseTarget(dt, player, fish, food) {
}
function updateColor(dt) {
if (color.curColor != color.targetColor) {
curTransTime = curTransTime + dt;
color.setBias((colorTransTime - curTransTime) / colorTransTime);
if (color.bias <= 0) {
color.baseColor = color.targetColor;
color.setBias(1);
curTransTime = 0;
}
}
var _local2 = 0;
while (_local2 < transArray.length) {
transArray[_local2].colorTransform = colorTrans;
_local2++;
}
_local2 = 0;
while (_local2 < weakLength) {
if (weakPointsHit[_local2] == 0) {
transArray[weakPoints[_local2]].colorTransform = colorTrans2;
}
_local2++;
}
}
function createFishMouth() {
var _local2 = mc.attachMovie(assetPrefix + "seghead1", "seg0", 99);
createMouth(_local2);
}
function createJellyMouth() {
var _local2 = mc.attachMovie(assetPrefix + "jellyhead1", "seg0", 99);
createMouth(_local2);
}
function createMouth(seg) {
segSounds[0] = 0;
segTag[0] = 0;
seg._xscale = segLength;
seg._yscale = segLength;
seg.evolveState = 1;
curNumSegs++;
numSegs++;
var _local3 = new flash.geom.Transform(seg);
transArray.push(_local3);
}
function collision(food) {
var _local4 = false;
if ((eating == -1) && (tempMin < mouthSize)) {
mc.seg0.gotoAndPlay(2);
if (tempFish != -2) {
targets[tempFish].wound(tempWeak);
eating = 1;
nutrition = 1;
if (targets[tempFish].ID == -1) {
_root.camera.shake(0);
}
} else {
eating = food[tempFood].foodType;
nutrition = food[tempFood].nutrition;
food[tempFood].alive = false;
if (eating == 100) {
_root.switchLevel(_root.curLevel + 1);
eating = 0;
_local4 = true;
var _local5 = _root.sndLoader.getSound(assetPrefix + "red");
_local5.setVolume(100);
_local5.start(0, 1);
} else if (eating == 101) {
_root.switchLevel(_root.curLevel - 1);
eating = 0;
_local4 = true;
var _local5 = _root.sndLoader.getSound(assetPrefix + "blue");
_local5.setVolume(100);
_local5.start(0, 1);
} else if (eating == 102) {
nutrition = 102;
eating = 1;
var _local6 = 1;
while (_local6 < numSegs) {
nutrition = nutrition + (mc["seg" + _local6].evolveState - segTag[_local6]);
_local6++;
}
var _local3 = 0;
while (_local3 < weakLength) {
if (weakPointsHit[_local3] < weakPointsHitC) {
nutrition++;
}
_local3++;
}
nutrition++;
}
}
if (!_local4) {
var _local6 = int(random(5));
sounds[_local6].setVolume(soundVolume);
sounds[_local6].start(0, 1);
}
}
}
function movementUpdate(dt, camera) {
var _local8;
if ((ID == -1) && (!toTarget)) {
_local8 = Math.atan2((_root.ymouse - camera.screenY) - screenY, (_root.xmouse - camera.screenX) - screenX);
} else {
_local8 = Math.atan2(targetY - posY, targetX - posX);
}
var _local7 = (_local8 - orient) % (Math.PI*2);
if (_local7 <= -3.14159265358979) {
orient = orient + ((turnSpeed * dt) * 30);
} else if (_local7 > Math.PI) {
orient = orient - ((turnSpeed * dt) * 30);
} else if (_local7 > 0) {
orient = orient + ((turnSpeed * dt) * 30);
} else if (_local7 < 0) {
orient = orient - ((turnSpeed * dt) * 30);
}
if (ID == -1) {
if (pressed && (!toTarget)) {
currentSpeed = Math.min(speed, currentSpeed + (dt * 400));
}
currentSpeed = currentSpeed + (((speed * 0.2) - currentSpeed) * 0.05);
} else if (wounded || (coward)) {
currentSpeed = panicIntensity * speed;
} else if (((!wounded) && (!coward)) && (panicIntensity > 1)) {
currentSpeed = panicIntensity * speed;
panicIntensity = panicIntensity * (1 - (dt * 2));
if (panicIntensity <= 1) {
panicIntensity = 0;
}
} else {
currentSpeed = speed;
}
posX = posX + ((currentSpeed * Math.cos(orient)) * dt);
posY = posY + ((currentSpeed * Math.sin(orient)) * dt);
if ((ID == -1) && (_root.switchingLevels)) {
drag(mc.seg0, posX, posY);
var _local3 = 0;
while (_local3 < numSegs) {
var _local4 = mc["seg" + _local3];
var _local5 = mc["seg" + (_local3 + 1)];
drag(_local5, _local4._x, _local4._y);
_local3++;
}
} else {
drag(mc.seg0, posX, posY);
var _local3 = 0;
while (_local3 < numSegs) {
var _local4 = mc["seg" + _local3];
var _local5 = mc["seg" + (_local3 + 1)];
drag(_local5, _local4._x, _local4._y);
_local3++;
}
}
}
function drag(seg, x, y) {
var _local4 = x - seg._x;
var _local3 = y - seg._y;
var _local2 = Math.atan2(_local3, _local4);
seg._rotation = (_local2 * 180) / Math.PI;
if (seg.evolveState < 0) {
seg._x = x - ((Math.cos(_local2) * seg._xscale) * 2);
seg._y = y - ((Math.sin(_local2) * seg._xscale) * 2);
} else {
seg._x = x - (Math.cos(_local2) * seg._xscale);
seg._y = y - (Math.sin(_local2) * seg._xscale);
}
}
function dist(x1, y1, x2, y2) {
var _local1 = Math.sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
return(_local1);
}
function rebirth() {
lifeCycle++;
numSegs = 3;
weakLength = 0;
var _local2 = 3;
while (_local2 <= 64) {
var _local3 = mc["seg" + _local2];
_local3.removeMovieClip();
_local2++;
}
}
function grow() {
if (curNumSegs <= maxSegs) {
var _local2;
_local2 = mc.attachMovie(assetPrefix + segName, "seg" + curNumSegs, 99 - curNumSegs);
segTimes[curNumSegs] = 0.25;
segSounds[curNumSegs] = int(random(5));
segTag[curNumSegs] = 0;
_local2._rotation = mc["seg" + (curNumSegs - 1)]._rotation;
_local2._x = mc["seg" + (curNumSegs - 1)]._x;
_local2._y = mc["seg" + (curNumSegs - 1)]._y;
_local2._xscale = segLength;
_local2._yscale = segLength;
_local2.evolveState = 1;
speed = speed + (segLength * 0.2);
if (curNumSegs == numSegs) {
numSegs++;
}
curNumSegs++;
var _local3 = new flash.geom.Transform(_local2);
transArray.push(_local3);
if (curNumSegs == 64) {
rebirth();
}
if (curNumSegs == 2) {
evolveSegment(1);
}
} else if (evolveMinSeg() == 0) {
evolveMinSeg();
}
}
function evolveMinSeg() {
var _local4 = 0;
var _local3 = mc.seg0.evolveState;
var _local2 = 1;
while (_local2 < curNumSegs) {
if (mc["seg" + _local2].evolveState < _local3) {
_local3 = mc["seg" + _local2].evolveState;
_local4 = _local2;
}
_local2++;
}
evolveSegment(_local4);
return(_local4);
}
function evolveRandomSeg() {
var _local3 = mc.seg1.evolveState;
var _local2 = 1;
while (_local2 < curNumSegs) {
if (mc["seg" + _local2].evolveState < _local3) {
_local3 = mc["seg" + _local2].evolveState;
}
_local2++;
}
var _local4 = Math.max(random(curNumSegs), 1);
while (mc["seg" + _local4].evolveState > _local3) {
_local4 = random(curNumSegs);
}
evolveSegment(_local4);
}
function heal(i) {
weakPointsHit[i] = weakPointsHitC;
var _local5 = mc["seg" + weakPoints[i]];
speed = speed + (((mc["seg" + weakPoints[i]].evolveState - 1) * segLength) * 0.4);
var _local3 = _root.sndLoader.getSound(assetPrefix + "heal");
_local3.setVolume(soundVolume);
_local3.start(0, 1);
_root.gameLevels[level].spawnEffect(0, 10, 1, 0.25, mc["seg" + (glowID - 1)]._x, mc["seg" + (glowID - 1)]._y);
}
function wound(weakPointID) {
if (level != _root.curLevel) {
return(undefined);
}
if (panic) {
wounded = true;
tempTargetX = targetX;
tempTargetY = targetY;
panicIntensity = panicIntensityDefault;
panicTimer = panicTimerDefault;
}
weakPointsHit[weakPointID] = 0;
speed = speed - (((mc["seg" + weakPoints[weakPointID]].evolveState - 1) * segLength) * 0.4);
var _local6 = mc["seg" + weakPoints[weakPointID]];
_local6._alpha = 0;
var _local4 = true;
var _local3 = 0;
while (_local3 < weakLength) {
if (weakPointsHit[_local3] != 0) {
_local4 = false;
break;
}
_local3++;
}
if (_local4) {
die();
}
}
function die() {
if (ID == -1) {
_root.switchLevel(_root.curLevel - 1);
var _local3 = _root.sndLoader.getSound(assetPrefix + "death");
_local3.setVolume(100);
_local3.start(0, 1);
if (numSegs > 3) {
dieExplosionRate = 1;
dieTimer = dieExplosionRate;
dieing = true;
dieSeg = numSegs - 1;
}
} else {
dieing = true;
dieExplosionRate = 2 / numSegs;
dieTimer = dieExplosionRate;
}
}
function dieUpdate(dt) {
if (_root.switchingLevels) {
return(undefined);
}
var _local6 = false;
dieTimer = dieTimer + dt;
while ((dieTimer > dieExplosionRate) && (dieSeg < numSegs)) {
dieTimer = dieTimer - dieExplosionRate;
var _local4 = 0;
var _local3 = 0;
var _local5 = dieSeg;
while (_local5 < numSegs) {
dieSeg++;
_local4 = mc["seg" + _local5]._x;
_local3 = mc["seg" + _local5]._y;
if (_local5 != 0) {
if (turnIntoFoodOnDeath && (segTag[_local5] > 0)) {
_root.gameLevels[level].spawnFoodAtLocation(segTag[_local5], _local4, _local3, 15, 10);
}
_root.gameLevels[level].spawnEffect(0, segLength / 20, segLength / 20, 0, _local4, _local3);
} else {
if (turnIntoFoodOnDeath) {
_root.gameLevels[level].spawnFoodAtLocation(0, _local4, _local3, 15, 10);
if (numSegs > 10) {
_root.gameLevels[level].spawnFoodAtLocation(99, _local4, _local3, 15, 10);
}
if (hasGoldEgg) {
_root.gameLevels[level].spawnFoodAtLocation(102, _local4, _local3, 25, 10);
}
if (spawnDownFood) {
_root.gameLevels[level].spawnFoodAtLocation(100, _local4, _local3, 35, 0);
}
}
_root.gameLevels[level].spawnEffect(0, segLength / 5, segLength / 20, 0, _local4, _local3);
}
speed = speed - (segLength * 0.2);
mc["seg" + _local5].removeMovieClip();
_local6 = true;
if (dieSeg >= numSegs) {
if (ID == -1) {
_root.gameLevels[level].killAllBulletFish();
numSegs--;
curNumSegs = numSegs;
dieing = false;
heal(0);
_root.gameLevels[level].spawnFoodAtLocation(1, _local4, _local3, 15, 10);
_root.gameLevels[level].spawnEffect(0, segLength / 4, segLength / 10, 0, _local4, _local3);
} else {
alive = false;
mc.removeMovieClip();
}
}
if (_local6) {
break;
}
_local5++;
}
}
}
function eatingUpdate(dt, camera) {
var _local3 = 0;
var _local6 = 0;
while (_local6 < numSegs) {
if (segTag[_local6] >= 1) {
_local3 = _local6;
}
_local6++;
}
if (eating > -1) {
if (nutrition <= 0) {
glowID = 0;
eating = -1;
eatingTimer = 0;
tempScaleX = mc.seg0._xscale;
tempScaleY = mc.seg0._yscale;
mc.seg0.gotoAndPlay(23);
} else {
mc["seg" + glowID]._xscale = tempScaleX * (1 + (eatingTimer / eatingTimerC));
mc["seg" + glowID]._yscale = tempScaleY * (1 + (eatingTimer / eatingTimerC));
if (boostTimer > 0) {
eatingTimer = eatingTimer - (dt * 2.5);
} else {
eatingTimer = eatingTimer - dt;
}
if (eatingTimer <= 0) {
mc["seg" + glowID]._xscale = tempScaleX;
mc["seg" + glowID]._yscale = tempScaleY;
glowID = Math.min(glowID + 1, numSegs);
tempScaleX = mc["seg" + glowID]._xscale;
tempScaleY = mc["seg" + glowID]._yscale;
if ((eating > 0) && (eating < 10)) {
if (nutrition > 0) {
if (!panic) {
_local6 = 0;
while (_local6 < weakLength) {
if ((weakPoints[_local6] == glowID) && (weakPointsHit[_local6] < weakPointsHitC)) {
heal(_local6);
nutrition--;
break;
}
_local6++;
}
}
while ((segTag[glowID] < mc["seg" + glowID].evolveState) && (nutrition > 0)) {
segTag[glowID]++;
mc["seg" + glowID].gotoAndStop(segTag[glowID] + 1);
nutrition--;
}
if (((glowID == (numSegs - 1)) && (segTag[glowID] == mc["seg" + glowID].evolveState)) && (nutrition > 0)) {
_local6 = 1;
while (_local6 < numSegs) {
segTag[_local6] = 0;
mc["seg" + _local6].gotoAndStop(1);
_local6++;
}
nutrition--;
grow();
_root.gameLevels[level].spawnEffect(0, segLength, segLength / 20, segTimes[glowID], mc["seg" + glowID]._x, mc["seg" + glowID]._y);
if (nutrition > 0) {
var _local5 = mc["seg" + (numSegs - 1)]._x;
var _local4 = mc["seg" + (numSegs - 1)]._y;
_root.gameLevels[level].spawnEffect(0, segLength / 20, (segLength / 20) + 1, 0, _local5, _local4);
if ((nutrition == 102) && (ID == -1)) {
PlayerXForm.turnPlayerIntoEgg(_local5, _local4, 25);
_root.floatToTop();
} else {
_root.gameLevels[level].spawnFoodAtLocation(nutrition, _local5, _local4, 15, 10);
}
nutrition = 0;
}
}
}
} else if (eating == 99) {
boostTimer = boostMax;
nutrition--;
} else if (eating == 0) {
if ((glowID == _local3) || (_local3 <= 1)) {
if (_local3 < 1) {
_local3 = 1;
}
if (mc["seg" + glowID].evolveState < maxEvolveStates) {
nutrition--;
evolveSegment(_local3);
} else {
_local6 = 1;
while (_local6 < numSegs) {
if (mc["seg" + _local6].evolveState < maxEvolveStates) {
evolveSegment(_local6);
break;
}
_local6++;
}
nutrition--;
}
}
}
eatingTimer = segTimes[glowID];
_root.gameLevels[level].spawnEffect(0, segLength / 20, segLength / 20, 0, mc["seg" + (glowID - 1)]._x, mc["seg" + (glowID - 1)]._y);
_local6 = int(random(5));
sounds[_local6].setVolume(soundVolume);
sounds[_local6].start(0, 1);
}
}
}
}
function evolveSegment(segNum) {
if (segNum == 0) {
mc["seg" + segNum].evolveState++;
return(undefined);
}
var _local4 = mc["seg" + segNum].evolveState;
_local4++;
if (_local4 <= maxEvolveStates) {
if (_local4 == 2) {
weakPoints[weakLength] = segNum;
weakPointsHit[weakLength] = weakPointsHitC;
weakLength++;
}
var _local10 = mc["seg" + segNum]._x;
var _local9 = mc["seg" + segNum]._y;
var _local7 = mc["seg" + segNum].vx;
var _local6 = mc["seg" + segNum].vy;
var _local5 = ("c" + _local4) + "_";
mc["seg" + segNum].removeMovieClip();
var _local3 = mc.attachMovie(_local5 + segName, "seg" + segNum, 99 - segNum);
_local3.evolveState = _local4;
speed = speed + (segLength * 0.4);
_local3._xscale = segLength;
_local3._yscale = segLength;
segTimes[curNumSegs] = 0.25 * _local4;
_local3._x = _local10;
_local3._y = _local9;
_local3.vx = _local7;
_local3.vy = _local6;
_local3.gotoAndStop(segTag[segNum] + 1);
segSounds[curNumSegs] = 0;
var _local8 = new flash.geom.Transform(_local3);
transArray[segNum] = _local8;
}
}
var pressed = false;
var orient = 0;
var lifeCycle = 0;
var tempScaleX = 1;
var tempScaleY = 1;
var eatingTimerC = 0.333333333333333;
var eatingTimer = Creature.prototype.eatingTimerC;
var eating = -1;
var nutrition = 0;
var weakPointsHitC = 3;
var boostMax = 12;
var boostTimer = 0;
}
Symbol 197 MovieClip [__Packages.Snakefish] Frame 0
class Snakefish extends Creature
{
var type, creatureType, panicIntensityDefault, createFishMouth, defaultNumSegs, grow, tempScaleX, mc, tempScaleY, sounds, assetPrefix, panicRange, segLength, numSegs, toTarget, wounded, behavior, panicIntensity, ID, panic, boss, hasTarget, speed, mouthSize, dist, posX, posY, targetX, targetY;
function Snakefish (posX, posY, numSegs, maxSegs, randEvolve, segLength, speed, turnSpeed, panic, mc, ID, prefix) {
super(posX, posY, numSegs, maxSegs, randEvolve, segLength, speed, turnSpeed, panic, mc, ID, prefix);
type = 1;
}
function initialize() {
creatureType = "Snakefish";
panicIntensityDefault = 1.2;
createFishMouth();
var _local3 = 1;
while (_local3 < defaultNumSegs) {
grow();
_local3++;
}
tempScaleX = mc.seg0._xscale;
tempScaleY = mc.seg0._yscale;
sounds = new Array();
_local3 = 0;
while (_local3 < 5) {
sounds[_local3] = new Sound(_root);
sounds[_local3].loadSound(((assetPrefix + "Food-samples-") + (_local3 + 1)) + "a.mp3", false);
sounds[_local3].setVolume(0);
_local3++;
}
panicRange = Math.min(((segLength * 3) + 150) + (numSegs * segLength), 500);
}
function chooseTarget(dt, player, fish, food) {
if (!toTarget) {
if (wounded) {
wounded = behavior.panicMovement(dt, this, player, panicRange, panicIntensity);
} else {
if (((ID == -1) || (!panic)) || (boss)) {
behavior.eatAnything(this, player, fish, food, false);
} else {
behavior.eatFoodOnly(this, food, false);
}
if (!hasTarget) {
if (dist(posX, posY, targetX, targetY) < (mouthSize + speed)) {
behavior.goToRandomLocation(this);
}
}
}
}
}
}
Symbol 198 MovieClip [__Packages.Jellyfish] Frame 0
class Jellyfish extends Creature
{
var type, creatureType, createJellyMouth, segName, defaultNumSegs, grow, tempScaleX, mc, tempScaleY, sounds, assetPrefix, ringAngle, orient, radius, wounded, behavior, panicRange, panicIntensity, hasTarget, dist, posX, posY, targetX, targetY, ID, screenY, screenX, turnSpeed, numSegs, pressed, currentSpeed, speed, radiusTarget, segLength, coward, drag;
function Jellyfish (posX, posY, numSegs, maxSegs, randEvolve, segLength, speed, turnSpeed, panic, mc, ID, prefix) {
super(posX, posY, numSegs, maxSegs, randEvolve, segLength, speed, turnSpeed, panic, mc, ID, prefix);
type = 2;
}
function initialize() {
creatureType = "Jellyfish";
createJellyMouth();
segName = "jellybody1";
var _local3 = 1;
while (_local3 < defaultNumSegs) {
grow();
_local3++;
}
tempScaleX = mc.seg1._xscale;
tempScaleY = mc.seg1._yscale;
sounds = new Array();
_local3 = 0;
while (_local3 < 5) {
sounds[_local3] = new Sound(_root);
sounds[_local3].loadSound(((assetPrefix + "Food-samples-") + (_local3 + 1)) + "b.mp3", false);
sounds[_local3].setVolume(0);
_local3++;
}
ringAngle = orient;
radius = 0;
}
function chooseTarget(dt, player, fish, food) {
if (wounded) {
wounded = behavior.panicMovement(dt, this, player, panicRange, panicIntensity);
} else {
behavior.eatAnything(this, player, fish, food, false);
if (!hasTarget) {
if (dist(posX, posY, targetX, targetY) < mc.seg0._yscale) {
behavior.goToRandomLocation(this);
}
}
}
}
function movementUpdate(dt, camera) {
var _local8;
if (ID == -1) {
_local8 = Math.atan2((_ymouse - camera.screenY) - screenY, (_xmouse - camera.screenX) - screenX);
} else {
_local8 = Math.atan2(targetY - posY, targetX - posX);
}
var _local7 = (_local8 - orient) % (Math.PI*2);
if (_local7 <= -3.14159265358979) {
orient = orient + ((turnSpeed * dt) * 30);
} else if (_local7 > Math.PI) {
orient = orient - ((turnSpeed * dt) * 30);
} else if (_local7 > 0) {
orient = orient + ((turnSpeed * dt) * 30);
} else if (_local7 < 0) {
orient = orient - ((turnSpeed * dt) * 30);
}
ringAngle = ringAngle + ((dt / numSegs) * 5);
if (ID == -1) {
if (pressed) {
currentSpeed = Math.min(speed, currentSpeed + (dt * 500));
radiusTarget = segLength + numSegs;
ringAngle = ringAngle + (dt * 5);
} else {
radiusTarget = (segLength + numSegs) * 2.5;
}
currentSpeed = currentSpeed + (((speed * 0.2) - currentSpeed) * 0.05);
} else {
radiusTarget = (segLength + numSegs) * (2.5 + Math.sin((_root.curTime / 1000) * Math.PI));
if (wounded || (coward)) {
currentSpeed = panicIntensity * speed;
} else if (((!wounded) && (!coward)) && (panicIntensity > 1)) {
currentSpeed = panicIntensity * speed;
panicIntensity = panicIntensity * (1 - (dt * 2));
if (panicIntensity <= 1) {
panicIntensity = 0;
}
} else {
currentSpeed = speed;
}
}
posX = posX + ((currentSpeed * Math.cos(orient)) * dt);
posY = posY + ((currentSpeed * Math.sin(orient)) * dt);
drag(mc.seg0, posX, posY);
radius = radius + (((radiusTarget - radius) * dt) * 5);
var _local3 = 1;
while (_local3 < numSegs) {
var _local5 = mc["seg" + _local3];
var _local4 = ringAngle + (((_local3 / (numSegs - 1)) * 2) * Math.PI);
drag(_local5, posX + (radius * Math.cos(_local4)), posY + (radius * Math.sin(_local4)));
_local3++;
}
}
}
Symbol 199 MovieClip [__Packages.Behavior] Frame 0
class Behavior
{
var panicColor, targetPlayerColor, targetFoodColor, targetFishColor, defaultColor;
function Behavior () {
panicColor = new XColor(49151);
targetPlayerColor = new XColor(16746564);
targetFoodColor = new XColor(16777215);
targetFishColor = new XColor(16746564);
defaultColor = new XColor(16777215);
}
function startBoost(subj, timeLeft, dt) {
subj.boostTimer = Math.max(0, subj.boostTimer - dt);
if (timeLeft > 0.1) {
subj.mc.seg0._xscale = subj.segLength * 2;
subj.mc.seg0._yscale = subj.segLength * 2;
} else {
subj.mc.seg0._xscale = subj.segLength * (1 + (timeLeft * 10));
subj.mc.seg0._yscale = subj.segLength * (1 + (timeLeft * 10));
}
return(true);
}
function stopBoost(subj) {
subj.mc.seg0._xscale = subj.segLength;
subj.mc.seg0._yscale = subj.segLength;
return(true);
}
function goToRandomLocation(subj) {
subj.targetX = random(_root.gameLevels[subj.level].levelSize * 2) - _root.gameLevels[subj.level].levelSize;
subj.targetY = random(_root.gameLevels[subj.level].levelSize * 2) - _root.gameLevels[subj.level].levelSize;
switchColor(subj, defaultColor);
return(true);
}
function panicMovement(dt, subj, player, panicRange, panicIntensity) {
if (player != null) {
subj.targets[0] = player;
}
var _local4 = (subj.mc.seg0._rotation * Math.PI) / 180;
if (dist(subj.posX, subj.posY, player.posX, player.posY) <= panicRange) {
subj.targetX = subj.targetX + (subj.currentSpeed * Math.cos(_local4));
subj.targetY = subj.targetY + (subj.currentSpeed * Math.sin(_local4));
}
subj.colorTransTime = 0.1;
switchColor(subj, panicColor);
subj.panicTimer = subj.panicTimer - dt;
if ((dist(subj.posX, subj.posY, player.posX, player.posY) >= panicRange) || ((subj.wounded && (!subj.coward)) && (subj.panicTimer < 0))) {
endPanic(subj);
return(false);
}
return(true);
}
function endPanic(subj) {
subj.targetX = subj.tempTargetX;
subj.targetY = subj.tempTargetY;
subj.panicTimer = 0;
subj.colorTransTime = subj.defaultColorTransTime;
switchColor(subj, defaultColor);
}
function endCoward(subj) {
if (subj.coward && (!subj.wounded)) {
endPanic(subj);
}
subj.coward = false;
}
function hordeMovement(subj, player, fish, food, inFront, attackDist, hordeDist, cowardDist, hordeNum) {
var _local4 = new Array();
var _local2 = 0;
while (_local2 < fish.length) {
if ((fish[_local2].ID != subj.ID) && (fish[_local2].type == subj.type)) {
if ((!fish[_local2].wounded) && (dist(subj.posX, subj.posY, fish[_local2].posX, fish[_local2].posY) <= hordeDist)) {
_local4.push(fish[_local2]);
}
}
_local2++;
}
if (!subj.wounded) {
if (_local4.length >= hordeNum) {
endCoward(subj);
if ((player != null) && (dist(player.posX, player.posY, subj.posX, subj.posY) <= attackDist)) {
subj.tempMin = attackDist;
eatPlayerOnly(subj, player, inFront);
_local2 = 0;
while (_local2 < _local4.length) {
endCoward(_local4[_local2]);
if (!_local4[_local2].wounded) {
_local4[_local2].tempMin = 99999 /* 0x01869F */;
_local4[_local2].hasTarget = false;
eatPlayerOnly(_local4[_local2], player, inFront);
_local4[_local2].hasChosenTarget = true;
}
_local2++;
}
} else {
eatFoodOnly(subj, food, inFront);
}
} else if ((player != null) && (dist(player.posX, player.posY, subj.posX, subj.posY) <= cowardDist)) {
if (!subj.coward) {
subj.coward = true;
subj.tempTargetX = subj.targetX;
subj.tempTargetY = subj.targetY;
subj.panicIntensity = subj.panicIntensityDefault;
subj.panicTimer = 0;
}
} else {
endCoward(subj);
eatFoodOnly(subj, food, inFront);
}
if ((!subj.hasTarget) && (!subj.coward)) {
switchColor(subj, defaultColor);
if (dist(subj.posX, subj.posY, subj.targetX, subj.targetY) < subj.mouthSize) {
goToRandomLocation(subj);
}
}
}
return(subj.hasTarget);
}
function eatAnything(subj, player, fish, food, inFront) {
findClosestFood(subj, food);
var _local2 = 0;
while (_local2 < fish.length) {
subj.targets[_local2] = fish[_local2];
_local2++;
}
if ((player != null) && (subj.ID != -1)) {
subj.targets[fish.length] = player;
}
findClosestWeakpoint(subj, inFront);
if ((subj.tempFood != -1) || (subj.tempFish != -2)) {
subj.hasTarget = true;
}
if (subj.tempFood != -1) {
switchColor(subj, targetFoodColor);
}
if (subj.tempFish != -2) {
switchColor(subj, targetFishColor);
}
if (subj.targets[subj.tempFish].ID == -1) {
switchColor(subj, targetPlayerColor);
}
if ((subj.tempFood == -1) && (subj.tempFish == -2)) {
switchColor(subj, defaultColor);
}
return(subj.hasTarget);
}
function eatFoodOnly(subj, food, inFront) {
findClosestFood(subj, food);
if (subj.tempFood != -1) {
subj.hasTarget = true;
switchColor(subj, targetFoodColor);
}
return(subj.hasTarget);
}
function eatPlayerOnly(subj, player, inFront) {
if (player != null) {
subj.targets[0] = player;
}
findClosestWeakpoint(subj, inFront);
if (subj.tempFish != -2) {
subj.hasTarget = true;
switchColor(subj, targetPlayerColor);
}
return(subj.hasTarget);
}
function eatPlayerAndFood(subj, player, food, inFront) {
findClosestFood(subj, food);
if (player != null) {
subj.targets[0] = player;
}
findClosestWeakpoint(subj, inFront);
if (subj.tempFood != -1) {
subj.hasTarget = true;
switchColor(subj, targetFoodColor);
}
if (subj.tempFish != -2) {
subj.hasTarget = true;
switchColor(subj, targetPlayerColor);
}
return(subj.hasTarget);
}
function findClosestFood(subj, food) {
var _local3 = 0;
while (_local3 < food.length) {
var _local6 = dist(food[_local3].posX, food[_local3].posY, subj.posX, subj.posY);
if ((subj == _root.player) || (food[_local3].foodType < 100)) {
if ((_local6 < subj.tempMin) && (food[_local3].alive)) {
subj.tempMin = _local6;
subj.tempFood = _local3;
subj.targetX = food[_local3].posX;
subj.targetY = food[_local3].posY;
}
}
_local3++;
}
}
function findClosestWeakpoint(subj, inFront) {
var _local3 = 0;
while (_local3 < subj.targets.length) {
if (subj.targets[_local3].ID != subj.ID) {
var _local4 = 0;
while (_local4 < subj.targets[_local3].weakLength) {
if (subj.targets[_local3].weakPointsHit[_local4] == subj.targets[_local3].weakPointsHitC) {
var _local6;
var _local5;
if (subj.targets[_local3].boss == false) {
_local6 = subj.targets[_local3].mc["seg" + subj.targets[_local3].weakPoints[_local4]]._x;
_local5 = subj.targets[_local3].mc["seg" + subj.targets[_local3].weakPoints[_local4]]._y;
} else {
_local6 = getBossWeakpointX(subj.targets[_local3], subj.targets[_local3].mc.seg0["weakPoint" + _local4]);
_local5 = getBossWeakpointY(subj.targets[_local3], subj.targets[_local3].mc.seg0["weakPoint" + _local4]);
}
if (inFront && (DotProd2D(subj.headingX, subj.headingY, _local6 - subj.posX, _local5 - subj.posY) <= 0)) {
} else {
var _local7 = dist(_local6, _local5, subj.posX, subj.posY);
if ((_local7 < subj.tempMin) && (subj.targets[_local3].weakPointsHit[_local4] == subj.targets[_local3].weakPointsHitC)) {
subj.tempMin = _local7;
subj.tempFish = _local3;
subj.tempWeak = _local4;
subj.targetX = _local6;
subj.targetY = _local5;
}
}
}
_local4++;
}
}
_local3++;
}
}
function getBossWeakpointX(boss, wp) {
var _local2 = (boss.mc.seg0._rotation * Math.PI) / 180;
var _local1 = (Math.cos(_local2) * wp._x) - (Math.sin(_local2) * wp._y);
_local1 = _local1 * (boss.mc.seg0._xscale * 0.01);
return(boss.mc.seg0._x + _local1);
}
function getBossWeakpointY(boss, wp) {
var _local2 = (boss.mc.seg0._rotation * Math.PI) / 180;
var _local1 = (Math.cos(_local2) * wp._y) + (Math.sin(_local2) * wp._x);
_local1 = _local1 * (boss.mc.seg0._yscale * 0.01);
return(boss.mc.seg0._y + _local1);
}
function dist(x1, y1, x2, y2) {
var _local1 = Math.sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
return(_local1);
}
function DotProd2D(x1, y1, x2, y2) {
return((x1 * x2) + (y1 * y2));
}
function switchColor(subj, dest) {
if (subj.ID != -1) {
if (subj.color.targetColor != dest.baseColor) {
subj.color.baseColor = subj.color.curColor;
subj.color.targetColor = dest.baseColor;
subj.curTransTime = 0;
}
}
}
}
Symbol 200 MovieClip [__Packages.PlayerXForm] Frame 0
class PlayerXForm
{
static var egg;
function PlayerXForm () {
}
static function update(dt) {
if (curHatchTime > 0) {
curHatchTime = curHatchTime - dt;
var _local2 = (hatchTime - curHatchTime) / hatchTime;
egg.alpha = Math.max(1 - _local2, 0);
_root.player.alpha = Math.min(_local2, 1);
egg.updateScreenPos(_root.camera);
egg.updateColor(dt);
if (curHatchTime <= 0) {
_root.player.alpha = 1;
egg.mc.removeMovieClip();
egg = null;
curHatchTime = 0;
}
}
}
static function turnPlayerIntoEgg(x, y, size) {
_root.formerSelf = _root.player;
_root.formerSelf.speed = _root.formerSelf.speed * 0.5;
_root.gameLevels[_root.curLevel].addPlayerAsFish(_root.player);
_root.playerNum++;
var _local3 = _root.createEmptyMovieClip("fish_player" + _root.playerNum, Camera3D.getNextDepth());
_root.player = new Snakefish(0, 0, 0, 16, 0, 15, 200, ((8 + random(3)) / 180) * Math.PI, false, _local3, -1, "c1_");
var _local2 = _root.player.mc.attachMovie("c1_food102", "seg0", 99);
_local2._xscale = size;
_local2._yscale = size;
_local2._x = x;
_local2._y = y;
_root.player.posX = x;
_root.player.posY = y;
_root.player.posZ = _root.formerSelf.posZ;
_root.player.segLength = size;
_root.player.numSegs = 1;
}
static function hatchPlayer() {
if ((curHatchTime == 0) && (_root.player.numSegs == 1)) {
curHatchTime = hatchTime;
egg = _root.player;
var _local3 = _root.player.posZ;
_root.playerNum++;
var _local2 = _root.createEmptyMovieClip("fish_player" + _root.playerNum, Camera3D.getNextDepth());
if (nextPlayerType == "Snakefish") {
_root.player = new Snakefish(0, 0, 3, 16, 0, 15, 200, ((8 + random(3)) / 180) * Math.PI, false, _local2, -1, "c1_");
} else if (nextPlayerType == "Jellyfish") {
_root.player = new Jellyfish(0, 0, 3, 16, 0, 15, 200, ((8 + random(3)) / 180) * Math.PI, false, _local2, -1, "c1_");
}
egg.alpha = 1;
_root.player.alpha = 0;
_root.player.posX = egg.posX;
_root.player.posY = egg.posY;
_root.player.posZ = _local3;
}
}
static var curHatchTime = 0;
static var hatchTime = 1;
static var isHatching = false;
static var nextPlayerType = "";
}
Symbol 201 MovieClip [__Packages.SndLoader] Frame 0
class SndLoader
{
var curSndIndex, sounds, filenames;
function SndLoader () {
initialize();
}
function initialize() {
curSndIndex = 0;
sounds = new Array();
filenames = ["c1_Flow-lvl 0 drone.mp3", "c1_red.mp3", "c1_Flow-lvl 1 drone.mp3", "c1_blue.mp3", "c1_heal.mp3", "c1_death.mp3", "c1_Flow-lvl 2 drone.mp3", "c1_Flow-lvl 3 drone.mp3", "c1_Flow-lvl 4 drone.mp3", "c1_Flow-lvl 5 drone.mp3", "c1_Flow-lvl 6 drone.mp3", "c1_Flow-lvl 7 drone.mp3", "c1_Flow-lvl 8 drone.mp3", "c1_Flow-lvl 9 drone.mp3", "c1_Flow-lvl 10 drone.mp3", "c1_Flow-lvl 11 drone.mp3", "c1_Flow-lvl 12 drone.mp3", "c1_Flow-lvl 13 drone.mp3", "c1_Flow-lvl 14 drone.mp3", "c1_Flow-lvl 15 drone.mp3", "c1_Flow-lvl 16 drone.mp3", "c1_Flow-lvl 17 drone.mp3", "c1_Flow-lvl 18 drone.mp3", "c1_Flow-lvl 19 drone.mp3"];
sounds = new Array(filenames.length);
var _local3 = 0;
while (_local3 < sounds.length) {
sounds[_local3] = new Sound(_root);
_local3++;
}
loadNext();
}
function update() {
if (sounds[curSndIndex - 1].getBytesTotal() == sounds[curSndIndex - 1].getBytesLoaded()) {
loadNext();
}
}
function loadNext() {
if (curSndIndex < filenames.length) {
trace("loading: " + filenames[curSndIndex]);
sounds[curSndIndex].loadSound(filenames[curSndIndex], false);
sounds[curSndIndex].stop();
sounds[curSndIndex].setVolume(0);
curSndIndex++;
}
}
function getSound(filename) {
filename = ("" + filename) + ".mp3";
var _local3 = -1;
var _local2 = 0;
while (_local2 < filenames.length) {
if (filename == filenames[_local2]) {
_local3 = _local2;
break;
}
_local2++;
}
if (_local3 == -1) {
return(null);
}
return(sounds[_local3]);
}
static function isLoaded(snd) {
return(snd.getBytesTotal() == snd.getBytesLoaded());
}
}
Symbol 202 MovieClip [__Packages.Flockfish] Frame 0
class Flockfish extends Creature
{
var type, creatureType, panicIntensityDefault, attackDist, hordeDist, cowardDist, hordeNum, panicRange, segLength, numSegs, flockDist, createJellyMouth, defaultNumSegs, tempScaleX, mc, tempScaleY, sounds, assetPrefix, hasChosenTarget, wounded, behavior, panicIntensity, panic, coward, ID, screenY, screenX, posY, targetY, posX, targetX, orient, turnSpeed, pressed, currentSpeed, speed, drag, maxSegs, curNumSegs, segTimes, segSounds, segTag, transArray, rebirth, evolveSegment;
function Flockfish (posX, posY, numSegs, maxSegs, randEvolve, segLength, speed, turnSpeed, panic, mc, ID, prefix) {
super(posX, posY, numSegs, maxSegs, randEvolve, segLength, speed, turnSpeed, panic, mc, ID, prefix);
type = 3;
}
function initialize() {
creatureType = "Flockfish";
panicIntensityDefault = 2.5;
attackDist = 250;
hordeDist = 200;
cowardDist = 250;
hordeNum = 1;
panicRange = Math.min(((segLength * 4) + 150) + (numSegs * segLength), 500);
flockDist = segLength * 4;
createJellyMouth();
var _local3 = 1;
while (_local3 < defaultNumSegs) {
grow();
_local3++;
}
tempScaleX = mc.seg1._xscale;
tempScaleY = mc.seg1._yscale;
sounds = new Array();
_local3 = 0;
while (_local3 < 5) {
sounds[_local3] = new Sound(_root);
sounds[_local3].loadSound(((assetPrefix + "Food-samples-") + (_local3 + 1)) + "b.mp3", false);
sounds[_local3].setVolume(0);
_local3++;
}
}
function chooseTarget(dt, player, fish, food) {
if (!hasChosenTarget) {
if (wounded) {
wounded = behavior.panicMovement(dt, this, player, panicRange, panicIntensity);
} else if (!panic) {
behavior.eatAnything(this, player, fish, food, false);
} else {
if (coward) {
behavior.panicMovement(dt, this, player, panicRange, panicIntensity);
}
behavior.hordeMovement(this, player, fish, food, false, attackDist, hordeDist, cowardDist, hordeNum);
}
}
}
function movementUpdate(dt, camera) {
var _local4;
if (ID == -1) {
_local4 = Math.atan2((_ymouse - camera.screenY) - screenY, (_xmouse - camera.screenX) - screenX);
} else {
_local4 = Math.atan2(targetY - posY, targetX - posX);
}
var _local3 = (_local4 - orient) % (Math.PI*2);
if (_local3 <= -3.14159265358979) {
orient = orient + ((turnSpeed * dt) * 30);
} else if (_local3 > Math.PI) {
orient = orient - ((turnSpeed * dt) * 30);
} else if (_local3 > 0) {
orient = orient + ((turnSpeed * dt) * 30);
} else if (_local3 < 0) {
orient = orient - ((turnSpeed * dt) * 30);
}
if (ID == -1) {
if (pressed) {
currentSpeed = Math.min(speed, currentSpeed + (dt * 500));
}
currentSpeed = currentSpeed + (((speed * 0.2) - currentSpeed) * 0.05);
} else if (wounded || (coward)) {
currentSpeed = panicIntensity * speed;
} else if (((!wounded) && (!coward)) && (panicIntensity > 1)) {
currentSpeed = panicIntensity * speed;
panicIntensity = panicIntensity * (1 - (dt * 2));
if (panicIntensity <= 1) {
panicIntensity = 0;
}
} else {
currentSpeed = speed;
}
posX = posX + ((currentSpeed * Math.cos(orient)) * dt);
posY = posY + ((currentSpeed * Math.sin(orient)) * dt);
drag(mc.seg0, posX, posY);
flockUpdate(dt);
}
function flockUpdate(dt) {
var _local3 = 1;
while (_local3 < numSegs) {
var _local4 = mc["seg" + _local3];
_local4.vx = _local4.vx * decay;
_local4.vy = _local4.vy * decay;
_local4._x = _local4._x + (_local4.vx * dt);
_local4._y = _local4._y + (_local4.vy * dt);
_local3++;
}
_local3 = 0;
while (_local3 < (numSegs - 1)) {
if ((_local3 == 0) || (mc["seg" + _local3].evolveState > 1)) {
var _local7 = mc["seg" + _local3];
var _local2 = 1;
while (_local2 < numSegs) {
if (mc["seg" + _local2].evolveState > 1) {
var _local6 = mc["seg" + _local2];
spring(_local7, _local6, dt);
}
_local2++;
}
}
_local3++;
}
_local3 = 0;
while (_local3 < (numSegs - 1)) {
if ((_local3 == 0) || (mc["seg" + _local3].evolveState > 1)) {
var _local7 = mc["seg" + _local3];
var _local2 = _local3 + 1;
while (_local2 < numSegs) {
if (mc["seg" + _local2].evolveState == 1) {
var _local6 = mc["seg" + _local2];
spring(_local7, _local6, dt);
} else {
_local3 = _local2 - 1;
break;
}
_local2++;
}
}
_local3++;
}
_local3 = 1;
while (_local3 < (numSegs - 1)) {
if (mc["seg" + _local3].evolveState == 1) {
var _local7 = mc["seg" + _local3];
var _local2 = _local3 + 1;
while (_local2 < numSegs) {
if (mc["seg" + _local2].evolveState == 1) {
var _local6 = mc["seg" + _local2];
spring(_local7, _local6, dt);
} else {
_local3 = _local2 - 1;
break;
}
_local2++;
}
}
_local3++;
}
}
function spring(partA, partB, dt) {
var _local3 = partB._x - partA._x;
var _local2 = partB._y - partA._y;
var _local9 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local9 > flockDist) {
var _local7 = ((2 * _local3) * springAmount) * dt;
var _local6 = ((2 * _local2) * springAmount) * dt;
partA.vx = partA.vx + _local7;
partA.vy = partA.vy + _local6;
partB.vx = partB.vx - _local7;
partB.vy = partB.vy - _local6;
} else if (_local9 < flockDist) {
if (_local3 >= 0) {
_local3 = flockDist - _local3;
} else {
_local3 = (-flockDist) - _local3;
}
if (_local2 >= 0) {
_local2 = flockDist - _local2;
} else {
_local2 = (-flockDist) - _local2;
}
var _local7 = (_local3 * springAmount) * dt;
var _local6 = (_local2 * springAmount) * dt;
partA.vx = partA.vx - _local7;
partA.vy = partA.vy - _local6;
partB.vx = partB.vx + _local7;
partB.vy = partB.vy + _local6;
}
}
function grow() {
if (curNumSegs <= maxSegs) {
var _local4;
_local4 = mc.attachMovie(assetPrefix + "segbody1", "seg" + curNumSegs, 99 - curNumSegs);
segTimes[curNumSegs] = 0.25;
segSounds[curNumSegs] = int(random(5));
segTag[curNumSegs] = 0;
_local4._rotation = mc["seg" + (curNumSegs - 1)]._rotation;
_local4._x = mc["seg" + (curNumSegs - 1)]._x;
_local4._y = mc["seg" + (curNumSegs - 1)]._y;
_local4.vx = 0;
_local4.vy = 0;
_local4._xscale = segLength;
_local4._yscale = segLength;
_local4.evolveState = 1;
speed = speed + (segLength * 0.5);
if (curNumSegs == numSegs) {
numSegs++;
}
curNumSegs++;
var _local6 = new flash.geom.Transform(_local4);
transArray.push(_local6);
if (curNumSegs == 64) {
rebirth();
}
if ((curNumSegs % 4) == 2) {
evolveSegment(curNumSegs - 1);
}
} else {
var _local5 = 0;
var _local3 = mc.seg0.evolveState;
var _local2 = 1;
while (_local2 < curNumSegs) {
if (mc["seg" + _local2].evolveState < _local3) {
_local3 = mc["seg" + _local2].evolveState;
_local5 = _local2;
}
_local2++;
}
evolveSegment(_local5);
if (_local5 == 0) {
evolveSegment(1);
}
}
}
var springAmount = 3;
var decay = 0.9;
}
Symbol 203 MovieClip [__Packages.Boss] Frame 0
class Boss extends Creature
{
var type, numSegs, defaultNumSegs, chargeDifficulty, boss, spawnID, spawnTimer, spawnTime, panicIntensityDefault, charging, updateChargeTarg, mc, segLength, posX, posY, weakLength, weakPoints, weakPointsHitC, weakPointsHit, transArray, sounds, assetPrefix, mouthSize, wounded, behavior, panicRange, panicIntensity, tempTempMinDefault, tempMinDefault, tempMin, targetX, targetY, tempTargetX, tempTargetY, dist, hasTarget, ID, screenY, screenX, orient, turnSpeed, currentSpeed, speed, drag, eating, tempFish, targets, tempWeak, nutrition, tempFood, panicTimer, die, dieExplosionRate, dieTimer, dieSeg, turnIntoFoodOnDeath, level, alive, clipName, eatingTimer, soundVolume;
function Boss (posX, posY, numSegs, segLength, speed, turnSpeed, mc, ID, prefix) {
super(posX, posY, numSegs, 1, 0, segLength, speed, turnSpeed, true, mc, ID, prefix);
type = 6;
}
function initialize() {
numSegs = defaultNumSegs;
chargeDifficulty = 3;
boss = true;
spawnID = -1;
spawnTimer = 0;
spawnTime = 0.1;
panicIntensityDefault = 10;
charging = false;
updateChargeTarg = false;
var _local5;
_local5 = mc.attachMovie("boss1", "seg0", 99);
_local5._xscale = segLength;
_local5._yscale = segLength;
_local5._x = posX;
_local5._y = posY;
_local5.evolveState = 1;
var _local4;
weakLength = 3;
var _local3 = 0;
while (_local3 < weakLength) {
weakPoints[_local3] = _local3;
weakPointsHit[_local3] = weakPointsHitC;
_local4 = new flash.geom.Transform(mc.seg0["weakPoint" + _local3]);
transArray.push(_local4);
_local3++;
}
_local4 = new flash.geom.Transform(mc.seg0.mouth);
transArray.push(_local4);
_local4 = new flash.geom.Transform(mc.seg0.body);
transArray.push(_local4);
sounds = new Array();
_local3 = 0;
while (_local3 < 4) {
sounds[_local3] = new Sound(_root);
sounds[_local3].loadSound(((assetPrefix + "boss ") + (_local3 + 1)) + ".mp3", false);
sounds[_local3].setVolume(0);
_local3++;
}
}
function chooseTarget(dt, player, fish, food) {
mouthSize = (mc.seg0._xscale * mc.seg0.mouth._xscale) * 0.0125;
if (wounded) {
wounded = behavior.panicMovement(dt, this, player, panicRange, panicIntensity);
if (!wounded) {
charging = true;
updateChargeTarg = true;
panicIntensity = panicIntensity * 1.5;
tempTempMinDefault = tempMinDefault;
tempMinDefault = 99999 /* 0x01869F */;
}
} else if (charging && (updateChargeTarg)) {
behavior.eatPlayerOnly(this, player, false);
if (tempMin <= (mouthSize * chargeDifficulty)) {
updateChargeTarg = false;
var _local2 = (mc.seg0._rotation * Math.PI) / 180;
targetX = targetX + ((3 * segLength) * Math.cos(_local2));
targetY = targetY + ((3 * segLength) * Math.sin(_local2));
tempTargetX = targetX;
tempTargetY = targetY;
tempMinDefault = tempTempMinDefault;
}
} else if (charging && (!updateChargeTarg)) {
behavior.eatPlayerOnly(this, player, false);
targetX = tempTargetX;
targetY = tempTargetY;
if (dist(posX, posY, targetX, targetY) <= (mouthSize * 5)) {
charging = false;
}
} else {
behavior.eatPlayerOnly(this, player, true);
if (!hasTarget) {
if (dist(posX, posY, targetX, targetY) < mouthSize) {
behavior.goToRandomLocation(this);
}
}
}
}
function movementUpdate(dt, camera) {
hasTarget = true;
var _local7;
if (ID == -1) {
_local7 = Math.atan2((_ymouse - camera.screenY) - screenY, (_xmouse - camera.screenX) - screenX);
} else {
_local7 = Math.atan2(targetY - posY, targetX - posX);
}
var _local6 = (_local7 - orient) % (Math.PI*2);
if (_local6 <= -3.14159265358979) {
orient = orient + ((turnSpeed * dt) * 30);
} else if (_local6 > Math.PI) {
orient = orient - ((turnSpeed * dt) * 30);
} else if (_local6 > 0) {
orient = orient + ((turnSpeed * dt) * 30);
} else if (_local6 < 0) {
orient = orient - ((turnSpeed * dt) * 30);
}
if (charging || (wounded)) {
currentSpeed = panicIntensity * speed;
} else if ((!charging) && (panicIntensity > 1)) {
currentSpeed = panicIntensity * speed;
panicIntensity = panicIntensity * (1 - dt);
} else if (hasTarget) {
currentSpeed = speed * 3;
} else {
currentSpeed = speed;
}
posX = posX + ((currentSpeed * Math.cos(orient)) * dt);
posY = posY + ((currentSpeed * Math.sin(orient)) * dt);
drag(mc.seg0, posX, posY);
var _local2 = 0;
while (_local2 < numSegs) {
var _local3 = mc["seg" + _local2];
var _local4 = mc["seg" + (_local2 + 1)];
drag(_local4, _local3._x, _local3._y);
_local2++;
}
spawnBullets(dt);
}
function collision(food) {
if ((eating == -1) && (tempMin < mouthSize)) {
mc.seg0.mouth.gotoAndPlay(2);
if (tempFish != -2) {
targets[tempFish].wound(tempWeak);
eating = 1;
nutrition = 0.5 * (mc["seg" + tempWeak]._xscale + mc["seg" + tempWeak]._yscale);
if (targets[tempFish].ID == -1) {
_root.camera.shake(8);
}
} else {
nutrition = food[tempFood].energy;
food[tempFood].energy = 0;
eating = food[tempFood].foodType;
}
}
}
function wound(weakPointID) {
weakPointsHit[weakPointID] = 0;
var _local4 = mc.seg0["weakPoint" + weakPoints[weakPointID]];
_local4._alpha = 0;
wounded = true;
panicIntensity = panicIntensityDefault;
panicTimer = 100;
spawnID = 1;
var _local3 = true;
var _local2 = 0;
while (_local2 < weakLength) {
if (weakPointsHit[_local2] != 0) {
_local3 = false;
break;
}
_local2++;
}
if (_local3) {
die();
}
}
function dieUpdate(dt) {
var _local7 = false;
dieExplosionRate = 0.1;
dieTimer = dieTimer + dt;
while ((dieTimer > dieExplosionRate) && (dieSeg < numSegs)) {
dieTimer = dieTimer - dieExplosionRate;
var _local4 = 0;
var _local3 = 0;
var _local5 = dieSeg;
while (_local5 < numSegs) {
dieSeg++;
var _local6 = mc.seg0.body["seg" + _local5];
_local4 = behavior.getBossWeakpointX(this, _local6);
_local3 = behavior.getBossWeakpointY(this, _local6);
if (_local5 != 0) {
if (turnIntoFoodOnDeath) {
_root.gameLevels[level].spawnFoodAtLocation(2, _local4, _local3, 15, 10);
}
_root.gameLevels[level].spawnEffect(0, segLength / 20, segLength / 20, 0, _local4, _local3);
} else {
if (turnIntoFoodOnDeath) {
_root.gameLevels[level].spawnFoodAtLocation(0, mc.seg0._x, mc.seg0._y, 15, 10);
}
_root.gameLevels[level].spawnEffect(0, segLength / 5, segLength / 20, 0, mc.seg0._x, mc.seg0._y);
}
_local7 = true;
_local6.removeMovieClip();
if (dieSeg >= numSegs) {
_local5 = 0;
while (_local5 < weakLength) {
_local6 = mc.seg0["weakPoint" + _local5];
_local4 = behavior.getBossWeakpointX(this, _local6);
_local3 = behavior.getBossWeakpointY(this, _local6);
_root.gameLevels[level].spawnFoodAtLocation(0, _local4, _local3, 15, 10);
_root.gameLevels[level].spawnFoodAtLocation(99, _local4, _local3, 15, 10);
_root.gameLevels[level].spawnEffect(0, segLength / 20, segLength / 20, 0, _local4, _local3);
_local5++;
}
mc.seg0.removeMovieClip();
alive = false;
_root[clipName].removeMovieClip();
}
if (_local7) {
break;
}
_local5++;
}
}
}
function spawnBullets(dt) {
if (spawnID > 0) {
spawnTimer = spawnTimer + dt;
if (spawnTimer > spawnTime) {
spawnTimer = 0;
var _local6 = 0;
var _local5 = 0;
var _local3 = mc.seg0.body["seg" + spawnID];
_local6 = behavior.getBossWeakpointX(this, _local3);
_local5 = behavior.getBossWeakpointY(this, _local3);
var _local4 = _root.gameLevels[level].spawnBulletAtLocation((random(4) + 5) - (spawnID * 0.5), _local6, _local5, _local3._xscale, 100, 5, 4, 0);
_local4.targetX = -targetX;
_local4.targetY = -targetY;
_local4.orient = random((Math.PI*2));
_local4.movementMode = 2;
_root.gameLevels[level].spawnEffect(0, _local3._xscale / 20, _local3._xscale / 20, 0, _local6, _local5);
sounds[3].setVolume(100);
sounds[3].start(0, 1);
spawnID++;
if (spawnID >= numSegs) {
spawnID = -1;
}
}
}
}
function eatingUpdate(dt, camera) {
if (eating > -1) {
eatingTimer = eatingTimer - (dt * 50);
if (eatingTimer <= 0) {
mc.seg0.mouth.gotoAndPlay(23);
eating = -1;
eatingTimer = 1;
if (nutrition > 0) {
var _local2 = 0;
while (_local2 < weakLength) {
if (weakPointsHit[_local2] < weakPointsHitC) {
nutrition--;
break;
}
_local2++;
}
}
var _local2 = int(random(3));
sounds[_local2].setVolume(soundVolume);
sounds[_local2].start(0, 1);
}
}
}
function heal(i) {
weakPointsHit[i] = weakPointsHitC;
var _local3 = mc["seg" + weakPoints[i]];
var _local4 = _root.sndLoader.getSound(assetPrefix + "heal");
_local4.setVolume(soundVolume);
_local4.start(0, 1);
var _local6 = 0;
var _local5 = 0;
_local3 = mc.seg0.body["seg" + i];
_local3.play();
_local6 = behavior.getBossWeakpointX(this, _local3);
_local5 = behavior.getBossWeakpointY(this, _local3);
_root.gameLevels[level].spawnEffect(0, 10, 1, 0.25, _local6, _local5);
}
}
Symbol 204 MovieClip [__Packages.Bullet] Frame 0
class Bullet extends Creature
{
var lifeTime, turnIntoFoodOnDeath, movementMode, type, creatureType, numSegs, defaultNumSegs, defaultColorTransTime, colorTransTime, mc, assetPrefix, segSounds, segTimes, segTag, segLength, transArray, tempScaleX, tempScaleY, sounds, soundLoops, behavior, eating, die;
function Bullet (lifeTime, posX, posY, segLength, speed, turnSpeed, mc, ID, prefix) {
super(posX, posY, 1, 1, 0, segLength, speed, turnSpeed, false, mc, ID, prefix);
this.lifeTime = lifeTime;
turnIntoFoodOnDeath = false;
movementMode = 1;
type = 5;
}
function initialize() {
creatureType = "Bullet";
numSegs = defaultNumSegs;
defaultColorTransTime = 0.1;
colorTransTime = defaultColorTransTime;
var _local4;
_local4 = mc.attachMovie(assetPrefix + "bullet1", "seg0", 99);
segSounds[0] = int(random(6));
segTimes[0] = 0.25;
segTag[0] = 0;
_local4._xscale = segLength;
_local4._yscale = segLength;
_local4.evolveState = 1;
var _local5 = new flash.geom.Transform(_local4);
transArray.push(_local5);
tempScaleX = mc.seg0._xscale;
tempScaleY = mc.seg0._yscale;
sounds = new Array();
soundLoops = new Array();
var _local3 = 0;
while (_local3 < 5) {
sounds[_local3] = _root.sndLoader.getSound(((assetPrefix + "Food-samples-") + (_local3 + 1)) + "a");
soundLoops[_local3] = _root.sndLoader.getSound(((assetPrefix + "Food-loop-") + (_local3 + 1)) + "a");
_local3++;
}
}
function chooseTarget(dt, player, fish, food) {
if (movementMode == 1) {
} else if (movementMode == 2) {
behavior.eatPlayerOnly(this, player, false);
}
}
function grow() {
}
function eatingUpdate(dt, camera) {
if (eating > -1) {
die();
}
}
}
Symbol 205 MovieClip [__Packages.Manta] Frame 0
class Manta extends Creature
{
var type, numSegs, defaultNumSegs, chargeDifficulty, boss, panicIntensityDefault, charging, updateChargeTarg, mc, segLength, posX, posY, weakLength, weakPoints, weakPointsHitC, weakPointsHit, transArray, sounds, assetPrefix, mouthSize, wounded, behavior, panicRange, panicIntensity, tempTempMinDefault, tempMinDefault, tempMin, targetX, targetY, tempTargetX, tempTargetY, dist, hasTarget, ID, screenY, screenX, orient, turnSpeed, currentSpeed, speed, drag, eating, tempFish, targets, tempWeak, nutrition, tempFood, panicTimer, die, level, eatingTimer, soundVolume, dieExplosionRate, dieTimer, dieSeg, turnIntoFoodOnDeath, initializeVars, alive, clipName;
function Manta (posX, posY, numSegs, segLength, speed, turnSpeed, mc, ID, prefix) {
super(posX, posY, numSegs, 1, 0, segLength, speed, turnSpeed, true, mc, ID, prefix);
type = 4;
}
function initialize() {
numSegs = defaultNumSegs;
chargeDifficulty = 3;
boss = true;
panicIntensityDefault = 7;
charging = false;
updateChargeTarg = false;
var _local5;
_local5 = mc.attachMovie("manta1", "seg0", 99);
trace("OK");
_local5._xscale = segLength;
_local5._yscale = segLength;
_local5._x = posX;
_local5._y = posY;
_local5.evolveState = 1;
var _local4;
weakLength = 2;
var _local3 = 0;
while (_local3 < weakLength) {
weakPoints[_local3] = _local3;
weakPointsHit[_local3] = weakPointsHitC;
_local4 = new flash.geom.Transform(mc.seg0["weakPoint" + _local3]);
transArray.push(_local4);
_local3++;
}
_local4 = new flash.geom.Transform(mc.seg0.mouth);
transArray.push(_local4);
_local4 = new flash.geom.Transform(mc.seg0.body);
transArray.push(_local4);
sounds = new Array();
_local3 = 0;
while (_local3 < 3) {
sounds[_local3] = new Sound(_root);
sounds[_local3].loadSound(((assetPrefix + "manta ") + (_local3 + 1)) + ".mp3", false);
sounds[_local3].setVolume(0);
_local3++;
}
}
function chooseTarget(dt, player, fish, food) {
mouthSize = (mc.seg0._xscale * mc.seg0.mouth._xscale) * 0.0125;
if (wounded) {
wounded = behavior.panicMovement(dt, this, player, panicRange, panicIntensity);
if (!wounded) {
charging = true;
updateChargeTarg = true;
panicIntensity = panicIntensity * 1.5;
tempTempMinDefault = tempMinDefault;
tempMinDefault = 99999 /* 0x01869F */;
}
} else if (charging && (updateChargeTarg)) {
behavior.eatPlayerOnly(this, player, false);
if (tempMin <= (mouthSize * chargeDifficulty)) {
updateChargeTarg = false;
var _local2 = (mc.seg0._rotation * Math.PI) / 180;
targetX = targetX + ((3 * segLength) * Math.cos(_local2));
targetY = targetY + ((3 * segLength) * Math.sin(_local2));
tempTargetX = targetX;
tempTargetY = targetY;
tempMinDefault = tempTempMinDefault;
}
} else if (charging && (!updateChargeTarg)) {
behavior.eatPlayerOnly(this, player, false);
targetX = tempTargetX;
targetY = tempTargetY;
if (dist(posX, posY, targetX, targetY) <= (mouthSize * 7.5)) {
charging = false;
}
} else {
behavior.eatPlayerAndFood(this, player, food, true);
if (!hasTarget) {
if (dist(posX, posY, targetX, targetY) < mouthSize) {
behavior.goToRandomLocation(this);
}
}
}
}
function movementUpdate(dt, camera) {
hasTarget = true;
var _local7;
if (ID == -1) {
_local7 = Math.atan2((_ymouse - camera.screenY) - screenY, (_xmouse - camera.screenX) - screenX);
} else {
_local7 = Math.atan2(targetY - posY, targetX - posX);
}
var _local6 = (_local7 - orient) % (Math.PI*2);
if (_local6 <= -3.14159265358979) {
orient = orient + ((turnSpeed * dt) * 30);
} else if (_local6 > Math.PI) {
orient = orient - ((turnSpeed * dt) * 30);
} else if (_local6 > 0) {
orient = orient + ((turnSpeed * dt) * 30);
} else if (_local6 < 0) {
orient = orient - ((turnSpeed * dt) * 30);
}
if (charging || (wounded)) {
currentSpeed = panicIntensity * speed;
} else if ((!charging) && (panicIntensity > 1)) {
currentSpeed = panicIntensity * speed;
panicIntensity = panicIntensity * (1 - dt);
} else if (hasTarget) {
currentSpeed = speed * 3;
} else {
currentSpeed = speed;
}
posX = posX + ((currentSpeed * Math.cos(orient)) * dt);
posY = posY + ((currentSpeed * Math.sin(orient)) * dt);
drag(mc.seg0, posX, posY);
var _local2 = 0;
while (_local2 < numSegs) {
var _local3 = mc["seg" + _local2];
var _local4 = mc["seg" + (_local2 + 1)];
drag(_local4, _local3._x, _local3._y);
_local2++;
}
}
function collision(food) {
if ((eating == -1) && (tempMin < mouthSize)) {
mc.seg0.mouth.gotoAndPlay(2);
if (tempFish != -2) {
targets[tempFish].wound(tempWeak);
eating = 1;
nutrition = 1;
if (targets[tempFish].ID == -1) {
_root.camera.shake(8);
}
} else {
nutrition = food[tempFood].nutrition;
food[tempFood].energy = 0;
food[tempFood].alive = false;
eating = food[tempFood].foodType;
}
}
}
function wound(weakPointID) {
weakPointsHit[weakPointID] = 0;
var _local4 = mc.seg0["weakPoint" + weakPoints[weakPointID]];
_local4._alpha = 0;
wounded = true;
panicIntensity = panicIntensityDefault;
panicTimer = 100;
var _local3 = true;
var _local2 = 0;
while (_local2 < weakLength) {
if (weakPointsHit[_local2] != 0) {
_local3 = false;
break;
}
_local2++;
}
if (_local3) {
die();
}
}
function spawnBullets() {
var _local7 = 0;
var _local6 = 0;
var _local5 = 0;
while (_local5 < numSegs) {
var _local3 = mc.seg0.body["seg" + (_local5 + 1)];
_local7 = behavior.getBossWeakpointX(this, _local3);
_local6 = behavior.getBossWeakpointY(this, _local3);
var _local4 = _root.gameLevels[level].spawnBulletAtLocation(random(4) + 2, _local7, _local6, _local3._xscale / 2, 75, 5, 8, 0);
_local4.targetX = -targetX;
_local4.targetY = -targetY;
_local4.orient = random((Math.PI*2));
_local4.movementMode = 2;
_root.gameLevels[level].spawnEffect(0, _local3._xscale / 40, _local3._xscale / 40, 0, _local7, _local6);
_local5++;
}
}
function eatingUpdate(dt, camera) {
if (eating > -1) {
eatingTimer = eatingTimer - (dt * 50);
if (eatingTimer <= 0) {
mc.seg0.mouth.gotoAndPlay(23);
eating = -1;
eatingTimer = 1;
if (nutrition > 0) {
var _local2 = 0;
while (_local2 < weakLength) {
if (weakPointsHit[_local2] < weakPointsHitC) {
heal(_local2);
nutrition--;
break;
}
_local2++;
}
}
var _local2 = int(random(3));
sounds[_local2].setVolume(soundVolume);
sounds[_local2].start(0, 1);
}
}
}
function heal(i) {
weakPointsHit[i] = weakPointsHitC;
var _local4 = mc["seg" + weakPoints[i]];
var _local3 = _root.sndLoader.getSound(assetPrefix + "heal");
_local3.setVolume(soundVolume);
_local3.start(0, 1);
var _local6 = 0;
var _local5 = 0;
_local4 = mc.seg0.body["seg" + i];
_local6 = behavior.getBossWeakpointX(this, _local4);
_local5 = behavior.getBossWeakpointY(this, _local4);
_root.gameLevels[level].spawnEffect(0, 10, 1, 0.25, _local6, _local5);
}
function dieUpdate(dt) {
var _local7 = false;
dieExplosionRate = 0.1;
dieTimer = dieTimer + dt;
while ((dieTimer > dieExplosionRate) && (dieSeg < numSegs)) {
dieTimer = dieTimer - dieExplosionRate;
var _local6 = 0;
var _local5 = 0;
var _local3 = dieSeg;
while (_local3 < numSegs) {
dieSeg++;
var _local4 = mc.seg0.body["seg" + _local3];
_local6 = behavior.getBossWeakpointX(this, _local4);
_local5 = behavior.getBossWeakpointY(this, _local4);
if (_local3 != 0) {
if (turnIntoFoodOnDeath) {
_root.gameLevels[level].spawnFoodAtLocation(1, _local6, _local5, 15, 10);
}
_root.gameLevels[level].spawnEffect(0, segLength / 20, segLength / 20, 0, _local6, _local5);
} else {
if (turnIntoFoodOnDeath) {
_root.gameLevels[level].spawnFoodAtLocation(0, mc.seg0._x, mc.seg0._y, 15, 10);
}
_root.gameLevels[level].spawnEffect(0, segLength / 5, segLength / 20, 0, mc.seg0._x, mc.seg0._y);
}
_local7 = true;
_local4.removeMovieClip();
if (dieSeg >= numSegs) {
if (ID == -1) {
_root.gameLevels[level].killAllBulletFish();
initializeVars();
initialize();
} else {
mc.seg0.removeMovieClip();
alive = false;
_root[clipName].removeMovieClip();
}
}
if (_local7) {
break;
}
_local3++;
}
}
}
}
Symbol 206 MovieClip [__Packages.Billboard] Frame 0
class Billboard extends GameObject
{
var posX, posY, posZ, mc, trans, colorTrans;
function Billboard (billName, zDepth, mc) {
super();
posX = (posY = 0);
posZ = zDepth;
this.mc = mc;
var _local3;
_local3 = mc.attachMovie(billName, "seg", 0);
_local3._xscale = 100;
_local3._yscale = 100;
_local3._x = posX;
_local3._y = posY;
trans = new flash.geom.Transform(_local3);
}
function update(camera) {
posX = 0;
posY = 0;
var _local2 = mc.seg;
_local2._x = 0;
_local2._y = 0;
trans.colorTransform = colorTrans;
}
}
Symbol 207 MovieClip [__Packages.Effect] Frame 0
class Effect extends GameObject
{
var mc, posX, posY, posZ, eType, eSize, eTime, eDelay, alive, timer;
function Effect (eType, eSize, eTime, eDelay, posX, posY, posZ, mc) {
super();
this.mc = mc;
reset(eType, eSize, eTime, eDelay, posX, posY, posZ);
}
function reset(eType, eSize, eTime, eDelay, posX, posY, posZ) {
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
this.eType = eType;
this.eSize = eSize;
this.eTime = eTime;
this.eDelay = eDelay;
alive = true;
timer = 0;
if (eType == 0) {
var _local2 = mc.attachMovie("ping", "eff", 0);
_local2._x = posX;
_local2._y = posY;
_local2._xscale = eSize * 10;
_local2._yscale = eSize * 10;
} else if (eType == 1) {
var _local2 = mc.attachMovie("pong", "eff", 0);
_local2._x = posX;
_local2._y = posY;
_local2._xscale = eSize * 10;
_local2._yscale = eSize * 10;
}
}
function update(dt, camera) {
timer = timer + dt;
if (timer > eDelay) {
if ((timer < eTime) && (alive)) {
mc.eff.gotoAndStop(int((timer / eTime) * 100));
} else {
timer = 0;
alive = false;
mc.eff.removeMovieClip();
}
}
}
}
Symbol 208 MovieClip [__Packages.Camera3D] Frame 0
class Camera3D extends GameObject
{
var targetX, targetY, targetZ, focalLength, zOffset, zScaleRatio, shaking, shakeTimePassed, shakeDelay, toTarget, posX, posY, shakeMax;
function Camera3D () {
super();
targetX = (targetY = (targetZ = 0));
focalLength = 400;
zOffset = 0;
zScaleRatio = 1;
shaking = false;
shakeTimePassed = 0;
shakeDelay = 0.1;
toTarget = false;
}
function updateMovement(dt) {
var _local3 = _root.player.currentSpeed;
if (toTarget) {
if ((Math.abs(targetX - posX) < ((_local3 * dt) * 0.5)) && (Math.abs(targetY - posY) < ((_local3 * dt) * 0.5))) {
posX = targetX;
posY = targetY;
} else {
var _local4 = Math.atan2(targetY - posY, targetX - posX);
posX = posX + ((_local3 * Math.cos(_local4)) * dt);
posY = posY + ((_local3 * Math.sin(_local4)) * dt);
}
}
}
function shake(shakeMagnitude) {
shaking = true;
if (shakeMagnitude <= 0) {
shakeMax = 4;
} else {
shakeMax = shakeMagnitude;
}
shakeMax = 20;
}
function updateShake(dt) {
if (!shaking) {
zOffset = zOffset + ((-zOffset) * dt);
} else {
shakeTimePassed = shakeTimePassed + dt;
zOffset = zOffset - ((shakeMax * dt) / shakeDelay);
if (shakeTimePassed > shakeDelay) {
shakeTimePassed = 0;
shaking = false;
}
}
}
static function inWindow(xx, yy, camera) {
if ((Math.abs((xx + camera.screenX) - (Stage.width * 0.5)) > (Stage.width * 1)) || (Math.abs((yy + camera.screenY) - (Stage.height * 0.5)) > (Stage.height * 1))) {
return(false);
}
return(true);
}
static function getNextDepth() {
return(nextDepth++);
}
static function drawRectangle(target_mc, boxWidth, boxHeight, fillColor, fillAlpha) {
with (target_mc) {
beginFill(fillColor, fillAlpha);
moveTo(0, 0);
lineTo(boxWidth, 0);
lineTo(boxWidth, boxHeight);
lineTo(0, boxHeight);
lineTo(0, 0);
endFill();
}
}
static var nextDepth = 0;
}
Symbol 209 MovieClip [__Packages.Particle] Frame 0
class Particle
{
var pNum, particles, pLife;
function Particle (pNum) {
this.pNum = pNum;
particles = new Array(pNum);
pLife = new Array(pNum);
var i = 0;
while (i < pNum) {
_root.createEmptyMovieClip("paricle_" + i, Camera3D.getNextDepth());
particles[i] = new GameObject();
var temp = (50 + random(range - 50));
particles[i].posZ = -temp;
particles[i].posX = (particles[i].mc["particle" + i]._x = random(Stage.width));
particles[i].posY = (particles[i].mc["particle" + i]._y = random(Stage.height));
particles[i].mc = eval ("paricle_" + i);
pLife[i] = (pLifeMax / pNum) * i;
var seg;
seg = particles[i].mc.attachMovie("particle", "particle" + i, Camera3D.getNextDepth());
seg._x = particles[i].posX;
seg._y = particles[i].posY;
seg._xscale = 15;
seg._yscale = 15;
particles[i].trans = new flash.geom.Transform(seg);
i++;
}
}
function update(dt, camera) {
var _local3 = 0;
while (_local3 < pNum) {
particles[_local3].mc["particle" + _local3].gotoAndStop(int((pLife[_local3] * totalFrame) / pLifeMax));
particles[_local3].updateScreenPos(camera);
pLife[_local3] = pLife[_local3] + dt;
if (_root.displayPlayerTarget) {
_root.background_mc.lineStyle(1, 16777215, 128);
_root.background_mc.moveTo(Stage.width / 2, Stage.height / 2);
_root.background_mc.lineTo(particles[_local3].screenX + camera.screenX, particles[_local3].screenY + camera.screenY);
}
if (pLife[_local3] > pLifeMax) {
pLife[_local3] = 0;
var _local4 = 50 + random(range - 50);
var _local6 = Stage.width / (Stage.height + Stage.width);
particles[_local3].posZ = camera.posZ - _local4;
particles[_local3].posX = (particles[_local3].mc["particle" + _local3]._x = ((((-camera.posX) + _xmouse) * (1 - (_local4 / camera.focalLength))) + random(4 * (range - _local4))) - (2 * (range - _local4)));
particles[_local3].posY = (particles[_local3].mc["particle" + _local3]._y = ((((-camera.posY) + _ymouse) * (1 - (_local4 / camera.focalLength))) + random(4 * (range - _local4))) - (2 * (range - _local4)));
}
_local3++;
}
}
var pLifeMax = 5;
var totalFrame = 50;
var range = 300;
}
Symbol 210 MovieClip [__Packages.LevelLoader] Frame 0
class LevelLoader
{
var xmlData;
function LevelLoader () {
}
function loadXML(filename) {
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = function (success) {
if (success) {
LevelLoader.isLoaded = true;
}
};
xmlData.load(filename);
}
function spawnCampaign(num) {
var _local13 = xmlData.firstChild;
var _local10 = _local13.childNodes;
var _local9 = -1;
var _local8 = 0;
while (_local8 < _local10.length) {
if (num == parseInt(_local10[_local8].attributes.num)) {
_local9 = _local8;
}
_local8++;
}
var _local12 = _local10[_local9].attributes.player;
PlayerXForm.nextPlayerType = _local12;
if (_local9 == -1) {
_local9 = _local10.length - 1;
}
if (_root.numPlayerBosses > 0) {
movePlayerBossToNewLevel();
}
var _local6 = _local10[_local9].childNodes;
_root.totalLevel = Math.max(_local6.length, _root.totalLevel);
_local8 = 0;
while (_local8 < _local6.length) {
if ((_local8 > 0) || ((_local8 == 0) && (_local9 == 0))) {
eraseLevel(_local8);
var _local5 = new GameLevel(_local8, _local6[_local8].attributes.levelSize);
} else {
var _local5 = _root.gameLevels[_local8];
}
_local5.bgColor.curColor = _local6[_local8].attributes.bgColor;
if ((_local8 > 0) || ((_local8 == 0) && (_local9 == 0))) {
var _local4 = _local6[_local8].childNodes;
var _local3 = 0;
while (_local3 < _local4.length) {
if (_local4[_local3].nodeName == "SpawnBillboard") {
spawnBillboard(_local4[_local3], _local5);
} else if (_local4[_local3].nodeName == "SpawnFood") {
spawnFood(_local4[_local3], _local5);
} else if (_local4[_local3].nodeName == "SpawnFish") {
spawnFish(_local4[_local3], _local5);
} else if (_local4[_local3].nodeName == "SpawnJellyfish") {
spawnJellyfish(_local4[_local3], _local5);
} else if (_local4[_local3].nodeName == "SpawnManta") {
spawnManta(_local4[_local3], _local5);
} else if (_local4[_local3].nodeName == "SpawnBoss") {
spawnBoss(_local4[_local3], _local5);
} else if (_local4[_local3].nodeName == "SpawnFlockfish") {
spawnFlockfish(_local4[_local3], _local5);
} else if (_local4[_local3].nodeName == "SpawnGoldEgg") {
spawnGoldEgg(_local4[_local3], _local5);
}
_local3++;
}
if ((_local8 < (_local6.length - 1)) || (_root.numPlayerBosses > 0)) {
_local5.spawnFood(1, 100, 35, 0);
}
if (_local8 > 0) {
_local5.spawnFood(1, 101, 35, 0);
}
}
_root.gameLevels[_local8] = _local5;
_local8++;
}
var _local7 = 0;
while (_local7 < (_root.numPlayerBosses - 1)) {
_root.gameLevels[_local6.length + _local7].respawnPlayerBoss();
_local7++;
}
_local8 = 0;
while (_local8 < _root.gameLevels.length) {
_root.gameLevels[_local8].unspawnGoldEgg();
_local8++;
}
_root.gameLevels[_root.gameLevels.length - 1].spawnGoldEgg(0);
}
function eraseLevel(num) {
_root.gameLevels[num].eraseData();
_root.gameLevels[num] = null;
}
function spawnGoldEgg(node, newLevel) {
newLevel.spawnGoldEgg(parseInt(node.attributes.fishNum));
}
function spawnBillboard(node, newLevel) {
newLevel.spawnBillboard(node.attributes.name, parseInt(node.attributes.posX), parseInt(node.attributes.posY));
}
function spawnFood(node, newLevel) {
newLevel.spawnFood(parseInt(node.attributes.num), parseInt(node.attributes.foodType), parseInt(node.attributes.hpMin), parseInt(node.attributes.hpVar));
}
function spawnFish(node, newLevel) {
var _local2 = false;
if (node.attributes.panic == "true") {
_local2 = true;
}
newLevel.spawnFish(parseInt(node.attributes.num), parseInt(node.attributes.numSegs), parseInt(node.attributes.maxSegs), parseInt(node.attributes.randEvolve), parseInt(node.attributes.segLength), parseInt(node.attributes.speedMin), parseInt(node.attributes.speedVar), parseInt(node.attributes.turnMin), parseInt(node.attributes.turnVar), _local2);
}
function spawnJellyfish(node, newLevel) {
var _local2 = false;
if (node.attributes.panic == "true") {
_local2 = true;
}
newLevel.spawnJellyfish(parseInt(node.attributes.num), parseInt(node.attributes.numSegs), parseInt(node.attributes.maxSegs), parseInt(node.attributes.randEvolve), parseInt(node.attributes.segLength), parseInt(node.attributes.speedMin), parseInt(node.attributes.speedVar), parseInt(node.attributes.turnMin), parseInt(node.attributes.turnVar), _local2);
}
function spawnManta(node, newLevel) {
newLevel.spawnManta(parseInt(node.attributes.num), parseInt(node.attributes.numSegs), parseInt(node.attributes.segLength), parseInt(node.attributes.speedMin), parseInt(node.attributes.speedVar), parseInt(node.attributes.turnMin), parseInt(node.attributes.turnVar));
}
function spawnBoss(node, newLevel) {
newLevel.spawnBoss(parseInt(node.attributes.num), parseInt(node.attributes.numSegs), parseInt(node.attributes.segLength), parseInt(node.attributes.speedMin), parseInt(node.attributes.speedVar), parseInt(node.attributes.turnMin), parseInt(node.attributes.turnVar));
}
function spawnFlockfish(node, newLevel) {
var _local2 = false;
if (node.attributes.panic == "true") {
_local2 = true;
}
newLevel.spawnFlockfish(parseInt(node.attributes.num), parseInt(node.attributes.numSegs), parseInt(node.attributes.maxSegs), parseInt(node.attributes.randEvolve), parseInt(node.attributes.segLength), parseInt(node.attributes.speedMin), parseInt(node.attributes.speedVar), parseInt(node.attributes.turnMin), parseInt(node.attributes.turnVar), _local2);
}
function movePlayerBossToNewLevel() {
var _local3 = _root.gameLevels[_root.totalLevel - 1];
var _local2 = new GameLevel(_root.gameLevels.length, _local3.levelSize);
_local2.bgColor.copy(_local3.bgColor);
_local2.spawnFood(1, 101, 35, 0);
_local2.spawnFood(10, 5, 15, 10);
var _local4 = _local3.playerBoss;
_local4.ID = 0;
_local4.posZ = _local2.zDepth;
_local2.fish[0] = _local3.playerBoss;
_local2.fishLength = 1;
_local2.playerBoss = _local3.playerBoss;
_local2.clonePlayerBoss();
_local3.remPlayerBoss();
_local2.bgMusic = _root.sndLoader.getSound(((_local2.assetPrefix + "Flow-lvl ") + 19) + " drone");
_local2.bgMusicStarted = false;
_root.gameLevels[_root.gameLevels.length] = _local2;
_root.totalLevel++;
}
static var isLoaded = false;
}