Refactored "hovered" state, to be more like "playing" state for arena ships
This commit is contained in:
parent
e357686a64
commit
a545251257
|
@ -16,6 +16,8 @@ module SpaceTac.View {
|
||||||
// List of ship sprites
|
// List of ship sprites
|
||||||
private ship_sprites: ArenaShip[];
|
private ship_sprites: ArenaShip[];
|
||||||
|
|
||||||
|
// Currently hovered ship
|
||||||
|
private hovered: ArenaShip;
|
||||||
// Currently playing ship
|
// Currently playing ship
|
||||||
private playing: ArenaShip;
|
private playing: ArenaShip;
|
||||||
|
|
||||||
|
@ -24,6 +26,7 @@ module SpaceTac.View {
|
||||||
this.battleview = battleview;
|
this.battleview = battleview;
|
||||||
this.ship_sprites = [];
|
this.ship_sprites = [];
|
||||||
this.playing = null;
|
this.playing = null;
|
||||||
|
this.hovered = null;
|
||||||
|
|
||||||
super(battleview.game);
|
super(battleview.game);
|
||||||
|
|
||||||
|
@ -80,11 +83,15 @@ module SpaceTac.View {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the hovered state on a ship sprite
|
// Set the hovered state on a ship sprite
|
||||||
setShipHovered(ship: Game.Ship, hovered: boolean): void {
|
setShipHovered(ship: Game.Ship): void {
|
||||||
|
if (this.hovered) {
|
||||||
|
this.hovered.setHovered(false);
|
||||||
|
}
|
||||||
var arena_ship = this.findShipSprite(ship);
|
var arena_ship = this.findShipSprite(ship);
|
||||||
if (arena_ship) {
|
if (arena_ship) {
|
||||||
arena_ship.setHovered(hovered);
|
arena_ship.setHovered(true);
|
||||||
}
|
}
|
||||||
|
this.hovered = arena_ship;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the playing state on a ship sprite
|
// Set the playing state on a ship sprite
|
||||||
|
|
|
@ -133,11 +133,9 @@ module SpaceTac.View {
|
||||||
|
|
||||||
// Set the currently hovered ship
|
// Set the currently hovered ship
|
||||||
setShipHovered(ship: Game.Ship): void {
|
setShipHovered(ship: Game.Ship): void {
|
||||||
if (this.ship_hovered) {
|
|
||||||
this.arena.setShipHovered(this.ship_hovered, false);
|
|
||||||
}
|
|
||||||
this.ship_hovered = ship;
|
this.ship_hovered = ship;
|
||||||
this.card_hovered.setShip(ship);
|
this.card_hovered.setShip(ship);
|
||||||
|
this.arena.setShipHovered(ship);
|
||||||
if (this.targetting) {
|
if (this.targetting) {
|
||||||
if (ship) {
|
if (ship) {
|
||||||
this.targetting.setTargetShip(ship);
|
this.targetting.setTargetShip(ship);
|
||||||
|
@ -145,9 +143,6 @@ module SpaceTac.View {
|
||||||
this.targetting.unsetTarget();
|
this.targetting.unsetTarget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ship) {
|
|
||||||
this.arena.setShipHovered(this.ship_hovered, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enter targetting mode
|
// Enter targetting mode
|
||||||
|
|
Loading…
Reference in a new issue