Exemplo n.º 1
0
 protected function check_range(Ship $target, Weapon $weapon)
 {
     $x = $target->getPos()['x'] - $this->getPos()['x'];
     $y = $target->getPos()['y'] - $this->getPos()['y'];
     $distance = sqrt(pow($x, 2) + pow($y, 2));
     if ($distance != 0) {
         if ($distance < $weapon->getRange()['short']) {
             return 1;
         } else {
             if ($distance < $weapon->getRange()['mid']) {
                 return 2;
             } else {
                 if ($distance < $weapon->getRange()['long']) {
                     return 3;
                 } else {
                     return 0;
                 }
             }
         }
     }
 }