home *** CD-ROM | disk | FTP | other *** search
- class MaggieWorld
- {
- var __LOWQUAL;
- var score;
- var oPlayer;
- static var target;
- var nFullTime = 125;
- var cTime = -10;
- var startTime = -10;
- var nTimeDec = 12.5;
- var nLowerTimeLimit = 45;
- var nDist = 10000;
- var germReq = 10;
- var timeBonus = 5000;
- var playerOffset = 100;
- var nPanic = 0.065;
- var __MIN_BENCHMARK = 600;
- function MaggieWorld(loc)
- {
- var _loc1_ = this;
- MaggieWorld.target = _loc1_;
- _loc1_.location = loc;
- _loc1_.oBuildings = new BuildingHandler(_loc1_.location.mcBuildingHolder);
- _loc1_.oBuildings.oWorld = _loc1_;
- _loc1_.oCitizens = new CitizenHandler(_loc1_.location.mcCitizens);
- _loc1_.oCitizens.oBuildings = _loc1_.oBuildings;
- _loc1_.oGerms = new GermHandler(_loc1_.location.mcGermHolder);
- _loc1_.oBuildings.oGerms = _loc1_.oGerms;
- _loc1_.oPlayer = _loc1_.location.mcPlayer;
- _loc1_.oPlayer.setBuilding(_loc1_.oBuildings,_loc1_.oCitizens,_loc1_.oGerms);
- _loc1_.oPlayer.setShadow(_loc1_.location.mcShadow);
- _loc1_.oPlayer.oWorld = _loc1_;
- _loc1_.oBundle = _loc1_.location.mcBundle;
- _loc1_.mcDraw = loc.mcDraw;
- _loc1_.oBundle.init(_loc1_.oPlayer,_loc1_.mcDraw);
- smashing.Menu.watchProp(_loc1_,"lives","text");
- smashing.Menu.watchProp(_loc1_,"level","text");
- smashing.Menu.watchProp(_loc1_,"score","text");
- smashing.Menu.watchProp(_loc1_,"cTimeRatio","funkyMeter");
- smashing.Menu.watchProp(_loc1_,"nDistRatio","funkyMeter");
- _loc1_.lives = 3;
- _loc1_.level = 1;
- _loc1_.score = 0;
- _loc1_.cTimeRatio = 0;
- _loc1_.nDistRatio = 0;
- _loc1_.__LOWQUAL = false;
- if(_global.maggiePerformance.processor < _loc1_.__MIN_BENCHMARK)
- {
- _loc1_.__LOWQUAL = true;
- }
- }
- function onEnter()
- {
- }
- function onExit()
- {
- }
- function onPlay()
- {
- if(this.__LOWQUAL)
- {
- _quality = "MEDIUM";
- }
- else
- {
- _quality = "HIGH";
- }
- }
- function onPause()
- {
- _quality = "HIGH";
- }
- function update(nElapsed)
- {
- var _loc1_ = this;
- var _loc2_ = nElapsed;
- _loc1_.cTime += _loc2_;
- _loc1_.cTimeRatio = _loc1_.cTime / _loc1_.nTime;
- _loc1_.mcDraw.clear();
- _loc1_.oCitizens.setRatio(_loc1_.cTime / _loc1_.nTime);
- _loc1_.oCitizens.update(_loc2_);
- _loc1_.oPlayer.update(_loc2_);
- _loc1_.oBundle.update(_loc2_);
- _loc1_.moveView(_loc2_);
- _loc1_.nDistRatio = smashing.Viewport.x / _loc1_.nDist;
- _loc1_.endCheck();
- _loc1_.oPlayer.render();
- _loc1_.oBundle.render();
- _loc1_.oGerms.update(_loc2_);
- _loc1_.oBuildings.render();
- var _loc3_ = _loc1_.nDistRatio - _loc1_.cTimeRatio;
- _root.nDebug1 = _loc1_.oBuildings.nTotalGerms;
- if(_loc3_ <= _loc1_.nPanic && _loc1_.howFar > 800)
- {
- smashing.Menu.target.funkyMeter.cTimeRatioCap.gotoAndStop("panic");
- }
- else
- {
- smashing.Menu.target.funkyMeter.cTimeRatioCap.gotoAndStop("normal");
- }
- updateAfterEvent();
- }
- function newGame()
- {
- this.startLevel();
- this.score = 0;
- }
- function startLevel()
- {
- var _loc1_ = this;
- var _loc2_ = _global;
- _loc1_.location.bg.gotoAndStop((_loc1_.level - 1) % 3 + 1);
- _loc1_.location.street.gotoAndStop((_loc1_.level - 1) % 3 + 1);
- _loc1_.howFar = 0;
- smashing.Viewport.reset();
- _loc1_.oBuildings.reset();
- _loc1_.oPlayer.reset();
- _loc1_.cTime = _loc1_.startTime;
- _loc1_.oCitizens.reset();
- _loc1_.oCitizens.setLevel(_loc1_.level);
- _loc1_.oGerms.reset();
- _loc1_.moveView = _loc1_.moveViewGame;
- _loc1_.endCheck = _loc1_.endCheckGame;
- _loc1_.cTime = _loc1_.startTime;
- _loc1_.cTimeRatio = 0;
- _loc1_.nTime = Math.max(_loc1_.nFullTime - _loc1_.nTimeDec * _loc1_.level,_loc1_.nLowerTimeLimit);
- _loc1_.nDistRatio = 0;
- _loc1_.oBundle.reset();
- if(_loc2_.bHelp == false)
- {
- _loc2_.mcRoot.startPopup.go();
- }
- if(_loc2_.bMute == false)
- {
- if(_loc2_.bHelp == false)
- {
- _loc2_.mcRoot.mcMusic.play();
- }
- }
- }
- function endLevelPrep()
- {
- var _loc1_ = this;
- _loc1_.endCheck = _loc1_.endCheckEnd;
- _loc1_.oBuildings.addHome();
- }
- function endLevel()
- {
- var _loc1_ = this;
- var _loc3_ = _global;
- _quality = "HIGH";
- _loc3_.mcRoot.mcMusic.oSound.stop();
- if(smashing.Viewport.x < _loc1_.nDist)
- {
- _loc1_.lives = _loc1_.lives - 1;
- if(_loc1_.lives <= 0)
- {
- _loc1_.endGame();
- }
- else
- {
- _loc3_.mcRoot.mcMenu.show("noTime");
- }
- }
- else if(_loc1_.oPlayer.germs < _loc1_.germReq)
- {
- _loc1_.lives = _loc1_.lives - 1;
- if(_loc1_.lives <= 0)
- {
- _loc1_.endGame();
- }
- else
- {
- _loc3_.mcRoot.mcMenu.show("noGerms");
- }
- }
- else
- {
- var finalRatio = _loc1_.nDistRatio - _loc1_.cTimeRatio;
- var _loc2_ = Math.floor(finalRatio * _loc1_.timeBonus);
- smashing.Menu.target.timeBonus = _loc2_;
- smashing.Menu.target.oldScore = _loc1_.score;
- _loc1_.score += _loc2_;
- smashing.Menu.target.newScore = _loc1_.score;
- _loc3_.mcRoot.mcMenu.show("levelEnd");
- _loc1_.level = _loc1_.level + 1;
- }
- }
- function endGame()
- {
- var _loc1_ = _global;
- _quality = "HIGH";
- _loc1_.mcRoot.oBase.pause();
- _loc1_.mcRoot.finalScore = this.score;
- _loc1_.mcRoot.gotoAndStop("end");
- }
- function reset()
- {
- this.cTime = this.startTime;
- }
- function moveViewGame(nElapsed)
- {
- var _loc1_ = this;
- smashing.Viewport.y = _loc1_.oPlayer.y;
- var lowBound = BuildingHandler.floor - smashing.Viewport.halfHeight + 15;
- if(smashing.Viewport.y > lowBound)
- {
- smashing.Viewport.y = lowBound;
- }
- else
- {
- var highBound = BuildingHandler.ceiling + smashing.Viewport.halfHeight;
- if(smashing.Viewport.y < highBound)
- {
- smashing.Viewport.y = highBound;
- }
- }
- var _loc3_ = _loc1_.oPlayer.x + _loc1_.playerOffset;
- if(_loc3_ > smashing.Viewport.startX)
- {
- smashing.Viewport.x = _loc3_;
- }
- else
- {
- smashing.Viewport.x = smashing.Viewport.startX;
- }
- var _loc2_ = BuildingHandler.homeLimit;
- if(_loc2_ != undefined)
- {
- if(smashing.Viewport.x > _loc2_)
- {
- smashing.Viewport.x = _loc2_;
- }
- }
- if(smashing.Viewport.x > _loc1_.howFar)
- {
- _loc1_.howFar = smashing.Viewport.x;
- }
- }
- function moveViewEnd(nElapsed)
- {
- smashing.Viewport.y = this.oPlayer.y;
- var _loc2_ = BuildingHandler.floor - smashing.Viewport.halfHeight + 15;
- if(smashing.Viewport.y > _loc2_)
- {
- smashing.Viewport.y = _loc2_;
- }
- else
- {
- var highBound = BuildingHandler.ceiling + smashing.Viewport.halfHeight;
- if(smashing.Viewport.y < highBound)
- {
- smashing.Viewport.y = highBound;
- }
- }
- var _loc1_ = this.oPlayer.x + this.playerOffset;
- if(_loc1_ - smashing.Viewport.x > 0)
- {
- smashing.Viewport.x = _loc1_;
- }
- var _loc3_ = BuildingHandler.home;
- var rightBorder = _loc3_.x + _loc3_._width - smashing.Viewport.halfWidth;
- if(smashing.Viewport.x > rightBorder)
- {
- smashing.Viewport.x = rightBorder;
- }
- }
- function endCheckGame()
- {
- var _loc1_ = this;
- if(_loc1_.cTimeRatio > _loc1_.nDistRatio)
- {
- _loc1_.endLevel();
- }
- if(smashing.Viewport.x >= _loc1_.nDist)
- {
- _loc1_.endLevelPrep();
- }
- }
- function endCheckEnd()
- {
- var _loc1_ = this;
- if(_loc1_.cTimeRatio > _loc1_.nDistRatio)
- {
- _loc1_.endLevel();
- }
- if(_loc1_.oPlayer.hitTest(BuildingHandler.home.mcHitArea))
- {
- _loc1_.endLevel();
- }
- }
- static function addScore(nScore)
- {
- MaggieWorld.target.score += nScore;
- }
- }
-