diff --git a/TODO.md b/TODO.md
index 39b72f2..be256b1 100644
--- a/TODO.md
+++ b/TODO.md
@@ -23,13 +23,13 @@ Menu/settings/saves
Map/story
---------
-* Add sound effects and more visual effects (jumps...)
* Add factions and reputation
* Allow to cancel secondary missions
* Forbid to end up with more than 5 ships in the fleet because of escorts
* Fix problems when several dialogs are active at the same time
* Add a zoom level, to see the location only
* Restore the progressive text effect
+* Improve performance when refreshing (and thus during jumps)
Character sheet
---------------
diff --git a/data/stage3/image/map/jump-effect.png b/data/stage3/image/map/jump-effect.png
new file mode 100644
index 0000000..9d64e48
Binary files /dev/null and b/data/stage3/image/map/jump-effect.png differ
diff --git a/data/stage3/sound/map/warp-in.wav b/data/stage3/sound/map/warp-in.wav
new file mode 100644
index 0000000..4ec53e0
Binary files /dev/null and b/data/stage3/sound/map/warp-in.wav differ
diff --git a/data/stage3/sound/map/warp-out.wav b/data/stage3/sound/map/warp-out.wav
new file mode 100644
index 0000000..5452d33
Binary files /dev/null and b/data/stage3/sound/map/warp-out.wav differ
diff --git a/graphics/ui/map.svg b/graphics/ui/map.svg
index ca22739..514c58e 100644
--- a/graphics/ui/map.svg
+++ b/graphics/ui/map.svg
@@ -20,6 +20,42 @@
enable-background="new">
+
+
+
+
+
+
+
+
+
+
+
@@ -1121,6 +1157,76 @@
fx="342.45343"
fy="142.875"
r="9.7939377" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{
- ui!: MainUI;
- view!: T;
- multistorage!: Multi.FakeRemoteStorage;
- clock!: FakeClock;
+ check!: TestContext
+ ui!: MainUI
+ view!: T
+ multistorage!: Multi.FakeRemoteStorage
+ clock: FakeClock
+ time = 0
+
+ constructor(test: TestSuite) {
+ this.clock = test.clock();
+ }
+
+ /**
+ * Advance the time in the view and fake testing clock
+ */
+ clockForward(milliseconds: number) {
+ this.time += milliseconds;
+ this.clock.forward(milliseconds);
+ this.ui.headlessStep(this.time, milliseconds);
+ }
}
/**
* Setup a headless test UI, with a single view started.
*/
export function setupSingleView(test: TestSuite, buildView: () => [T, object]) {
- let testgame = new TestGame();
+ let testgame = new TestGame(test);
test.asetup(() => new Promise((resolve, reject) => {
let check = new TestContext(); // TODO Should be taken from test suite
@@ -25,6 +40,7 @@ module TK.SpaceTac.UI.Specs {
check.patch(console, "warn", null);
testgame.ui = new MainUI(true);
+ testgame.check = check;
let [scene, scenedata] = buildView();
@@ -133,6 +149,17 @@ module TK.SpaceTac.UI.Specs {
}
}
+ /**
+ * Check a simulation of a tweened property
+ */
+ export function checkTween(game: TestGame, obj: T, property: P, expected: number[]): void {
+ let tweendata = game.view.animations.simulate(obj, property, expected.length);
+ game.check.equals(tweendata.length, expected.length, "number of points");
+ expected.forEach((value, idx) => {
+ game.check.nears(tweendata[idx], value, undefined, `point ${idx}`);
+ });
+ }
+
/**
* Simulate a click on a button
*/
diff --git a/src/ui/battle/WeaponEffect.spec.ts b/src/ui/battle/WeaponEffect.spec.ts
index a3ac85c..9520665 100644
--- a/src/ui/battle/WeaponEffect.spec.ts
+++ b/src/ui/battle/WeaponEffect.spec.ts
@@ -1,20 +1,12 @@
module TK.SpaceTac.UI.Specs {
testing("WeaponEffect", test => {
let testgame = setupBattleview(test);
- let clock = test.clock();
- let t = 0;
function checkEmitters(step: string, expected: number) {
test.check.same(testgame.view.arena.layer_weapon_effects.length, expected, `${step} - layer children`);
//test.check.same(keys(testgame.view.particles.emitters).length, expected, `${step} - registered emitters`);
}
- function fastForward(milliseconds: number) {
- t += milliseconds;
- clock.forward(milliseconds);
- testgame.ui.headlessStep(t, milliseconds);
- }
-
test.case("displays shield hit effect", check => {
let battleview = testgame.view;
battleview.timer = new Timer();
@@ -25,7 +17,7 @@ module TK.SpaceTac.UI.Specs {
let layer = battleview.arena.layer_weapon_effects;
check.equals(layer.length, 1);
- clock.forward(600);
+ testgame.clockForward(600);
check.equals(layer.length, 2);
let child = layer.list[0];
@@ -91,12 +83,12 @@ module TK.SpaceTac.UI.Specs {
effect.gunEffect();
checkEmitters("gun effect started", 1);
- fastForward(6000);
+ testgame.clockForward(6000);
checkEmitters("gun effect ended", 0);
effect.hullImpactEffect({ x: 0, y: 0 }, { x: 50, y: 50 }, 1000, 2000);
checkEmitters("hull effect started", 1);
- fastForward(8500);
+ testgame.clockForward(8500);
checkEmitters("hull effect ended", 0);
});
diff --git a/src/ui/common/Animations.spec.ts b/src/ui/common/Animations.spec.ts
index 2650188..7ead98b 100644
--- a/src/ui/common/Animations.spec.ts
+++ b/src/ui/common/Animations.spec.ts
@@ -65,5 +65,21 @@ module TK.SpaceTac.UI.Specs {
check.nears(points[2], 0);
check.nears(points[3], Math.PI * 0.25);
});
+
+ test.case("stops previous animations before starting a new one", check => {
+ let obj = { x: 0, y: 0 };
+ testgame.view.animations.addAnimation(obj, { x: 1 }, 1000);
+ testgame.clockForward(1);
+ testgame.clockForward(1);
+ check.equals(testgame.view.tweens.getAllTweens().length, 1);
+ testgame.view.animations.addAnimation(obj, { y: 1 }, 1000);
+ testgame.clockForward(1);
+ testgame.clockForward(1);
+ check.equals(testgame.view.tweens.getAllTweens().length, 2);
+ testgame.view.animations.addAnimation(obj, { x: 2 }, 1000);
+ testgame.clockForward(1);
+ testgame.clockForward(1);
+ check.equals(testgame.view.tweens.getAllTweens().length, 2);
+ });
});
}
diff --git a/src/ui/common/Animations.ts b/src/ui/common/Animations.ts
index 0304e76..09d46ff 100644
--- a/src/ui/common/Animations.ts
+++ b/src/ui/common/Animations.ts
@@ -22,11 +22,9 @@ module TK.SpaceTac.UI {
* This is a wrapper around phaser's tweens.
*/
export class Animations {
- private tweens: Phaser.Tweens.TweenManager
private immediate = false
- constructor(tweens: Phaser.Tweens.TweenManager) {
- this.tweens = tweens;
+ constructor(private tweens: Phaser.Tweens.TweenManager) {
}
/**
@@ -39,11 +37,14 @@ module TK.SpaceTac.UI {
}
/**
- * Kill previous tweens from an object
+ * Kill previous tweens currently running on an object's properties
*/
- killPrevious(obj: object): void {
- // TODO Only updated properties
- this.tweens.killTweensOf(obj);
+ killPrevious(obj: T, properties: Extract[]): void {
+ this.tweens.getTweensOf(obj).forEach(tween => {
+ if (tween.data && any(tween.data, data => bool(data.key) && contains(properties, data.key))) {
+ tween.stop();
+ }
+ });
}
/**
@@ -70,7 +71,7 @@ module TK.SpaceTac.UI {
* Display an object, with opacity transition
*/
show(obj: IAnimationFadeable, duration = 1000, alpha = 1): void {
- this.killPrevious(obj);
+ this.killPrevious(obj, ['alpha']);
if (!obj.visible) {
obj.alpha = 0;
@@ -105,7 +106,7 @@ module TK.SpaceTac.UI {
* Hide an object, with opacity transition
*/
hide(obj: IAnimationFadeable, duration = 1000, alpha = 0): void {
- this.killPrevious(obj);
+ this.killPrevious(obj, ['alpha']);
if (obj.changeStateFrame) {
obj.changeStateFrame("Out");
@@ -155,8 +156,8 @@ module TK.SpaceTac.UI {
* Add an asynchronous animation to an object.
*/
addAnimation(obj: T, properties: Partial, duration: number, ease = "Linear", delay = 0, loop = 1, yoyo = false): Promise {
- return new Promise((resolve, reject) => {
- this.killPrevious(obj);
+ return new Promise(resolve => {
+ this.killPrevious(obj, keys(properties));
this.tweens.add(merge