home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Aventura / starisland.swf / scripts / __Packages / illusoft / GameTile012.as < prev    next >
Encoding:
Text File  |  2007-12-10  |  4.4 KB  |  161 lines

  1. class illusoft.GameTile012 extends illusoft.GameTile
  2. {
  3.    var lastTime;
  4.    var nt;
  5.    var character;
  6.    var dmc;
  7.    var game;
  8.    var Enemy;
  9.    var dynamicsEngine;
  10.    var impressed = false;
  11.    var StartedAnt0 = false;
  12.    var StartedAnt1 = false;
  13.    var StartedAnt2 = false;
  14.    var StartedAnt4 = false;
  15.    function GameTile012(id, dEngine, character, game, gamemc, nextLevel)
  16.    {
  17.       super(id,dEngine,character,game,gamemc,nextLevel);
  18.       this.lastTime = new Date().getTime();
  19.    }
  20.    function Update(x)
  21.    {
  22.       super.Update(x);
  23.       this.nt = new Date().getTime();
  24.       this.checkJumper();
  25.       if(this.dmc.downer.fblock.red_btn.hitTest(this.character.dmc))
  26.       {
  27.          this.character.dmc._visible = false;
  28.          this.dmc.downer.ch._visible = true;
  29.          this.impressed = true;
  30.       }
  31.       if(this.impressed)
  32.       {
  33.          this.dmc.downer.play();
  34.          this.DoMovie();
  35.       }
  36.       if(!this.StartedAnt0)
  37.       {
  38.          this.startAnts(0);
  39.       }
  40.       if(!this.StartedAnt1)
  41.       {
  42.          this.startAnts(1);
  43.       }
  44.       if(!this.StartedAnt2)
  45.       {
  46.          this.startAnts(2);
  47.       }
  48.       if(!this.StartedAnt4)
  49.       {
  50.          this.startAnts(4);
  51.       }
  52.       this.checkChild(1);
  53.       this.checkChild(2);
  54.       this.FindChild(3);
  55.       this.checkChild(4);
  56.       this.checkChild(0);
  57.    }
  58.    function startAnts(yourAnt)
  59.    {
  60.       var temp = this.dmc + ".Driver" + yourAnt;
  61.       if(this.character.dmc.hitTest(temp))
  62.       {
  63.          switch(yourAnt)
  64.          {
  65.             case 0:
  66.                this.StartedAnt0 = true;
  67.                break;
  68.             case 1:
  69.                this.StartedAnt1 = true;
  70.                break;
  71.             case 2:
  72.                this.StartedAnt2 = true;
  73.                break;
  74.             case 4:
  75.                this.StartedAnt4 = true;
  76.          }
  77.          eval(this.dmc + ".ant" + yourAnt).play();
  78.       }
  79.    }
  80.    function FindChild(mychild)
  81.    {
  82.       var temp = eval(this.dmc + "." + "childChar" + mychild);
  83.       if(this.character.dmc.hitTest(temp) && temp._visible)
  84.       {
  85.          temp._visible = false;
  86.          _global.sounds.PlaySound("bling");
  87.          this.character.FoundChild(temp._name);
  88.       }
  89.    }
  90.    function checkChild(mychild)
  91.    {
  92.       var temp = eval(this.dmc + ".ant" + mychild);
  93.       if(this.character.dmc.hitTest(temp.antbody.ChildBody) && temp.antbody.childCharN._visible)
  94.       {
  95.          _global.sounds.PlaySound("bling");
  96.          this.character.FoundChild(temp._name);
  97.          temp.stop();
  98.          temp.antbody.childCharN._visible = false;
  99.          var i = 0;
  100.          while(i < this.game.arrEnemy.length)
  101.          {
  102.             if(this.game.arrEnemy[i] == "ant" + mychild + ".antbody")
  103.             {
  104.                this.game.DeleteEnemy(i,"die");
  105.             }
  106.             i++;
  107.          }
  108.       }
  109.    }
  110.    function checkJumper()
  111.    {
  112.       if(this.character.dmc.hitTest(this.dmc.button1))
  113.       {
  114.          this.character.MoveUp(30);
  115.          if(this.nt - this.lastTime > 500)
  116.          {
  117.             _global.sounds.PlaySound("boing");
  118.             this.lastTime = this.nt;
  119.          }
  120.       }
  121.    }
  122.    function DoMovie()
  123.    {
  124.       var _loc2_ = this.game.camYSpeed;
  125.       this.game.camYSpeed = 0.5;
  126.       if(this.dmc.downer._currentframe > 5 && this.dmc.downer._currentframe <= 15)
  127.       {
  128.          illusoft.Game.Instance.character.wheelPrimitive.setPos(this.dmc.downer._x + this.dmc.downer.ch._x,this.dmc.downer._y + this.dmc.downer.ch._y);
  129.       }
  130.       if(this.dmc.downer._currentframe == 15)
  131.       {
  132.          this.dmc.downer._visible = false;
  133.          this.character.dmc._visible = true;
  134.          this.game.camYSpeed = _loc2_;
  135.          this.character.KillEnemy();
  136.          this.impressed = false;
  137.       }
  138.    }
  139.    function Init()
  140.    {
  141.       super.Init();
  142.       _global.sounds.StartMusic("loop3");
  143.       this.StartedAnt0 = false;
  144.       this.StartedAnt1 = false;
  145.       this.StartedAnt2 = false;
  146.       this.StartedAnt4 = false;
  147.       this.lastTime = new Date().getTime();
  148.       this.Enemy = "ant1.antbody/ant2.antbody/ant4.antbody/ant0.antbody/";
  149.       var c = new org.cove.flade.surfaces.CircleTile(this.dmc.myCir1._x,this.dmc.myCir1._y,this.dmc.myCir1._width / 2,this.dmc);
  150.       c.onContact = function()
  151.       {
  152.          delete c;
  153.       };
  154.       this.dynamicsEngine.addSurface(c);
  155.    }
  156.    function Close()
  157.    {
  158.       super.Close();
  159.    }
  160. }
  161.