From e357686a64305379407c53f0481c8340fe2440f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Fri, 23 Jan 2015 01:00:00 +0100 Subject: [PATCH] Added basic "playing" ship indicator for arena --- .../images/battle/arena/shipspriteplaying.png | Bin 0 -> 212 bytes src/scripts/view/Preload.ts | 1 + src/scripts/view/battle/Arena.ts | 16 ++++++++++++++++ src/scripts/view/battle/ArenaShip.ts | 15 +++++++++++++++ src/scripts/view/battle/LogProcessor.ts | 1 + 5 files changed, 33 insertions(+) create mode 100644 src/assets/images/battle/arena/shipspriteplaying.png diff --git a/src/assets/images/battle/arena/shipspriteplaying.png b/src/assets/images/battle/arena/shipspriteplaying.png new file mode 100644 index 0000000000000000000000000000000000000000..de3db3e02e47c11d50fb3c8b8e4dfe33f8234555 GIT binary patch literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=oCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#KBG9FHRps!7EwT0SCg=kLATKn>)9125|0lM5Mvnr~cS=1pa*|Gd1Y24s|{tDnm{r-UW|^d2pk literal 0 HcmV?d00001 diff --git a/src/scripts/view/Preload.ts b/src/scripts/view/Preload.ts index b446827..32d6383 100644 --- a/src/scripts/view/Preload.ts +++ b/src/scripts/view/Preload.ts @@ -18,6 +18,7 @@ module SpaceTac.View { this.load.image("battle-actionpointsempty", "assets/images/battle/actionpointsempty.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-shipspriteplaying", "assets/images/battle/arena/shipspriteplaying.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("common-standard-bar-background", "assets/images/common/standard-bar-background.png"); diff --git a/src/scripts/view/battle/Arena.ts b/src/scripts/view/battle/Arena.ts index 6bbd9d5..9d86f30 100644 --- a/src/scripts/view/battle/Arena.ts +++ b/src/scripts/view/battle/Arena.ts @@ -16,10 +16,14 @@ module SpaceTac.View { // List of ship sprites private ship_sprites: ArenaShip[]; + // Currently playing ship + private playing: ArenaShip; + // Create a graphical arena for ship sprites to fight in a 2D space constructor(battleview: BattleView) { this.battleview = battleview; this.ship_sprites = []; + this.playing = null; super(battleview.game); @@ -82,5 +86,17 @@ module SpaceTac.View { 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; + } } } diff --git a/src/scripts/view/battle/ArenaShip.ts b/src/scripts/view/battle/ArenaShip.ts index e6f1e05..d3000d0 100644 --- a/src/scripts/view/battle/ArenaShip.ts +++ b/src/scripts/view/battle/ArenaShip.ts @@ -12,6 +12,9 @@ module SpaceTac.View { // Hover effect hover: Phaser.Image; + // Playing effect + playing: Phaser.Image; + // Create a ship sprite usable in the Arena constructor(battleview: BattleView, ship: Game.Ship) { this.ship = ship; @@ -32,6 +35,12 @@ module SpaceTac.View { this.sprite.anchor.set(0.5, 0.5); 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 this.sprite.input.useHandCursor = true; this.sprite.onInputOver.add(() => { @@ -54,6 +63,12 @@ module SpaceTac.View { 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 moveTo(x: number, y: number, animate: boolean = true) { var angle = Math.atan2(y - this.y, x - this.x); diff --git a/src/scripts/view/battle/LogProcessor.ts b/src/scripts/view/battle/LogProcessor.ts index a02e2bb..fb34104 100644 --- a/src/scripts/view/battle/LogProcessor.ts +++ b/src/scripts/view/battle/LogProcessor.ts @@ -35,6 +35,7 @@ module SpaceTac.View { switch (event.code) { case "ship_change": // Playing ship changed + this.view.arena.setShipPlaying(event.target.ship); this.view.card_playing.setShip(event.target.ship); this.view.action_bar.setShip(event.target.ship); break;