Updated starting battle positions
This commit is contained in:
parent
6d01734238
commit
a4db1f6ba3
1
TODO
1
TODO
|
@ -23,6 +23,7 @@
|
||||||
* Arena: fix effects originating from real ship location instead of current sprite (when AI fires then moves)
|
* Arena: fix effects originating from real ship location instead of current sprite (when AI fires then moves)
|
||||||
* Arena: add engine trail
|
* Arena: add engine trail
|
||||||
* Arena: draw move exclusion circles (only on clonflict or in tactical mode ?)
|
* Arena: draw move exclusion circles (only on clonflict or in tactical mode ?)
|
||||||
|
* Remove "initial events" injection
|
||||||
* Fix capacity limit effect not refreshing associated value (for example, on "limit power capacity to 3", potential "power" value change is not broadcast)
|
* Fix capacity limit effect not refreshing associated value (for example, on "limit power capacity to 3", potential "power" value change is not broadcast)
|
||||||
* Actions: show power usage/recovery in power bar, on action hover
|
* Actions: show power usage/recovery in power bar, on action hover
|
||||||
* Actions: fix targetting not resetting when using keyboard shortcuts
|
* Actions: fix targetting not resetting when using keyboard shortcuts
|
||||||
|
|
|
@ -38,23 +38,23 @@ module TS.SpaceTac {
|
||||||
var battle = new Battle(fleet1, fleet2, 1000, 500);
|
var battle = new Battle(fleet1, fleet2, 1000, 500);
|
||||||
battle.placeShips();
|
battle.placeShips();
|
||||||
|
|
||||||
expect(ship1.arena_x).toBeCloseTo(50, 0.0001);
|
expect(ship1.arena_x).toBeCloseTo(250, 0.0001);
|
||||||
expect(ship1.arena_y).toBeCloseTo(150, 0.0001);
|
expect(ship1.arena_y).toBeCloseTo(150, 0.0001);
|
||||||
expect(ship1.arena_angle).toBeCloseTo(0, 0.0001);
|
expect(ship1.arena_angle).toBeCloseTo(0, 0.0001);
|
||||||
|
|
||||||
expect(ship2.arena_x).toBeCloseTo(50, 0.0001);
|
expect(ship2.arena_x).toBeCloseTo(250, 0.0001);
|
||||||
expect(ship2.arena_y).toBeCloseTo(250, 0.0001);
|
expect(ship2.arena_y).toBeCloseTo(250, 0.0001);
|
||||||
expect(ship2.arena_angle).toBeCloseTo(0, 0.0001);
|
expect(ship2.arena_angle).toBeCloseTo(0, 0.0001);
|
||||||
|
|
||||||
expect(ship3.arena_x).toBeCloseTo(50, 0.0001);
|
expect(ship3.arena_x).toBeCloseTo(250, 0.0001);
|
||||||
expect(ship3.arena_y).toBeCloseTo(350, 0.0001);
|
expect(ship3.arena_y).toBeCloseTo(350, 0.0001);
|
||||||
expect(ship3.arena_angle).toBeCloseTo(0, 0.0001);
|
expect(ship3.arena_angle).toBeCloseTo(0, 0.0001);
|
||||||
|
|
||||||
expect(ship4.arena_x).toBeCloseTo(950, 0.0001);
|
expect(ship4.arena_x).toBeCloseTo(750, 0.0001);
|
||||||
expect(ship4.arena_y).toBeCloseTo(300, 0.0001);
|
expect(ship4.arena_y).toBeCloseTo(300, 0.0001);
|
||||||
expect(ship4.arena_angle).toBeCloseTo(Math.PI, 0.0001);
|
expect(ship4.arena_angle).toBeCloseTo(Math.PI, 0.0001);
|
||||||
|
|
||||||
expect(ship5.arena_x).toBeCloseTo(950, 0.0001);
|
expect(ship5.arena_x).toBeCloseTo(750, 0.0001);
|
||||||
expect(ship5.arena_y).toBeCloseTo(200, 0.0001);
|
expect(ship5.arena_y).toBeCloseTo(200, 0.0001);
|
||||||
expect(ship5.arena_angle).toBeCloseTo(Math.PI, 0.0001);
|
expect(ship5.arena_angle).toBeCloseTo(Math.PI, 0.0001);
|
||||||
});
|
});
|
||||||
|
|
|
@ -138,9 +138,14 @@ module TS.SpaceTac {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Defines the initial ship positions of all engaged fleets
|
// Defines the initial ship positions of all engaged fleets
|
||||||
placeShips(): void {
|
placeShips(vertical = true): void {
|
||||||
this.placeFleetShips(this.fleets[0], this.width * 0.05, this.height * 0.5, 0);
|
if (vertical) {
|
||||||
this.placeFleetShips(this.fleets[1], this.width * 0.95, this.height * 0.5, Math.PI);
|
this.placeFleetShips(this.fleets[0], this.width * 0.25, this.height * 0.5, 0, this.height);
|
||||||
|
this.placeFleetShips(this.fleets[1], this.width * 0.75, this.height * 0.5, Math.PI, this.height);
|
||||||
|
} else {
|
||||||
|
this.placeFleetShips(this.fleets[0], this.width * 0.5, this.height * 0.90, -Math.PI / 2, this.width);
|
||||||
|
this.placeFleetShips(this.fleets[1], this.width * 0.5, this.height * 0.10, Math.PI / 2, this.width);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count the number of fleets still alive
|
// Count the number of fleets still alive
|
||||||
|
@ -306,12 +311,16 @@ module TS.SpaceTac {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Defines the initial ship positions for one fleet
|
/**
|
||||||
// x and y are the center of the fleet placement
|
* Defines the initial ship positions for one fleet
|
||||||
// facing_angle is the forward angle in radians
|
*
|
||||||
private placeFleetShips(fleet: Fleet, x: number, y: number, facing_angle: number): void {
|
* *x* and *y* are the center of the fleet formation
|
||||||
|
* *facing_angle* is the forward angle in radians
|
||||||
|
* *width* is the formation width
|
||||||
|
*/
|
||||||
|
private placeFleetShips(fleet: Fleet, x: number, y: number, facing_angle: number, width: number): void {
|
||||||
var side_angle = facing_angle + Math.PI * 0.5;
|
var side_angle = facing_angle + Math.PI * 0.5;
|
||||||
var spacing = this.height * 0.2;
|
var spacing = width * 0.2;
|
||||||
var total_length = spacing * (fleet.ships.length - 1);
|
var total_length = spacing * (fleet.ships.length - 1);
|
||||||
var dx = Math.cos(side_angle);
|
var dx = Math.cos(side_angle);
|
||||||
var dy = Math.sin(side_angle);
|
var dy = Math.sin(side_angle);
|
||||||
|
|
|
@ -109,8 +109,8 @@ module TS.SpaceTac.UI {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set location
|
// Set location
|
||||||
if (ship.alive) {
|
if (this.battleview.battle.turn == 1 && ship.alive && ship.fleet.player === this.battleview.player) {
|
||||||
this.position.set(ship.arena_x - 150 * Math.cos(ship.arena_angle), ship.arena_y - 150 * Math.sin(ship.arena_angle));
|
this.position.set(ship.arena_x - 500 * Math.cos(ship.arena_angle), ship.arena_y - 500 * Math.sin(ship.arena_angle));
|
||||||
this.moveTo(ship.arena_x, ship.arena_y, ship.arena_angle);
|
this.moveTo(ship.arena_x, ship.arena_y, ship.arena_angle);
|
||||||
} else {
|
} else {
|
||||||
this.moveTo(ship.arena_x, ship.arena_y, ship.arena_angle, false);
|
this.moveTo(ship.arena_x, ship.arena_y, ship.arena_angle, false);
|
||||||
|
@ -165,8 +165,8 @@ module TS.SpaceTac.UI {
|
||||||
} else if (event instanceof DamageEvent) {
|
} else if (event instanceof DamageEvent) {
|
||||||
this.displayEffect(`${event.hull + event.shield} damage`, false);
|
this.displayEffect(`${event.hull + event.shield} damage`, false);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (event instanceof MoveEvent) {
|
} else if (event instanceof MoveEvent && !event.initial) {
|
||||||
let duration = this.moveTo(event.target.x, event.target.y, event.facing_angle, !event.initial);
|
let duration = this.moveTo(event.target.x, event.target.y, event.facing_angle, true);
|
||||||
return duration;
|
return duration;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue