Add riverboat captain career and distinct ship classes
Add class-specific vessel geometry and sea motion, a guided helm qualification path, dockside sailing orders, and local excursions at all 24 ports.
This commit is contained in:
@@ -9,8 +9,17 @@ namespace BigShipTycoon
|
||||
private int inspectedPort = 1;
|
||||
private int selectedVoyage;
|
||||
private bool worldChart;
|
||||
private bool RiverChart => Ship?.HullIndex == Market.River;
|
||||
private float chartScrollPosition;
|
||||
|
||||
private static readonly Vector2[][] RiverBanksOnChart =
|
||||
{
|
||||
new[] { new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, .33f), new Vector2(.82f, .42f),
|
||||
new Vector2(.63f, .40f), new Vector2(.45f, .29f), new Vector2(.29f, .40f), new Vector2(.14f, .59f), new Vector2(0, .55f) },
|
||||
new[] { new Vector2(0, .79f), new Vector2(.16f, .81f), new Vector2(.36f, .62f), new Vector2(.49f, .54f),
|
||||
new Vector2(.70f, .65f), new Vector2(.86f, .65f), new Vector2(1, .55f), new Vector2(1, 1), new Vector2(0, 1) }
|
||||
};
|
||||
|
||||
private static readonly Vector2[][] AtlanticCoastlines =
|
||||
{
|
||||
new[]
|
||||
@@ -69,24 +78,31 @@ namespace BigShipTycoon
|
||||
|
||||
private void DrawPorts(VisualElement pageRoot)
|
||||
{
|
||||
if (!VisibleChartPort(inspectedPort))
|
||||
inspectedPort = Ship?.Port ?? 0;
|
||||
var board = Add(pageRoot, "navigation-chart");
|
||||
board.styleSheets.Add(Resources.Load<StyleSheet>("Chart"));
|
||||
var heading = Add(board, "chart-heading");
|
||||
AddText(heading, Ship == null ? "PORT DIRECTORY" : $"ABOARD {Ship.Name.ToUpperInvariant()}", "chart-kicker");
|
||||
AddDisplay(heading, "Shipping chart", "chart-heading-title");
|
||||
AddDisplay(heading, RiverChart ? "River chart" : "Shipping chart", "chart-heading-title");
|
||||
|
||||
var plot = Add(board, "chart-plot");
|
||||
plot.generateVisualContent += DrawChart;
|
||||
DrawChartLabels(plot);
|
||||
|
||||
var switches = Add(board, "chart-scopes");
|
||||
switches.Add(Action("Atlantic", () => ChangeChart(false), worldChart ? "chart-scope" : "chart-scope chart-scope-current", "chart-atlantic"));
|
||||
switches.Add(Action("World", () => ChangeChart(true), worldChart ? "chart-scope chart-scope-current" : "chart-scope", "chart-world"));
|
||||
if (!RiverChart)
|
||||
{
|
||||
switches.Add(Action("Atlantic", () => ChangeChart(false), worldChart ? "chart-scope" : "chart-scope chart-scope-current", "chart-atlantic"));
|
||||
switches.Add(Action("World", () => ChangeChart(true), worldChart ? "chart-scope chart-scope-current" : "chart-scope", "chart-world"));
|
||||
}
|
||||
if (Ship != null)
|
||||
DrawItineraryButton(switches, Ship);
|
||||
|
||||
for (int i = 0; i < ChartPortCount; i++)
|
||||
for (int i = 0; i < Market.Ports.Count; i++)
|
||||
{
|
||||
if (!VisibleChartPort(i))
|
||||
continue;
|
||||
int portId = i;
|
||||
PortSpec port = Market.Ports[i];
|
||||
bool berth = Ship?.Port == i;
|
||||
@@ -109,13 +125,13 @@ namespace BigShipTycoon
|
||||
|
||||
var marker = Action("", () => InspectChartPort(portId), styles, "port-" + i);
|
||||
marker.tooltip = $"{port.Name} · {(berth ? "Current port" : cleared ? "Permit held" : "Permit required")}";
|
||||
Vector2 point = ChartPoint(port);
|
||||
Vector2 point = ChartPoint(i);
|
||||
marker.style.left = Length.Percent(point.x * 100);
|
||||
marker.style.top = Length.Percent(point.y * 100);
|
||||
var light = Add(marker, "chart-pin-light");
|
||||
light.pickingMode = PickingMode.Ignore;
|
||||
var caption = AddText(marker, port.Name, point.x > .77f ? "chart-pin-label chart-pin-label-west" : "chart-pin-label");
|
||||
caption.EnableInClassList("chart-pin-label-on-focus", worldChart && !selected && !berth && Ship?.Itinerary?.NextPort != i);
|
||||
caption.EnableInClassList("chart-pin-label-on-focus", !RiverChart && worldChart && !selected && !berth && Ship?.Itinerary?.NextPort != i);
|
||||
plot.Add(marker);
|
||||
}
|
||||
|
||||
@@ -149,17 +165,22 @@ namespace BigShipTycoon
|
||||
|
||||
private void AddChartDirectory(VisualElement parent)
|
||||
{
|
||||
var choices = new List<string>(ChartPortCount);
|
||||
for (int i = 0; i < ChartPortCount; i++)
|
||||
choices.Add(Market.Ports[i].Name);
|
||||
var choices = new List<string>();
|
||||
var ids = new List<int>();
|
||||
for (int i = 0; i < Market.Ports.Count; i++)
|
||||
if (VisibleChartPort(i))
|
||||
{
|
||||
ids.Add(i);
|
||||
choices.Add(Market.Ports[i].Name);
|
||||
}
|
||||
|
||||
var selector = new DropdownField(choices, inspectedPort) { name = "chart-directory" };
|
||||
var selector = new DropdownField(choices, ids.IndexOf(inspectedPort)) { name = "chart-directory" };
|
||||
selector.AddToClassList("chart-directory");
|
||||
selector.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int port = choices.IndexOf(evt.newValue);
|
||||
if (port >= 0)
|
||||
InspectChartPort(port);
|
||||
InspectChartPort(ids[port]);
|
||||
});
|
||||
parent.Add(selector);
|
||||
}
|
||||
@@ -172,7 +193,7 @@ namespace BigShipTycoon
|
||||
bool berth = ship?.Port == selected;
|
||||
Voyage quote = ship == null ? null : company.Forecast(ship, selected);
|
||||
bool permitted = company.Permits[selected];
|
||||
bool eligible = ship == null || ship.HullIndex >= port.MinimumHull;
|
||||
bool eligible = ship == null || Market.CanVisit(ship.HullIndex, selected);
|
||||
int nextCall = ship?.Itinerary?.NextPort ?? -1;
|
||||
|
||||
AddDisplay(parent, port.Name, "chart-port-name");
|
||||
@@ -189,7 +210,7 @@ namespace BigShipTycoon
|
||||
|
||||
AddText(parent, berth ? "CURRENT BERTH" : "PORT CONDITIONS", "chart-paper-kicker chart-paper-section");
|
||||
ChartLine(parent, "Fuel at this port", $"{Money(Market.FuelPrice(selected, company.Day))} / t");
|
||||
ChartLine(parent, "Arrival dues", Money(port.Fee));
|
||||
ChartLine(parent, "Arrival dues", Money(Company.PortCallFee(ship, selected)));
|
||||
ChartLine(parent, "Destination appeal", $"{port.Appeal:P0}");
|
||||
ChartLine(parent, "Minimum hull", Market.Hulls[port.MinimumHull].Name);
|
||||
if (quote != null)
|
||||
@@ -229,6 +250,8 @@ namespace BigShipTycoon
|
||||
}
|
||||
|
||||
private int ChartPortCount => worldChart ? Market.Ports.Count : Market.StarterPortCount;
|
||||
private bool VisibleChartPort(int port) => port >= 0 && (RiverChart ? port == 0 || Market.IsRiverPort(port)
|
||||
: port < ChartPortCount && !Market.IsRiverPort(port));
|
||||
|
||||
private void InspectChartPort(int port)
|
||||
{
|
||||
@@ -259,19 +282,29 @@ namespace BigShipTycoon
|
||||
Render();
|
||||
}
|
||||
|
||||
private Vector2 ChartPoint(PortSpec port)
|
||||
private Vector2 ChartPoint(int portIndex)
|
||||
{
|
||||
if (RiverChart)
|
||||
return PlotInset(RiverChartPoint(portIndex));
|
||||
PortSpec port = Market.Ports[portIndex];
|
||||
Vector2 point = worldChart
|
||||
? new Vector2((port.Longitude + 180) / 360, (76 - port.Latitude) / 137)
|
||||
: new Vector2(port.MapX, port.MapY);
|
||||
return PlotInset(point);
|
||||
}
|
||||
|
||||
private static Vector2 RiverChartPoint(int portIndex) => portIndex switch
|
||||
{
|
||||
0 => new Vector2(.86f, .56f), Market.Brickell => new Vector2(.48f, .43f), _ => new Vector2(.16f, .70f)
|
||||
};
|
||||
|
||||
private static Vector2 PlotInset(Vector2 point) => new Vector2(.035f + point.x * .93f, .035f + point.y * .93f);
|
||||
|
||||
private void DrawChartLabels(VisualElement plot)
|
||||
{
|
||||
if (worldChart)
|
||||
if (RiverChart)
|
||||
OceanName("MIAMI RIVER", .25f, .24f);
|
||||
else if (worldChart)
|
||||
{
|
||||
OceanName("NORTH PACIFIC", .15f, .62f);
|
||||
OceanName("ATLANTIC", .37f, .56f);
|
||||
@@ -319,7 +352,7 @@ namespace BigShipTycoon
|
||||
painter.fillColor = new Color(.139f, .255f, .276f);
|
||||
painter.strokeColor = new Color(.49f, .55f, .49f, .72f);
|
||||
painter.lineWidth = 1.15f;
|
||||
foreach (Vector2[] outline in worldChart ? WorldCoastlines.Shapes : AtlanticCoastlines)
|
||||
foreach (Vector2[] outline in RiverChart ? RiverBanksOnChart : worldChart ? WorldCoastlines.Shapes : AtlanticCoastlines)
|
||||
{
|
||||
painter.BeginPath();
|
||||
painter.MoveTo(Point(PlotInset(outline[0])));
|
||||
@@ -333,7 +366,7 @@ namespace BigShipTycoon
|
||||
Ship ship = Ship;
|
||||
int berth = ship?.Port ?? -1;
|
||||
int selectionOrigin = EditingItinerary && ship != null ? ItineraryTail(ship) : berth;
|
||||
bool CanShow(Lane lane) => lane.A < ChartPortCount && lane.B < ChartPortCount;
|
||||
bool CanShow(Lane lane) => VisibleChartPort(lane.A) && VisibleChartPort(lane.B);
|
||||
bool IsSelected(Lane lane) => selectionOrigin >= 0 && lane.Other(selectionOrigin) == inspectedPort;
|
||||
|
||||
foreach (Lane lane in Market.Lanes)
|
||||
@@ -378,11 +411,11 @@ namespace BigShipTycoon
|
||||
|
||||
void DrawLane(Lane lane, Color color, float thickness)
|
||||
{
|
||||
Vector2 a = ChartPoint(Market.Ports[lane.A]);
|
||||
Vector2 b = ChartPoint(Market.Ports[lane.B]);
|
||||
Vector2 a = ChartPoint(lane.A);
|
||||
Vector2 b = ChartPoint(lane.B);
|
||||
painter.strokeColor = color;
|
||||
painter.lineWidth = thickness;
|
||||
if (worldChart && Mathf.Abs(a.x - b.x) > .465f)
|
||||
if (!RiverChart && worldChart && Mathf.Abs(a.x - b.x) > .465f)
|
||||
{
|
||||
if (a.x > b.x)
|
||||
(a, b) = (b, a);
|
||||
@@ -398,7 +431,7 @@ namespace BigShipTycoon
|
||||
{
|
||||
painter.BeginPath();
|
||||
painter.MoveTo(Point(from));
|
||||
float rise = (worldChart ? .10f : .145f) * Vector2.Distance(from, to);
|
||||
float rise = (RiverChart ? 0 : worldChart ? .10f : .145f) * Vector2.Distance(from, to);
|
||||
painter.QuadraticCurveTo(Point((from + to) / 2 - new Vector2(0, rise)), Point(to));
|
||||
painter.Stroke();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user