Added basic "playing" ship indicator for arena
This commit is contained in:
parent
d69459a7e3
commit
e357686a64
BIN
src/assets/images/battle/arena/shipspriteplaying.png
Normal file
BIN
src/assets/images/battle/arena/shipspriteplaying.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 212 B |
|
@ -18,6 +18,7 @@ module SpaceTac.View {
|
||||||
this.load.image("battle-actionpointsempty", "assets/images/battle/actionpointsempty.png");
|
this.load.image("battle-actionpointsempty", "assets/images/battle/actionpointsempty.png");
|
||||||
this.load.image("battle-actionpointsfull", "assets/images/battle/actionpointsfull.png");
|
this.load.image("battle-actionpointsfull", "assets/images/battle/actionpointsfull.png");
|
||||||
this.load.image("battle-arena-shipspritehover", "assets/images/battle/arena/shipspritehover.png");
|
this.load.image("battle-arena-shipspritehover", "assets/images/battle/arena/shipspritehover.png");
|
||||||
|
this.load.image("battle-arena-shipspriteplaying", "assets/images/battle/arena/shipspriteplaying.png");
|
||||||
this.load.image("battle-ship-card", "assets/images/battle/ship-card.png");
|
this.load.image("battle-ship-card", "assets/images/battle/ship-card.png");
|
||||||
this.load.image("battle-arena-ship01", "assets/images/battle/arena/ship01.png");
|
this.load.image("battle-arena-ship01", "assets/images/battle/arena/ship01.png");
|
||||||
this.load.image("common-standard-bar-background", "assets/images/common/standard-bar-background.png");
|
this.load.image("common-standard-bar-background", "assets/images/common/standard-bar-background.png");
|
||||||
|
|
|
@ -16,10 +16,14 @@ module SpaceTac.View {
|
||||||
// List of ship sprites
|
// List of ship sprites
|
||||||
private ship_sprites: ArenaShip[];
|
private ship_sprites: ArenaShip[];
|
||||||
|
|
||||||
|
// Currently playing ship
|
||||||
|
private playing: ArenaShip;
|
||||||
|
|
||||||
// Create a graphical arena for ship sprites to fight in a 2D space
|
// Create a graphical arena for ship sprites to fight in a 2D space
|
||||||
constructor(battleview: BattleView) {
|
constructor(battleview: BattleView) {
|
||||||
this.battleview = battleview;
|
this.battleview = battleview;
|
||||||
this.ship_sprites = [];
|
this.ship_sprites = [];
|
||||||
|
this.playing = null;
|
||||||
|
|
||||||
super(battleview.game);
|
super(battleview.game);
|
||||||
|
|
||||||
|
@ -82,5 +86,17 @@ module SpaceTac.View {
|
||||||
arena_ship.setHovered(hovered);
|
arena_ship.setHovered(hovered);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the playing state on a ship sprite
|
||||||
|
setShipPlaying(ship: Game.Ship): void {
|
||||||
|
if (this.playing) {
|
||||||
|
this.playing.setPlaying(false);
|
||||||
|
}
|
||||||
|
var arena_ship = this.findShipSprite(ship);
|
||||||
|
if (arena_ship) {
|
||||||
|
arena_ship.setPlaying(true);
|
||||||
|
}
|
||||||
|
this.playing = arena_ship;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,9 @@ module SpaceTac.View {
|
||||||
// Hover effect
|
// Hover effect
|
||||||
hover: Phaser.Image;
|
hover: Phaser.Image;
|
||||||
|
|
||||||
|
// Playing effect
|
||||||
|
playing: Phaser.Image;
|
||||||
|
|
||||||
// Create a ship sprite usable in the Arena
|
// Create a ship sprite usable in the Arena
|
||||||
constructor(battleview: BattleView, ship: Game.Ship) {
|
constructor(battleview: BattleView, ship: Game.Ship) {
|
||||||
this.ship = ship;
|
this.ship = ship;
|
||||||
|
@ -32,6 +35,12 @@ module SpaceTac.View {
|
||||||
this.sprite.anchor.set(0.5, 0.5);
|
this.sprite.anchor.set(0.5, 0.5);
|
||||||
this.addChild(this.sprite);
|
this.addChild(this.sprite);
|
||||||
|
|
||||||
|
// Add playing effect
|
||||||
|
this.playing = new Phaser.Image(battleview.game, 0, 0, "battle-arena-shipspriteplaying", 0);
|
||||||
|
this.playing.anchor.set(0.5, 0.5);
|
||||||
|
this.playing.visible = false;
|
||||||
|
this.addChild(this.playing);
|
||||||
|
|
||||||
// Handle input on ship sprite
|
// Handle input on ship sprite
|
||||||
this.sprite.input.useHandCursor = true;
|
this.sprite.input.useHandCursor = true;
|
||||||
this.sprite.onInputOver.add(() => {
|
this.sprite.onInputOver.add(() => {
|
||||||
|
@ -54,6 +63,12 @@ module SpaceTac.View {
|
||||||
this.hover.visible = hovered;
|
this.hover.visible = hovered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the playing state on this ship
|
||||||
|
// This will toggle the "playing" indicator
|
||||||
|
setPlaying(playing: boolean) {
|
||||||
|
this.playing.visible = playing;
|
||||||
|
}
|
||||||
|
|
||||||
// Move the sprite to a location
|
// Move the sprite to a location
|
||||||
moveTo(x: number, y: number, animate: boolean = true) {
|
moveTo(x: number, y: number, animate: boolean = true) {
|
||||||
var angle = Math.atan2(y - this.y, x - this.x);
|
var angle = Math.atan2(y - this.y, x - this.x);
|
||||||
|
|
|
@ -35,6 +35,7 @@ module SpaceTac.View {
|
||||||
switch (event.code) {
|
switch (event.code) {
|
||||||
case "ship_change":
|
case "ship_change":
|
||||||
// Playing ship changed
|
// Playing ship changed
|
||||||
|
this.view.arena.setShipPlaying(event.target.ship);
|
||||||
this.view.card_playing.setShip(event.target.ship);
|
this.view.card_playing.setShip(event.target.ship);
|
||||||
this.view.action_bar.setShip(event.target.ship);
|
this.view.action_bar.setShip(event.target.ship);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue