Frame 2
fscommand ("ictvcmd", "focus");
Array.prototype.getItemIndex = function (tItem) {
var _local3 = this.length;
var _local2 = 0;
while (_local2 < _local3) {
if (this[_local2] == tItem) {
return(_local2);
}
_local2++;
}
return(-1);
};
this.goto = function (tStr) {
_global.gGameState = tStr;
this.gotoAndPlay(tStr);
};
this.setKeys = function () {
this.keyDetect = new Object();
this.keyDetect.onKeyDown = function () {
keyPressed(Key.isDown(38), Key.isDown(40), Key.isDown(37), Key.isDown(39), Key.isDown(32));
if (Selection.getFocus() == null) {
fscommand ("ictvcmd", "focus");
}
};
Key.addListener(this.keyDetect);
this.pKeyDelay = 0;
this.pKeyActive = true;
};
this.setKeyInt = function () {
};
this.clearKeyInt = function () {
this.pKeyActive = true;
clearInterval(this.pKeyDelay);
};
this.keyPressed = function (aUp, aDown, aLeft, aRight, aAction) {
if (this.pKeyActive) {
this.pKeyActive = false;
this.pKeyDelay = setInterval(this, "clearKeyInt", 200);
switch (gGameState) {
case "menu" :
if (aAction) {
this.soul_mc.clearMap();
this.goto("newGame");
}
break;
case "newGame" :
if (aAction) {
this.goto("game");
}
break;
case "game" :
this.grid_mc.selector_mc.moveSelect(aRight - aLeft, aDown - aUp);
if (!aAction) {
break;
}
this.grid_mc.selector_mc.pressSelect();
}
}
};
this.setKeys();
this.goto("menu");
Frame 9
stop();
Frame 15
stop();
Frame 21
this.init = function () {
this.grid_mc.loadGrid(5);
};
this.init();
stop();
Frame 22
this.gameover_mc.gotoAndStop("full");
Frame 44
this.goto("menu");
Symbol 19 MovieClip [mc.tile] Frame 1
this.init = function () {
this._x = this.pPos.x;
this._y = this.pPos.y;
if (this._parent._name == "grid_mc") {
var _local2 = Math.floor(this.pNum / 8);
var _local3 = this.pNum - (Math.floor(this.pNum / 8) * 8);
this._y = (-80 - ((8 - _local2) * 100)) - (_local3 * 15);
} else {
this._y = this._y - 160;
}
this.pSpeedX = 0;
this.pSpeedY = 0;
this.pLandTest = false;
this.pCenter = new Object();
this.pCenter.x = (this.pCenter.y = 0);
this.pAngle = 0;
this.pAngleStep = 0.628318530717959;
this.pDirection = 1;
this.pDepth = this.getDepth();
this.pState = 0;
this.gotoAndStop(this.pColour + 1);
};
this.scaleTile = function () {
this.pSpeedY = 0;
this.pState = 4;
this.addEnterFrame();
};
this.destroyTile = function () {
this.pSpeedX = 0;
this.pSpeedY = Math.random() * -8;
this.pState = 5;
this.addEnterFrame();
};
this.startTile = function () {
this._x = this.pPos.x;
this._y = this.pPos.y;
this._xscale = 100;
this._yscale = 100;
this._alpha = 100;
var _local2 = Math.floor(this.pNum / 8);
var _local3 = this.pNum - (Math.floor(this.pNum / 8) * 8);
this.pSpeedY = 15;
this.pLandTest = false;
this.pState = 1;
this.addEnterFrame();
this.gotoAndStop(this.pColour + 1);
this._parent.tileDropDone();
};
this.renewTile = function (n, c) {
this.pPos.y = -140 + (40 * Math.floor(n / 8));
this._x = pPos.x;
this._y = -250;
this.pNum = n;
this.pColour = c;
this.gotoAndStop(this.pColour + 1);
this.pSpeedY = 0;
this.pState = 1;
this.addEnterFrame();
};
this.hideTile = function () {
this._y = this.pPos.y - 160;
this.pState = 0;
this.removeEnterFrame();
};
this.placeTile = function (tY, tC) {
this._xscale = 100;
this._yscale = 100;
this._y = this.pPos.y - tY;
this.pColour = tC;
this.gotoAndStop(this.pColour + 1);
this.pSpeedY = 0;
this.pState = 1;
this.addEnterFrame();
};
this.dropTile = function (d, tId) {
this.pPos.y = this.pPos.y + (d * 40);
this.pNum = this.pNum + (d * 8);
this.pSpeedY = 0;
this.pState = 1;
this.addEnterFrame();
};
this.removeTile = function () {
this.pSpeedY = 0;
this.pState = 3;
this.addEnterFrame();
};
this.moveTile = function (aX, aY, aDir, aNewNum) {
this.pCenter.x = this.pPos.x - ((this.pPos.x - aX) / 2);
this.pCenter.y = this.pPos.y - ((this.pPos.y - aY) / 2);
this.pDirection = aDir;
switch (true) {
case this.pPos.x < aX :
this.pAngle = -3.14159265358979;
break;
case this.pPos.x > aX :
this.pAngle = 0;
break;
case this.pPos.y < aY :
this.pAngle = -1.5707963267949;
break;
case this.pPos.y > aY :
this.pAngle = (Math.PI/2);
}
this.pPos.x = aX;
this.pPos.y = aY;
this.pNum = aNewNum;
this.pState = 2;
this.addEnterFrame();
};
this.removeEnterFrame = function () {
delete this.onEnterFrame;
};
this.addEnterFrame = function () {
this.onEnterFrame = function () {
switch (this.pState) {
case 1 :
this.pSpeedY = Math.min(this.pSpeedY + 2, 50);
this._y = this._y + this.pSpeedY;
if (this._y >= this.pPos.y) {
this._y = this.pPos.y;
this.pState = 0;
this._parent.tileDropDone();
}
break;
case 2 :
this.pAngle = this.pAngle + (this.pAngleStep * this.pDirection);
this._x = this.pCenter.x + (Math.cos(this.pAngle) * 20);
this._y = this.pCenter.y + (Math.sin(this.pAngle) * 20);
if (Math.abs(this._x - this.pPos.x) < 1) {
if (Math.abs(this._y - this.pPos.y) < 1) {
this._x = this.pPos.x;
this._y = this.pPos.y;
this.pState = 0;
this._parent.tileSwapDone();
}
}
break;
case 3 :
this.pSpeedY = this.pSpeedY + 10;
this._xscale = this._xscale - this.pSpeedY;
this._yscale = this._yscale - this.pSpeedY;
if (this._xscale <= 0) {
this._xscale = 100;
this._yscale = 100;
this._y = -180;
this.pState = 0;
this._parent.tileClearDone();
}
break;
case 4 :
this.pSpeedY = this.pSpeedY + 5;
this._xscale = this._xscale - this.pSpeedY;
this._yscale = this._yscale - this.pSpeedY;
if (this._xscale <= 0) {
this._xscale = 0;
this._yscale = 0;
this.pState = 0;
this._parent.tileScaleDone();
}
break;
case 5 :
this.pSpeedY = Math.min(this.pSpeedY + 2, 50);
this._x = this._x + this.pSpeedX;
this._y = this._y + this.pSpeedY;
if (this._y < 180) {
break;
}
this.pState = 0;
this._parent.tileDestroyDone();
}
if (pState == 0) {
this.removeEnterFrame();
}
};
};
this.init();
stop();
Symbol 30 MovieClip [mc.selector] Frame 1
this.init = function () {
this.pPosX = (this.pPosY = 3);
this.pPosNum = (this.pPosY * 8) + this.pPosX;
this._x = 20 + ((this.pPosX - 4) * 40);
this._y = 20 + ((this.pPosY - 4) * 40);
this.pSelection = -1;
this.pActive = false;
this.pVisible = true;
this.hilite1_mc._visible = false;
this.hilite2_mc._visible = false;
this.hilite3_mc._visible = false;
this.hilite4_mc._visible = false;
this.hideSelector();
this.pSelectSnd = new Sound(this);
this.pSelectSnd.attachSound("snd.select");
};
this.setActive = function (tState) {
this.pActive = tState;
if (tState) {
this._x = 20 + ((this.pPosX - 4) * 40);
this._y = 20 + ((this.pPosY - 4) * 40);
}
};
this.hideSelector = function () {
this._y = -200;
};
this.removeSelector = function () {
this.removeMovieClip();
};
this.moveSelect = function (aX, aY) {
this.pPosX = this.pPosX + aX;
this.pPosY = this.pPosY + aY;
this.pPosX = Math.max(0, Math.min(7, this.pPosX));
this.pPosY = Math.max(0, Math.min(7, this.pPosY));
this._x = 20 + ((this.pPosX - 4) * 40);
this._y = 20 + ((this.pPosY - 4) * 40);
if (this.pSelection != -1) {
if (this.pSelection != ((this.pPosY * 8) + this.pPosX)) {
this._parent.swapBlocks(this.pSelection, (this.pPosY * 8) + this.pPosX);
this.pSelection = -1;
this.gotoAndStop("hilite");
this.hilite1_mc._visible = false;
this.hilite2_mc._visible = false;
this.hilite3_mc._visible = false;
this.hilite4_mc._visible = false;
}
}
};
this.pressSelect = function () {
if (this.pActive) {
if (this.pSelection == -1) {
this.pSelection = (this.pPosY * 8) + this.pPosX;
this.gotoAndStop("select");
this.hilite1_mc._visible = true;
this.hilite2_mc._visible = true;
this.hilite3_mc._visible = true;
this.hilite4_mc._visible = true;
this.pSelectSnd.start();
} else {
this.pSelection = -1;
this.gotoAndStop("hilite");
this.hilite1_mc._visible = false;
this.hilite2_mc._visible = false;
this.hilite3_mc._visible = false;
this.hilite4_mc._visible = false;
}
}
};
this.init();
Symbol 30 MovieClip [mc.selector] Frame 4
stop();
Symbol 44 MovieClip [mc.number] Frame 1
this.numbers_mc.stop();
this.init = function () {
if (this.pId == undefined) {
this.pTotal = 0;
} else if (this.pId != 1) {
this._x = -20;
} else {
this.pTotal = 0;
}
if (this.pId < 5) {
this.attachMovie("mc.number", "num_mc", 0);
this.num_mc.pId = this.pId + 1;
this.num_mc.pSnapping = this.pSnapping;
}
};
this.step = function (tStep) {
this.pTotal = this.pTotal + (tStep * 30);
this.setTo(this.pTotal);
};
this.setValue = function (t) {
this.pTotal = t * 30;
this.setTo(this.pTotal);
};
this.setTo = function (tY) {
var _local2 = tY % 300;
var _local4 = -(_local2 - (_local2 % 30));
this.numbers_mc._y = -(_local2 - (_local2 % 30));
this.num_mc.setTo(tY / 10);
};
this.init();
stop();
Symbol 64 Button
on (release) {
this.goto("newGame");
}
Symbol 68 MovieClip Frame 2
this.init = function () {
this.attachMovie("mc.number", "nums_mc", 1);
this.nums_mc.pId = 1;
this.nums_mc.pSnapping = true;
this.nums_mc._x = 125;
this.nums_mc._y = 18;
this.nums_mc._xscale = 75;
this.nums_mc._yscale = 75;
this.pScore = 0;
this.pBonus = 0;
this.pLevel = 0;
};
this.getScore = function () {
return(this.pScore);
};
this.updateScore = function (t) {
this.pScore = this.pScore + ((t * 5) * this.pBonus);
this.nums_mc.setValue(this.pScore);
};
this.updateBonus = function (t) {
this.pBonus++;
this.bonus_mc.setValue(this.pBonus);
};
this.clearBonus = function (t) {
this.pBonus = 0;
this.bonus_mc.setValue(this.pBonus);
};
this.updateLevel = function () {
this.pLevel++;
this.level_mc.setValue(this.pLevel);
};
this.init();
this.updateLevel();
Symbol 68 MovieClip Frame 5
this.stop();
Symbol 76 MovieClip Frame 1
this.timerMask_mc._yscale = 0;
this.init = function () {
if (this.pPause == undefined) {
this.pPause = true;
this.pSpeed = 0.2;
this.pTime = 100;
this.pStep = 100;
trace("speed2 = " + this.pSpeed);
}
};
this.increaseSpeed = function () {
this.pSpeed = this.pSpeed + 0.02;
trace("speed = " + this.pSpeed);
};
this.addTimer = function (t) {
this.pTime = this.pTime + (t * 1.5);
this.pStep = this.pTime;
this.drawTimer();
};
this.resetTimer = function () {
this.pPause = true;
this.pStep = 100;
this.pTime = 100;
};
this.pauseTimer = function () {
delete onEnterFrame;
this.pPause = true;
};
this.resumeTimer = function () {
this.onEnterFrame = animate;
this.pPause = false;
};
this.fire = function () {
this.pauseTimer();
this._parent.grid_mc.gameOver();
this._parent.grid_mc.selector_mc.removeSelector();
};
this.drawTimer = function () {
if (this.pTime > 100) {
this.pTime = 100;
} else if (this.pTime < 0) {
this.pTime = 0;
this.fire();
}
if (this.pTime <= this.pStep) {
this.pStep = this.pStep - 2;
this.timerMask_mc._yscale = 100 - this.pTime;
}
};
this.animate = function () {
this.pTime = this.pTime - this.pSpeed;
this.drawTimer();
};
this.init();
stop();
Symbol 76 MovieClip Frame 14
this.fire();
this.gotoAndStop(1);
Symbol 79 MovieClip Frame 2
function SmallGrid(aRange) {
this.init();
}
SmallGrid.prototype.init = function () {
this.pData = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0);
};
SmallGrid.prototype.reorder = function () {
x = 0;
while (x < 3) {
var _local3 = 0;
y = 0;
while (y < 3) {
var _local2 = x + (y * 3);
if (this.pData[_local2] == 0) {
_local3++;
} else if (_local3 > 0) {
this.pData[_local2 - (_local3 * 3)] = this.pData[_local2] + 0;
this.pData[_local2] = 0;
}
y++;
}
x++;
}
};
SmallGrid.prototype.clearGrid = function () {
var _local2 = 0;
while (_local2 < 9) {
this.pData[_local2] = 0;
_local2++;
}
};
SmallGrid.prototype.checkGrid = function () {
var _local5;
var _local4;
var _local3;
var _local2;
var _local6 = new Array();
_local5 = 0;
while (_local5 < 9) {
_local4 = _local5 - Math.floor(_local5 / 3);
_local3 = _local5 % 3;
_local2 = this.getCellColour(_local4);
if (_local2 != 0) {
if ((this.getCellColour(_local4 + 1) == _local2) && (this.getCellColour(_local4 + 2) == _local2)) {
_local6.push(_local4, _local4 + 1, _local4 + 2);
}
}
_local2 = this.getCellColour(_local3);
if (_local2 != 0) {
if ((this.getCellColour(_local3 + 3) == _local2) && (this.getCellColour(_local3 + 6) == _local2)) {
_local6.push(_local3, _local3 + 3, _local3 + 6);
}
}
_local5 = _local5 + 4;
}
return(_local6);
};
SmallGrid.prototype.removeBlocks = function () {
var _local9 = new Array([], []);
var _local10 = this.pData.slice();
var _local3 = this.pColours.slice();
var _local5;
var _local2;
var _local8;
var _local7 = 6;
while (_local7 < 9) {
_local5 = 0;
_local2 = _local7 + 0;
_local8 = 0;
while (_local2 >= 0) {
if (_local10[_local2] == 0) {
if (_local3.length == 0) {
_local3 = this.pColours.slice();
} else {
var _local4 = _local3[Math.round(Math.random() * (_local3.length - 1))];
_local3.splice(_local3.getItemIndex(_local4), 1);
}
var _local6 = (_local7 - 6) + (_local8 * 3);
_local9[1].push(new Array(_local2, _local6, _local4));
this.pData[_local6] = _local4;
_local8++;
_local5++;
} else if (_local5 > 0) {
_local9[0].push(new Array(_local2, _local5));
this.pData[_local2 + (_local5 * 3)] = _local10[_local2];
}
_local2 = _local2 - 3;
}
_local7++;
}
return(_local9);
};
SmallGrid.prototype.checkBlocks = function (tCellNum) {
var _local12;
var _local11;
var _local6;
var _local14;
var _local16;
var _local15;
var _local17;
var _local3;
var _local7;
var _local8;
var _local10;
var _local9;
_local12 = new Array();
_local11 = new Array();
_local6 = this.getCellColour(tCellNum);
_local14 = Math.floor(tCellNum / 3);
_local16 = 2 - _local14;
_local15 = tCellNum - (Math.floor(tCellNum / 3) * 3);
_local17 = 2 - _local15;
_local7 = 1;
while (_local7 <= _local14) {
_local3 = tCellNum - (_local7 * 3);
if (this.getCellColour(_local3) == _local6) {
_local11.push(_local3);
} else {
break;
}
_local7++;
}
_local8 = 1;
while (_local8 <= _local16) {
_local3 = tCellNum + (_local8 * 3);
if (this.getCellColour(_local3) == _local6) {
_local11.push(_local3);
} else {
break;
}
_local8++;
}
_local10 = 1;
while (_local10 <= _local15) {
_local3 = tCellNum - _local10;
if (this.getCellColour(_local3) == _local6) {
_local12.push(_local3);
} else {
break;
}
_local10++;
}
_local9 = 1;
while (_local9 <= _local17) {
_local3 = tCellNum + _local9;
if (this.getCellColour(_local3) == _local6) {
_local12.push(_local3);
} else {
break;
}
_local9++;
}
var _local13 = new Array();
_local13.push(tCellNum);
if (_local12.length >= 2) {
_local13 = _local13.concat(_local12);
_parent.scores_mc.updateBonus();
_parent.scores_mc.updateScore(_local12.length + 1);
_parent.fuse_mc.addFuse(_local12.length + 1);
updateBlockCount();
}
if (_local11.length >= 2) {
_local13 = _local13.concat(_local11);
_parent.scores_mc.updateBonus();
_parent.scores_mc.updateScore(_local11.length + 1);
_parent.fuse_mc.addFuse(_local11.length + 1);
updateBlockCount();
}
if (_local13.length > 1) {
var _local18 = _local13.length;
var _local4 = 0;
while (_local4 < _local18) {
this.pData[_local13[_local4]] = 0;
_local4++;
}
}
return(_local13);
};
SmallGrid.prototype.swapBlocks = function (tCellID1, tCellID2) {
var _local3 = this.getCellColour(tCellID1);
var _local2 = this.getCellColour(tCellID2);
this.pData[tCellID1] = _local2;
this.pData[tCellID2] = _local3;
};
SmallGrid.prototype.fillGrid = function () {
var _local3;
var _local5;
var _local6;
var _local4;
var _local2 = 0;
while (_local2 < 9) {
_local3 = this.pColours.slice();
if (Math.round(_local2 % 3) > 1) {
_local6 = this.getCellColour(_local2 - 1);
if ((_local6 - this.getCellColour(_local2 - 2)) == 0) {
_local4 = _local3.getItemIndex(_local6);
_local3.splice(_local4, 1);
}
}
if (Math.floor(_local2 / 3) > 1) {
_local5 = this.getCellColour(_local2 - 3);
if ((_local5 - this.getCellColour(_local2 - 6)) == 0) {
_local4 = _local3.getItemIndex(_local5);
_local3.splice(_local4, 1);
}
}
this.pData[_local2] = _local3[Math.round(Math.random() * (_local3.length - 1))];
_local2++;
}
};
SmallGrid.prototype.getCellColour = function (aNum) {
var _local2 = this.pData[aNum];
return(_local2);
};
SmallGrid.prototype.setCellColour = function (aId, aColour) {
this.pData[aId] = aColour + 0;
};
SmallGrid.prototype.printGrid = function () {
var _local3 = "";
var _local4 = 0;
while (_local4 < 3) {
_local3 = "";
var _local2 = 0;
while (_local2 < 3) {
_local3 = _local3 + this.getCellColour((_local4 * 3) + _local2);
_local2++;
}
trace(_local3);
_local4++;
}
trace("");
};
this.init = function () {
this.pGrid = new SmallGrid();
this.pBlockCount = 0;
this.pSpaces = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0);
this.pTileLocs = new Array(9);
this.pTileCheck = 0;
this.pClearedTiles = new Array();
this.setMask(this.soulMask_mc);
var _local3;
var _local2 = 0;
while (_local2 < 9) {
_local3 = new Object();
_local3.pNum = _local2;
_local3.pPos = new Object();
_local3.pPos.x = -40 + (40 * (_local2 % 3));
_local3.pPos.y = 40 - (40 * Math.floor(_local2 / 3));
_local3.pColour = _local2 + 1;
this.attachMovie("mc.tile", ("t" + _local2) + "_mc", _local2, _local3);
this.pTileLocs[_local2] = ("t" + _local2) + "_mc";
_local2++;
}
};
this.clearMap = function () {
var _local2 = 0;
while (_local2 < 9) {
this[this.pTileLocs[_local2]].hideTile();
this.pSpaces[_local2] = 0;
_local2++;
}
this.pBlockCount = 0;
this.pGrid.clearGrid();
};
this.addTile = function (tTileC) {
if (this.pBlockCount < 9) {
this.pBlockCount++;
var _local2 = this.pSpaces.getItemIndex(0);
this[this.pTileLocs[_local2]].placeTile(140, tTileC);
this.pSpaces[_local2] = 1;
this.pGrid.setCellColour(_local2, tTileC);
this.pTileCheck++;
}
};
this.tileScaleDone = function () {
if ((--this.pTileCheck) == 0) {
var _local8 = this.pClearedTiles.length / 3;
var _local6 = 0;
while (_local6 < _local8) {
var _local7 = this.pClearedTiles[_local6 * 3];
if (_local7 < 6) {
if (_local7 == (this.pClearedTiles[(_local6 * 3) + 1] - 1)) {
var _local4 = 0;
while (_local4 < 3) {
var _local5 = ((_local6 * 3) + _local4) % 3;
var _local3 = 0;
var _local2 = _local5;
while (_local2 < (_local5 + 7)) {
if (this.pSpaces[_local2] == 0) {
_local3++;
} else if (_local3 > 0) {
this[this.pTileLocs[_local2]].hideTile();
this[this.pTileLocs[_local2 - (_local3 * 3)]].placeTile(40, this.pGrid.getCellColour(_local2));
this.pSpaces[_local2] = 0;
this.pSpaces[_local2 - (_local3 * 3)] = 1;
this.pTileCheck++;
}
_local2 = _local2 + 3;
}
_local4++;
}
this.pGrid.reorder();
}
}
_local6++;
}
}
};
this.tileDropDone = function () {
if ((--this.pTileCheck) == 0) {
var _local3 = this.pGrid.checkGrid();
var _local4 = _local3.length;
if (_local4 > 0) {
this.pClearedTiles.splice(0);
var _local2 = 0;
while (_local2 < _local4) {
this[this.pTileLocs[_local3[_local2]]].scaleTile();
this.pGrid.setCellColour(_local3[_local2], 0);
this.pSpaces[_local3[_local2]] = 0;
this.pBlockCount--;
this.pClearedTiles.push(_local3[_local2]);
this.pTileCheck++;
_local2++;
}
if (this._parent._currentframe > 16) {
this._parent.scores_mc.updateScore(100);
}
}
}
};
this.init();
stop();
Symbol 84 MovieClip Frame 53
this._parent.demoSoul_mc.addTile(4);
Symbol 86 MovieClip Frame 1
stop();
Symbol 86 MovieClip Frame 25
this._parent.gotoAndPlay("exit");
Symbol 89 MovieClip Frame 2
function GameGrid(aRange) {
this.init(aRange);
}
GameGrid.prototype.init = function (aRange) {
this.pData = new Array(64);
};
GameGrid.prototype.setRange = function (aRange) {
this.pColours = [1, 2, 3, 4, 5, 6, 7, 8].slice(0, aRange);
this.fillGrid();
};
GameGrid.prototype.checkGrid = function () {
var _local4;
var _local3;
var _local11;
var _local12;
var _local5;
var _local9;
var _local10;
var _local6 = new Array();
_local12 = 0;
_local11 = _local12;
_local3 = _local11;
_local4 = _local3;
_local5 = 0;
while (_local5 < 64) {
_local9 = ((_local5 < 63) ? ((_local5 * 8) % 63) : (_local5));
_local10 = this.getCellColour(_local9);
if (_local10 == _local12) {
_local3++;
} else {
_local12 = _local10;
if (_local3 > 2) {
var _local7 = 1;
while (_local7 <= _local3) {
_local6.push(_local9 - (_local7 * 8));
_local7++;
}
_parent.scores_mc.updateBonus();
_parent.scores_mc.updateScore(_local3);
_parent.pirate_mc.parrot_mc.playCombo();
_parent.timer_mc.addTimer(_local3);
updateBlockCount();
}
_local3 = 1;
}
if (_local9 > 55) {
if (_local3 > 2) {
var _local7 = 0;
while (_local7 < _local3) {
_local6.push(_local9 - (_local7 * 8));
_local7++;
}
_parent.scores_mc.updateBonus();
_parent.scores_mc.updateScore(_local3);
_parent.pirate_mc.parrot_mc.playCombo();
_parent.timer_mc.addTimer(_local3);
updateBlockCount();
}
_local3 = 0;
}
_local10 = this.getCellColour(_local5);
if (_local10 == _local11) {
_local4++;
} else {
_local11 = _local10;
if (_local4 > 2) {
var _local7 = 1;
while (_local7 <= _local4) {
_local6.push(_local5 - _local7);
_local7++;
}
_parent.scores_mc.updateBonus();
_parent.scores_mc.updateScore(_local4);
_parent.pirate_mc.parrot_mc.playCombo();
_parent.timer_mc.addTimer(_local4);
updateBlockCount();
}
_local4 = 1;
}
if (((_local5 + 1) % 8) == 0) {
if (_local4 > 2) {
var _local7 = 0;
while (_local7 < _local4) {
_local6.push(_local5 - _local7);
_local7++;
}
_parent.scores_mc.updateBonus();
_parent.scores_mc.updateScore(_local4);
_parent.pirate_mc.parrot_mc.playCombo();
_parent.timer_mc.addTimer(_local4);
updateBlockCount();
}
_local4 = 0;
}
_local5++;
}
if (_local6.length > 1) {
var _local13 = _local6.length;
var _local8 = 0;
while (_local8 < _local13) {
if (this.getCellColour(_local6[_local8]) == 0) {
_local6.splice(_local8, 1);
_local13--;
_local8--;
} else {
this.pData[_local6[_local8]] = 0;
}
_local8++;
}
}
return(_local6);
};
GameGrid.prototype.removeBlocks = function () {
var _local9 = new Array([], []);
var _local10 = this.pData.slice();
var _local3 = this.pColours.slice();
var _local5;
var _local2;
var _local8;
var _local7 = 56;
while (_local7 < 64) {
_local5 = 0;
_local2 = _local7 + 0;
_local8 = 0;
while (_local2 >= 0) {
if (_local10[_local2] == 0) {
if (_local3.length == 0) {
_local3 = this.pColours.slice();
} else {
var _local4 = _local3[Math.round(Math.random() * (_local3.length - 1))];
_local3.splice(_local3.getItemIndex(_local4), 1);
}
var _local6 = (_local7 - 56) + (_local8 * 8);
_local9[1].push(new Array(_local2, _local6, _local4));
this.pData[_local6] = _local4;
_local8++;
_local5++;
} else if (_local5 > 0) {
_local9[0].push(new Array(_local2, _local5));
this.pData[_local2 + (_local5 * 8)] = _local10[_local2];
}
_local2 = _local2 - 8;
}
_local7++;
}
return(_local9);
};
GameGrid.prototype.checkBlocks = function (tCellNum) {
var _local12;
var _local11;
var _local6;
var _local14;
var _local16;
var _local15;
var _local17;
var _local3;
var _local7;
var _local8;
var _local10;
var _local9;
_local12 = new Array();
_local11 = new Array();
_local6 = this.getCellColour(tCellNum);
_local14 = Math.floor(tCellNum / 8);
_local16 = 7 - _local14;
_local15 = tCellNum - (Math.floor(tCellNum / 8) * 8);
_local17 = 7 - _local15;
_local7 = 1;
while (_local7 <= _local14) {
_local3 = tCellNum - (_local7 * 8);
if (this.getCellColour(_local3) == _local6) {
_local11.push(_local3);
} else {
break;
}
_local7++;
}
_local8 = 1;
while (_local8 <= _local16) {
_local3 = tCellNum + (_local8 * 8);
if (this.getCellColour(_local3) == _local6) {
_local11.push(_local3);
} else {
break;
}
_local8++;
}
_local10 = 1;
while (_local10 <= _local15) {
_local3 = tCellNum - _local10;
if (this.getCellColour(_local3) == _local6) {
_local12.push(_local3);
} else {
break;
}
_local10++;
}
_local9 = 1;
while (_local9 <= _local17) {
_local3 = tCellNum + _local9;
if (this.getCellColour(_local3) == _local6) {
_local12.push(_local3);
} else {
break;
}
_local9++;
}
var _local13 = new Array();
_local13.push(tCellNum);
if (_local12.length >= 2) {
_local13 = _local13.concat(_local12);
_parent.scores_mc.updateBonus();
_parent.scores_mc.updateScore(_local12.length + 1);
_parent.timer_mc.addTimer(_local12.length + 1);
updateBlockCount();
}
if (_local11.length >= 2) {
_local13 = _local13.concat(_local11);
_parent.scores_mc.updateBonus();
_parent.scores_mc.updateScore(_local11.length + 1);
_parent.timer_mc.addTimer(_local11.length + 1);
updateBlockCount();
}
if (_local13.length > 1) {
_parent.soul_mc.addTile(_local6);
var _local18 = _local13.length;
var _local4 = 0;
while (_local4 < _local18) {
this.pData[_local13[_local4]] = 0;
_local4++;
}
}
return(_local13);
};
GameGrid.prototype.swapBlocks = function (tCellID1, tCellID2) {
var _local3 = this.getCellColour(tCellID1);
var _local2 = this.getCellColour(tCellID2);
this.pData[tCellID1] = _local2;
this.pData[tCellID2] = _local3;
};
GameGrid.prototype.fillGrid = function () {
var _local3;
var _local5;
var _local6;
var _local4;
var _local2 = 0;
while (_local2 < 64) {
_local3 = this.pColours.slice();
if (Math.round(_local2 % 8) > 1) {
_local6 = this.getCellColour(_local2 - 1);
if ((_local6 - this.getCellColour(_local2 - 2)) == 0) {
_local4 = _local3.getItemIndex(_local6);
_local3.splice(_local4, 1);
}
}
if (Math.floor(_local2 / 8) > 1) {
_local5 = this.getCellColour(_local2 - 8);
if ((_local5 - this.getCellColour(_local2 - 16)) == 0) {
_local4 = _local3.getItemIndex(_local5);
_local3.splice(_local4, 1);
}
}
this.pData[_local2] = _local3[Math.round(Math.random() * (_local3.length - 1))];
_local2++;
}
};
GameGrid.prototype.getCellColour = function (aNum) {
var _local2 = this.pData[aNum];
return(_local2);
};
GameGrid.prototype.printGrid = function () {
var _local3 = "";
var _local4 = 0;
while (_local4 < 8) {
_local3 = "";
var _local2 = 0;
while (_local2 < 8) {
_local3 = _local3 + this.getCellColour((_local4 * 8) + _local2);
_local2++;
}
trace(_local3);
_local4++;
}
trace("");
};
this.init = function () {
this.pBlockCount = 0;
this.pLevelEnd = false;
this.pRange = 0;
this.pLevel = 1;
this.attachMovie("mc.selector", "selector_mc", 10000);
this.pGrid = new GameGrid(8);
this.pTileLocs = new Array(64);
this.pTileCheck = 0;
this.pSwappedTiles = new Array(2);
this.pClearedTiles = new Array();
this.setMask(this.tileMask_mc);
this.pComboSnd = new Sound(this);
this.pComboSnd.attachSound("snd.combo");
this.pErrorSnd = new Sound(this);
this.pErrorSnd.attachSound("snd.error");
this.pSwishSnd = new Sound(this);
this.pSwishSnd.attachSound("snd.swish");
this.pBellsSnd = new Sound(this);
this.pBellsSnd.attachSound("snd.bells");
var _local3;
var _local2 = 0;
while (_local2 < 64) {
_local3 = new Object();
_local3.pNum = _local2;
_local3.pPos = new Object();
_local3.pPos.x = -140 + (40 * (_local2 % 8));
_local3.pPos.y = -140 + (40 * Math.floor(_local2 / 8));
_local3.pColour = 1;
this.attachMovie("mc.tile", ("t" + _local2) + "_mc", _local2, _local3);
this.pTileLocs[_local2] = ("t" + _local2) + "_mc";
_local2++;
}
};
this.printTileLocs = function () {
var _local6 = 0;
while (_local6 < 8) {
var _local4 = "";
var _local3 = 0;
while (_local3 < 8) {
var _local5 = (_local6 * 8) + _local3;
var _local2 = this.pTileLocs[_local5];
_local2 = _local2.slice(1, -3);
_local4 = (_local4 + _local2) + ", ";
_local3++;
}
trace(_local4);
_local6++;
}
};
this.updateBlockCount = function () {
this.pComboSnd.start();
this.pBlockCount++;
if (this.pLevel < 5) {
this.pLevelEnd = this.pBlockCount >= 20;
}
};
this.gameOver = function () {
this.pTileCheck = 0;
var _local2 = 0;
while (_local2 < 64) {
this[this.pTileLocs[_local2]].destroyTile();
this.pTileCheck++;
_local2++;
}
this.pBellsSnd.start();
};
this.tileDestroyDone = function () {
if ((--this.pTileCheck) == 0) {
this._parent.gameover_mc.gotoAndPlay("end");
}
};
this.swapBlocks = function (aB1, aB2, aReturn) {
this.selector_mc.setActive(false);
var _local5 = -140 + (40 * (aB1 % 8));
var _local7 = -140 + (40 * Math.floor(aB1 / 8));
var _local8 = this.pTileLocs[aB1];
var _local4 = -140 + (40 * (aB2 % 8));
var _local6 = -140 + (40 * Math.floor(aB2 / 8));
var _local9 = this.pTileLocs[aB2];
if (_local4 != _local5) {
var _local10 = ((_local4 > _local5) * 2) - 1;
} else {
var _local10 = ((_local6 > _local7) * 2) - 1;
}
this[_local8].moveTile(_local4, _local6, _local10, aB2);
this[_local9].moveTile(_local5, _local7, _local10, aB1);
this.pSwappedTiles[0] = aB1;
this.pSwappedTiles[1] = aB2;
if (!aReturn) {
this.pSwishSnd.start();
this.pTileCheck = 2;
} else {
this.pErrorSnd.start();
this.selector_mc.setActive(true);
}
this.pTileLocs[aB1] = _local9;
this.pTileLocs[aB2] = _local8;
this.pGrid.swapBlocks(aB1, aB2);
};
this.tileClearDone = function () {
if ((--this.pTileCheck) == 0) {
var _local3 = this.pGrid.removeBlocks();
var _local4 = this.pTileLocs.slice();
var _local9 = _local3[0].length;
var _local2 = 0;
while (_local2 < _local9) {
var _local5 = _local3[0][_local2][0];
var _local6 = _local3[0][_local2][1];
this[_local4[_local5]].dropTile(_local6, _local5);
this.pTileLocs[_local5 + (_local6 * 8)] = _local4[_local5];
this.pTileCheck++;
_local2++;
}
_local9 = _local3[1].length;
_local2 = 0;
while (_local2 < _local9) {
var _local5 = _local3[1][_local2][0];
var _local7 = _local3[1][_local2][1];
var _local8 = _local3[1][_local2][2];
this[_local4[_local5]].renewTile(_local7, _local8);
this.pTileLocs[_local7] = _local4[_local5];
this.pTileCheck++;
_local2++;
}
}
};
this.tileScaleDone = function () {
if ((--this.pTileCheck) == 0) {
this._parent.scores_mc.clearBonus();
this._parent.scores_mc.updateLevel();
this.pRange = Math.min(++this.pRange, 8);
this.loadGrid(this.pRange);
this._parent.timer_mc.increaseSpeed();
this.pLevelEnd = false;
}
};
this.tileDropDone = function () {
if ((--this.pTileCheck) == 0) {
var _local3 = this.pGrid.checkGrid();
var _local4 = _local3.length;
this.pTileCheck = 0;
this.pClearedTiles.splice(0);
if (_local4 > 2) {
var _local2 = 0;
while (_local2 < _local4) {
this[this.pTileLocs[_local3[_local2]]].removeTile();
this.pClearedTiles.push(_local3[_local2]);
this.pTileCheck++;
_local2++;
}
}
if (_local4 == 0) {
if (this.pLevelEnd) {
var _local2 = 0;
while (_local2 < 64) {
this[this.pTileLocs[_local2]].scaleTile();
this.pTileCheck++;
_local2++;
}
this.pLevel++;
this._parent.soul_mc.clearMap();
} else {
this._parent.scores_mc.clearBonus();
this.selector_mc.setActive(true);
this._parent.timer_mc.resumeTimer();
if (this.pBlockCount == 0) {
this.pBellsSnd.start();
}
}
}
}
};
this.tileSwapDone = function () {
if ((--this.pTileCheck) == 0) {
this._parent.timer_mc.pauseTimer();
var _local4 = this.pGrid.checkBlocks(this.pSwappedTiles[0]);
var _local3 = this.pGrid.checkBlocks(this.pSwappedTiles[1]);
var _local5 = _local4.length;
var _local6 = _local3.length;
if (!((_local5 > 2) || (_local6 > 2))) {
this.swapBlocks(this.pSwappedTiles[1], this.pSwappedTiles[0], 1);
this._parent.timer_mc.resumeTimer();
} else {
this.pTileCheck = 0;
this.pClearedTiles.splice(0);
if (_local5 > 2) {
var _local2 = 0;
while (_local2 < _local5) {
this[this.pTileLocs[_local4[_local2]]].removeTile();
this.pClearedTiles.push(_local4[_local2]);
this.pTileCheck++;
_local2++;
}
}
if (_local6 > 2) {
var _local2 = 0;
while (_local2 < _local6) {
this[this.pTileLocs[_local3[_local2]]].removeTile();
this.pClearedTiles.push(_local3[_local2]);
this.pTileCheck++;
_local2++;
}
}
}
}
};
this.loadGrid = function (tRange) {
this.pRange = tRange;
this._parent.timer_mc.resetTimer();
this.pGrid.setRange(tRange);
this.pBlockCount = 0;
var _local3;
var _local2 = 0;
while (_local2 < 64) {
_local3 = this[("t" + _local2) + "_mc"];
_local3.pNum = _local2;
_local3.pPos.x = -140 + (40 * (_local2 % 8));
_local3.pPos.y = -140 + (40 * Math.floor(_local2 / 8));
_local3.pColour = this.pGrid.getCellColour(_local2);
this.pTileLocs[_local2] = ("t" + _local2) + "_mc";
_local3.startTile();
_local2++;
}
this.pTileCheck = 64;
};
this.init();
stop();