1
0
Fork 0

Refactored "hovered" state, to be more like "playing" state for arena ships

This commit is contained in:
Michaël Lemaire 2015-01-23 01:00:00 +01:00 committed by Michaël Lemaire
parent e357686a64
commit a545251257
2 changed files with 10 additions and 8 deletions

View file

@ -16,6 +16,8 @@ module SpaceTac.View {
// List of ship sprites
private ship_sprites: ArenaShip[];
// Currently hovered ship
private hovered: ArenaShip;
// Currently playing ship
private playing: ArenaShip;
@ -24,6 +26,7 @@ module SpaceTac.View {
this.battleview = battleview;
this.ship_sprites = [];
this.playing = null;
this.hovered = null;
super(battleview.game);
@ -80,11 +83,15 @@ module SpaceTac.View {
}
// 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);
if (arena_ship) {
arena_ship.setHovered(hovered);
arena_ship.setHovered(true);
}
this.hovered = arena_ship;
}
// Set the playing state on a ship sprite

View file

@ -133,11 +133,9 @@ module SpaceTac.View {
// Set the currently hovered ship
setShipHovered(ship: Game.Ship): void {
if (this.ship_hovered) {
this.arena.setShipHovered(this.ship_hovered, false);
}
this.ship_hovered = ship;
this.card_hovered.setShip(ship);
this.arena.setShipHovered(ship);
if (this.targetting) {
if (ship) {
this.targetting.setTargetShip(ship);
@ -145,9 +143,6 @@ module SpaceTac.View {
this.targetting.unsetTarget();
}
}
if (ship) {
this.arena.setShipHovered(this.ship_hovered, true);
}
}
// Enter targetting mode