home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / attention_hog.swf / scripts / __Packages / com / leadpipe / attentionhog / Ability.as next >
Encoding:
Text File  |  2008-09-22  |  3.2 KB  |  122 lines

  1. class com.leadpipe.attentionhog.Ability
  2. {
  3.    var target;
  4.    var methodName;
  5.    var controlKey;
  6.    var icon;
  7.    var gauge;
  8.    var isInputType;
  9.    var isDisabled;
  10.    var timerPowerUp;
  11.    var initInputSwitch;
  12.    var powerUpMode;
  13.    var initSwitchPower;
  14.    var initSwitch;
  15.    static var instanceList = new Array();
  16.    function Ability(t, mn, ck, ic, g, i)
  17.    {
  18.       com.leadpipe.attentionhog.Ability.instanceList.push(this);
  19.       this.target = t;
  20.       this.methodName = mn;
  21.       this.controlKey = ck;
  22.       this.icon = ic;
  23.       this.gauge = g;
  24.       this.isInputType = i;
  25.       this.isDisabled = false;
  26.       this.timerPowerUp = new com.leadpipe.attentionhog.Timer(this,"stopPowerUp",7000,7000);
  27.    }
  28.    function check()
  29.    {
  30.       if(this.isDisabled)
  31.       {
  32.          return undefined;
  33.       }
  34.       if(Key.isDown(this.controlKey))
  35.       {
  36.          this.initInputSwitch = this.initInputSwitch + 1;
  37.       }
  38.       else
  39.       {
  40.          this.initInputSwitch = 0;
  41.       }
  42.       if(this.powerUpMode)
  43.       {
  44.          this.initSwitchPower = this.initSwitchPower + 1;
  45.          if(this.isInputType && this.initInputSwitch == 1)
  46.          {
  47.             this.target[this.methodName](true,this.powerUpMode);
  48.          }
  49.          else if(this.isInputType == false && this.initSwitchPower == 1)
  50.          {
  51.             this.initInputSwitch = 0;
  52.             this.target[this.methodName](true,this.powerUpMode);
  53.          }
  54.       }
  55.       else if(Key.isDown(this.controlKey) && this.gauge.getLevel() > 0)
  56.       {
  57.          this.gauge.decrease();
  58.          this.initSwitch = this.initSwitch + 1;
  59.          if(this.initSwitch == 1)
  60.          {
  61.             this.target[this.methodName](true,this.powerUpMode);
  62.          }
  63.       }
  64.       else
  65.       {
  66.          if(this.initSwitch > 0)
  67.          {
  68.             this.target[this.methodName](false,this.powerUpMode);
  69.          }
  70.          this.initSwitch = 0;
  71.       }
  72.    }
  73.    function startPowerUp()
  74.    {
  75.       this.powerUpMode = true;
  76.       this.initSwitchPower = 0;
  77.       this.timerPowerUp.start();
  78.       this.icon.gotoAndStop("super");
  79.    }
  80.    function stopPowerUp()
  81.    {
  82.       this.timerPowerUp.clear();
  83.       this.powerUpMode = false;
  84.       this.target[this.methodName](false,this.powerUpMode);
  85.       this.initSwitch = 0;
  86.       this.icon.gotoAndStop(1);
  87.    }
  88.    function setDisabled(d)
  89.    {
  90.       this.isDisabled = d;
  91.       if(this.isDisabled)
  92.       {
  93.          this.timerPowerUp.clear();
  94.          this.target[this.methodName](false,false);
  95.          this.initSwitch = 0;
  96.          this.powerUpMode = false;
  97.          this.icon.gotoAndStop(1);
  98.       }
  99.    }
  100.    static function checkAll()
  101.    {
  102.       for(var _loc1_ in com.leadpipe.attentionhog.Ability.instanceList)
  103.       {
  104.          com.leadpipe.attentionhog.Ability.instanceList[_loc1_].check();
  105.       }
  106.    }
  107.    static function stopPowerUpAll()
  108.    {
  109.       for(var _loc1_ in com.leadpipe.attentionhog.Ability.instanceList)
  110.       {
  111.          com.leadpipe.attentionhog.Ability.instanceList[_loc1_].stopPowerUp();
  112.       }
  113.    }
  114.    static function disableAll(d)
  115.    {
  116.       for(var _loc2_ in com.leadpipe.attentionhog.Ability.instanceList)
  117.       {
  118.          com.leadpipe.attentionhog.Ability.instanceList[_loc2_].setDisabled(d);
  119.       }
  120.    }
  121. }
  122.