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

  1. class illusoft.GameTile013 extends illusoft.GameTile
  2. {
  3.    var levelComplete;
  4.    var dmc;
  5.    var character;
  6.    var lastTime;
  7.    var myCurrentwindmill;
  8.    var r1;
  9.    var r2;
  10.    var r3;
  11.    var r4;
  12.    var Enemy;
  13.    var gameMC;
  14.    var surfaces;
  15.    var dynamicsEngine;
  16.    var allowedTime = 15;
  17.    var doAttack = false;
  18.    var Duration = 0;
  19.    function GameTile013(id, dEngine, character, game, gamemc, nextLevel)
  20.    {
  21.       super(id,dEngine,character,game,gamemc,nextLevel);
  22.    }
  23.    function Update(x)
  24.    {
  25.       super.Update(x);
  26.       if(!this.levelComplete)
  27.       {
  28.          if(x > 900 && x < 2733 || x > 3600 && x < 5400)
  29.          {
  30.             _global.sounds.LoopSound("fc",100);
  31.          }
  32.          else
  33.          {
  34.             _global.sounds.FadeVolume("fc",false,false);
  35.          }
  36.          if(this.character.dmc.hitTest(this.dmc.bee1.sou) && this.dmc.bee1._visible || this.character.dmc.hitTest(this.dmc.bee2.sou) && this.dmc.bee2._visible || this.character.dmc.hitTest(this.dmc.bee3.sou) && this.dmc.bee3._visible || this.character.dmc.hitTest(this.dmc.bee4.sou) && this.dmc.bee4._visible || this.character.dmc.hitTest(this.dmc.bee5.sou) && this.dmc.bee5._visible || this.character.dmc.hitTest(this.dmc.bee6.sou) && this.dmc.bee6._visible || this.character.dmc.hitTest(this.dmc.bee7.sou) && this.dmc.bee7._visible)
  37.          {
  38.             _global.sounds.LoopSound("bee",100);
  39.          }
  40.          else
  41.          {
  42.             _global.sounds.FadeVolume("bee",false,false);
  43.          }
  44.       }
  45.       var _loc5_ = new Date().getTime();
  46.       if(this.character.dmc.hitTest(this.dmc.mine1))
  47.       {
  48.          this.dmc.mine1.play();
  49.          if(_loc5_ - this.lastTime > 1000)
  50.          {
  51.             _global.sounds.PlaySound("explode");
  52.             this.lastTime = _loc5_;
  53.          }
  54.          this.character.MoveUp(6);
  55.       }
  56.       this.changeWindMill();
  57.       this.r1.ReSet(this.myCurrentwindmill.t1._x / 2 + this.myCurrentwindmill._x,this.myCurrentwindmill.t1._y / 2 + this.myCurrentwindmill._y);
  58.       this.r2.ReSet(this.myCurrentwindmill.t2._x / 2 + this.myCurrentwindmill._x,this.myCurrentwindmill.t2._y / 2 + this.myCurrentwindmill._y);
  59.       this.r3.ReSet(this.myCurrentwindmill.t3._x / 2 + this.myCurrentwindmill._x,this.myCurrentwindmill.t3._y / 2 + this.myCurrentwindmill._y);
  60.       this.r4.ReSet(this.myCurrentwindmill.t4._x / 2 + this.myCurrentwindmill._x,this.myCurrentwindmill.t4._y / 2 + this.myCurrentwindmill._y);
  61.       this.TimeUnderFlower();
  62.    }
  63.    function changeWindMill()
  64.    {
  65.       if(this.character.dmc.hitTest(this.dmc.ranger122))
  66.       {
  67.          this.myCurrentwindmill = this.dmc.cross2;
  68.       }
  69.       if(this.character.dmc.hitTest(this.dmc.ranger223))
  70.       {
  71.          this.myCurrentwindmill = this.dmc.cross3;
  72.       }
  73.       if(this.character.dmc.hitTest(this.dmc.ranger324))
  74.       {
  75.          this.myCurrentwindmill = this.dmc.cross4;
  76.       }
  77.       if(this.character.dmc.hitTest(this.dmc.ranger423))
  78.       {
  79.          this.myCurrentwindmill = this.dmc.cross3;
  80.       }
  81.       if(this.character.dmc.hitTest(this.dmc.ranger322))
  82.       {
  83.          this.myCurrentwindmill = this.dmc.cross2;
  84.       }
  85.       if(this.character.dmc.hitTest(this.dmc.ranger221))
  86.       {
  87.          this.myCurrentwindmill = this.dmc.cross1;
  88.       }
  89.    }
  90.    function TimeUnderFlower()
  91.    {
  92.       var k = false;
  93.       var i = 1;
  94.       while(i < 8)
  95.       {
  96.          if(this.character.dmc.hitTest(this.dmc + ".hitter" + i))
  97.          {
  98.             k = true;
  99.             break;
  100.          }
  101.          i++;
  102.       }
  103.       if(k)
  104.       {
  105.          this.Duration = this.Duration + 1;
  106.          if(this.Duration > this.allowedTime)
  107.          {
  108.             eval(this.dmc + ".bee" + i).gotoAndPlay("beat");
  109.             this.Duration = -60;
  110.          }
  111.       }
  112.       else
  113.       {
  114.          this.Duration = 0;
  115.       }
  116.    }
  117.    function Init()
  118.    {
  119.       super.Init();
  120.       _global.sounds.StartMusic("loop1");
  121.       this.Enemy = "bee1/bee2/bee3/bee4/bee5/bee6/bee7";
  122.       this.lastTime = new Date().getTime();
  123.       this.myCurrentwindmill = this.dmc.cross1;
  124.       var ca = this.character;
  125.       var _loc7_ = this.dmc.cross1._x;
  126.       var _loc6_ = this.dmc.cross1._y;
  127.       var _loc5_ = this.myCurrentwindmill.t1._width / 2;
  128.       var _loc4_ = this.myCurrentwindmill.t1._height / 2;
  129.       this.r1 = new org.cove.flade.surfaces.MoveRectangleTile(0,0,_loc5_,_loc4_,this.gameMC);
  130.       this.r2 = new org.cove.flade.surfaces.MoveRectangleTile(0,0,_loc5_,_loc4_,this.gameMC);
  131.       this.r3 = new org.cove.flade.surfaces.MoveRectangleTile(0,0,_loc5_,_loc4_,this.gameMC);
  132.       this.r4 = new org.cove.flade.surfaces.MoveRectangleTile(0,0,_loc5_,_loc4_,this.gameMC);
  133.       this.r1.onContact = function()
  134.       {
  135.          ca.AllowJump(true);
  136.       };
  137.       this.r2.onContact = this.r3.onContact = this.r4.onContact = this.r1.onContact;
  138.       this.surfaces.push(this.r1);
  139.       this.surfaces.push(this.r2);
  140.       this.surfaces.push(this.r3);
  141.       this.surfaces.push(this.r4);
  142.       this.dynamicsEngine.addSurface(this.r1);
  143.       this.dynamicsEngine.addSurface(this.r2);
  144.       this.dynamicsEngine.addSurface(this.r3);
  145.       this.dynamicsEngine.addSurface(this.r4);
  146.    }
  147.    function Close()
  148.    {
  149.       _global.sounds.FadeVolume("bee",false,false);
  150.       _global.sounds.FadeVolume("fc",false,false);
  151.       super.Close();
  152.       this.surfaces.clear();
  153.    }
  154.    function LevelComplete()
  155.    {
  156.       this.levelComplete = true;
  157.       _global.sounds.FadeVolume("bee",false,false);
  158.       _global.sounds.FadeVolume("fc",false,false);
  159.    }
  160. }
  161.