Started work on remote session saving (WIP)
1
TODO
|
@ -5,6 +5,7 @@
|
|||
* Character sheet: highlight allowed destinations during drag-and-drop, with text hints
|
||||
* Character sheet: when transferring to another ship, if the item can't be equipped (unmatched requirements), the transfer is cancelled instead of trying cargo
|
||||
* Character sheet: effective skill is sometimes not updated when upgrading base skill
|
||||
* Menu: end appear animation when a button is clicked
|
||||
* Add permanent effects to ship models to ease balancing
|
||||
* Find incentives to move from starting position
|
||||
* Fix targetting not resetting when using action shortcuts
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
"private": true,
|
||||
"dependencies": {
|
||||
"phaser": "2.6.2",
|
||||
"parse": "1.9.2",
|
||||
"jasmine-core": "jasmine#^2.5.2",
|
||||
"deep-diff": "0.3.0"
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
version="1.1"
|
||||
id="svg8"
|
||||
sodipodi:docname="title.svg"
|
||||
inkscape:version="0.92.0 unknown"
|
||||
inkscape:version="0.92.1 r15371"
|
||||
inkscape:export-filename="/home/michael/workspace/spacetac/out/assets/images/menu/title.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96">
|
||||
|
@ -212,6 +212,38 @@
|
|||
result="composite2"
|
||||
id="feComposite7405" />
|
||||
</filter>
|
||||
<filter
|
||||
style="color-interpolation-filters:sRGB"
|
||||
inkscape:label="Drop Shadow"
|
||||
id="filter9551">
|
||||
<feFlood
|
||||
flood-opacity="0.211765"
|
||||
flood-color="rgb(255,255,255)"
|
||||
result="flood"
|
||||
id="feFlood9541" />
|
||||
<feComposite
|
||||
in="flood"
|
||||
in2="SourceGraphic"
|
||||
operator="out"
|
||||
result="composite1"
|
||||
id="feComposite9543" />
|
||||
<feGaussianBlur
|
||||
in="composite1"
|
||||
stdDeviation="1.4"
|
||||
result="blur"
|
||||
id="feGaussianBlur9545" />
|
||||
<feOffset
|
||||
dx="0"
|
||||
dy="0"
|
||||
result="offset"
|
||||
id="feOffset9547" />
|
||||
<feComposite
|
||||
in="offset"
|
||||
in2="SourceGraphic"
|
||||
operator="atop"
|
||||
result="composite2"
|
||||
id="feComposite9549" />
|
||||
</filter>
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
|
@ -220,11 +252,11 @@
|
|||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.7"
|
||||
inkscape:cx="1018.5056"
|
||||
inkscape:cy="493.50647"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer2"
|
||||
inkscape:zoom="89.6"
|
||||
inkscape:cx="287.94937"
|
||||
inkscape:cy="957.67084"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer4"
|
||||
showgrid="false"
|
||||
showguides="true"
|
||||
inkscape:lockguides="false"
|
||||
|
@ -234,7 +266,8 @@
|
|||
inkscape:window-x="0"
|
||||
inkscape:window-y="20"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:snap-page="true" />
|
||||
inkscape:snap-page="true"
|
||||
inkscape:snap-global="false" />
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
|
@ -243,7 +276,7 @@
|
|||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
|
@ -486,4 +519,196 @@
|
|||
y="209.34711"
|
||||
style="font-size:14.11111069px;fill:#4b8ad4;fill-opacity:1;stroke-width:0.26458332px">Quick battle</tspan></text>
|
||||
</g>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer4"
|
||||
inkscape:label="Load dialog"
|
||||
style="display:inline">
|
||||
<rect
|
||||
style="fill:#1e3959;fill-opacity:1;fill-rule:evenodd;stroke:#8fbcbd;stroke-width:0.79374999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.96170211"
|
||||
id="rect4557"
|
||||
width="354.92212"
|
||||
height="116.0214"
|
||||
x="76.538948"
|
||||
y="32.743774"
|
||||
inkscape:export-filename="/home/michael/workspace/perso/spacetac/out/assets/images/menu/load-bg.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:7.05555534px;line-height:6.61458302px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
x="97.2136"
|
||||
y="67.559311"
|
||||
id="text4560"
|
||||
inkscape:export-filename="/home/michael/workspace/perso/spacetac/out/assets/images/menu/load-bg.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan4558"
|
||||
x="97.2136"
|
||||
y="67.559311"
|
||||
style="font-size:11.28888893px;fill:#ffffff;fill-opacity:1;stroke-width:0.26458332px">Load a saved game</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:7.05555534px;line-height:6.61458302px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
x="95.460739"
|
||||
y="125.1629"
|
||||
id="text4564"
|
||||
inkscape:export-filename="/home/michael/workspace/perso/spacetac/out/assets/images/menu/load-bg.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan4562"
|
||||
x="95.460739"
|
||||
y="125.1629"
|
||||
style="font-size:11.28888893px;fill:#ffffff;fill-opacity:1;stroke-width:0.26458332px">Enter an invite code</tspan></text>
|
||||
<rect
|
||||
style="fill:#8bb8ba;fill-opacity:1;fill-rule:evenodd;stroke:#fbfbfb;stroke-width:0.5291667;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.4595745"
|
||||
id="rect5683"
|
||||
width="128.48969"
|
||||
height="22.278383"
|
||||
x="228.9494"
|
||||
y="110.90936"
|
||||
inkscape:export-filename="/home/michael/workspace/perso/spacetac/out/assets/images/menu/load-bg.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<path
|
||||
sodipodi:type="star"
|
||||
style="display:inline;fill:#267482;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.26458335px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;filter:url(#filter9551)"
|
||||
id="path4777"
|
||||
sodipodi:sides="3"
|
||||
sodipodi:cx="350.90195"
|
||||
sodipodi:cy="64.444939"
|
||||
sodipodi:r1="5.7819242"
|
||||
sodipodi:r2="2.8909619"
|
||||
sodipodi:arg1="2.0943951"
|
||||
sodipodi:arg2="3.1415927"
|
||||
inkscape:flatsided="true"
|
||||
inkscape:rounded="0"
|
||||
inkscape:randomized="0"
|
||||
d="m 348.01098,69.452232 0,-10.014587 8.67289,5.007294 z"
|
||||
inkscape:transform-center-x="-1.4454898"
|
||||
inkscape:transform-center-y="3.6247564e-06"
|
||||
inkscape:export-filename="/home/michael/workspace/perso/spacetac/out/assets/images/character/scroll.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<rect
|
||||
style="fill:#8fbcbd;fill-opacity:0.96470588;fill-rule:evenodd;stroke:#fbfbfb;stroke-width:0.5291667;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.45882353"
|
||||
id="rect6552"
|
||||
width="94.872017"
|
||||
height="51.026787"
|
||||
x="245.75824"
|
||||
y="38.931549"
|
||||
inkscape:export-filename="/home/michael/workspace/perso/spacetac/out/assets/images/menu/load-bg.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<use
|
||||
x="0"
|
||||
y="0"
|
||||
xlink:href="#path4777"
|
||||
inkscape:transform-center-x="1.4454929"
|
||||
inkscape:transform-center-y="3.6247564e-06"
|
||||
id="use6554"
|
||||
width="100%"
|
||||
height="100%"
|
||||
transform="matrix(-1,0,0,1,586.38849,-6.6582243e-7)" />
|
||||
<g
|
||||
id="g6590"
|
||||
style="stroke-width:0.5291667;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
transform="translate(-16.179248,-22.874057)">
|
||||
<text
|
||||
id="text6566"
|
||||
y="100.1637"
|
||||
x="270.46942"
|
||||
style="font-style:normal;font-weight:normal;font-size:7.05555534px;line-height:6.61458302px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.5291667;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
xml:space="preserve"><tspan
|
||||
style="font-size:8.46666622px;stroke-width:0.5291667;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
y="100.1637"
|
||||
x="270.46942"
|
||||
id="tspan6564"
|
||||
sodipodi:role="line">On your computer</tspan></text>
|
||||
<text
|
||||
id="text6570"
|
||||
y="78.997025"
|
||||
x="271.16394"
|
||||
style="font-style:normal;font-weight:normal;font-size:7.05555534px;line-height:6.61458302px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.5291667;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
xml:space="preserve"><tspan
|
||||
style="font-size:8.46666622px;stroke-width:0.5291667;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
y="78.997025"
|
||||
x="271.16394"
|
||||
id="tspan6568"
|
||||
sodipodi:role="line">2017-05-03 18:30</tspan></text>
|
||||
</g>
|
||||
<g
|
||||
id="g6668"
|
||||
transform="translate(0,-3.8146973e-6)">
|
||||
<circle
|
||||
r="18.898809"
|
||||
cy="64.444946"
|
||||
cx="390.90109"
|
||||
id="path6600"
|
||||
style="fill:#343434;fill-opacity:0.41914894;fill-rule:evenodd;stroke:#c7c7c7;stroke-width:1.05833328;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.47021275" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path6604"
|
||||
d="m 378.80715,63.843591 9.88896,11.091685 14.29893,-20.980659 -15.10075,13.363477 z"
|
||||
style="fill:#a0f26a;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
</g>
|
||||
<circle
|
||||
style="fill:#19232c;fill-opacity:1;stroke:#90cedf;stroke-width:0.60000002;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:59.55590439;stroke-opacity:1;filter:url(#filter4662)"
|
||||
id="use7600-7"
|
||||
cx="254"
|
||||
cy="149.29829"
|
||||
r="3.2072344"
|
||||
inkscape:export-filename="/home/michael/workspace/perso/spacetac/out/assets/images/menu/load-bg.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<use
|
||||
style="display:inline"
|
||||
x="0"
|
||||
y="0"
|
||||
xlink:href="#use7600-7"
|
||||
id="use7603-5"
|
||||
transform="translate(-1.9835942e-6,29.108755)"
|
||||
width="100%"
|
||||
height="100%"
|
||||
inkscape:export-filename="/home/michael/workspace/perso/spacetac/out/assets/images/menu/load-bg.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<path
|
||||
style="display:inline;fill:none;fill-rule:evenodd;stroke:#b4c5cc;stroke-width:2.56500006;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:5.13000024, 5.13000024;stroke-dashoffset:8.46450043;stroke-opacity:0.56470588"
|
||||
d="M 254,178.43669 V 149.46351"
|
||||
id="path7605-3"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:export-filename="/home/michael/workspace/perso/spacetac/out/assets/images/menu/load-bg.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<g
|
||||
id="g6672"
|
||||
transform="translate(0,0.52916667)">
|
||||
<use
|
||||
transform="translate(-0.3779762,57.074418)"
|
||||
height="100%"
|
||||
width="100%"
|
||||
id="use6602"
|
||||
xlink:href="#path6600"
|
||||
y="0"
|
||||
x="0" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="rect6659"
|
||||
d="m 399.34314,110.16048 -8.81985,8.81984 -8.81982,-8.81982 -2.53922,2.53921 8.81983,8.81983 -8.81984,8.81984 2.53886,2.53887 8.81985,-8.81984 8.81982,8.81982 2.53922,-2.53921 -8.81983,-8.81983 8.81984,-8.81984 z"
|
||||
style="fill:#b4220c;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
</g>
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#8bb8ba;stroke-width:0.79374999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 76.634672,96.232741 H 431.45982"
|
||||
id="path6674"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:export-filename="/home/michael/workspace/perso/spacetac/out/assets/images/menu/load-bg.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
</g>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
BIN
out/assets/images/common/button-cancel.png
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
out/assets/images/common/button-ok.png
Normal file
After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
BIN
out/assets/images/menu/load-bg.png
Normal file
After Width: | Height: | Size: 29 KiB |
|
@ -6,34 +6,37 @@
|
|||
<title>SpaceTac</title>
|
||||
|
||||
<style>
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
background: #000000;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.game {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
}
|
||||
html,
|
||||
body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
background: #000000;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.game {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="-space-tac" class="game"></div>
|
||||
|
||||
<script src="vendor/parse/parse.min.js"></script>
|
||||
<script src="vendor/phaser/build/phaser.min.js"></script>
|
||||
<script src="build.js"></script>
|
||||
|
||||
<script>
|
||||
window.oncontextmenu = function (e) { e.preventDefault(); };
|
||||
window.onload = function () {
|
||||
new TS.SpaceTac.MainUI();
|
||||
window.ui = new TS.SpaceTac.MainUI();
|
||||
window.connection = new TS.SpaceTac.Multi.Connection(window.ui);
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
|
@ -50,9 +50,9 @@ module TS.SpaceTac {
|
|||
}
|
||||
|
||||
// Create a quick random battle, for testing purposes
|
||||
static newQuickRandom(start = true, level = 1): Battle {
|
||||
var player1 = Player.newQuickRandom("John", level, true);
|
||||
var player2 = Player.newQuickRandom("Carl", level, true);
|
||||
static newQuickRandom(start = true, level = 1, shipcount = 5): Battle {
|
||||
var player1 = Player.newQuickRandom("John", level, shipcount, true);
|
||||
var player2 = Player.newQuickRandom("Carl", level, shipcount, true);
|
||||
|
||||
var result = new Battle(player1.fleet, player2.fleet);
|
||||
if (start) {
|
||||
|
|
|
@ -72,7 +72,7 @@ module TS.SpaceTac {
|
|||
});
|
||||
|
||||
it("can receive simulated initial state events", function () {
|
||||
let battle = Battle.newQuickRandom();
|
||||
let battle = Battle.newQuickRandom(true, 1, 4);
|
||||
let playing = nn(battle.playing_ship);
|
||||
battle.log.clear();
|
||||
battle.log.addFilter("value");
|
||||
|
|
|
@ -21,10 +21,10 @@ module TS.SpaceTac {
|
|||
}
|
||||
|
||||
// Create a quick random player, with a fleet, for testing purposes
|
||||
static newQuickRandom(name: string, level = 1, upgrade = false): Player {
|
||||
static newQuickRandom(name: string, level = 1, shipcount = 4, upgrade = false): Player {
|
||||
let player = new Player(new Universe(), name);
|
||||
let generator = new FleetGenerator();
|
||||
player.fleet = generator.generate(level, player, 4, upgrade);
|
||||
player.fleet = generator.generate(level, player, shipcount, upgrade);
|
||||
return player;
|
||||
}
|
||||
|
||||
|
|
64
src/multi/Connection.ts
Normal file
|
@ -0,0 +1,64 @@
|
|||
/// <reference path="Parse.d.ts" />
|
||||
|
||||
module TS.SpaceTac.Multi {
|
||||
/**
|
||||
* Multiplayer connection to a Parse server
|
||||
*/
|
||||
export class Connection {
|
||||
ui: MainUI
|
||||
serializer = new Serializer(TS.SpaceTac)
|
||||
model_session = Parse.Object.extend("SpaceTacSession")
|
||||
token_chars = "abcdefghjkmnpqrstuvwxyz123456789"
|
||||
|
||||
constructor(ui: MainUI) {
|
||||
this.ui = ui;
|
||||
|
||||
Parse.initialize("thunderk.net");
|
||||
Parse.serverURL = 'https://rs.thunderk.net/parse';
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an unused session token
|
||||
*/
|
||||
getUnusedToken(length = 5): string {
|
||||
let token = range(length).map(() => RandomGenerator.global.choice(<any>this.token_chars)).join("");
|
||||
// TODO check if it is unused on server
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish current session to remote server, and return a session token
|
||||
*/
|
||||
publish(): string {
|
||||
let session = new this.model_session();
|
||||
let token = this.getUnusedToken();
|
||||
|
||||
session.set("token", token);
|
||||
session.set("data", this.serializer.serialize(this.ui.session));
|
||||
|
||||
session.save();
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a session from a remote server, by its token
|
||||
*/
|
||||
load(token: string): void {
|
||||
let query = new Parse.Query(this.model_session);
|
||||
query.equalTo("token", token);
|
||||
query.find({
|
||||
success: (results: any) => {
|
||||
if (results.length == 1) {
|
||||
let data = results[0].get("data");
|
||||
let session = this.serializer.unserialize(data);
|
||||
if (session instanceof GameSession) {
|
||||
this.ui.session = session;
|
||||
this.ui.state.start('router');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
1100
src/multi/Parse.d.ts
vendored
Normal file
|
@ -15,7 +15,13 @@ module TS.SpaceTac.UI {
|
|||
this.loadImage("menu/button.png");
|
||||
this.loadImage("menu/button-hover.png");
|
||||
this.loadImage("menu/star.png");
|
||||
this.loadImage("battle/waiting.png");
|
||||
this.loadImage("menu/load-bg.png");
|
||||
this.loadImage("common/standard-bar-background.png");
|
||||
this.loadImage("common/standard-bar-foreground.png");
|
||||
this.loadImage("common/waiting.png");
|
||||
this.loadImage("common/arrow.png");
|
||||
this.loadImage("common/button-ok.png");
|
||||
this.loadImage("common/button-cancel.png");
|
||||
this.loadImage("battle/shiplist-background.png");
|
||||
this.loadImage("battle/shiplist-own.png");
|
||||
this.loadImage("battle/shiplist-enemy.png");
|
||||
|
@ -76,8 +82,6 @@ module TS.SpaceTac.UI {
|
|||
this.loadImage("battle/outcome/button-map.png");
|
||||
this.loadImage("battle/outcome/button-revert.png");
|
||||
this.loadImage("battle/outcome/button-loot.png");
|
||||
this.loadImage("common/standard-bar-background.png");
|
||||
this.loadImage("common/standard-bar-foreground.png");
|
||||
this.loadImage("map/starsystem-background.png");
|
||||
this.loadImage("map/current-location.png");
|
||||
this.loadImage("map/zoom-in.png");
|
||||
|
@ -104,7 +108,6 @@ module TS.SpaceTac.UI {
|
|||
this.loadImage("character/slot-weapon.png");
|
||||
this.loadImage("character/upgrade-available.png");
|
||||
this.loadImage("character/price-tag.png");
|
||||
this.loadImage("character/scroll.png");
|
||||
this.loadImage("equipment/ironhull.png");
|
||||
this.loadImage("equipment/forcefield.png");
|
||||
this.loadImage("equipment/nuclearreactor.png");
|
||||
|
|
|
@ -47,7 +47,7 @@ module TS.SpaceTac.UI {
|
|||
this.addChild(this.actions);
|
||||
|
||||
// Waiting icon
|
||||
this.icon_waiting = new Phaser.Image(this.game, this.width / 2, 50, "battle-waiting", 0);
|
||||
this.icon_waiting = new Phaser.Image(this.game, this.width / 2, 50, "common-waiting", 0);
|
||||
this.icon_waiting.anchor.set(0.5, 0.5);
|
||||
this.icon_waiting.scale.set(0.5, 0.5);
|
||||
this.game.tweens.create(this.icon_waiting).to({ "angle": 360 }, 3000).loop().start();
|
||||
|
|
|
@ -8,8 +8,8 @@ module TS.SpaceTac.UI.Specs {
|
|||
let battleview = testgame.battleview;
|
||||
var list = battleview.ship_list;
|
||||
|
||||
expect(battleview.battle.play_order.length).toBe(8);
|
||||
expect(list.children.length).toBe(8);
|
||||
expect(battleview.battle.play_order.length).toBe(10);
|
||||
expect(list.children.length).toBe(10);
|
||||
|
||||
expect(list.findPlayPosition(battleview.battle.play_order[0])).toBe(0);
|
||||
expect(list.findPlayPosition(battleview.battle.play_order[1])).toBe(1);
|
||||
|
@ -18,7 +18,7 @@ module TS.SpaceTac.UI.Specs {
|
|||
spyOn(battleview.battle, "playAI").and.stub();
|
||||
battleview.battle.advanceToNextShip();
|
||||
|
||||
expect(list.findPlayPosition(battleview.battle.play_order[0])).toBe(7);
|
||||
expect(list.findPlayPosition(battleview.battle.play_order[0])).toBe(9);
|
||||
expect(list.findPlayPosition(battleview.battle.play_order[1])).toBe(0);
|
||||
expect(list.findPlayPosition(battleview.battle.play_order[2])).toBe(1);
|
||||
});
|
||||
|
|
|
@ -85,7 +85,7 @@ module TS.SpaceTac.UI {
|
|||
if (position === 0) {
|
||||
item.moveTo(20, 20 - this.y, animate);
|
||||
} else {
|
||||
item.moveTo(8, 38 + position * 102 - this.y, animate);
|
||||
item.moveTo(8, 40 + position * 104 - this.y, animate);
|
||||
}
|
||||
this.setChildIndex(item, position);
|
||||
});
|
||||
|
|
|
@ -120,11 +120,11 @@ module TS.SpaceTac.UI {
|
|||
this.mode_title.anchor.set(0.5, 0.5);
|
||||
this.addChild(this.mode_title);
|
||||
|
||||
this.loot_next = new Phaser.Button(this.game, 1890, 850, "character-scroll", () => this.paginate(1));
|
||||
this.loot_next = new Phaser.Button(this.game, 1890, 850, "common-arrow", () => this.paginate(1));
|
||||
this.loot_next.anchor.set(0.5, 0.5);
|
||||
this.addChild(this.loot_next);
|
||||
|
||||
this.loot_prev = new Phaser.Button(this.game, 1238, 850, "character-scroll", () => this.paginate(-1));
|
||||
this.loot_prev = new Phaser.Button(this.game, 1238, 850, "common-arrow", () => this.paginate(-1));
|
||||
this.loot_prev.anchor.set(0.5, 0.5);
|
||||
this.loot_prev.angle = 180;
|
||||
this.addChild(this.loot_prev);
|
||||
|
|
|
@ -9,7 +9,7 @@ module TS.SpaceTac.UI {
|
|||
private width: number;
|
||||
private height: number;
|
||||
|
||||
constructor(parent: BaseView | UIComponent, width: number, height: number) {
|
||||
constructor(parent: BaseView | UIComponent, width: number, height: number, background_key: string | null = null) {
|
||||
if (parent instanceof UIComponent) {
|
||||
this.view = parent.view;
|
||||
this.parent = parent;
|
||||
|
@ -22,6 +22,10 @@ module TS.SpaceTac.UI {
|
|||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
if (background_key) {
|
||||
this.container.add(new Phaser.Image(this.view.game, 0, 0, background_key));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,6 +69,13 @@ module TS.SpaceTac.UI {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the position in pixels.
|
||||
*/
|
||||
setPosition(x: number, y: number): void {
|
||||
this.container.position.set(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Position the component inside the boundaries of its parent.
|
||||
*
|
||||
|
@ -83,5 +94,15 @@ module TS.SpaceTac.UI {
|
|||
this.container.position.set(rx, ry);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a button in the component, positioning its center.
|
||||
*/
|
||||
addButton(x: number, y: number, on_click: Function, bg_normal: string, bg_hover = bg_normal, angle = 0) {
|
||||
let button = new Phaser.Button(this.view.game, x, y, bg_normal, on_click);
|
||||
button.anchor.set(0.5, 0.5);
|
||||
button.angle = angle;
|
||||
this.container.add(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
17
src/ui/menu/LoadDialog.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
/// <reference path="../common/UIComponent.ts"/>
|
||||
|
||||
module TS.SpaceTac.UI {
|
||||
/**
|
||||
* Dialog to load a saved game, or join an online one
|
||||
*/
|
||||
export class LoadDialog extends UIComponent {
|
||||
constructor(parent: MainMenu) {
|
||||
super(parent, 1344, 566, "menu-load-bg");
|
||||
|
||||
this.addButton(600, 115, () => null, "common-arrow", "common-arrow", 180);
|
||||
this.addButton(1038, 115, () => null, "common-arrow", "common-arrow", 0);
|
||||
this.addButton(1224, 115, () => null, "common-button-cancel");
|
||||
this.addButton(1224, 341, () => null, "common-button-cancel");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/// <reference path="TestGame.ts" />
|
||||
/// <reference path="../TestGame.ts" />
|
||||
/// <reference path="MainMenu.ts" />
|
||||
|
||||
module TS.SpaceTac.UI.Specs {
|
|
@ -1,12 +1,16 @@
|
|||
/// <reference path="BaseView.ts"/>
|
||||
/// <reference path="../BaseView.ts"/>
|
||||
|
||||
module TS.SpaceTac.UI {
|
||||
/**
|
||||
* Main menu (first interactive screen)
|
||||
*/
|
||||
export class MainMenu extends BaseView {
|
||||
layer_stars: Phaser.Group;
|
||||
layer_title: Phaser.Group;
|
||||
button_new_game: Phaser.Button;
|
||||
button_quick_battle: Phaser.Button;
|
||||
button_load_game: Phaser.Button;
|
||||
dialog_load_game: LoadDialog;
|
||||
|
||||
create() {
|
||||
super.create();
|
||||
|
@ -28,13 +32,18 @@ module TS.SpaceTac.UI {
|
|||
|
||||
// Menu buttons
|
||||
this.button_new_game = this.addButton(322, 674, "New Game", "Start a new campaign in a generated universe", this.onNewGame);
|
||||
this.button_load_game = this.addButton(960, 674, "Load Game", "Load a saved campaign", this.onLoadGame);
|
||||
this.button_load_game = this.addButton(960, 674, "Load / Join", "Load a saved game or join a friend", this.onLoadGame);
|
||||
this.button_quick_battle = this.addButton(1606, 674, "Quick Battle", "Play a single generated battle", this.onQuickBattle);
|
||||
|
||||
// Title
|
||||
let title = this.add.image(960, 225, "menu-title", 0, this.layer_title);
|
||||
title.anchor.set(0.5, 0);
|
||||
|
||||
// Dialogs
|
||||
this.dialog_load_game = new LoadDialog(this);
|
||||
this.dialog_load_game.setPosition(264, 160);
|
||||
this.dialog_load_game.setVisible(false);
|
||||
|
||||
this.tweens.create(this.layer_title).to({ x: 0 }, 3000, Phaser.Easing.Circular.Out).start();
|
||||
}
|
||||
|
||||
|
@ -82,22 +91,7 @@ module TS.SpaceTac.UI {
|
|||
|
||||
// Called when "Load Game" is clicked
|
||||
onLoadGame(): void {
|
||||
var gameui = <MainUI>this.game;
|
||||
|
||||
if (gameui.loadGame()) {
|
||||
this.game.state.start("router");
|
||||
} else {
|
||||
var error = this.game.add.text(this.button_load_game.x, this.button_load_game.y + 40,
|
||||
"No saved game found",
|
||||
{ font: "bold 16px Arial", fill: "#e04040" });
|
||||
error.anchor.set(0.5, 0.5);
|
||||
var tween = this.game.tweens.create(error);
|
||||
tween.to({ y: error.y + 100, alpha: 0 }, 1000, Phaser.Easing.Exponential.In);
|
||||
tween.onComplete.addOnce(() => {
|
||||
error.destroy();
|
||||
});
|
||||
tween.start();
|
||||
}
|
||||
this.dialog_load_game.setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,4 +5,4 @@
|
|||
"jasmine": "registry:dt/jasmine#2.5.2+20170317130948",
|
||||
"phaser": "github:thunderk/phaser/typescript/typings.json#v2.6.2a"
|
||||
}
|
||||
}
|
||||
}
|