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

  1. class PlayerSelectionHandler
  2. {
  3.    var players;
  4.    var currentSelected;
  5.    var posPrecision;
  6.    function PlayerSelectionHandler(players)
  7.    {
  8.       this.players = players;
  9.       this.currentSelected = -1;
  10.       this.posPrecision = 10;
  11.    }
  12.    function analysis(x_mouse, y_mouse)
  13.    {
  14.       var _loc2_ = undefined;
  15.       _loc2_ = 0;
  16.       while(_loc2_ < this.players.length)
  17.       {
  18.          if(x_mouse <= this.players[_loc2_].getX() + this.posPrecision && x_mouse >= this.players[_loc2_].getX() - this.posPrecision)
  19.          {
  20.             if(y_mouse <= this.players[_loc2_].getY() + this.posPrecision && y_mouse >= this.players[_loc2_].getY() - this.posPrecision)
  21.             {
  22.                if(_loc2_ != this.currentSelected)
  23.                {
  24.                   trace("Selection Handler - MSG: Select Player " + _loc2_);
  25.                   if(this.currentSelected != -1)
  26.                   {
  27.                      this.players[this.currentSelected].modeNoSelected();
  28.                   }
  29.                   this.players[_loc2_].modeSelectedStatic();
  30.                   this.currentSelected = _loc2_;
  31.                   return true;
  32.                }
  33.                trace("Selection Handler - MSG: Player " + _loc2_ + " is selected yet.");
  34.                return false;
  35.             }
  36.          }
  37.          _loc2_ = _loc2_ + 1;
  38.       }
  39.    }
  40.    function getCurrentSelected()
  41.    {
  42.       return this.currentSelected;
  43.    }
  44.    function selectPlayer(playerNumber)
  45.    {
  46.       if(this.currentSelected != -1)
  47.       {
  48.          this.players[this.currentSelected].modeNoSelected();
  49.       }
  50.       this.players[playerNumber].modeSelectedStatic();
  51.       this.currentSelected = playerNumber;
  52.    }
  53.    function trace()
  54.    {
  55.       trace("Selection Handler - Umount Players   :       " + this.players.length);
  56.       trace("Selection Handler - CurrentSelected  :       " + this.currentSelected);
  57.       trace("Selection Handler - PosPrecision  \t: \t\t" + this.posPrecision);
  58.    }
  59. }
  60.