home *** CD-ROM | disk | FTP | other *** search
- class illusoft.GameTile
- {
- var id;
- var dynamicsEngine;
- var character;
- var gameMC;
- var game;
- var nextLevel;
- var surfaces;
- var surfaceStatus;
- var dmc;
- var Enemy;
- var edges;
- var childs;
- var gate1;
- var portal;
- var jetstream;
- var normalGravities;
- var button1;
- var portal_graph;
- var helps;
- var rrs;
- var onEnterFrame;
- var _parent;
- var levelComplete;
- var startTime = 0;
- var missionTime = 180000;
- var pauseTime = 0;
- var groundx = 0;
- var groundy = 0;
- var isActive = false;
- var minX = 0;
- var maxX = 0;
- function GameTile(id, dEngine, character, game, gamemc, nextLevel)
- {
- this.id = id;
- this.dynamicsEngine = dEngine;
- this.character = character;
- this.gameMC = gamemc;
- this.game = game;
- var _loc2_ = this;
- this.nextLevel = nextLevel;
- this.surfaces = new Array();
- this.surfaceStatus = new Array();
- }
- function GetCharMC()
- {
- return this.dmc.char;
- }
- function Setup(gx, gy, surfaceData, childs, gate1Ar, portalAr, jetAr, normalGravities, switch1Ar, portalGrAr, helps, rrs)
- {
- this.groundx = gx;
- this.groundy = gy;
- this.dmc._x = - this.groundx;
- this.dmc._y = - this.groundy;
- this.GenerateSurfaces(surfaceData,- gx,- gy);
- this.GenerateChilds(childs,- gx,- gy);
- this.GenerateGate(gate1Ar,- gx,- gy,switch1Ar);
- this.GeneratePortal(portalAr,- gx,- gy);
- this.GenerateJetStream(jetAr,- gx,- gy);
- this.GenerateNormalGravities(normalGravities,- gx,- gy);
- this.GenerateRoundedRects(rrs,- gx,- gy);
- this.GenerateExPortal(portalGrAr,- gx,- gy);
- this.GenerateHelps(helps,- gx,- gy);
- }
- function GetBounds()
- {
- return {left:this.dmc._x,right:this.dmc._x + this.dmc._width};
- }
- function GenerateGate(gateAr, dx, dy, switchAr)
- {
- if(gateAr != null)
- {
- var _loc4_ = this.AddGate(gateAr[0] + dx,gateAr[1] + dy,gateAr[2],gateAr[3],gateAr[4]);
- if(switchAr != null)
- {
- this.AddSwitch(switchAr[0] + dx,switchAr[1] + dy,switchAr[2],switchAr[3],switchAr[4],_loc4_);
- }
- }
- }
- function GeneratePortal(portalAr, dx, dy)
- {
- this.AddPortal(portalAr[0] + dx,portalAr[1] + dy,portalAr[2],portalAr[3],portalAr[4]);
- }
- function GenerateExPortal(portalAr, dx, dy)
- {
- if(portalAr != null)
- {
- this.AddExPortal(portalAr[0] + dx,portalAr[1] + dy,portalAr[2],portalAr[3],portalAr[4]);
- }
- }
- function GenerateJetStream(jetAr, dx, dy)
- {
- if(jetAr != null)
- {
- this.AddJetStream(jetAr[0] + dx,jetAr[1] + dy,jetAr[2],jetAr[3],jetAr[4]);
- }
- }
- function GenerateChilds(childs, dx, dy)
- {
- var _loc3_ = 0;
- while(_loc3_ < childs.length)
- {
- var _loc2_ = childs[_loc3_];
- if(_loc2_ != null)
- {
- this.AddChildChar(_loc2_[0] + dx,_loc2_[1] + dy,_loc2_[2],_loc2_[3],_loc2_[4]);
- }
- _loc3_ = _loc3_ + 1;
- }
- }
- function GenerateNormalGravities(normalGravities, dx, dy)
- {
- var _loc3_ = 0;
- while(_loc3_ < normalGravities.length)
- {
- var _loc2_ = normalGravities[_loc3_];
- if(_loc2_ != null)
- {
- this.AddNormalGravity(_loc2_[0] + dx,_loc2_[1] + dy,_loc2_[2],_loc2_[3],_loc2_[4]);
- }
- _loc3_ = _loc3_ + 1;
- }
- }
- function GenerateRoundedRects(rrs, dx, dy)
- {
- var _loc3_ = 0;
- while(_loc3_ < rrs.length)
- {
- var _loc2_ = rrs[_loc3_];
- if(_loc2_ != null)
- {
- this.AddRoundedRect(_loc2_[0] + dx,_loc2_[1] + dy,_loc2_[2],_loc2_[3],_loc2_[4]);
- }
- _loc3_ = _loc3_ + 1;
- }
- }
- function GenerateHelps(helps, dx, dy)
- {
- var _loc3_ = 0;
- while(_loc3_ < helps.length)
- {
- var _loc2_ = helps[_loc3_];
- if(_loc2_ != null)
- {
- this.AddHelp(_loc2_[0] + dx,_loc2_[1] + dy,_loc2_[2],_loc2_[3],_loc2_[4]);
- }
- _loc3_ = _loc3_ + 1;
- }
- }
- function Update(x)
- {
- var _loc5_ = Math.round(x / 150);
- var _loc2_ = this.minX;
- while(_loc2_ < this.maxX)
- {
- var _loc4_ = _loc2_ == _loc5_ || _loc2_ + 1 == _loc5_ || _loc2_ - 1 == _loc5_;
- if(this.surfaceStatus[_loc2_] != _loc4_)
- {
- var _loc3_ = 0;
- while(_loc3_ < this.surfaces.length)
- {
- this.surfaces[_loc2_][_loc3_].setActiveState(_loc4_);
- _loc3_ = _loc3_ + 1;
- }
- this.surfaceStatus[_loc2_] = _loc4_;
- }
- _loc2_ = _loc2_ + 1;
- }
- }
- function GenerateSurfaces(surfaceData, dx, dy)
- {
- var cref = this;
- var _loc7_ = 0;
- while(_loc7_ < surfaceData.length)
- {
- var _loc4_ = surfaceData[_loc7_];
- var _loc3_ = _loc4_[0] + dx;
- var _loc10_ = _loc4_[1] + dy;
- var _loc2_ = _loc4_[2] + dx;
- var _loc9_ = _loc4_[3] + dy;
- if(this.minX == null || _loc3_ < this.minX)
- {
- this.minX = _loc3_;
- }
- else if(this.maxX == null || _loc3_ > this.maxX)
- {
- this.maxX = _loc3_;
- }
- if(_loc2_ < this.minX)
- {
- this.minX = _loc2_;
- }
- else if(_loc2_ > this.maxX)
- {
- this.maxX = _loc2_;
- }
- var _loc5_ = Math.round((_loc3_ + _loc2_) / 300);
- if(this.surfaces[_loc5_] == null)
- {
- this.surfaces[_loc5_] = new Array();
- this.surfaceStatus[_loc5_] = true;
- }
- var _loc11_ = _loc4_[4];
- var _loc6_ = new org.cove.flade.surfaces.LineSurface(_loc3_,_loc10_,_loc2_,_loc9_,this.gameMC);
- this.surfaces[_loc5_].push(_loc6_);
- this.dynamicsEngine.addSurface(_loc6_);
- var _loc8_ = _loc2_ - _loc3_;
- var _loc12_ = _loc9_ - _loc10_;
- if(_loc8_ != 0 && Math.abs(_loc12_ / _loc8_) < 1.3 && _loc11_ && _loc8_ > 0)
- {
- _loc6_.onContact = function()
- {
- cref.character.AllowJump(true,this);
- };
- }
- _loc7_ = _loc7_ + 1;
- }
- }
- function AddLineSurface(line, allowJump)
- {
- this.surfaces.push(line);
- var cref = this;
- line.onContact = function()
- {
- cref.character.AllowJump(allowJump);
- };
- this.dynamicsEngine.addSurface(line);
- }
- function AddCircleSurface(circle, allowJump)
- {
- this.surfaces.push(circle);
- var cref = this;
- circle.onContact = function()
- {
- cref.character.AllowJump(allowJump);
- };
- this.dynamicsEngine.addSurface(circle);
- }
- function SetActive(active)
- {
- if(this.isActive != active)
- {
- for(var _loc4_ in this.surfaces)
- {
- var _loc2_ = this.surfaces[_loc4_];
- _loc2_.setActiveState(active);
- }
- this.isActive = active;
- }
- }
- function Start()
- {
- if(_root.pad1 != undefined)
- {
- removeMovieClip(_root.pad1);
- }
- illusoft.Game.Instance.running = true;
- this.character.ShowInfo(_root);
- this.game.arrEnemy = this.Enemy.split("/");
- this.game.protecttime = 60;
- trace("Start:" + this.id);
- if(SharedObject.getLocal("Agame.starisland").data[this.id] == null)
- {
- SharedObject.getLocal("Agame.starisland").data[this.id] = 0;
- SharedObject.getLocal("Agame.starisland").data[this.id].flush();
- }
- var _loc4_ = SharedObject.getLocal("Agame.starisland").data[this.id];
- var _loc3_ = _loc4_ % 60;
- this.character.info_mc.RegTime.text = int(_loc4_ / 60) + " " + (_loc3_ >= 10 ? _loc3_ : "0" + _loc3_);
- }
- function Init()
- {
- var classRef = this;
- this.game.chafe = 1;
- this.game.Thisscore = 0;
- this.game.GetStars = 0;
- this.game.KilledEnemies = 0;
- this.dmc = this.gameMC.attachMovie(this.id,this.id + new Date().getTime(),this.gameMC.getNextHighestDepth());
- this.dmc.onEnterFrame = function()
- {
- classRef.Setup(this.groundx,this.groundy,this.edges,this.childs,this.gate1,this.portal,this.jetstream,this.normalGravities,this.button1,this.portal_graph,this.helps,this.rrs);
- delete this.onEnterFrame;
- };
- }
- function AddRectangleSurface(surface, allowJump)
- {
- this.surfaces.push(surface);
- var cref = this;
- surface.onContact = function()
- {
- cref.character.AllowJump(allowJump);
- };
- this.dynamicsEngine.addSurface(surface);
- }
- function AddRectangleSurface2(surface, allowJump)
- {
- this.surfaces.push(surface);
- var _loc2_ = this;
- surface.onContact = function()
- {
- surface.setActiveState(false);
- };
- this.dynamicsEngine.addSurface(surface);
- }
- function AddRoundedRectangle(rr)
- {
- this.surfaces.push(rr);
- this.dynamicsEngine.addSurface(rr);
- }
- function AddChildChar(xPos, yPos, width, height, mc)
- {
- var rc = new illusoft.utils.RectangleCheck(xPos,yPos,width,height,this.gameMC);
- this.surfaces.push(rc);
- var cref = this;
- mc._visible = true;
- rc.onContact = function()
- {
- rc.setActiveState(false);
- rc.setVisible(false);
- _global.sounds.PlaySound("bling");
- mc._visible = false;
- cref.character.FoundChild(mc._name);
- };
- this.dynamicsEngine.addSurface(rc);
- }
- function AddJetStream(xPos, yPos, width, height, mc)
- {
- var _loc2_ = new illusoft.utils.RectangleCheck(xPos,yPos,width,height,this.gameMC);
- this.surfaces.push(_loc2_);
- var cref = this;
- mc._visible = false;
- _loc2_.onContact = function()
- {
- cref.game.Stream();
- cref.character.AllowJump(false);
- };
- this.dynamicsEngine.addSurface(_loc2_);
- }
- function AddNormalGravity(xPos, yPos, width, height, mc)
- {
- var _loc2_ = new illusoft.utils.RectangleCheck(xPos,yPos,width,height,this.gameMC);
- this.surfaces.push(_loc2_);
- var cref = this;
- mc._visible = false;
- _loc2_.onContact = function()
- {
- cref.game.NormalGravity();
- cref.character.AllowJump(false);
- };
- this.dynamicsEngine.addSurface(_loc2_);
- }
- function AddRoundedRect(xPos, yPos, width, height, mc)
- {
- var _loc2_ = new illusoft.utils.RoundedRectangle(xPos,yPos,width,height,25,this.dynamicsEngine,this.character,this.gameMC);
- this.surfaces.push(_loc2_);
- var _loc3_ = this;
- mc._visible = false;
- _loc2_.onContact = function()
- {
- };
- this.dynamicsEngine.addSurface(_loc2_);
- }
- function AddGate(xPos, yPos, width, height, mc, switchAr)
- {
- var _loc2_ = new org.cove.flade.surfaces.RectangleTile(xPos,yPos,width,height,this.gameMC);
- this.gate1 = new illusoft.Gate(mc,_loc2_);
- this.surfaces.push(_loc2_);
- var cref = this;
- mc._visible = true;
- _loc2_.onContact = function()
- {
- cref.CheckGate();
- };
- this.dynamicsEngine.addSurface(_loc2_);
- return this.gate1;
- }
- function AddHelp(xPos, yPos, width, height, mc, switchAr)
- {
- var _loc2_ = new illusoft.utils.RectangleCheck(xPos,yPos,width,height,this.gameMC);
- var help = new illusoft.Help(mc,_loc2_,this.game);
- this.surfaces.push(_loc2_);
- var _loc4_ = this;
- mc._visible = true;
- _loc2_.onContact = function()
- {
- help.Show();
- };
- this.dynamicsEngine.addSurface(_loc2_);
- }
- function AddSwitch(xPos, yPos, width, height, mc, gate)
- {
- var _loc2_ = new org.cove.flade.surfaces.CircleTile(xPos,yPos,width / 2,this.gameMC);
- this.surfaces.push(_loc2_);
- _loc2_.onContact = function()
- {
- gate.Open();
- };
- this.dynamicsEngine.addSurface(_loc2_);
- var _loc3_ = new illusoft.Switch(mc,_loc2_);
- gate.SetSwitch(_loc3_);
- }
- function AddPortal(xPos, yPos, width, height, mc)
- {
- var _loc4_ = new org.cove.flade.surfaces.RectangleTile(xPos,yPos,width,height,this.gameMC);
- this.portal = new illusoft.Portal(mc,_loc4_);
- this.surfaces.push(_loc4_);
- var cref = this;
- mc._visible = true;
- mc.AniDone = function()
- {
- cref.GoToNextLevel();
- };
- mc.RotateDone = function()
- {
- illusoft.Game.Instance.running = false;
- var _loc3_ = this._parent.levelComplete;
- _loc3_._x = - cref.gameMC._x + 250;
- _loc3_._y = - cref.gameMC._y + 120;
- _loc3_.gotoAndPlay(1);
- _loc3_._visible = true;
- cref.game.listenForKeys = false;
- cref.GetCharMC()._visible = false;
- _global.sounds.PlaySound("surprise");
- };
- _loc4_.onContact = function()
- {
- cref.CheckPortal();
- };
- this.dynamicsEngine.addSurface(_loc4_);
- }
- function AddExPortal(xPos, yPos, width, height, mc)
- {
- var _loc2_ = new org.cove.flade.surfaces.RectangleTile(xPos,yPos,width,height,this.gameMC);
- this.surfaces.push(_loc2_);
- var _loc4_ = this;
- mc._visible = true;
- mc.stars._visible = false;
- this.dynamicsEngine.addSurface(_loc2_);
- }
- function CheckPortal()
- {
- if(this.character.HasAllChilds())
- {
- this.LevelComplete();
- this.game.LevelComplete();
- this.portal.Open();
- }
- }
- function LevelComplete()
- {
- }
- function GetPortalPos()
- {
- var _loc2_ = this.dmc.portal;
- return new illusoft.utils.Point(_loc2_._x + _loc2_._width / 2,_loc2_._y + _loc2_._height / 2);
- }
- function CheckGate()
- {
- }
- function OpenGate()
- {
- if(this.gate1 != null)
- {
- this.gate1.Open();
- }
- }
- function HasAllChilds()
- {
- }
- function GoToNextLevel()
- {
- this.game.GoToNextLevel();
- }
- function Close()
- {
- this.dmc._visible = false;
- this.character.HideInfo();
- this.Enemy = "";
- this.game.SetUnderWater(false);
- this.game.NormalGravity();
- this.dynamicsEngine.ClearSurfaces();
- removeMovieClip(this.dmc);
- delete this.dmc;
- }
- function StartToTime()
- {
- this.startTime = getTimer();
- trace(this.startTime);
- this.levelComplete = false;
- this.character.info_mc.txtChild.text = "0/5";
- this.character.info_mc.txtScore.text = this.game.Totalscore;
- this.character.UpdateBlood(true);
- }
- function GetPlayedTime()
- {
- if(this.game.listenForKeys)
- {
- return this.pauseTime - this.startTime;
- }
- return this.pauseTime - this.startTime;
- }
- function GetTimeLeft()
- {
- if(this.game.listenForKeys)
- {
- if(this.pauseTime != 0)
- {
- this.startTime += getTimer() - this.pauseTime;
- this.pauseTime = 0;
- }
- return this.missionTime + this.startTime - getTimer();
- }
- if(this.pauseTime == 0)
- {
- this.pauseTime = getTimer();
- }
- return this.missionTime + this.startTime - this.pauseTime;
- }
- }
-