1
0
Fork 0

Fixed cone targetting sometimes impacting the shooter

This commit is contained in:
Michaël Lemaire 2017-10-05 19:33:10 +02:00
parent a42d9e77aa
commit 5337abc056
2 changed files with 8 additions and 2 deletions

View file

@ -98,7 +98,6 @@ Common UI
Technical
---------
* Run jasmine tests in random order by default, and fix problems
* Pack all images in atlases
* Pack sounds

View file

@ -82,7 +82,14 @@ module TK.SpaceTac {
} else if (this.angle) {
let angle = arenaAngle(source, target);
let maxangle = (this.angle * 0.5) * Math.PI / 180;
return ships.filter(ship => arenaDistance(source, ship.location) <= this.range && Math.abs(angularDistance(arenaAngle(source, ship.location), angle)) < maxangle);
return ships.filter(ship => {
let dist = arenaDistance(source, ship.location);
if (dist < 0.000001 || dist > this.range) {
return false;
} else {
return Math.abs(angularDistance(arenaAngle(source, ship.location), angle)) < maxangle;
}
});
} else {
return ships.filter(ship => target.ship === ship);
}