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

  1. class PlayerBallInterceptorHandler
  2. {
  3.    var players;
  4.    var ball;
  5.    var posPrecision;
  6.    function PlayerBallInterceptorHandler(players, ball)
  7.    {
  8.       this.players = players;
  9.       this.ball = ball;
  10.       this.posPrecision = 20;
  11.    }
  12.    function analysis(playerShooterNumber)
  13.    {
  14.       var _loc2_ = undefined;
  15.       _loc2_ = 0;
  16.       while(_loc2_ < this.players.length)
  17.       {
  18.          if(this.ball.getX() <= this.players[_loc2_].getX() + this.posPrecision && this.ball.getX() >= this.players[_loc2_].getX() - this.posPrecision)
  19.          {
  20.             if(this.ball.getY() <= this.players[_loc2_].getY() + this.posPrecision && this.ball.getY() >= this.players[_loc2_].getY() - this.posPrecision)
  21.             {
  22.                if(this.ball.isBallInAirTest() == false)
  23.                {
  24.                   if(playerShooterNumber != _loc2_)
  25.                   {
  26.                      trace("PlayerBallInterceptorHandler - Ball Interception by Player " + _loc2_ + " !");
  27.                      this.ball.interruptMovement();
  28.                      this.players[playerShooterNumber].setPlayerBallOwner(false);
  29.                      this.players[_loc2_].setPlayerBallOwner(true);
  30.                      this.ball.setInitialScale();
  31.                      return true;
  32.                   }
  33.                }
  34.             }
  35.          }
  36.          _loc2_ = _loc2_ + 1;
  37.       }
  38.    }
  39.    function trace()
  40.    {
  41.       trace("PlayerBallInterceptorHandler - Umount Players   :       " + this.players.length);
  42.       trace("PlayerBallInterceptorHandler - PosPrecision  \t: \t\t" + this.posPrecision);
  43.    }
  44. }
  45.