home *** CD-ROM | disk | FTP | other *** search
- class ShootZoneHandler
- {
- var mc;
- var ball;
- var state;
- var quadZoneArray;
- var detected;
- var quadZone;
- function ShootZoneHandler(mc, ball)
- {
- this.mc = mc;
- this.ball = ball;
- this.state = 1;
- this.setRandomState();
- this.quadZoneArray = new Array();
- this.setZone();
- this.detected = false;
- }
- function setZone()
- {
- var _loc2_ = 10;
- var _loc3_ = 10;
- this.quadZone = new QuadZone2D(new Point2D(this.mc._x,this.mc._y),18,76);
- this.quadZoneArray[0] = new QuadZone2D(new Point2D(this.mc._x + 4,this.mc._y + 7.2),_loc2_,_loc3_);
- this.quadZoneArray[1] = new QuadZone2D(new Point2D(this.mc._x + 4,this.mc._y + 7.2 + 10 + 7.2),_loc2_,_loc3_);
- this.quadZoneArray[2] = new QuadZone2D(new Point2D(this.mc._x + 4,this.mc._y + 7.2 + 10 + 7.2 + 10 + 7.2),_loc2_,_loc3_);
- 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_);
- this.detected = false;
- }
- function move(x, y)
- {
- this.mc._x = x;
- this.mc._y = y;
- this.setZone();
- this.detected = false;
- }
- function setRandomState()
- {
- var _loc2_ = random(5);
- while(true)
- {
- _loc2_ = random(5);
- if(!(_loc2_ == 0 || _loc2_ == this.state))
- {
- break;
- }
- }
- this.state = _loc2_;
- }
- function manage_OneShootArea()
- {
- this.mc._visible = false;
- if(this.detected == true)
- {
- return undefined;
- }
- if(this.quadZone.isObjectInZone(this.ball.getX(),this.ball.getY()) == true)
- {
- trace("ShootZoneHandler \t: Ball In Shoot Zone !");
- this.detected = true;
- return 1;
- }
- return -1;
- }
- function manage_QuadShootArea()
- {
- this.mc._visible = true;
- this.mc.gotoAndStop("Z" + this.state);
- if(this.state == 0)
- {
- trace("ShootZoneHandler \t\t\t: Random ERROR !");
- }
- if(this.detected == true)
- {
- return undefined;
- }
- if(this.quadZoneArray[this.state - 1].isObjectInZone(this.ball.getX(),this.ball.getY()) == true)
- {
- trace("ShootZoneHandler \t: Ball In Shoot Zone Number : " + this.state);
- this.setRandomState();
- trace("ShootZoneHandler\t\t\t\t: New Shoot Zone\t\t\t: " + this.state);
- this.detected = true;
- return 1;
- }
- return -1;
- }
- function setReady()
- {
- this.detected = false;
- }
- function trace()
- {
- trace("ShootZoneHandler: - X\t\t\t: " + this.mc._x);
- trace("ShootZoneHandler: - Y\t\t\t: " + this.mc._y);
- trace("ShootZoneHandler: - One Zone\t\t: ");
- this.quadZone.trace();
- trace("ShootZoneHandler: - Current State: " + this.state);
- var _loc2_ = undefined;
- _loc2_ = 0;
- while(_loc2_ < this.quadZoneArray.length)
- {
- this.quadZoneArray[_loc2_].trace();
- _loc2_ = _loc2_ + 1;
- }
- }
- }
-