home *** CD-ROM | disk | FTP | other *** search
/ Equipe de France et Bonbons / EquipeFrancePromoCD.iso / pages / cs_cadbury / loadergfx.swf / scripts / __Packages / ShootZoneHandler.as < prev    next >
Encoding:
Text File  |  2006-03-19  |  3.1 KB  |  107 lines

  1. class ShootZoneHandler
  2. {
  3.    var mc;
  4.    var ball;
  5.    var state;
  6.    var quadZoneArray;
  7.    var detected;
  8.    var quadZone;
  9.    function ShootZoneHandler(mc, ball)
  10.    {
  11.       this.mc = mc;
  12.       this.ball = ball;
  13.       this.state = 1;
  14.       this.setRandomState();
  15.       this.quadZoneArray = new Array();
  16.       this.setZone();
  17.       this.detected = false;
  18.    }
  19.    function setZone()
  20.    {
  21.       var _loc2_ = 10;
  22.       var _loc3_ = 10;
  23.       this.quadZone = new QuadZone2D(new Point2D(this.mc._x,this.mc._y),18,76);
  24.       this.quadZoneArray[0] = new QuadZone2D(new Point2D(this.mc._x + 4,this.mc._y + 7.2),_loc2_,_loc3_);
  25.       this.quadZoneArray[1] = new QuadZone2D(new Point2D(this.mc._x + 4,this.mc._y + 7.2 + 10 + 7.2),_loc2_,_loc3_);
  26.       this.quadZoneArray[2] = new QuadZone2D(new Point2D(this.mc._x + 4,this.mc._y + 7.2 + 10 + 7.2 + 10 + 7.2),_loc2_,_loc3_);
  27.       this.quadZoneArray[3] = new QuadZone2D(new Point2D(this.mc._x + 4,this.mc._y + 7.2 + 10 + 7.2 + 10 + 7.2 + 10 + 7.2),_loc2_,_loc3_);
  28.       this.detected = false;
  29.    }
  30.    function move(x, y)
  31.    {
  32.       this.mc._x = x;
  33.       this.mc._y = y;
  34.       this.setZone();
  35.       this.detected = false;
  36.    }
  37.    function setRandomState()
  38.    {
  39.       var _loc2_ = random(5);
  40.       while(true)
  41.       {
  42.          _loc2_ = random(5);
  43.          if(!(_loc2_ == 0 || _loc2_ == this.state))
  44.          {
  45.             break;
  46.          }
  47.       }
  48.       this.state = _loc2_;
  49.    }
  50.    function manage_OneShootArea()
  51.    {
  52.       this.mc._visible = false;
  53.       if(this.detected == true)
  54.       {
  55.          return undefined;
  56.       }
  57.       if(this.quadZone.isObjectInZone(this.ball.getX(),this.ball.getY()) == true)
  58.       {
  59.          trace("ShootZoneHandler            \t: Ball In Shoot Zone !");
  60.          this.detected = true;
  61.          return 1;
  62.       }
  63.       return -1;
  64.    }
  65.    function manage_QuadShootArea()
  66.    {
  67.       this.mc._visible = true;
  68.       this.mc.gotoAndStop("Z" + this.state);
  69.       if(this.state == 0)
  70.       {
  71.          trace("ShootZoneHandler \t\t\t: Random ERROR !");
  72.       }
  73.       if(this.detected == true)
  74.       {
  75.          return undefined;
  76.       }
  77.       if(this.quadZoneArray[this.state - 1].isObjectInZone(this.ball.getX(),this.ball.getY()) == true)
  78.       {
  79.          trace("ShootZoneHandler            \t: Ball In Shoot Zone Number : " + this.state);
  80.          this.setRandomState();
  81.          trace("ShootZoneHandler\t\t\t\t: New Shoot Zone\t\t\t: " + this.state);
  82.          this.detected = true;
  83.          return 1;
  84.       }
  85.       return -1;
  86.    }
  87.    function setReady()
  88.    {
  89.       this.detected = false;
  90.    }
  91.    function trace()
  92.    {
  93.       trace("ShootZoneHandler: - X\t\t\t: " + this.mc._x);
  94.       trace("ShootZoneHandler: - Y\t\t\t: " + this.mc._y);
  95.       trace("ShootZoneHandler: - One Zone\t\t: ");
  96.       this.quadZone.trace();
  97.       trace("ShootZoneHandler: - Current State: " + this.state);
  98.       var _loc2_ = undefined;
  99.       _loc2_ = 0;
  100.       while(_loc2_ < this.quadZoneArray.length)
  101.       {
  102.          this.quadZoneArray[_loc2_].trace();
  103.          _loc2_ = _loc2_ + 1;
  104.       }
  105.    }
  106. }
  107.