242 lines
13 KiB
C#
242 lines
13 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
|
||
namespace Soundings
|
||
{
|
||
public enum WeatherCondition { Calm, Swell, Storm }
|
||
|
||
public enum Facility
|
||
{
|
||
Empty, Cabin, Dining, Entertainment, Tank, Bar, Amenity, Galley, Stores, Water, Waste, Workshop,
|
||
Suite, GrandSuite, Restaurant, GrandTheater, ResortPool, CocktailLounge, Extension,
|
||
Shop, ShoppingArcade, Spa, WaterPark, Casino, CasinoLounge, GrandCasino
|
||
}
|
||
|
||
public sealed class FacilitySpec
|
||
{
|
||
public readonly string Name, Mark, Details;
|
||
public readonly int Price, Capacity, MinimumHull, FarePremiumPercent;
|
||
private readonly Vector2Int[][] footprints = new Vector2Int[4][];
|
||
|
||
public FacilitySpec(string name, string mark, string details, int price, int capacity,
|
||
int length = 1, int minimumHull = Market.Coastal, int farePremiumPercent = 0,
|
||
int depth = 1, bool corner = false)
|
||
{
|
||
Name = name;
|
||
Mark = mark;
|
||
Details = details;
|
||
Price = price;
|
||
Capacity = capacity;
|
||
MinimumHull = minimumHull;
|
||
FarePremiumPercent = farePremiumPercent;
|
||
|
||
var bays = new List<Vector2Int>(length * depth);
|
||
for (int row = 0; row < depth; row++)
|
||
for (int column = 0; column < length; column++)
|
||
if (!corner || row == 0 || column == 0)
|
||
bays.Add(new Vector2Int(column, row));
|
||
footprints[0] = bays.ToArray();
|
||
for (int rotation = 1; rotation < footprints.Length; rotation++)
|
||
footprints[rotation] = Turn(footprints[rotation - 1]);
|
||
}
|
||
|
||
public int BayCount => footprints[0].Length;
|
||
public IReadOnlyList<Vector2Int> Footprint(int rotation) => footprints[rotation & 3];
|
||
|
||
private static Vector2Int[] Turn(Vector2Int[] bays)
|
||
{
|
||
var rotated = new Vector2Int[bays.Length];
|
||
for (int i = 0; i < bays.Length; i++)
|
||
rotated[i] = new Vector2Int(-bays[i].y, bays[i].x);
|
||
Array.Sort(rotated, (left, right) => left.y != right.y ? left.y.CompareTo(right.y) : left.x.CompareTo(right.x));
|
||
// Keep the first occupied bay as the anchor, even when a lower row reaches farther left.
|
||
Vector2Int anchor = rotated[0];
|
||
for (int i = 0; i < rotated.Length; i++)
|
||
rotated[i] -= anchor;
|
||
return rotated;
|
||
}
|
||
}
|
||
|
||
public sealed class HullSpec
|
||
{
|
||
public readonly string Name, Description;
|
||
public readonly int Columns, Rows, StarterDecks, MaxDecks, Price, Voyages, Reputation, Tank, CrewPerDay, HullWearCost;
|
||
public readonly float Length, Beam;
|
||
public readonly double TonsPerMile;
|
||
|
||
public HullSpec(string name, string description, int columns, int rows, int starterDecks, int maxDecks, int price,
|
||
int voyages, int reputation, int tank, double tonsPerMile, int crewPerDay, int hullWearCost, float length, float beam)
|
||
{
|
||
Name = name;
|
||
Description = description;
|
||
Columns = columns;
|
||
Rows = rows;
|
||
StarterDecks = starterDecks;
|
||
MaxDecks = maxDecks;
|
||
Price = price;
|
||
Voyages = voyages;
|
||
Reputation = reputation;
|
||
Tank = tank;
|
||
TonsPerMile = tonsPerMile;
|
||
CrewPerDay = crewPerDay;
|
||
HullWearCost = hullWearCost;
|
||
Length = length;
|
||
Beam = beam;
|
||
}
|
||
}
|
||
|
||
public sealed class PortSpec
|
||
{
|
||
public readonly string Name, Country, Region;
|
||
public readonly int FuelPrice, Fee, Permit, Reputation, MinimumHull;
|
||
public readonly double Appeal, MarketSize;
|
||
public readonly float MapX, MapY, Longitude, Latitude;
|
||
|
||
public PortSpec(string name, string country, string region, int fuelPrice, int fee, int permit,
|
||
int reputation, int minimumHull, double appeal, double marketSize, float mapX, float mapY, float longitude, float latitude)
|
||
{
|
||
Name = name;
|
||
Country = country;
|
||
Region = region;
|
||
FuelPrice = fuelPrice;
|
||
Fee = fee;
|
||
Permit = permit;
|
||
Reputation = reputation;
|
||
MinimumHull = minimumHull;
|
||
Appeal = appeal;
|
||
MarketSize = marketSize;
|
||
MapX = mapX;
|
||
MapY = mapY;
|
||
Longitude = longitude;
|
||
Latitude = latitude;
|
||
}
|
||
}
|
||
|
||
public readonly struct Lane
|
||
{
|
||
public readonly int A, B, Miles;
|
||
|
||
public Lane(int a, int b, int miles)
|
||
{
|
||
A = a;
|
||
B = b;
|
||
Miles = miles;
|
||
}
|
||
|
||
public int Other(int port) => port == A ? B : port == B ? A : -1;
|
||
}
|
||
|
||
public static class Market
|
||
{
|
||
public const int StarterPortCount = 8;
|
||
public static int UsedPrice(int hull) => hull == 0 ? 105000 : 245000;
|
||
public const int MaxFleet = 8;
|
||
public const int Coastal = 0;
|
||
public const int Regional = 1;
|
||
public const int Ocean = 2;
|
||
public const int Bermuda = 5;
|
||
public const int Lisbon = 7;
|
||
public const int MinFare = 150;
|
||
public const int MaxFare = 4000;
|
||
|
||
public static readonly IReadOnlyList<FacilitySpec> Facilities = new[]
|
||
{
|
||
new FacilitySpec("Clear berth", "–", "Recover 25% of the build cost", 0, 0),
|
||
new FacilitySpec("Cabins", "CB", "32 guest berths", 8400, 32),
|
||
new FacilitySpec("Dining hall", "DH", "48 seats · 3 services", 11800, 48),
|
||
new FacilitySpec("Show lounge", "SL", "80 seats · improves demand", 15400, 80),
|
||
new FacilitySpec("Bunker tank", "BT", "+65 t of fuel capacity", 14200, 65),
|
||
new FacilitySpec("Bar", "BR", "72 drink orders per service", 14800, 72),
|
||
new FacilitySpec("Pool terrace", "PT", "64 amenity admissions per service", 18600, 64),
|
||
new FacilitySpec("Galley", "GY", "+96 meals per service window", 22100, 96),
|
||
new FacilitySpec("Stores", "ST", "+900 meal portions of storage", 17600, 900),
|
||
new FacilitySpec("Water plant", "WP", "+14,000 L storage and +6,000 L/day output", 25400, 14000),
|
||
new FacilitySpec("Sewage", "SW", "+10,000 L buffer and +7,000 L/day treatment", 19800, 10000),
|
||
new FacilitySpec("Workshop", "WS", "Increases the benefit of onboard servicing", 18700, 2),
|
||
new FacilitySpec("Suites", "SU", "28 suite berths · 50% above base fare", 28500, 28, 2, Regional, 50),
|
||
new FacilitySpec("Grand suites", "GS", "36 suite berths · 90% above base fare", 46600, 36, 3, Ocean, 90),
|
||
new FacilitySpec("Restaurant", "RT", "108 seats · 3 services", 26200, 108, 2, Regional),
|
||
new FacilitySpec("Grand theater", "GT", "256 show seats", 52300, 256, 3, Ocean),
|
||
new FacilitySpec("Resort pool", "RP", "216 amenity admissions per service", 57200, 216, 3, Regional),
|
||
new FacilitySpec("Cocktail lounge", "CL", "156 drink orders per service", 32100, 156, 2, Regional),
|
||
new FacilitySpec("Continued berth", "", "", 0, 0),
|
||
new FacilitySpec("Gift shop", "SH", "64 retail orders per service", 12600, 64),
|
||
new FacilitySpec("Shopping arcade", "SA", "190 retail orders per service", 41500, 190, 2, Regional, depth: 2, corner: true),
|
||
new FacilitySpec("Spa retreat", "SP", "144 amenity admissions per service", 48300, 144, 2, Regional, depth: 2),
|
||
new FacilitySpec("Water park", "WP", "460 amenity admissions per service", 107000, 460, 3, Ocean, depth: 2),
|
||
new FacilitySpec("Casino", "CS", "144 gaming seats · table stakes and guest payouts", 57900, 144, 2, Regional, depth: 2),
|
||
new FacilitySpec("Casino lounge", "CG", "54 gaming seats · table stakes and guest payouts", 32700, 54, 2),
|
||
new FacilitySpec("Grand casino", "GC", "264 gaming seats · table stakes and guest payouts", 109000, 264, 3, Ocean, depth: 2)
|
||
};
|
||
|
||
internal static bool IsCasino(Facility facility) => facility is Facility.Casino or Facility.CasinoLounge or Facility.GrandCasino;
|
||
|
||
public static readonly IReadOnlyList<HullSpec> Hulls = new[]
|
||
{
|
||
new HullSpec("Coastal", "A compact hull for short Caribbean crossings.", 6, 2, 2, 3, 210000, 0, 0, 74, .092, 7200, 1200, 72, 14),
|
||
new HullSpec("Regional", "More deck space and range for island chains.", 8, 3, 4, 5, 355000, 3, 24, 185, .121, 12800, 2300, 104, 19),
|
||
new HullSpec("Ocean Class", "A transatlantic hull for a world-class flagship.", 10, 3, 6, 8, 690000, 9, 42, 440, .152, 21800, 4700, 142, 25)
|
||
};
|
||
|
||
public static readonly IReadOnlyList<PortSpec> Ports = new[]
|
||
{
|
||
new PortSpec("Miami", "United States", "Florida", 685, 9200, 0, 0, 0, .94, 1.12, .14f, .63f, -80.2f, 25.8f),
|
||
new PortSpec("Nassau", "The Bahamas", "Caribbean", 825, 7600, 0, 0, 0, 1.14, .87, .24f, .67f, -77.4f, 25.1f),
|
||
new PortSpec("Key West", "United States", "Florida", 725, 5600, 14500, 15, 0, .91, .77, .11f, .78f, -81.8f, 24.6f),
|
||
new PortSpec("Cozumel", "Mexico", "Caribbean", 590, 8700, 21000, 21, 0, 1.10, .90, .06f, .94f, -87, 20.5f),
|
||
new PortSpec("San Juan", "Puerto Rico, U.S.", "Caribbean", 650, 10500, 34000, 25, 1, 1.17, 1.00, .39f, .86f, -66.1f, 18.5f),
|
||
new PortSpec("Bermuda", "United Kingdom", "North Atlantic", 910, 12100, 48000, 32, 1, 1.22, .83, .46f, .45f, -64.8f, 32.3f),
|
||
new PortSpec("Ponta Delgada", "Portugal", "Azores", 625, 9500, 57000, 42, 2, 1.20, .73, .69f, .42f, -25.7f, 37.7f),
|
||
new PortSpec("Lisbon", "Portugal", "Europe", 670, 14200, 71000, 45, 2, 1.37, 1.15, .87f, .26f, -9.1f, 38.7f),
|
||
new PortSpec("Barcelona", "Spain", "Mediterranean", 688, 16200, 37000, 46, 2, 1.33, 1.18, 0, 0, 2.2f, 41.4f),
|
||
new PortSpec("Port Said", "Egypt", "Mediterranean", 604, 19200, 33000, 48, 2, 1.20, .99, 0, 0, 32.3f, 31.3f),
|
||
new PortSpec("Salalah", "Oman", "Indian Ocean", 559, 11900, 31000, 48, 2, 1.25, .94, 0, 0, 54.1f, 17.0f),
|
||
new PortSpec("Mumbai", "India", "Indian Ocean", 588, 15100, 45000, 50, 2, 1.32, 1.19, 0, 0, 72.8f, 19.1f),
|
||
new PortSpec("Singapore", "Singapore", "Southeast Asia", 570, 16800, 52000, 52, 2, 1.37, 1.27, 0, 0, 103.8f, 1.3f),
|
||
new PortSpec("Benoa", "Indonesia", "Southeast Asia", 634, 12800, 42000, 52, 2, 1.35, 1.02, 0, 0, 115.2f, -8.7f),
|
||
new PortSpec("Sydney", "Australia", "Oceania", 740, 16700, 51000, 55, 2, 1.42, 1.20, 0, 0, 151.2f, -33.9f),
|
||
new PortSpec("Auckland", "New Zealand", "Oceania", 721, 13400, 46000, 55, 2, 1.36, 1.11, 0, 0, 174.8f, -36.8f),
|
||
new PortSpec("Papeete", "French Polynesia", "South Pacific", 771, 13800, 42000, 55, 2, 1.44, 1.12, 0, 0, -149.6f, -17.5f),
|
||
new PortSpec("Honolulu", "United States", "North Pacific", 757, 16200, 52000, 58, 2, 1.41, 1.16, 0, 0, -157.9f, 21.3f),
|
||
new PortSpec("San Diego", "United States", "Pacific Coast", 718, 15300, 51000, 58, 2, 1.35, 1.21, 0, 0, -117.2f, 32.7f),
|
||
new PortSpec("Puerto Vallarta", "Mexico", "Pacific Coast", 606, 11900, 36000, 58, 2, 1.29, 1.03, 0, 0, -105.2f, 20.7f),
|
||
new PortSpec("Balboa", "Panama", "Central America", 635, 22700, 43000, 58, 2, 1.26, 1.07, 0, 0, -79.6f, 8.9f),
|
||
new PortSpec("Cartagena", "Colombia", "South America", 599, 14600, 45000, 58, 2, 1.35, 1.12, 0, 0, -75.5f, 10.4f)
|
||
};
|
||
|
||
public static readonly IReadOnlyList<Lane> Lanes = new[]
|
||
{
|
||
new Lane(0, 1, 185), new Lane(0, 2, 150), new Lane(1, 2, 270), new Lane(2, 3, 455),
|
||
new Lane(0, 3, 590), new Lane(0, 4, 985), new Lane(1, 4, 735), new Lane(1, 5, 840),
|
||
new Lane(0, 5, 913), new Lane(4, 5, 865), new Lane(5, 6, 1920), new Lane(5, 7, 2790),
|
||
new Lane(6, 7, 815), new Lane(7, 8, 605), new Lane(8, 9, 1630), new Lane(9, 10, 1645),
|
||
new Lane(10, 11, 1160), new Lane(11, 12, 2510), new Lane(12, 13, 920), new Lane(13, 14, 2540),
|
||
new Lane(14, 15, 1165), new Lane(15, 16, 2250), new Lane(16, 17, 2380), new Lane(17, 18, 2270),
|
||
new Lane(18, 19, 1110), new Lane(19, 20, 1585), new Lane(20, 21, 265), new Lane(21, 0, 1080)
|
||
};
|
||
|
||
public static int FuelPrice(int port, int day)
|
||
{
|
||
int weeklyMove = ((day / 7 * 13 + port * 9) % 31) - 15;
|
||
return Ports[port].FuelPrice + weeklyMove;
|
||
}
|
||
|
||
public static bool TryDistance(int origin, int destination, out int miles)
|
||
{
|
||
foreach (Lane lane in Lanes)
|
||
{
|
||
if (lane.Other(origin) == destination && destination >= 0)
|
||
{
|
||
miles = lane.Miles;
|
||
return true;
|
||
}
|
||
}
|
||
miles = 0;
|
||
return false;
|
||
}
|
||
|
||
public static int Clamp(int value, int min, int max) => Math.Max(min, Math.Min(max, value));
|
||
}
|
||
}
|