home *** CD-ROM | disk | FTP | other *** search
- class PlayerSelectionHandler
- {
- var players;
- var currentSelected;
- var posPrecision;
- function PlayerSelectionHandler(players)
- {
- this.players = players;
- this.currentSelected = -1;
- this.posPrecision = 10;
- }
- function analysis(x_mouse, y_mouse)
- {
- var _loc2_ = undefined;
- _loc2_ = 0;
- while(_loc2_ < this.players.length)
- {
- if(x_mouse <= this.players[_loc2_].getX() + this.posPrecision && x_mouse >= this.players[_loc2_].getX() - this.posPrecision)
- {
- if(y_mouse <= this.players[_loc2_].getY() + this.posPrecision && y_mouse >= this.players[_loc2_].getY() - this.posPrecision)
- {
- if(_loc2_ != this.currentSelected)
- {
- trace("Selection Handler - MSG: Select Player " + _loc2_);
- if(this.currentSelected != -1)
- {
- this.players[this.currentSelected].modeNoSelected();
- }
- this.players[_loc2_].modeSelectedStatic();
- this.currentSelected = _loc2_;
- return true;
- }
- trace("Selection Handler - MSG: Player " + _loc2_ + " is selected yet.");
- return false;
- }
- }
- _loc2_ = _loc2_ + 1;
- }
- }
- function getCurrentSelected()
- {
- return this.currentSelected;
- }
- function selectPlayer(playerNumber)
- {
- if(this.currentSelected != -1)
- {
- this.players[this.currentSelected].modeNoSelected();
- }
- this.players[playerNumber].modeSelectedStatic();
- this.currentSelected = playerNumber;
- }
- function trace()
- {
- trace("Selection Handler - Umount Players : " + this.players.length);
- trace("Selection Handler - CurrentSelected : " + this.currentSelected);
- trace("Selection Handler - PosPrecision \t: \t\t" + this.posPrecision);
- }
- }
-