map: Added mission markers
This commit is contained in:
parent
7c03a1e2d1
commit
ce3543026e
2
TODO.md
2
TODO.md
|
@ -4,6 +4,7 @@ To-Do-list
|
||||||
Menu/settings/saves
|
Menu/settings/saves
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
* Save locally first, make saving to cloud an option
|
||||||
* Allow to delete cloud saves
|
* Allow to delete cloud saves
|
||||||
* Fix cloud save games with "Level 0 - 0 ships"
|
* Fix cloud save games with "Level 0 - 0 ships"
|
||||||
|
|
||||||
|
@ -17,7 +18,6 @@ Map/story
|
||||||
* Add factions and reputation
|
* Add factions and reputation
|
||||||
* Allow to cancel secondary missions
|
* Allow to cancel secondary missions
|
||||||
* Forbid to end up with more than 5 ships in the fleet because of escorts
|
* Forbid to end up with more than 5 ships in the fleet because of escorts
|
||||||
* Show missions' destination near systems/locations
|
|
||||||
|
|
||||||
Character sheet
|
Character sheet
|
||||||
---------------
|
---------------
|
||||||
|
|
|
@ -26,7 +26,7 @@ module TS.SpaceTac {
|
||||||
let contact_location = randomLocation(random, [start_location.star], [start_location]);
|
let contact_location = randomLocation(random, [start_location.star], [start_location]);
|
||||||
let contact_character = new Ship(null, "Osten-37", ShipModel.getRandomModel(1, random));
|
let contact_character = new Ship(null, "Osten-37", ShipModel.getRandomModel(1, random));
|
||||||
contact_character.fleet.setLocation(contact_location, true);
|
contact_character.fleet.setLocation(contact_location, true);
|
||||||
this.addPart(new MissionPartGoTo(this, contact_location, `Find your contact in ${contact_location.star.name}`));
|
this.addPart(new MissionPartGoTo(this, contact_location, `Find your contact in ${contact_location.star.name}`, MissionPartDestinationHint.SYSTEM));
|
||||||
conversation = this.addPart(new MissionPartConversation(this, [contact_character], "Speak with your contact"));
|
conversation = this.addPart(new MissionPartConversation(this, [contact_character], "Speak with your contact"));
|
||||||
conversation.addPiece(contact_character, "Finally, you came!");
|
conversation.addPiece(contact_character, "Finally, you came!");
|
||||||
conversation.addPiece(contact_character, "Sorry for not broadcasting my position. As you may have encountered, this star system is not safe anymore.");
|
conversation.addPiece(contact_character, "Sorry for not broadcasting my position. As you may have encountered, this star system is not safe anymore.");
|
||||||
|
|
|
@ -36,6 +36,13 @@ module TS.SpaceTac {
|
||||||
forceComplete(): void {
|
forceComplete(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a location hint about this part
|
||||||
|
*/
|
||||||
|
getLocationHint(): Star | StarLocation | null {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event called when the part starts
|
* Event called when the part starts
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,16 +1,27 @@
|
||||||
/// <reference path="MissionPart.ts" />
|
/// <reference path="MissionPart.ts" />
|
||||||
|
|
||||||
module TS.SpaceTac {
|
module TS.SpaceTac {
|
||||||
|
/**
|
||||||
|
* Level of hint to help find a destination
|
||||||
|
*/
|
||||||
|
export enum MissionPartDestinationHint {
|
||||||
|
PRECISE,
|
||||||
|
SYSTEM_AND_INFO,
|
||||||
|
SYSTEM
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mission part that requires the fleet to go to a specific location
|
* A mission part that requires the fleet to go to a specific location
|
||||||
*/
|
*/
|
||||||
export class MissionPartGoTo extends MissionPart {
|
export class MissionPartGoTo extends MissionPart {
|
||||||
destination: StarLocation
|
destination: StarLocation
|
||||||
|
hint: MissionPartDestinationHint
|
||||||
|
|
||||||
constructor(mission: Mission, destination: StarLocation, directive?: string) {
|
constructor(mission: Mission, destination: StarLocation, directive?: string, hint = MissionPartDestinationHint.PRECISE) {
|
||||||
super(mission, directive || `Go to ${destination.star.name} system`);
|
super(mission, directive || `Go to ${destination.star.name} system`);
|
||||||
|
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
|
this.hint = hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkCompleted(): boolean {
|
checkCompleted(): boolean {
|
||||||
|
@ -21,5 +32,9 @@ module TS.SpaceTac {
|
||||||
this.destination.clearEncounter();
|
this.destination.clearEncounter();
|
||||||
this.fleet.setLocation(this.destination, true);
|
this.fleet.setLocation(this.destination, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLocationHint(): Star | StarLocation | null {
|
||||||
|
return (this.hint == MissionPartDestinationHint.PRECISE) ? this.destination : this.destination.star;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,13 @@ module TS.SpaceTac.UI {
|
||||||
export class ActiveMissionsDisplay extends UIComponent {
|
export class ActiveMissionsDisplay extends UIComponent {
|
||||||
private missions: ActiveMissions
|
private missions: ActiveMissions
|
||||||
private hash: number
|
private hash: number
|
||||||
|
private markers?: MissionLocationMarker
|
||||||
|
|
||||||
constructor(parent: BaseView, missions: ActiveMissions) {
|
constructor(parent: BaseView, missions: ActiveMissions, markers?: MissionLocationMarker) {
|
||||||
super(parent, 520, 240);
|
super(parent, 520, 240);
|
||||||
this.missions = missions;
|
this.missions = missions;
|
||||||
this.hash = missions.getHash();
|
this.hash = missions.getHash();
|
||||||
|
this.markers = markers;
|
||||||
|
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
|
@ -36,13 +38,25 @@ module TS.SpaceTac.UI {
|
||||||
private update() {
|
private update() {
|
||||||
this.clearContent();
|
this.clearContent();
|
||||||
|
|
||||||
|
let markers: [StarLocation | Star, number][] = [];
|
||||||
|
|
||||||
let active = this.missions.getCurrent();
|
let active = this.missions.getCurrent();
|
||||||
let spacing = 80;
|
let spacing = 80;
|
||||||
let offset = 245 - active.length * spacing;
|
let offset = 245 - active.length * spacing;
|
||||||
active.forEach((mission, idx) => {
|
active.forEach((mission, idx) => {
|
||||||
this.addImage(35, offset + spacing * idx, "map-missions", mission.main ? 0 : 1);
|
let frame = mission.main ? 0 : 1;
|
||||||
|
this.addImage(35, offset + spacing * idx, "map-missions", frame);
|
||||||
this.addText(90, offset + spacing * idx, mission.current_part.title, "#d2e1f3", 20, false, false, 430, true);
|
this.addText(90, offset + spacing * idx, mission.current_part.title, "#d2e1f3", 20, false, false, 430, true);
|
||||||
|
|
||||||
|
let location = mission.current_part.getLocationHint();
|
||||||
|
if (location) {
|
||||||
|
markers.push([location, frame]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.markers) {
|
||||||
|
this.markers.setMarkers(markers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
68
src/ui/map/MissionLocationMarker.ts
Normal file
68
src/ui/map/MissionLocationMarker.ts
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
module TS.SpaceTac.UI {
|
||||||
|
/**
|
||||||
|
* Marker to show a mission location on the map
|
||||||
|
*/
|
||||||
|
export class MissionLocationMarker {
|
||||||
|
private container: Phaser.Group
|
||||||
|
private markers: [StarLocation | Star, number][]
|
||||||
|
private zoomed = true
|
||||||
|
private current_star: Star
|
||||||
|
|
||||||
|
constructor(view: BaseView, parent: Phaser.Group) {
|
||||||
|
this.container = view.game.add.group(parent, "mission_markers");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the active markers (location and frame)
|
||||||
|
*/
|
||||||
|
setMarkers(markers: [StarLocation | Star, number][]): void {
|
||||||
|
this.markers = markers;
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the zoom level
|
||||||
|
*/
|
||||||
|
setZoom(level: number, star: Star): void {
|
||||||
|
this.zoomed = level >= 2;
|
||||||
|
this.current_star = star;
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh the display
|
||||||
|
*/
|
||||||
|
refresh(): void {
|
||||||
|
this.container.removeAll(true);
|
||||||
|
|
||||||
|
this.markers.forEach(([location, frame], index) => {
|
||||||
|
let focus = this.zoomed ? location : (location instanceof StarLocation ? location.star : location);
|
||||||
|
if (location !== this.current_star || !this.zoomed) {
|
||||||
|
let marker = this.getMarker(focus, index - 1);
|
||||||
|
let image = new Phaser.Image(this.container.game, marker.x, marker.y, "map-missions", frame);
|
||||||
|
image.scale.set(marker.scale);
|
||||||
|
image.anchor.set(0.5);
|
||||||
|
this.container.add(image);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private getMarker(focus: Star | StarLocation, offset: number): { x: number, y: number, scale: number } {
|
||||||
|
if (focus instanceof StarLocation) {
|
||||||
|
let system = focus.star;
|
||||||
|
return {
|
||||||
|
x: focus.universe_x + offset * system.radius * 0.05,
|
||||||
|
y: focus.universe_y - system.radius * 0.08,
|
||||||
|
scale: system.radius * 0.001
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
x: focus.x + offset * focus.radius * 0.6,
|
||||||
|
y: focus.y - focus.radius * 0.7,
|
||||||
|
scale: focus.radius * 0.01
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,8 +28,9 @@ module TS.SpaceTac.UI {
|
||||||
// Fleets
|
// Fleets
|
||||||
player_fleet: FleetDisplay
|
player_fleet: FleetDisplay
|
||||||
|
|
||||||
// Frame to highlight current location
|
// Markers
|
||||||
current_location: CurrentLocationMarker
|
current_location: CurrentLocationMarker
|
||||||
|
mission_markers: MissionLocationMarker
|
||||||
|
|
||||||
// Actions for selected location
|
// Actions for selected location
|
||||||
actions: MapLocationMenu
|
actions: MapLocationMenu
|
||||||
|
@ -91,11 +92,13 @@ module TS.SpaceTac.UI {
|
||||||
this.current_location = new CurrentLocationMarker(this, this.player_fleet);
|
this.current_location = new CurrentLocationMarker(this, this.player_fleet);
|
||||||
this.layer_universe.add(this.current_location);
|
this.layer_universe.add(this.current_location);
|
||||||
|
|
||||||
|
this.mission_markers = new MissionLocationMarker(this, this.layer_universe);
|
||||||
|
|
||||||
this.actions = new MapLocationMenu(this);
|
this.actions = new MapLocationMenu(this);
|
||||||
this.actions.setPosition(30, 30);
|
this.actions.setPosition(30, 30);
|
||||||
this.actions.moveToLayer(this.layer_overlay);
|
this.actions.moveToLayer(this.layer_overlay);
|
||||||
|
|
||||||
this.missions = new ActiveMissionsDisplay(this, this.player.missions);
|
this.missions = new ActiveMissionsDisplay(this, this.player.missions, this.mission_markers);
|
||||||
this.missions.setPosition(20, 720);
|
this.missions.setPosition(20, 720);
|
||||||
this.missions.moveToLayer(this.layer_overlay);
|
this.missions.moveToLayer(this.layer_overlay);
|
||||||
|
|
||||||
|
@ -175,6 +178,9 @@ module TS.SpaceTac.UI {
|
||||||
*/
|
*/
|
||||||
updateInfo(current_star: Star | null, interactive = true) {
|
updateInfo(current_star: Star | null, interactive = true) {
|
||||||
this.current_location.setZoom(this.zoom);
|
this.current_location.setZoom(this.zoom);
|
||||||
|
if (current_star) {
|
||||||
|
this.mission_markers.setZoom(this.zoom, current_star);
|
||||||
|
}
|
||||||
|
|
||||||
this.starlinks.forEach(linkgraphics => {
|
this.starlinks.forEach(linkgraphics => {
|
||||||
let link = <StarLink>linkgraphics.data.link;
|
let link = <StarLink>linkgraphics.data.link;
|
||||||
|
@ -229,7 +235,7 @@ module TS.SpaceTac.UI {
|
||||||
let ymin = min(accessible.map(star => star.y));
|
let ymin = min(accessible.map(star => star.y));
|
||||||
let ymax = max(accessible.map(star => star.y));
|
let ymax = max(accessible.map(star => star.y));
|
||||||
let dmax = Math.max(xmax - xmin, ymax - ymin);
|
let dmax = Math.max(xmax - xmin, ymax - ymin);
|
||||||
this.setCamera(xmin + (xmax - xmin) * 0.5, ymin + (ymax - ymin) * 0.5, dmax * 1.1);
|
this.setCamera(xmin + (xmax - xmin) * 0.5, ymin + (ymax - ymin) * 0.5, dmax * 1.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue