Started visual feedback for blast radius (WIP)
This commit is contained in:
parent
496b75b982
commit
cc6b6695f8
|
@ -25,7 +25,7 @@ module SpaceTac {
|
|||
newGame(): Game.Universe {
|
||||
// Currently create a quick battle
|
||||
var universe = new Game.Universe();
|
||||
universe.startQuickBattle();
|
||||
universe.startQuickBattle(true);
|
||||
return universe;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ module SpaceTac.Game {
|
|||
}
|
||||
|
||||
// Start a new "quick battle" game
|
||||
startQuickBattle(): void {
|
||||
this.battle = Game.Battle.newQuickRandom(true);
|
||||
startQuickBattle(with_ai: boolean = false): void {
|
||||
this.battle = Game.Battle.newQuickRandom(with_ai);
|
||||
this.player = this.battle.fleets[0].player;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,15 @@ module SpaceTac.Game {
|
|||
}
|
||||
}
|
||||
|
||||
// Get the effect area radius of this action
|
||||
getBlastRadius(ship: Ship): number {
|
||||
if (this.equipment) {
|
||||
return this.equipment.blast;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Method to check if a target is applicable for this action
|
||||
// Will call checkLocationTarget or checkShipTarget by default
|
||||
checkTarget(battle: Battle, ship: Ship, target: Target): Target {
|
||||
|
|
|
@ -23,6 +23,11 @@ module SpaceTac.Game.Equipments {
|
|||
this.can_target_space = can_target_space;
|
||||
}
|
||||
|
||||
// Set the effect radius (blast) for this weapon
|
||||
setBlast(min_blast: number, max_blast: number = null): void {
|
||||
this.blast = new Range(min_blast, max_blast);
|
||||
}
|
||||
|
||||
protected getActionForEquipment(equipment: Equipment): BaseAction {
|
||||
var result = new FireWeaponAction(equipment, this.can_target_space);
|
||||
return result;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
module SpaceTac.Game.Equipments {
|
||||
"use strict";
|
||||
|
||||
// Equipment: Gatling Gun
|
||||
export class GatlingGun extends AbstractWeapon {
|
||||
constructor() {
|
||||
super("Gatling Gun", 50, 100);
|
||||
|
|
17
src/scripts/game/equipments/SubMunitionMissile.ts
Normal file
17
src/scripts/game/equipments/SubMunitionMissile.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
/// <reference path="AbstractWeapon.ts"/>
|
||||
|
||||
module SpaceTac.Game.Equipments {
|
||||
"use strict";
|
||||
|
||||
export class SubMunitionMissile extends AbstractWeapon {
|
||||
constructor() {
|
||||
super("SubMunition Missile", 30, 50);
|
||||
|
||||
this.setRange(350, 400, true);
|
||||
this.setBlast(150, 200);
|
||||
|
||||
this.ap_usage = new Range(4, 5);
|
||||
this.min_level = new IntegerRange(1, 3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@ module SpaceTac.Game.Specs {
|
|||
describe("Universe", () => {
|
||||
it("serializes to a string", () => {
|
||||
var universe = new Universe();
|
||||
universe.startQuickBattle();
|
||||
universe.startQuickBattle(false);
|
||||
|
||||
// Dump and reload
|
||||
var dumped = universe.saveToString();
|
||||
|
|
|
@ -118,7 +118,7 @@ module SpaceTac.View {
|
|||
// This will check the target against current action and adjust it if needed
|
||||
processHover(target: Game.Target): void {
|
||||
target = this.action.checkTarget(this.battleview.battle, this.ship, target);
|
||||
this.targetting.setTarget(target, false);
|
||||
this.targetting.setTarget(target, false, this.action.getBlastRadius(this.ship));
|
||||
this.bar.updateFadings(this.action.getActionPointsUsage(this.battleview.battle, this.ship, target));
|
||||
}
|
||||
|
||||
|
|
|
@ -46,9 +46,6 @@ module SpaceTac.View {
|
|||
// Indicator of interaction disabled
|
||||
icon_waiting: Phaser.Image;
|
||||
|
||||
// Listener for space key presses
|
||||
private space_key: Phaser.Key;
|
||||
|
||||
// Lines used to highlight hovered ship
|
||||
private line_hover_left: Phaser.Graphics;
|
||||
private line_hover_right: Phaser.Graphics;
|
||||
|
@ -61,14 +58,12 @@ module SpaceTac.View {
|
|||
this.ship_hovered = null;
|
||||
this.log_processor = null;
|
||||
this.background = null;
|
||||
this.space_key = null;
|
||||
this.line_hover_left = null;
|
||||
this.line_hover_right = null;
|
||||
}
|
||||
|
||||
// Create view graphics
|
||||
create() {
|
||||
var battleview = this;
|
||||
var game = this.game;
|
||||
|
||||
// Background
|
||||
|
@ -77,7 +72,7 @@ module SpaceTac.View {
|
|||
game.add.existing(this.background);
|
||||
|
||||
// Add arena (local map)
|
||||
this.arena = new Arena(battleview);
|
||||
this.arena = new Arena(this);
|
||||
game.add.existing(this.arena);
|
||||
|
||||
// Add UI layer
|
||||
|
@ -107,8 +102,8 @@ module SpaceTac.View {
|
|||
this.log_processor = new LogProcessor(this);
|
||||
|
||||
// Key mapping
|
||||
this.space_key = this.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);
|
||||
this.space_key.onUp.add(this.onSpaceKeyPressed, this);
|
||||
var key_space = this.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);
|
||||
key_space.onUp.add(this.onSpaceKeyPressed, this);
|
||||
var key_s = this.input.keyboard.addKey(Phaser.Keyboard.S);
|
||||
key_s.onUp.add(() => {
|
||||
(<GameRouter>this.game).saveGame();
|
||||
|
@ -158,11 +153,6 @@ module SpaceTac.View {
|
|||
this.line_hover_right = null;
|
||||
}
|
||||
|
||||
if (this.space_key) {
|
||||
this.space_key.onUp.remove(this.onSpaceKeyPressed, this);
|
||||
this.space_key = null;
|
||||
}
|
||||
|
||||
this.battle = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,10 @@ module SpaceTac.View {
|
|||
target_corrected: Game.Target;
|
||||
line_corrected: Phaser.Graphics;
|
||||
|
||||
// Circle for effect radius
|
||||
blast_radius: number;
|
||||
blast: Phaser.Graphics;
|
||||
|
||||
// Signal to receive hovering events
|
||||
targetHovered: Phaser.Signal;
|
||||
|
||||
|
@ -32,9 +36,14 @@ module SpaceTac.View {
|
|||
|
||||
// Visual effects
|
||||
if (battleview) {
|
||||
this.blast = new Phaser.Graphics(battleview.game, 0, 0);
|
||||
this.blast.visible = false;
|
||||
battleview.arena.add(this.blast);
|
||||
this.line_initial = new Phaser.Graphics(battleview.game, 0, 0);
|
||||
this.line_initial.visible = false;
|
||||
battleview.arena.add(this.line_initial);
|
||||
this.line_corrected = new Phaser.Graphics(battleview.game, 0, 0);
|
||||
this.line_corrected.visible = false;
|
||||
battleview.arena.add(this.line_corrected);
|
||||
}
|
||||
|
||||
|
@ -53,6 +62,9 @@ module SpaceTac.View {
|
|||
if (this.line_corrected) {
|
||||
this.line_corrected.destroy();
|
||||
}
|
||||
if (this.blast) {
|
||||
this.blast.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
// Update visual effects for current targetting
|
||||
|
@ -67,6 +79,7 @@ module SpaceTac.View {
|
|||
} else {
|
||||
this.line_initial.visible = false;
|
||||
}
|
||||
|
||||
if (this.source && this.target_corrected) {
|
||||
this.line_corrected.clear();
|
||||
this.line_corrected.lineStyle(3, 0x00FF00);
|
||||
|
@ -76,6 +89,17 @@ module SpaceTac.View {
|
|||
} else {
|
||||
this.line_corrected.visible = false;
|
||||
}
|
||||
|
||||
if (this.target_corrected && this.blast_radius) {
|
||||
this.blast.clear();
|
||||
this.blast.lineStyle(5, 0x208620, 0.4);
|
||||
this.blast.beginFill(0x60D860, 0.2);
|
||||
this.blast.drawCircle(this.target_corrected.x, this.target_corrected.y, this.blast_radius * 2);
|
||||
this.blast.endFill();
|
||||
this.blast.visible = true;
|
||||
} else {
|
||||
this.blast.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,8 +109,9 @@ module SpaceTac.View {
|
|||
}
|
||||
|
||||
// Set a target from a target object
|
||||
setTarget(target: Game.Target, dispatch: boolean = true): void {
|
||||
setTarget(target: Game.Target, dispatch: boolean = true, blast_radius: number = 0): void {
|
||||
this.target_corrected = target;
|
||||
this.blast_radius = blast_radius;
|
||||
if (dispatch) {
|
||||
this.target_initial = target ? Game.Tools.copyObject(target) : null;
|
||||
this.targetHovered.dispatch(this.target_corrected);
|
||||
|
|
Loading…
Reference in a new issue