home *** CD-ROM | disk | FTP | other *** search
- buildMap = function(xLoc, yLoc)
- {
- this.container_mc.attachMovie(_global.levelMap,_global.levelMap,_global.levelNumber);
- this.container_mc[levelMap]._x = xLoc - 2;
- this.container_mc[levelMap]._y = yLoc - 2;
- this.container_mc.createEmptyMovieClip("boardMC",50);
- this.container_mc.boardMC._x = xLoc;
- this.container_mc.boardMC._y = yLoc;
- i = 0;
- while(i < mapH)
- {
- j = 0;
- while(j < MapW)
- {
- this.container_mc.boardMC.attachMovie("tile","t_" + i + "_" + j,++d);
- this.container_mc.boardMC["t_" + i + "_" + j]._x = j * tileW;
- this.container_mc.boardMC["t_" + i + "_" + j]._y = i * tileH;
- if(myMap[i][j][0] == "d0")
- {
- _global.dirtCount += 1;
- }
- if(myMap[i][j][0] == "p0")
- {
- this.container_mc.boardMC["t_" + i + "_" + j].x = j;
- this.container_mc.boardMC["t_" + i + "_" + j].y = i;
- }
- if(myMap[i][j][1] == 9)
- {
- this.container_mc.boardMC["t_" + i + "_" + j].xTile = j;
- this.container_mc.boardMC["t_" + i + "_" + j].yTile = i;
- this.container_mc.boardMC["t_" + i + "_" + j].onEnterFrame = exitTile;
- }
- this.container_mc.boardMC["t_" + i + "_" + j].gotoAndStop(myMap[i][j][0]);
- j++;
- }
- i++;
- }
- };
- buildCharacters = function(xLoc, yLoc)
- {
- this.container_mc.createEmptyMovieClip("playersMC",51);
- this.container_mc.playersMC._x = xLoc;
- this.container_mc.playersMC._y = yLoc;
- i = 0;
- while(i < myCharacters.length)
- {
- if(myCharacters[i][0] == "H")
- {
- myMapHeroStartX = myCharacters[i][1];
- myMapHeroStartY = myCharacters[i][2];
- placeHero();
- }
- else if(myCharacters[i][0] == "V")
- {
- placeVillan(myCharacters[i][1],myCharacters[i][2],i);
- }
- i++;
- }
- };
- placeHero = function()
- {
- this.container_mc.playersMC.attachMovie("hero","hero",100);
- this.container_mc.playersMC.hero._x = myMapHeroStartX * tileW + tileW / 2;
- this.container_mc.playersMC.hero._y = myMapHeroStartY * tileH + tileH / 2;
- _global.heroDuration = 18;
- _global.heroState = 3;
- _global.heroStateBaseTime = _global.masterClock;
- };
- placeVillan = function(startX, startY, number)
- {
- this.container_mc.playersMC.attachMovie("villan","villan" + number,number);
- this.container_mc.playersMC["villan" + number]._x = startX * tileW + tileW / 2;
- this.container_mc.playersMC["villan" + number]._y = startY * tileH + tileH / 2;
- _global.dirtCount += 1;
- _global.villanCount += 1;
- };
- powerUp = function(x, y)
- {
- this.attachMovie("hundredpoints","pointspopup" + x,x = x + 1);
- this["pointspopup" + x]._x = x + this.container_mc._x;
- this["pointspopup" + x]._y = y + _global.containerStartY;
- _global.gameScore += 100;
- _global.heroDuration = _global.levelHeroDuration;
- _global.heroState = 1;
- _global.heroStateBaseTime = _global.masterClock;
- };
- killHero = function(x, y)
- {
- this.playSfxHero();
- this.attachMovie("minushundred","pointspopup" + x,x = x + 1);
- this["pointspopup" + x]._x = x + this.container_mc._x;
- this["pointspopup" + x]._y = y + _global.containerStartY;
- _global.gameScore -= 100;
- _global.heroTile = 0;
- if(_global.heroLives > 0)
- {
- _global.heroLives -= 1;
- this.placeHero();
- }
- else
- {
- _global.levelDone = true;
- _global.heroLives -= 1;
- this.levelScore();
- this.container_mc.playersMC.hero.removeMovieClip();
- this.tint.fadeMe = "up";
- }
- };
- killVillan = function(myName, x, y)
- {
- this.playSfxVillan();
- this.attachMovie("fiftypoints","pointspopup" + x,x = x + 1);
- this["pointspopup" + x]._x = x + this.container_mc._x;
- this["pointspopup" + x]._y = y + _global.containerStartY;
- this.container_mc.playersMC[myName].baseTime = _global.masterClock;
- this.container_mc.playersMC[myName].dead = true;
- this.container_mc.playersMC[myName].xtile = heroTile[0];
- this.container_mc.playersMC[myName].ytile = heroTile[1];
- this.container_mc.playersMC[myName]._x = -5000;
- this.container_mc.playersMC[myName]._y = -5000;
- _global.dirtCount -= 1;
- _global.villanCount -= 1;
- _global.levelDust += 1;
- _global.gameScore += 50;
- };
- _global.pupTile = function()
- {
- if(this._global.masterClock - this.baseTime > this._global.cycloneRespon)
- {
- if(this._global.villanCount != 0 && this._global.dirtCount != 0)
- {
- if(this._global.myMap[this.y][this.x][0] != "c0")
- {
- _global.dirtCount -= 1;
- }
- this.gotoAndStop("p0");
- this._global.myMap[this.y][this.x][0] = "p0";
- delete this.onEnterFrame;
- }
- }
- if(_global.levelStarted == true && _global.levelDone == true && _global.fusionExit == true)
- {
- this._global.myMap[this.y][this.x][0] = "p0";
- delete this.onEnterFrame;
- }
- };
- _global.exitTile = function()
- {
- if(_global.dirtCount == 0 && this._global.levelDone != true)
- {
- if(this._global.heroTile[0] == this.xTile && this._global.heroTile[1] == this.yTile)
- {
- this._global.levelDone = true;
- this._parent._parent._parent.stopSfxPup();
- this._parent._parent._parent.playSfxExit();
- this._parent._parent._parent.container_mc.playersMC.hero._x = this._x + _global.tileW / 2;
- }
- }
- };
- levelBuild = function()
- {
- this.setDynamics();
- this.buildMap(xLoc,yLoc);
- this.buildCharacters(xLoc,yLoc);
- _global.levelBaseTime = _global.masterClock;
- _global.levelStarted = true;
- };
- levelScore = function()
- {
- this.scoring.displayDirt = 10 * _global.levelDirt;
- this.scoring.displayDust = 50 * _global.levelDust;
- this.scoring.displayPup = 100 * _global.levelPup;
- if(_global.heroLives >= 0)
- {
- if(_global.levelParTime >= _global.levelSecondsTime)
- {
- this.scoring.displayTime = 50 * (_global.levelParTime - _global.levelSecondsTime);
- }
- else
- {
- this.scoring.displayTime = -5 * (_global.levelSecondsTime - _global.levelParTime);
- }
- }
- else
- {
- this.scoring.displayTime = 0;
- }
- _global.levelTally = this.scoring.displayDirt + this.scoring.displayDust + this.scoring.displayPup + this.scoring.displayTime;
- this.scoring.displayTotal = _global.levelTally;
- };
- this.levelBuild();
-