home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Aventura / sinta.swf / scripts / MonsterGenerator.as < prev    next >
Encoding:
Text File  |  2008-08-08  |  2.1 KB  |  95 lines

  1. package
  2. {
  3.    import flash.display.*;
  4.    import flash.events.*;
  5.    import flash.text.*;
  6.    import flash.utils.*;
  7.    
  8.    [Embed(source="/_assets/assets.swf", symbol="MonsterGenerator")]
  9.    public class MonsterGenerator extends MovieClip
  10.    {
  11.        
  12.       
  13.       public var monsterType:int;
  14.       
  15.       public var timer:Timer;
  16.       
  17.       public var emitting:Boolean;
  18.       
  19.       public var monsterCount:int;
  20.       
  21.       public var col:int;
  22.       
  23.       public var precursor:Boolean;
  24.       
  25.       public var maxMonster:int;
  26.       
  27.       public var row:int;
  28.       
  29.       public var game:PlatformGame;
  30.       
  31.       public function MonsterGenerator(param1:PlatformGame)
  32.       {
  33.          super();
  34.          addFrameScript(0,frame1,3,frame4);
  35.          game = param1;
  36.       }
  37.       
  38.       internal function init() : *
  39.       {
  40.          var _loc1_:int = 0;
  41.          precursor = false;
  42.          _loc1_ = 0;
  43.          switch(monsterType)
  44.          {
  45.             case 22:
  46.                maxMonster = 2;
  47.                _loc1_ = 10000;
  48.                break;
  49.             case 25:
  50.                maxMonster = 1;
  51.                _loc1_ = 7000;
  52.                break;
  53.             default:
  54.                maxMonster = 2;
  55.                _loc1_ = 10000;
  56.          }
  57.          emitting = true;
  58.          monsterCount = 0;
  59.          timer = new Timer(_loc1_ + Math.random() * 2000,0);
  60.          timer.start();
  61.          timer.addEventListener(TimerEvent.TIMER,emit);
  62.       }
  63.       
  64.       public function resetTimer() : *
  65.       {
  66.          timer.reset();
  67.          timer.start();
  68.       }
  69.       
  70.       internal function frame1() : *
  71.       {
  72.          stop();
  73.       }
  74.       
  75.       internal function frame4() : *
  76.       {
  77.          stop();
  78.       }
  79.       
  80.       public function emit(param1:Event) : *
  81.       {
  82.          if(monsterCount >= maxMonster || !emitting)
  83.          {
  84.             return;
  85.          }
  86.          if(monsterType == 22)
  87.          {
  88.             game.sounds.snakespawn.play();
  89.          }
  90.          game.createMonster(monsterType,col,row,this);
  91.          ++monsterCount;
  92.       }
  93.    }
  94. }
  95.