diff --git a/Assets/BigShipTycoon/Editor/EconomyVerification.cs b/Assets/BigShipTycoon/Editor/EconomyVerification.cs index faa324a..b98a358 100644 --- a/Assets/BigShipTycoon/Editor/EconomyVerification.cs +++ b/Assets/BigShipTycoon/Editor/EconomyVerification.cs @@ -9,6 +9,7 @@ namespace BigShipTycoon.Editor { VerifyUsedStartAndProfit(); VerifyFinancedStartAndConstruction(); + VerifyCaptainCareer(); VerifyHullDeckProgression(); VerifyMultiBerthFacilities(); VerifyRotatableFacilities(); @@ -23,7 +24,29 @@ namespace BigShipTycoon.Editor VerifyPortOrders(); VerifyMultiStopItinerary(); VerifyShoreExcursions(); - Debug.Log("Big Ship Tycoon economy verification passed for both starts, pricing, fuel, venue and sun deck refits, MEGA commissions and facilities, fleet settlements, saves, weather, ship systems, crew payroll, laundry, port orders, multi-stop itineraries and shore excursions."); + Debug.Log("Big Ship Tycoon economy verification passed for all starts, Captain Career, pricing, fuel, venue and sun deck refits, MEGA commissions and facilities, fleet settlements, saves, weather, ship systems, crew payroll, laundry, port orders, multi-stop itineraries and shore excursions."); + } + + private static void VerifyCaptainCareer() + { + var previous = Company.Start(false); + Array.Resize(ref previous.Permits, Market.Brickell); + Require(previous.CanLoad() && previous.Permits.Length == Market.Ports.Count && !previous.IsCaptainCareer + && previous.Forecast(previous.ActiveShip, Market.Brickell) == null, "earlier careers keep their permits and ocean routes"); + + var company = Company.StartCaptain(); + Ship river = company.ActiveShip; + Require(company.CanLoad() && river.HullIndex == Market.River && river.Hull.Length == 32 + && river.Decks.Count == 1 && company.Forecast(river, 1) == null + && company.Forecast(river, Market.Brickell).NetIncome > 0 && company.ShipyardBlock(Market.Coastal, true) != null, + "the river start sails profitable local routes and must earn Coastal command"); + Require(company.Build(river, 0, 5, Facility.Suite) != null, "the riverboat cannot install Regional facilities"); + Complete(company, river, Market.Brickell); + Complete(company, river, Market.Mangrove); + var resumed = JsonUtility.FromJson(JsonUtility.ToJson(company)); + Require(resumed.CanLoad() && resumed.IsCaptainCareer && resumed.CommandVoyages(Market.River) == 2 + && resumed.HelmQualifications(Market.River) == 0 && resumed.ShipyardBlock(Market.Coastal, true) != null, + "ordinary river crossings persist without satisfying the practical helm requirement"); } private static void VerifyMegaLiner() @@ -264,10 +287,17 @@ namespace BigShipTycoon.Editor for (int i = 0; i < Market.Ports.Count; i++) { var tours = ShoreExcursions.Catalog(i); - Require(tours.Count == 2, "two distinct local shore tours at " + Market.Ports[i].Name); + Require(tours.Count == 3, "three distinct local shore tours at " + Market.Ports[i].Name); foreach (ShoreTour tour in tours) Require(names.Add(tour.Name) && tour.MinPrice < tour.StandardPrice && tour.StandardPrice < tour.MaxPrice, "unique and priced shore tour " + tour.Name); + var route = new Voyage { Destination = i, Guests = 32, Weather = WeatherCondition.Calm }; + ShoreBooking[] local = ShoreExcursions.Forecast(route, new[] + { + new ShoreOffer { Tour = 2, Price = tours[2].StandardPrice, Capacity = tours[2].MaxCapacity } + }); + Require(local.Length == 1 && local[0].Tour == 2 && local[0].Guests > 0 && local[0].Revenue > local[0].OperatorCost, + "the third local excursion can be booked at " + Market.Ports[i].Name); } Company company = Company.Start(false); @@ -291,12 +321,14 @@ namespace BigShipTycoon.Editor offer.Capacity = catalog[1].MaxCapacity; var indoor = new ShoreOffer { Tour = 0, Price = catalog[0].MinPrice, Capacity = catalog[0].MaxCapacity }; + var studio = new ShoreOffer { Tour = 2, Price = catalog[2].MinPrice, Capacity = catalog[2].MaxCapacity }; quote.Weather = WeatherCondition.Calm; int actualGuests = quote.Guests; quote.Guests = 75; - ShoreBooking[] shared = ShoreExcursions.Forecast(quote, new[] { offer, indoor }); - Require(shared[0].Guests > 0 && shared[1].Guests > 0 && shared[0].Guests + shared[1].Guests <= quote.Guests, - "multiple shore tours share a finite passenger pool"); + ShoreBooking[] shared = ShoreExcursions.Forecast(quote, new[] { offer, indoor, studio }); + Require(shared.Length == 3 && shared[0].Guests > 0 && shared[1].Guests > 0 && shared[2].Guests > 0 + && shared[0].Guests + shared[1].Guests + shared[2].Guests <= quote.Guests, + "all three shore tours share a finite passenger pool"); quote.Guests = actualGuests; ShoreCall delayed = null, onTime = null; @@ -601,6 +633,8 @@ namespace BigShipTycoon.Editor for (int port = Market.StarterPortCount; port < Market.Ports.Count; port++) { + if (Market.IsRiverPort(port)) + continue; Require(company.Permit(port) == null, "global port permit"); ship.Fare = 400 + 170 * company.Forecast(ship, port).Days; Complete(company, ship, port); @@ -744,6 +778,21 @@ namespace BigShipTycoon.Editor && stocked.Plan.FoodCost > light.Plan.FoodCost && stocked.Plan.ProgramCost > 0, "port food orders respect capacity and itemized costs"); Require(PortPlanning.FoodPriceCents(0, company.Day) != PortPlanning.FoodPriceCents(1, company.Day), "ports have different food prices"); + Voyage economy = company.Forecast(ship, 1); + Voyage express = company.Forecast(ship, 1); + PortPlanning.Apply(ship, economy, company.Day, null, EntertainmentProgram.Shipboard, PassageOrder.Economy); + PortPlanning.Apply(ship, express, company.Day, null, EntertainmentProgram.Shipboard, PassageOrder.Express); + var economical = new OnboardSession(ship, economy); + var faster = new OnboardSession(ship, express); + Require(economy.RequiredFuel < light.RequiredFuel && express.RequiredFuel > light.RequiredFuel + && economy.FuelExpense < light.FuelExpense && express.FuelExpense > light.FuelExpense + && economical.EngineMode == 0 && faster.EngineMode == 2 && economical.SpeedFactor < faster.SpeedFactor, + "departure sailing orders change fuel requirements, costs and sailing speed"); + economical.AdvanceTo(1); + faster.AdvanceTo(1); + Require(economical.Report().FuelBurn == economy.DepartureFuelBurn && faster.Report().FuelBurn == express.DepartureFuelBurn, + "steady sailing orders consume the planned fuel quantity"); + var understocked = new OnboardSession(ship, light) { Assisted = false }; var provisioned = new OnboardSession(ship, stocked) { Assisted = false }; understocked.AdvanceTo(.5f); diff --git a/Assets/BigShipTycoon/Editor/TycoonBuild.cs b/Assets/BigShipTycoon/Editor/TycoonBuild.cs index c427de5..9c17520 100644 --- a/Assets/BigShipTycoon/Editor/TycoonBuild.cs +++ b/Assets/BigShipTycoon/Editor/TycoonBuild.cs @@ -24,7 +24,7 @@ namespace BigShipTycoon.Editor EditorBuildSettings.scenes = new[] { new EditorBuildSettingsScene(ScenePath, true) }; PlayerSettings.companyName = "Big Ship Tycoon"; PlayerSettings.productName = "Big Ship Tycoon"; - PlayerSettings.bundleVersion = "0.14.0"; + PlayerSettings.bundleVersion = "0.15.0"; PlayerSettings.defaultScreenWidth = 1920; PlayerSettings.defaultScreenHeight = 1080; PlayerSettings.fullScreenMode = FullScreenMode.FullScreenWindow; diff --git a/Assets/BigShipTycoon/Resources/Audio/PA/ApproachPort22.wav b/Assets/BigShipTycoon/Resources/Audio/PA/ApproachPort22.wav new file mode 100644 index 0000000..0b6c15c Binary files /dev/null and b/Assets/BigShipTycoon/Resources/Audio/PA/ApproachPort22.wav differ diff --git a/Assets/BigShipTycoon/Resources/Audio/PA/ApproachPort22.wav.meta b/Assets/BigShipTycoon/Resources/Audio/PA/ApproachPort22.wav.meta new file mode 100644 index 0000000..24967ac --- /dev/null +++ b/Assets/BigShipTycoon/Resources/Audio/PA/ApproachPort22.wav.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: a06717a292f9696c2b30b2ae098981c8 +AudioImporter: + externalObjects: {} + serializedVersion: 8 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigShipTycoon/Resources/Audio/PA/ApproachPort23.wav b/Assets/BigShipTycoon/Resources/Audio/PA/ApproachPort23.wav new file mode 100644 index 0000000..c57bfdc Binary files /dev/null and b/Assets/BigShipTycoon/Resources/Audio/PA/ApproachPort23.wav differ diff --git a/Assets/BigShipTycoon/Resources/Audio/PA/ApproachPort23.wav.meta b/Assets/BigShipTycoon/Resources/Audio/PA/ApproachPort23.wav.meta new file mode 100644 index 0000000..b5a12f5 --- /dev/null +++ b/Assets/BigShipTycoon/Resources/Audio/PA/ApproachPort23.wav.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: f3e687d2e63d56f53ad71ede794a575a +AudioImporter: + externalObjects: {} + serializedVersion: 8 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigShipTycoon/Resources/Audio/PA/DeparturePort22.wav b/Assets/BigShipTycoon/Resources/Audio/PA/DeparturePort22.wav new file mode 100644 index 0000000..cf7a14a Binary files /dev/null and b/Assets/BigShipTycoon/Resources/Audio/PA/DeparturePort22.wav differ diff --git a/Assets/BigShipTycoon/Resources/Audio/PA/DeparturePort22.wav.meta b/Assets/BigShipTycoon/Resources/Audio/PA/DeparturePort22.wav.meta new file mode 100644 index 0000000..72b0043 --- /dev/null +++ b/Assets/BigShipTycoon/Resources/Audio/PA/DeparturePort22.wav.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 09f229b4f2b7d1a3aa517fcdfb34ea4d +AudioImporter: + externalObjects: {} + serializedVersion: 8 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigShipTycoon/Resources/Audio/PA/DeparturePort23.wav b/Assets/BigShipTycoon/Resources/Audio/PA/DeparturePort23.wav new file mode 100644 index 0000000..77e26d5 Binary files /dev/null and b/Assets/BigShipTycoon/Resources/Audio/PA/DeparturePort23.wav differ diff --git a/Assets/BigShipTycoon/Resources/Audio/PA/DeparturePort23.wav.meta b/Assets/BigShipTycoon/Resources/Audio/PA/DeparturePort23.wav.meta new file mode 100644 index 0000000..f1b88c9 --- /dev/null +++ b/Assets/BigShipTycoon/Resources/Audio/PA/DeparturePort23.wav.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 5181a9e0aeedf8fd4bad1bbb685c4ad1 +AudioImporter: + externalObjects: {} + serializedVersion: 8 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigShipTycoon/Resources/Chart.uss b/Assets/BigShipTycoon/Resources/Chart.uss index bc5178f..55f80ee 100644 --- a/Assets/BigShipTycoon/Resources/Chart.uss +++ b/Assets/BigShipTycoon/Resources/Chart.uss @@ -697,3 +697,9 @@ border-color: #ffd58f; border-width: 2px; } + +.navigation-chart .port-sailing-selected { + background-color: #315957; + border-color: #769c86; + color: #f6e7c1; +} diff --git a/Assets/BigShipTycoon/Resources/HarborWater.shader b/Assets/BigShipTycoon/Resources/HarborWater.shader index 58cf155..ccac81a 100644 --- a/Assets/BigShipTycoon/Resources/HarborWater.shader +++ b/Assets/BigShipTycoon/Resources/HarborWater.shader @@ -151,7 +151,7 @@ Shader "BigShipTycoon/Harbor Water" float swellDetail = 1 - smoothstep(175, 700, distance); float textureDetail = 1 - smoothstep(68, 525, distance); float surfaceDetail = 1 - smoothstep(23, 175, distance); - float roughness = lerp(.60, 1.18, _WeatherSeverity); + float roughness = lerp(.60, 1.18, _WeatherSeverity) * lerp(1, .66, _TycoonRiverWater); float2 slope = waves.yz * swellDetail + WindSlope(position, chop.b, _SeaTime) * textureDetail * roughness + ((chop.rg - .5) * .34 + rippleSlope * .29) * textureDetail * roughness + surfaceSlope * (.115 * surfaceDetail * roughness); @@ -162,6 +162,8 @@ Shader "BigShipTycoon/Harbor Water" float cap = saturate(dot(normal, Sun) * .84 + (chop.b - .5) * textureDetail * .63 + .35); float3 fromBelow = lerp(float3(.028,.125,.192), float3(.078,.250,.294), cap); fromBelow = lerp(fromBelow, fromBelow * .57 + float3(.022,.032,.036), _WeatherSeverity); + float3 riverWater = lerp(float3(.061,.130,.113), float3(.139,.249,.215), cap); + fromBelow = lerp(fromBelow, riverWater, _TycoonRiverWater); if (_PortMotion > .5) { float3 shallowWater = lerp(float3(.03,.31,.32), float3(.15,.52,.48), cap); @@ -173,10 +175,11 @@ Shader "BigShipTycoon/Harbor Water" float reflectedLight = pow(sunHit, lerp(28, 15, _WeatherSeverity)); color += (nearSun * .43 + reflectedLight * .13) * float3(1,.86,.65) * (1 - _WeatherSeverity * .88); - float crest = waves.x / lerp(.35, 1.46, _WeatherSeverity * _WeatherSeverity); + float crest = waves.x / WaveAmplitude(_WeatherSeverity); float churn = .55 * chop.b + .28 * ripples.b + .17 * surface.b; float capFoam = smoothstep(.65, .85, churn + crest * .19 + length(slope) * .17); - color = lerp(color, float3(.64,.74,.76), capFoam * textureDetail * (.035 + _WeatherSeverity * .58)); + color = lerp(color, float3(.64,.74,.76), capFoam * textureDetail * (.035 + _WeatherSeverity * .58) + * lerp(1, .26, _TycoonRiverWater)); if (_HullSpan.x > 1) { diff --git a/Assets/BigShipTycoon/Resources/OceanWaves.cginc b/Assets/BigShipTycoon/Resources/OceanWaves.cginc index 14bb774..f4a395c 100644 --- a/Assets/BigShipTycoon/Resources/OceanWaves.cginc +++ b/Assets/BigShipTycoon/Resources/OceanWaves.cginc @@ -1,18 +1,24 @@ #ifndef TYCOON_OCEAN_WAVES #define TYCOON_OCEAN_WAVES +float _TycoonRiverWater; + +float WaveAmplitude(float storm) +{ + return lerp(lerp(.61, 1.95, storm * storm), lerp(.22, .44, storm), _TycoonRiverWater); +} + float3 OceanWave(float2 position, float time, float storm) { - float amplitude = lerp(.35, 1.46, storm * storm); - float2 windWave = float2(.052, .115); - float2 swellWave = float2(-.073, .170); - float2 crossWave = float2(.217, -.136); + float2 windWave = lerp(float2(.052, .115), float2(.197, .235), _TycoonRiverWater); + float2 swellWave = lerp(float2(-.024, .054), float2(-.088, .13), _TycoonRiverWater); + float2 crossWave = lerp(float2(.217, -.136), float2(.40, -.31), _TycoonRiverWater); float s1, c1, s2, c2, s3, c3; - sincos(dot(position, windWave) - time * .93, s1, c1); - sincos(dot(position, swellWave) - time * 1.22 + 1.3, s2, c2); - sincos(dot(position, crossWave) - time * 1.64 + 2.9, s3, c3); - float2 gradient = .65 * windWave * c1 + .25 * swellWave * c2 + .10 * crossWave * c3; - return amplitude * float3(.65 * s1 + .25 * s2 + .10 * s3, gradient); + sincos(dot(position, windWave) - time * lerp(.93, 1.55, _TycoonRiverWater), s1, c1); + sincos(dot(position, swellWave) - time * lerp(.75, 1.02, _TycoonRiverWater) + 1.3, s2, c2); + sincos(dot(position, crossWave) - time * lerp(1.64, 2.03, _TycoonRiverWater) + 2.9, s3, c3); + float2 gradient = .49 * windWave * c1 + .39 * swellWave * c2 + .12 * crossWave * c3; + return WaveAmplitude(storm) * float3(.49 * s1 + .39 * s2 + .12 * s3, gradient); } #endif diff --git a/Assets/BigShipTycoon/Resources/Passage.uss b/Assets/BigShipTycoon/Resources/Passage.uss index 2f18600..0745098 100644 --- a/Assets/BigShipTycoon/Resources/Passage.uss +++ b/Assets/BigShipTycoon/Resources/Passage.uss @@ -295,3 +295,10 @@ .voyage-map-north { position: absolute; top: 8px; left: 10px; color: #c4d6d1; font-size: 12px; } .voyage-map-key { margin-left: 10px; } .voyage-map-swatch { width: 12px; height: 2px; margin-right: 4px; } + +.helm-practice-readout { + color: #d9cba3; + font-size: 13px; + white-space: normal; + margin: 3px 0 6px; +} diff --git a/Assets/BigShipTycoon/Resources/PortScenerySurface.shader b/Assets/BigShipTycoon/Resources/PortScenerySurface.shader index a793953..1432536 100644 --- a/Assets/BigShipTycoon/Resources/PortScenerySurface.shader +++ b/Assets/BigShipTycoon/Resources/PortScenerySurface.shader @@ -79,6 +79,12 @@ Shader "BigShipTycoon/Port Scenery Surface" albedo *= 1 + TycoonStipple(face, 18) * .17 + TycoonStipple(face, 7.8) * .070; else if (_Detail == 7) albedo *= 1 + TycoonGrain(face, 33) * .105; + else if (_Detail == 8) + { + float reeds = smoothstep(-.27,.24, coarse * .67 + relief * .51); + float thatch = TycoonStipple(face + fine, 20) * .13 + TycoonGrain(face, 13) * .09; + albedo = lerp(albedo * float3(.71,.84,.79), albedo * float3(1.16,1.07,.87), reeds) * (1 + fine * .20 + thatch); + } float diffuse = saturate(dot(n, sun)); float sky = n.y * .5 + .5; diff --git a/Assets/BigShipTycoon/Runtime/CaptainCareer.cs b/Assets/BigShipTycoon/Runtime/CaptainCareer.cs new file mode 100644 index 0000000..e3d5b7e --- /dev/null +++ b/Assets/BigShipTycoon/Runtime/CaptainCareer.cs @@ -0,0 +1,68 @@ +using System; +using UnityEngine; + +namespace BigShipTycoon +{ + public sealed partial class Company + { + [SerializeField] private bool captainCareer; + [SerializeField] private int[] commandVoyages, helmQualifications; + + public bool IsCaptainCareer => captainCareer; + public int CommandVoyages(int hullIndex) => captainCareer ? commandVoyages[hullIndex] : 0; + public int HelmQualifications(int hullIndex) => captainCareer ? helmQualifications[hullIndex] : 0; + + public static Company StartCaptain() + { + var company = new Company + { + Cash = 96000, Reputation = 15, Bridge = true, captainCareer = true, + commandVoyages = new int[Market.Hulls.Count], helmQualifications = new int[Market.Hulls.Count] + }; + company.Permits[0] = company.Permits[1] = company.Permits[Market.Brickell] = company.Permits[Market.Mangrove] = true; + company.Fleet.Add(CreateShip(Market.River, "MV Heron", true, true)); + return company; + } + + internal static (int Previous, int Trips, int Checks) CommandRequirement(int hullIndex) => hullIndex switch + { + Market.Coastal => (Market.River, 2, 1), Market.Regional => (Market.Coastal, 3, 1), + Market.Ocean => (Market.Regional, 4, 2), Market.Mega => (Market.Ocean, 6, 2), _ => (-1, 0, 0) + }; + + internal string CommandBlock(int hullIndex) + { + if (!IsCaptainCareer) + return hullIndex == Market.River ? "Riverboats are available in Captain Career." : null; + var (previous, trips, checks) = CommandRequirement(hullIndex); + if (previous < 0 || CommandVoyages(previous) >= trips && HelmQualifications(previous) >= checks) + return null; + return $"{Market.Hulls[previous].Name} command: {CommandVoyages(previous)}/{trips} voyages and {HelmQualifications(previous)}/{checks} helm qualifications."; + } + + internal void RecordHelmQualification(Ship ship) + { + int hull = ship.HullIndex; + if (IsCaptainCareer && helmQualifications[hull] < commandVoyages[hull]) + helmQualifications[hull]++; + } + + private bool ValidCaptainCareer() + { + if (!IsCaptainCareer) + return true; + if (commandVoyages?.Length != Market.Hulls.Count || helmQualifications?.Length != Market.Hulls.Count) + return false; + long logged = 0; + for (int hull = 0; hull < commandVoyages.Length; hull++) + { + if (helmQualifications[hull] < 0 || helmQualifications[hull] > commandVoyages[hull]) + return false; + logged += commandVoyages[hull]; + } + return logged == Voyages && Permits[Market.Brickell] && Permits[Market.Mangrove]; + } + + internal static int PortCallFee(Ship ship, int port) => ship?.HullIndex == Market.River && port == 0 ? 350 : Market.Ports[port].Fee; + } +} diff --git a/Assets/BigShipTycoon/Runtime/CaptainCareer.cs.meta b/Assets/BigShipTycoon/Runtime/CaptainCareer.cs.meta new file mode 100644 index 0000000..66f4009 --- /dev/null +++ b/Assets/BigShipTycoon/Runtime/CaptainCareer.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 79c2023c792c9f26682daa750c5a91c6 \ No newline at end of file diff --git a/Assets/BigShipTycoon/Runtime/Company.cs b/Assets/BigShipTycoon/Runtime/Company.cs index e553b35..7c9b31f 100644 --- a/Assets/BigShipTycoon/Runtime/Company.cs +++ b/Assets/BigShipTycoon/Runtime/Company.cs @@ -88,7 +88,7 @@ namespace BigShipTycoon if (!legacy && owners[anchor] != 0) return false; FacilitySpec spec = Market.Facilities[(int)facility]; - if (hull < spec.MinimumHull || (spec.BayCount == 1 && rotation != 0)) + if (!Market.MeetsHullRequirement(hull, spec.MinimumHull) || (spec.BayCount == 1 && rotation != 0)) return false; foreach (Vector2Int offset in spec.Footprint(rotation)) { @@ -132,17 +132,17 @@ namespace BigShipTycoon public int CasinoCapacity => FacilityCapacity(Facility.CasinoLounge) + FacilityCapacity(Facility.Casino) + FacilityCapacity(Facility.GrandCasino) + FacilityCapacity(Facility.RoyalCasino); public int Capacity => Math.Min(Beds, Meals); - public int GalleyCapacity => (HullIndex == Market.Mega ? 540 : 168 + HullIndex * 72) + public int GalleyCapacity => (HullIndex == Market.River ? 56 : HullIndex == Market.Mega ? 540 : 168 + HullIndex * 72) + FacilityCapacity(Facility.Galley) + FacilityCapacity(Facility.ProductionGalley); - public int FoodCapacity => (HullIndex == Market.Mega ? 5600 : 1500 + HullIndex * 640) + public int FoodCapacity => (HullIndex == Market.River ? 220 : HullIndex == Market.Mega ? 5600 : 1500 + HullIndex * 640) + FacilityCapacity(Facility.Stores) + FacilityCapacity(Facility.ColdChain); - public int WaterCapacity => (HullIndex == Market.Mega ? 62000 : 16000 + HullIndex * 7600) + public int WaterCapacity => (HullIndex == Market.River ? 4400 : HullIndex == Market.Mega ? 62000 : 16000 + HullIndex * 7600) + FacilityCapacity(Facility.Water) + FacilityCapacity(Facility.MembranePlant); - public int WaterProduction => (HullIndex == Market.Mega ? 28000 : 9000 + HullIndex * 3900) + public int WaterProduction => (HullIndex == Market.River ? 2600 : HullIndex == Market.Mega ? 28000 : 9000 + HullIndex * 3900) + Count(Facility.Water) * 6000 + Count(Facility.MembranePlant) * 36000; - public int WasteCapacity => (HullIndex == Market.Mega ? 52000 : 12000 + HullIndex * 6800) + public int WasteCapacity => (HullIndex == Market.River ? 3600 : HullIndex == Market.Mega ? 52000 : 12000 + HullIndex * 6800) + FacilityCapacity(Facility.Waste) + FacilityCapacity(Facility.ReclamationPlant); - public int WasteTreatment => (HullIndex == Market.Mega ? 26000 : 5500 + HullIndex * 3400) + public int WasteTreatment => (HullIndex == Market.River ? 1950 : HullIndex == Market.Mega ? 26000 : 5500 + HullIndex * 3400) + Count(Facility.Waste) * 7000 + Count(Facility.ReclamationPlant) * 40000; internal int FittedRepairCapacity => FacilityCapacity(Facility.Workshop) + FacilityCapacity(Facility.EngineeringCenter); internal int FittedLaundryCapacity => FacilityCapacity(Facility.LaundryPlant); @@ -186,7 +186,8 @@ namespace BigShipTycoon + (Onboard?.Expenses ?? 0); public int NetIncome => TicketSales + OnboardSales - OperatingCash - FuelExpense - LoanInterest + (ShoreReport?.NetIncome ?? 0); public int CashChange => TicketSales + OnboardSales - OperatingCash - LoanInterest - Principal + (ShoreReport?.NetIncome ?? 0); - public int RequiredFuel => FuelBurn + Reserve; + public int DepartureFuelBurn => Plan == null || Onboard != null ? FuelBurn : PortPlanning.PlannedFuel(FuelBurn, Plan.Order); + public int RequiredFuel => DepartureFuelBurn + Reserve; internal Voyage CopyForPassage(bool hasDeparturePlan) { @@ -198,7 +199,8 @@ namespace BigShipTycoon copy.ShoreReport = null; copy.Plan = hasDeparturePlan && Plan != null ? new DeparturePlan { - FoodUnits = Plan.FoodUnits, FoodCost = Plan.FoodCost, Program = Plan.Program, ProgramCost = Plan.ProgramCost + FoodUnits = Plan.FoodUnits, FoodCost = Plan.FoodCost, Program = Plan.Program, ProgramCost = Plan.ProgramCost, + Order = Plan.Order } : null; return copy; } @@ -240,10 +242,12 @@ namespace BigShipTycoon public bool CanLoad() { + if (Permits?.Length == Market.Brickell && !IsCaptainCareer) + Array.Resize(ref Permits, Market.Ports.Count); if (Version != SaveVersion || Day < 1 || Cash < 0 || Debt < 0 || Reputation < 0 || Reputation > 100 || Voyages < 0 || Permits == null || Permits.Length != Market.Ports.Count || !Permits[0] || !Permits[1] || Fleet == null || Fleet.Count > Market.MaxFleet || History == null || History.Count > MaxHistory - || (Fleet.Count == 0 ? SelectedShip != -1 : SelectedShip < 0 || SelectedShip >= Fleet.Count)) + || (Fleet.Count == 0 ? SelectedShip != -1 : SelectedShip < 0 || SelectedShip >= Fleet.Count) || !ValidCaptainCareer()) return false; var callIds = new HashSet(); @@ -251,8 +255,10 @@ namespace BigShipTycoon { if (ship == null || string.IsNullOrWhiteSpace(ship.Name) || ship.HullIndex < 0 || ship.HullIndex >= Market.Hulls.Count || ship.Port < 0 || ship.Port >= Permits.Length || !Permits[ship.Port] || ship.Condition < 24 + || ship.HullIndex == Market.River && !IsCaptainCareer || !Market.CanVisit(ship.HullIndex, ship.Port) || ship.Condition > 100 || ship.Fare < Market.MinFare || ship.Fare > Market.MaxFare - || ship.Decks == null || ship.Decks.Count < Market.Hulls[0].StarterDecks || ship.Decks.Count > ship.Hull.MaxDecks + || ship.Decks == null || ship.Decks.Count < (ship.HullIndex == Market.River ? 1 : Market.Hulls[0].StarterDecks) + || ship.Decks.Count > ship.Hull.MaxDecks || ship.Fuel < 0 || double.IsNaN(ship.FuelValue) || double.IsInfinity(ship.FuelValue) || ship.FuelValue < 0) return false; @@ -293,7 +299,7 @@ namespace BigShipTycoon { if ((uint)hullIndex >= (uint)Market.Hulls.Count) return "Choose a hull at the shipyard."; - if (used && hullIndex >= Market.Ocean) + if (used && Market.HullRank(hullIndex) >= Market.HullRank(Market.Ocean)) return $"{Market.Hulls[hullIndex].Name} hulls are available as new commissions."; if (Fleet.Count >= Market.MaxFleet) return "The fleet has reached its eight-ship limit."; @@ -307,6 +313,9 @@ namespace BigShipTycoon internal string ShipyardUnlock(int hullIndex) { + string command = CommandBlock(hullIndex); + if (command != null) + return command; HullSpec hull = Market.Hulls[hullIndex]; if (hullIndex == Market.Mega && !Flagship) return "Complete the Ocean Class flagship charter from Bermuda to Lisbon."; @@ -348,13 +357,20 @@ namespace BigShipTycoon Name = name, HullIndex = hullIndex, Condition = original ? 78 : used ? 72 : 100, - Fare = hullIndex switch { Market.Coastal => 550, Market.Regional => 850, Market.Mega => 1450, _ => 1250 }, - Fuel = original ? 48 : used ? 25 : 0 + Fare = hullIndex switch { Market.River => 340, Market.Coastal => 550, Market.Regional => 850, Market.Mega => 1450, _ => 1250 }, + Fuel = hullIndex == Market.River ? used ? 13 : 0 : original ? 48 : used ? 25 : 0 }; ship.FuelValue = ship.Fuel * Market.FuelPrice(0, 1); for (int i = 0; i < ship.Hull.StarterDecks; i++) ship.AddEmptyDeck(); - if (used) + if (used && hullIndex == Market.River) + { + ship.Decks[0].Cells[0] = Facility.Cabin; + ship.Decks[0].Cells[1] = Facility.Dining; + ship.Decks[0].Cells[3] = Facility.Bar; + ship.Decks[0].Cells[4] = Facility.Entertainment; + } + else if (used) { for (int i = 0; i < 8; i++) ship.Decks[0].Cells[i] = Facility.Cabin; @@ -367,7 +383,7 @@ namespace BigShipTycoon return ship; } - public int DeckPrice(Ship ship) => 29000 + ship.Decks.Count * 8500 + ship.HullIndex * 13000; + public int DeckPrice(Ship ship) => ship.HullIndex == Market.River ? 13500 : 29000 + ship.Decks.Count * 8500 + ship.HullIndex * 13000; public string AddDeck(Ship ship) { @@ -402,7 +418,7 @@ namespace BigShipTycoon bool turning = previous == plan; if (turning && rotation == deck.RotationAt(anchor)) return null; - if (ship.HullIndex < spec.MinimumHull) + if (!Market.MeetsHullRequirement(ship.HullIndex, spec.MinimumHull)) return $"Requires a {Market.Hulls[spec.MinimumHull].Name} hull or larger."; if (!turning && previous != Facility.Empty) return "Clear this berth before building another facility."; @@ -515,12 +531,16 @@ namespace BigShipTycoon { if (!Market.TryDistance(ship.Port, destination, out int miles)) return null; + bool river = ship.HullIndex == Market.River; + if ((river || Market.IsRiverPort(ship.Port) || Market.IsRiverPort(destination)) + && (!Market.CanVisit(ship.HullIndex, ship.Port) || !Market.CanVisit(ship.HullIndex, destination))) + return null; PortSpec from = Market.Ports[ship.Port]; PortSpec to = Market.Ports[destination]; - int days = 1 + (int)Math.Ceiling(miles / 415.0); + int days = river ? 1 : 1 + (int)Math.Ceiling(miles / 415.0); var (fuel, reserve) = LegFuel(ship, miles); - double referenceFare = 330 + days * 88 + to.Appeal * 125; + double referenceFare = river ? 235 + to.Appeal * 110 : 330 + days * 88 + to.Appeal * 125; double fareFactor = Math.Pow(referenceFare / ship.Fare, 1.55); double season = 1 + .13 * Math.Cos((Day + destination * 13) * 2 * Math.PI / 112); int recentSailings = 0; @@ -534,7 +554,12 @@ namespace BigShipTycoon double saturation = Math.Max(.66, 1 - recentSailings * .085); double entertainment = Math.Min(1, (double)ship.Entertainment / Math.Max(1, ship.Capacity)); - double classDemand = ship.HullIndex == Market.Mega ? 230 + ship.Capacity * .68 : 150 + ship.Capacity * .50; + double classDemand = ship.HullIndex switch + { + Market.River => 38 + ship.Capacity * .62, + Market.Mega => 230 + ship.Capacity * .68, + _ => 150 + ship.Capacity * .50 + }; double marketDemand = classDemand * from.MarketSize * to.Appeal * season * saturation; double product = (.66 + Reputation * .006 + entertainment * .20) * (.8 + ship.Condition * .002); int roomDemand = Math.Max(0, (int)Math.Round(marketDemand * fareFactor * product)); @@ -572,7 +597,7 @@ namespace BigShipTycoon CrewAssigned = crew, Crew = CrewMarket.Payroll(crew) * days, Catering = guests * days * 27, - PortFees = from.Fee / 2 + to.Fee, + PortFees = PortCallFee(ship, ship.Port) / 2 + PortCallFee(ship, destination), FuelExpense = (int)Math.Round(Math.Min(fuel, ship.Fuel) * unitCost + Math.Max(0, fuel - ship.Fuel) * Market.FuelPrice(ship.Port, Day)), LoanInterest = (int)Math.Ceiling(Debt * .13 * days / 365), @@ -591,8 +616,8 @@ namespace BigShipTycoon return $"This itinerary's next stop is {Market.Ports[itinerary.NextPort].Name}."; if (!Permits[quote.Destination]) return "Obtain a destination permit in Ports."; - if (ship.HullIndex < Market.Ports[quote.Destination].MinimumHull) - return "This destination requires a larger hull class."; + if (!Market.CanVisit(ship.HullIndex, ship.Port) || !Market.CanVisit(ship.HullIndex, quote.Destination)) + return ship.HullIndex == Market.River ? "This riverboat is certified for local river routes." : "This destination requires a different hull class."; if (ship.Beds == 0 || ship.Meals == 0) return "Build cabins and dining before carrying guests."; if (ship.Condition < 25) @@ -606,6 +631,10 @@ namespace BigShipTycoon if (assigned < CrewMarket.Minimum(ship, role)) return $"Assign the required {department.Name.ToLowerInvariant()} in the crew office."; } + if (quote.Plan?.Order == PassageOrder.Express && (quote.CrewAssigned is { Length: > 0 } + ? quote.CrewAssigned[(int)CrewRole.Engineering] : ship.CrewCount(CrewRole.Engineering)) + < CrewMarket.Recommended(ship, CrewRole.Engineering) * .85) + return "Express requires 85% of the recommended engineering crew."; if (quote.RequiredFuel > ship.Tank) return $"This route needs {quote.RequiredFuel} t. Add a bunker tank or use a larger hull."; if (ship.Fuel < quote.RequiredFuel) @@ -653,6 +682,8 @@ namespace BigShipTycoon Debt -= quote.Principal; Reputation = Market.Clamp(Reputation + quote.ReputationChange, 0, 100); Voyages++; + if (IsCaptainCareer) + commandVoyages[ship.HullIndex]++; LifetimeProfit += quote.NetIncome; Flagship |= ship.HullIndex == Market.Ocean && ship.Capacity >= 320 && ship.Entertainment >= 160 && quote.Origin == Market.Bermuda && quote.Destination == Market.Lisbon; diff --git a/Assets/BigShipTycoon/Runtime/CompanyPages.cs b/Assets/BigShipTycoon/Runtime/CompanyPages.cs index 512ee0a..32456da 100644 --- a/Assets/BigShipTycoon/Runtime/CompanyPages.cs +++ b/Assets/BigShipTycoon/Runtime/CompanyPages.cs @@ -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("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(ChartPortCount); - for (int i = 0; i < ChartPortCount; i++) - choices.Add(Market.Ports[i].Name); + var choices = new List(); + var ids = new List(); + 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(); } diff --git a/Assets/BigShipTycoon/Runtime/ConstructionPages.cs b/Assets/BigShipTycoon/Runtime/ConstructionPages.cs index cc35ff2..2d3a427 100644 --- a/Assets/BigShipTycoon/Runtime/ConstructionPages.cs +++ b/Assets/BigShipTycoon/Runtime/ConstructionPages.cs @@ -9,7 +9,7 @@ namespace BigShipTycoon { private static readonly (int HullIndex, bool Used)[] Offers = { (Market.Coastal, true), (Market.Coastal, false), (Market.Regional, true), (Market.Regional, false), - (Market.Ocean, false), (Market.Mega, false) }; + (Market.Ocean, false), (Market.Mega, false), (Market.River, true), (Market.River, false) }; private enum DeckTools { GuestFacilities, LargerVenues, LeisureAndRetail, ShipSystems, Gaming, MegaVenues, MegaSystems } private DeckTools deckTools; @@ -66,6 +66,11 @@ namespace BigShipTycoon Notify(null); Render(); }, "work-deck-tab", "sun-deck-open"); + if (ship.HullIndex == Market.River) + { + sunDeck.SetEnabled(false); + sunDeck.tooltip = "The riverboat has a fixed roof."; + } sunDeck.EnableInClassList("work-selected", sunDeckEditing); band.Add(sunDeck); for (int i = ship.Decks.Count - 1; i >= 0; i--) @@ -184,7 +189,7 @@ namespace BigShipTycoon foreach (Facility option in options) { FacilitySpec spec = Market.Facilities[(int)option]; - bool locked = ship.HullIndex < spec.MinimumHull; + bool locked = !Market.MeetsHullRequirement(ship.HullIndex, spec.MinimumHull); Button button = Action("", () => { if (tool != option) @@ -328,7 +333,8 @@ namespace BigShipTycoon private string PlacementBlock(Ship ship, int cell) { FacilitySpec spec = Market.Facilities[(int)tool]; - return ship.HullIndex < spec.MinimumHull ? VenueRequirement(spec) : company.BuildBlock(ship, deckIndex, cell, tool, toolRotation); + return !Market.MeetsHullRequirement(ship.HullIndex, spec.MinimumHull) + ? VenueRequirement(spec) : company.BuildBlock(ship, deckIndex, cell, tool, toolRotation); } private void BuildAtBerth(Ship ship, Deck deck, int cell) @@ -403,7 +409,7 @@ namespace BigShipTycoon FacilitySpec spec = Market.Facilities[(int)selected]; if (selected == Facility.Empty) return "Select any bay in a fitted room to remove it and recover 25%."; - if (ship.HullIndex < spec.MinimumHull) + if (!Market.MeetsHullRequirement(ship.HullIndex, spec.MinimumHull)) return VenueRequirement(spec); string plan = spec.BayCount == 1 ? "Select an open bay" : $"Point at a bay to preview the {FootprintLabel(spec, rotation)} fitting"; return $"{plan}. {spec.Name} · {spec.Details} · {Money(spec.Price)}"; @@ -609,6 +615,8 @@ namespace BigShipTycoon { int selection = item; var offer = Offers[item]; + if (offer.HullIndex == Market.River && !company.IsCaptainCareer) + continue; HullSpec candidate = Market.Hulls[offer.HullIndex]; string requirement = company.ShipyardUnlock(offer.HullIndex); Button option = Action("", () => @@ -662,6 +670,13 @@ namespace BigShipTycoon contract.Add(buy); if (block != null) AddText(contract, block, "work-contract-block"); + else if (company.IsCaptainCareer) + { + var (previous, trips, checks) = Company.CommandRequirement(hullIndex); + if (previous >= 0) + AddText(contract, $"{Market.Hulls[previous].Name} command signed off · {trips} voyages · {checks} helm qualifications", + "work-yard-specs"); + } } private void DrawShipyardService(VisualElement order, Ship ship) @@ -774,8 +789,9 @@ namespace BigShipTycoon Painter2D pen = context.painter2D; DrawDraftGrid(pen, bounds, 33); Vector2 P(float x, float y) => new Vector2(bounds.width * x, bounds.height * y); - float stern = .178f - hullIndex * .028f; - float bow = .833f + hullIndex * .029f; + int rank = Market.HullRank(hullIndex); + float stern = .207f - rank * .029f; + float bow = .804f + rank * .029f; float L(float position) => Mathf.Lerp(stern, bow, position); void Path(params float[] xy) { @@ -817,16 +833,23 @@ namespace BigShipTycoon Path(1,.897f, .988f,.913f); pen.Stroke(); - pen.fillColor = new Color(.13f, .23f, .24f); + pen.fillColor = hullIndex switch + { + Market.River => new Color(.17f, .30f, .31f), + Market.Coastal => new Color(.24f, .36f, .43f), + Market.Regional => new Color(.18f, .40f, .41f), + Market.Ocean => new Color(.12f, .22f, .31f), + _ => new Color(.22f, .32f, .36f) + }; pen.strokeColor = DraftInk; pen.lineWidth = 1.8f; pen.BeginPath(); Vector2 transom = P(stern, .56f); Vector2 aftDeck = P(L(.21f), .565f); Vector2 foreDeck = P(L(.79f), .565f); - Vector2 stem = P(bow, .49f); - Vector2 forwardKeel = P(L(.903f), .712f); - Vector2 aftKeel = P(L(.135f), .712f); + Vector2 stem = P(bow, hullIndex is Market.River or Market.Coastal ? .548f : .49f); + Vector2 forwardKeel = P(L(hullIndex == Market.Ocean ? .844f : .937f), .712f); + Vector2 aftKeel = P(L(hullIndex is Market.River or Market.Coastal ? .070f : .145f), .712f); pen.MoveTo(transom); TraceDraftCurve(pen, transom, P(L(.11f), .57f), aftDeck); pen.LineTo(foreDeck); @@ -847,8 +870,20 @@ namespace BigShipTycoon int allowedDecks = Market.Hulls[hullIndex].MaxDecks; bool mega = hullIndex == Market.Mega; float deckRise = mega ? .0275f : .047f; - float LeftEdge(int level) => mega ? level >= levels - 1 ? .285f : .055f + level * .0018f : .079f + level * .031f; - float RightEdge(int level) => mega ? .934f - level * .0041f : .872f - level * .04f; + float LeftEdge(int level) => hullIndex switch + { + Market.Regional => .10f + level * .047f, + Market.Ocean => .055f + level * .017f, + Market.Mega => level >= levels - 1 ? .285f : .055f + level * .0018f, + _ => .079f + level * .031f + }; + float RightEdge(int level) => hullIndex switch + { + Market.Coastal => .79f - level * .023f, + Market.Ocean => .898f - level * .047f, + Market.Mega => .934f - level * .0041f, + _ => .872f - level * .04f + }; pen.strokeColor = new Color(DraftFine.r, DraftFine.g, DraftFine.b, .28f); pen.BeginPath(); for (int level = levels; level < allowedDecks; level++) @@ -883,13 +918,38 @@ namespace BigShipTycoon } float top = .57f - levels * deckRise; - pen.fillColor = new Color(.38f, .30f, .19f); pen.strokeColor = DraftGold; - pen.BeginPath(); - Path(.403f,top, .420f,top - .111f, .466f,top - .111f, .452f,top); - pen.ClosePath(); - pen.Fill(); - pen.Stroke(); + void RoofDetail(Color fill, params float[] coordinates) + { + pen.fillColor = fill; + pen.BeginPath(); + Path(coordinates); + pen.ClosePath(); + pen.Fill(); + pen.Stroke(); + } + var glazing = new Color(.20f, .42f, .46f); + var red = new Color(.55f, .28f, .22f); + switch (hullIndex) + { + case Market.River: + RoofDetail(glazing, .63f,top, .63f,top - .069f, .80f,top - .069f, .818f,top); + break; + case Market.Coastal: + RoofDetail(red, .378f,top, .380f,top - .056f, .424f,top - .060f, .435f,top); + break; + case Market.Regional: + RoofDetail(glazing, .320f,top, .311f,top - .092f, .340f,top - .092f, .362f,top); + RoofDetail(glazing, .388f,top, .376f,top - .079f, .404f,top - .079f, .428f,top); + break; + case Market.Ocean: + RoofDetail(red, .263f,top, .236f,top - .128f, .291f,top - .128f, .330f,top); + break; + case Market.Mega: + RoofDetail(glazing, .36f,top, .38f,top - .063f, .46f,top - .062f, .48f,top); + RoofDetail(glazing, .662f,top, .689f,top - .062f, .71f,top - .077f, .736f,top - .054f, .753f,top); + break; + } pen.strokeColor = DraftInk; pen.BeginPath(); Path(.645f,top + .01f, .645f,top - .125f); diff --git a/Assets/BigShipTycoon/Runtime/CrewMarket.cs b/Assets/BigShipTycoon/Runtime/CrewMarket.cs index 35617f3..2b49459 100644 --- a/Assets/BigShipTycoon/Runtime/CrewMarket.cs +++ b/Assets/BigShipTycoon/Runtime/CrewMarket.cs @@ -13,13 +13,13 @@ namespace BigShipTycoon public readonly int DailyWage; private readonly int[] complement; - internal CrewRoleSpec(CrewRole role, string name, string description, int dailyWage, int coastal, int regional, int ocean, int mega) + internal CrewRoleSpec(CrewRole role, string name, string description, int dailyWage, int coastal, int regional, int ocean, int mega, int river) { Role = role; Name = name; Description = description; DailyWage = dailyWage; - complement = new[] { coastal, regional, ocean, mega }; + complement = new[] { coastal, regional, ocean, mega, river }; } internal int StarterCount(int hull) => complement[hull]; @@ -31,20 +31,20 @@ namespace BigShipTycoon public static readonly IReadOnlyList Roles = new[] { - new CrewRoleSpec(CrewRole.Bridge, "Bridge officers", "Stand navigation watches and keep crossings on schedule.", 350, 4, 6, 10, 13), - new CrewRoleSpec(CrewRole.Engineering, "Engineering", "Keep propulsion, water and treatment systems running.", 220, 8, 14, 24, 36), - new CrewRoleSpec(CrewRole.Galley, "Galley crew", "Cook meals and staff the galley during busy seatings.", 155, 12, 21, 36, 65), - new CrewRoleSpec(CrewRole.Housekeeping, "Hotel services", "Turn over cabins and serve guests at bars, shops and amenities.", 130, 14, 24, 44, 84), - new CrewRoleSpec(CrewRole.Laundry, "Laundry crew", "Wash cabin linen and towels using the ship’s freshwater supply.", 115, 5, 9, 18, 36), - new CrewRoleSpec(CrewRole.Entertainment, "Entertainment", "Run the ship’s shows and guest programming.", 140, 4, 7, 16, 33) + new CrewRoleSpec(CrewRole.Bridge, "Bridge officers", "Stand navigation watches and keep crossings on schedule.", 350, 4, 6, 10, 13, 1), + new CrewRoleSpec(CrewRole.Engineering, "Engineering", "Keep propulsion, water and treatment systems running.", 220, 8, 14, 24, 36, 2), + new CrewRoleSpec(CrewRole.Galley, "Galley crew", "Cook meals and staff the galley during busy seatings.", 155, 12, 21, 36, 65, 2), + new CrewRoleSpec(CrewRole.Housekeeping, "Hotel services", "Turn over cabins and serve guests at bars, shops and amenities.", 130, 14, 24, 44, 84, 2), + new CrewRoleSpec(CrewRole.Laundry, "Laundry crew", "Wash cabin linen and towels using the ship’s freshwater supply.", 115, 5, 9, 18, 36, 1), + new CrewRoleSpec(CrewRole.Entertainment, "Entertainment", "Run the ship’s shows and guest programming.", 140, 4, 7, 16, 33, 1) }; internal static bool IsRole(CrewRole role) => (uint)role < (uint)Roles.Count; public static int Minimum(Ship ship, CrewRole role) => role switch { - CrewRole.Bridge => ship.HullIndex == Market.Mega ? 9 : 2 + ship.HullIndex, - CrewRole.Engineering => ship.HullIndex == Market.Mega ? 15 : 4 + 2 * ship.HullIndex, + CrewRole.Bridge => ship.HullIndex == Market.River ? 1 : ship.HullIndex == Market.Mega ? 9 : 2 + ship.HullIndex, + CrewRole.Engineering => ship.HullIndex == Market.River ? 1 : ship.HullIndex == Market.Mega ? 15 : 4 + 2 * ship.HullIndex, _ => 0 }; @@ -59,7 +59,8 @@ namespace BigShipTycoon CrewRole.Engineering => extraDecks * 2 + ship.Count(Facility.Workshop) + ship.Count(Facility.EngineeringCenter) * 3, CrewRole.Galley => extraDecks + ship.Count(Facility.Galley) * 2 + ship.Count(Facility.ProductionGalley) * 5, CrewRole.Housekeeping => extraDecks * 2 + ship.SuiteBerths / 60, - CrewRole.Laundry => extraDecks + ship.Beds / (100 + 75 * ship.HullIndex) + ship.Count(Facility.LaundryPlant) * 4, + CrewRole.Laundry => extraDecks + ship.Beds / (ship.HullIndex == Market.River ? 45 : 100 + 75 * ship.HullIndex) + + ship.Count(Facility.LaundryPlant) * 4, CrewRole.Entertainment => ship.Entertainment / 190, _ => 0 }; diff --git a/Assets/BigShipTycoon/Runtime/CruiseItinerary.cs b/Assets/BigShipTycoon/Runtime/CruiseItinerary.cs index 69d9483..c3e5b2c 100644 --- a/Assets/BigShipTycoon/Runtime/CruiseItinerary.cs +++ b/Assets/BigShipTycoon/Runtime/CruiseItinerary.cs @@ -83,8 +83,9 @@ namespace BigShipTycoon PortSpec port = Market.Ports[destination]; if (!Permits[destination]) return $"Acquire the permit for {port.Name} first."; - if (ship.HullIndex < port.MinimumHull) - return $"{port.Name} requires a {Market.Hulls[port.MinimumHull].Name} hull."; + if (!Market.CanVisit(ship.HullIndex, destination)) + return ship.HullIndex == Market.River ? "Choose a port on the local river chart." + : $"{port.Name} requires a {Market.Hulls[port.MinimumHull].Name} hull."; var (burn, reserve) = LegFuel(ship, miles); if (burn + reserve > ship.Tank) return $"This leg needs {burn + reserve} t including reserve. Fit a larger fuel tank first."; @@ -108,7 +109,7 @@ namespace BigShipTycoon int origin = itinerary.Origin; foreach (int port in itinerary.Stops) { - if (port < 0 || port >= Market.Ports.Count || !Market.TryDistance(origin, port, out _)) + if ((uint)port >= (uint)Market.Ports.Count || !Market.CanVisit(ship.HullIndex, port) || !Market.TryDistance(origin, port, out _)) return false; origin = port; } diff --git a/Assets/BigShipTycoon/Runtime/DeckAmbience.cs b/Assets/BigShipTycoon/Runtime/DeckAmbience.cs index aa6bfca..410ed52 100644 --- a/Assets/BigShipTycoon/Runtime/DeckAmbience.cs +++ b/Assets/BigShipTycoon/Runtime/DeckAmbience.cs @@ -134,7 +134,7 @@ namespace BigShipTycoon if (decks == null) return focus; int deckCount = displayedShip.Decks.Count; - float roof = MegaDeckGeometry.RoofHeight(deckCount, SunDeckZone.Sky); + float roof = MegaDeckGeometry.RoofHeight(deckCount, SunDeckZone.Sky, displayedShip); if (!onFoot) listener.y = roof; float outdoors = session?.Quote.Weather == WeatherCondition.Storm ? .16f : 1f; diff --git a/Assets/BigShipTycoon/Runtime/DeckPassengers.cs b/Assets/BigShipTycoon/Runtime/DeckPassengers.cs index fe0dbbd..0cde1d9 100644 --- a/Assets/BigShipTycoon/Runtime/DeckPassengers.cs +++ b/Assets/BigShipTycoon/Runtime/DeckPassengers.cs @@ -100,7 +100,7 @@ namespace BigShipTycoon promenade.Crowd.SetActive(false); } - public float FloorHeight(int index) => VesselExterior.DeckBase + index * VesselExterior.DeckSpacing + .08f; + public float FloorHeight(int index) => VesselExterior.BaseDeck(ship) + index * VesselExterior.DeckSpacing + .08f; private (float Aft, float Fore, float HalfWidth) RoomEnvelope(int index) { @@ -118,7 +118,7 @@ namespace BigShipTycoon return new Vector3(envelope.Aft + .85f, FloorHeight(index) + EyeHeight, -envelope.HalfWidth + rowDepth + AisleWidth * .5f); } - private float BridgeHeight => VesselExterior.DeckBase + ship.Decks.Count * VesselExterior.DeckSpacing; + private float BridgeHeight => MegaDeckGeometry.RoofHeight(ship.Decks.Count, SunDeckZone.Sky, ship); private float BridgeHalfWidth => ship.HasAftTerrace ? MegaDeckGeometry.ForShip(ship, ship.Decks.Count - 1, ship.Decks.Count).Beam * .58f : beam * .66f; private float BridgeAft => BridgeCenter - 4.45f; @@ -235,7 +235,7 @@ namespace BigShipTycoon float width = plan.HalfBeam; float aft = plan.Offset - plan.Length * .305f; float fore = terrace ? plan.Offset + plan.Length * .31f : Mathf.Min(BridgeCenter - 6.0f, plan.Offset + plan.Length * .17f); - int walkers = terrace ? 10 : 7 + ship.HullIndex * 3; + int walkers = terrace ? 10 : ship.HullIndex == Market.River ? 4 : 7 + ship.HullIndex * 3; for (int side = -1; side <= 1; side += 2) { for (int i = 0; i < walkers; i++) @@ -337,16 +337,17 @@ namespace BigShipTycoon var interior = new Geometry(this, layout.Interior.transform); var cutaway = new Geometry(this, layout.Cutaway.transform); Vector2[] hull = Outline(.97f, beam * .98f); - float baseLevel = VesselExterior.DeckBase; + float baseLevel = VesselExterior.BaseDeck(ship); structure.Mesh(0).Loft(hull, Vector2.zero, false, - new Vector3(.93f, -1.2f, .69f), new Vector3(.99f, 0, .95f), - new Vector3(1f, 2.0f, 1f), new Vector3(1f, baseLevel - .20f, 1f)); + new Vector3(.93f, ship.HullIndex == Market.River ? -.77f : -1.2f, .69f), new Vector3(.99f, 0, .95f), + new Vector3(1f, ship.HullIndex == Market.River ? .67f : 2.0f, 1f), new Vector3(1f, baseLevel - .20f, 1f)); structure.Mesh(1).Loft(hull, Vector2.zero, false, new Vector3(1.002f, baseLevel - .21f, 1.003f), new Vector3(1.003f, baseLevel, 1.003f)); structure.Mesh(2).Loft(hull, Vector2.zero, true, new Vector3(.998f, baseLevel - .01f, .998f), new Vector3(.998f, baseLevel + .01f, .998f)); + float stripe = ship.HullIndex == Market.River ? .66f : 3.3f; structure.Mesh(8).Loft(hull, Vector2.zero, false, - new Vector3(1.003f, 3.3f, 1.004f), new Vector3(1.003f, 3.37f, 1.004f)); + new Vector3(1.003f, stripe, 1.004f), new Vector3(1.003f, stripe + .07f, 1.004f)); Vector2[] outline = hull; for (int layer = 0; layer < index; layer++) @@ -950,7 +951,7 @@ namespace BigShipTycoon private void DrawForedeck(Geometry shape) { - float level = VesselExterior.DeckBase + .04f; + float level = VesselExterior.BaseDeck(ship) + .04f; float from = BridgeFore - 1.44f; float nose = length * .498f; Vector2[] outline = diff --git a/Assets/BigShipTycoon/Runtime/FirstVoyageGuide.cs b/Assets/BigShipTycoon/Runtime/FirstVoyageGuide.cs index 50119f8..65defc2 100644 --- a/Assets/BigShipTycoon/Runtime/FirstVoyageGuide.cs +++ b/Assets/BigShipTycoon/Runtime/FirstVoyageGuide.cs @@ -12,6 +12,7 @@ namespace BigShipTycoon private const int StarterCabinModules = 4; private static int StarterBerths => StarterCabinModules * Market.Facilities[(int)Facility.Cabin].Capacity; + private static int GuideBerths(Ship ship) => ship.HullIndex == Market.River ? Market.Facilities[(int)Facility.Cabin].Capacity : StarterBerths; private GuideStep guideContext; private Ship guideFareShip; private int guideInitialFare; @@ -70,13 +71,13 @@ namespace BigShipTycoon return GuideStep.Review; if (ship == null) return GuideStep.GetShip; - if (ship.Beds < StarterBerths) + if (ship.Beds < GuideBerths(ship)) return GuideStep.Cabins; - if (ship.Meals < StarterBerths) + if (ship.Meals < GuideBerths(ship)) return GuideStep.Dining; Voyage quote = page == 3 ? company.Forecast(ship, inspectedPort) : null; - if (quote == null || !company.Permits[quote.Destination] || ship.HullIndex < Market.Ports[quote.Destination].MinimumHull) + if (quote == null || !company.Permits[quote.Destination] || !Market.CanVisit(ship.HullIndex, quote.Destination)) return GuideStep.SetCourse; if (ship.Fuel < quote.RequiredFuel) return GuideStep.Bunker; @@ -125,9 +126,9 @@ namespace BigShipTycoon return ("Register your first ship", "Choose a hull you can afford and sign the commission or purchase.", "buy-ship"); case GuideStep.Cabins: - return GuideFacility(Facility.Cabin, $"Outfit passenger cabins · {Ship.Beds}/{StarterBerths} berths"); + return GuideFacility(Facility.Cabin, $"Outfit passenger cabins · {Ship.Beds}/{GuideBerths(Ship)} berths"); case GuideStep.Dining: - return GuideFacility(Facility.Dining, $"Fit dining for {StarterBerths} guests"); + return GuideFacility(Facility.Dining, $"Fit dining for {GuideBerths(Ship)} guests"); case GuideStep.Bunker: Voyage crossing = company.Forecast(Ship, inspectedPort); @@ -146,7 +147,9 @@ namespace BigShipTycoon string blocker = company.DepartureBlock(Ship, departure); if (blocker != null) return ("Clear departure", blocker, null); - return ("Clear departure", "Choose Cast off. Watch the crossing or skip to arrival.", "dispatch"); + return company.IsCaptainCareer + ? ("Clear departure", "Choose Cast off, then open the bridge to try your first helm check.", "dispatch") + : ("Clear departure", "Choose Cast off. Watch the crossing or skip to arrival.", "dispatch"); case GuideStep.Review: if (page != 4) @@ -158,6 +161,10 @@ namespace BigShipTycoon case GuideStep.AtSea: if (passageServiceArea >= 0) return ("Work the service deck", "Walk up to the equipment and press F when the station prompt appears. You can switch operating modes here.", "service-assist"); + if (company.IsCaptainCareer && !passageHelm.Practice.Qualified && !passageExploring) + return passageBridge + ? ("Practise at the helm", "Use the heading and rudder readouts to complete the bridge check.", passageHelm.Manual ? null : "helm-toggle") + : ("Start your helm check", "Open the bridge and take the helm to log a qualification for this class.", "passage-bridge"); if (passageBridge) return ("Navigate from the bridge", "Face the wheel and press F to take the helm. Return to autopilot to walk around again.", "helm-toggle"); if (passageExploring) @@ -200,11 +207,11 @@ namespace BigShipTycoon foreach (Lane lane in Market.Lanes) { int next = lane.Other(Ship.Port); - if (next < 0 || !company.Permits[next] || Ship.HullIndex < Market.Ports[next].MinimumHull) + if (next < 0 || !company.Permits[next] || !Market.CanVisit(Ship.HullIndex, next)) continue; string port = Market.Ports[next].Name; - if (!worldChart && next >= Market.StarterPortCount) + if (!RiverChart && !worldChart && next >= Market.StarterPortCount) return (heading, $"Switch to World and select {port} to review that sailing.", "chart-world"); return (heading, $"Select {port}, an open port linked to your current berth.", $"port-{next}"); } diff --git a/Assets/BigShipTycoon/Runtime/FleetPassageSave.cs b/Assets/BigShipTycoon/Runtime/FleetPassageSave.cs index defeba0..81eca27 100644 --- a/Assets/BigShipTycoon/Runtime/FleetPassageSave.cs +++ b/Assets/BigShipTycoon/Runtime/FleetPassageSave.cs @@ -191,7 +191,8 @@ namespace BigShipTycoon DeparturePlan plan = voyage.Plan; return !hasDeparturePlan || (plan != null && plan.FoodUnits >= 0 && plan.FoodUnits <= ship.FoodCapacity && plan.FoodCost >= 0 - && plan.ProgramCost >= 0 && (uint)plan.Program <= (uint)EntertainmentProgram.Headline); + && plan.ProgramCost >= 0 && (uint)plan.Program <= (uint)EntertainmentProgram.Headline + && (uint)plan.Order <= (uint)PassageOrder.Express); } } } diff --git a/Assets/BigShipTycoon/Runtime/FleetPassages.cs b/Assets/BigShipTycoon/Runtime/FleetPassages.cs index 816646f..cb682bc 100644 --- a/Assets/BigShipTycoon/Runtime/FleetPassages.cs +++ b/Assets/BigShipTycoon/Runtime/FleetPassages.cs @@ -134,7 +134,10 @@ namespace BigShipTycoon fleetPassages.Remove(ship); UpdateVoyageReserves(); - return company.Sail(ship, session.Quote.Destination, session); + string result = company.Sail(ship, session.Quote.Destination, session); + if (result == null && company.IsCaptainCareer && passage.Helm.Arrived && passage.Helm.Practice.Qualified) + company.RecordHelmQualification(ship); + return result; } private void UpdateBackgroundPassages(float delta) diff --git a/Assets/BigShipTycoon/Runtime/Harbor.cs b/Assets/BigShipTycoon/Runtime/Harbor.cs index a97b792..06ce015 100644 --- a/Assets/BigShipTycoon/Runtime/Harbor.cs +++ b/Assets/BigShipTycoon/Runtime/Harbor.cs @@ -25,7 +25,7 @@ namespace BigShipTycoon private float yaw = DefaultYaw, pitch = DefaultPitch, zoom = 1f; private float targetYaw = DefaultYaw, targetPitch = DefaultPitch, targetZoom = 1f; private Vector3 orbitOffset, targetOrbitOffset; - private float seaTime, seaSeverity, passageDistance; + private float seaTime, seaSeverity, passageDistance, passageHeading; private Vector3 hullMotion, hullMotionVelocity; private bool sailing; private Bounds hullBounds; @@ -46,6 +46,8 @@ namespace BigShipTycoon public RenderTexture Frame { get; private set; } internal Vector3 PassageWorldPosition => vessel != null ? vessel.position : Vector3.zero; + internal Vector3 PassageSeaMotion => hullMotion; + internal float HorizonRoll => Mathf.Asin(Mathf.Clamp(viewCamera.transform.right.y, -1, 1)) * Mathf.Rad2Deg; internal bool PassageUsesPerspective => sailing && cameraMode == CameraMode.Orbit && !viewCamera.orthographic; internal Vector3 FirstPersonPosition => freePosition; internal bool FirstPersonPositionIsClear => walkSpace != null && walkSpace.CanStand(freePosition); @@ -346,12 +348,15 @@ namespace BigShipTycoon sailing = true; seaSeverity = (int)weather / 2f; seaTime = 0; - float nominalKnots = 17f + 2f * (displayedShip?.HullIndex ?? 0); + bool river = displayedShip?.HullIndex == Market.River; + float nominalKnots = river ? 10f : 17f + 2f * (displayedShip?.HullIndex ?? 0); float weatherSlowdown = weather == WeatherCondition.Storm ? 1.32f : weather == WeatherCondition.Swell ? 1.14f : 1f; passageDistance = nominalKnots * .514444f * duration / weatherSlowdown; hullMotion = hullMotionVelocity = Vector3.zero; + passageHeading = 0; water.SetFloat("_WeatherSeverity", seaSeverity); Shader.SetGlobalFloat("_TycoonSeaWeather", seaSeverity); + Shader.SetGlobalFloat("_TycoonRiverWater", river ? 1f : 0f); Shader.SetGlobalFloat("_TycoonSeaSailing", 1); wake.Reset(); SetPassage(Vector2.zero, 0, 0, 0); @@ -365,48 +370,76 @@ namespace BigShipTycoon float sine = Mathf.Sin(headingRadians); float cosine = Mathf.Cos(headingRadians); var center = new Vector2(routePosition.x, -routePosition.y) * passageDistance; + bool river = displayedShip?.HullIndex == Market.River; if (vessel != null && delta > 0) { - // Use wave heights along the waterline to drive a damped heave, pitch and roll. - Vector2 bow = new Vector2(cosine, -sine) * (vesselLength * .36f); - Vector2 port = new Vector2(sine, cosine) * (vesselBeam * .86f); - float fore = WaveHeight(center + bow), aft = WaveHeight(center - bow); - float left = WaveHeight(center + port), right = WaveHeight(center - port); - var target = new Vector3((fore + aft + left + right) * .25f, - Mathf.Atan2(right - left, 2 * port.magnitude) * Mathf.Rad2Deg, - Mathf.Atan2(fore - aft, 2 * bow.magnitude) * Mathf.Rad2Deg); - float response = .48f + vesselLength * .005f; - hullMotion = Vector3.SmoothDamp(hullMotion, target, ref hullMotionVelocity, response, Mathf.Infinity, delta); + Vector3 target = SampleSeaResponse(center, seaTime, heading, vesselLength, vesselBeam, seaSeverity, river); + float mass = Mathf.InverseLerp(28f, 300f, vesselLength); + float turnRate = Mathf.Clamp(Mathf.DeltaAngle(passageHeading, heading) / delta, -18f, 18f); + target.y += turnRate * Mathf.Clamp01(speed / (river ? 10f : 19f)) * Mathf.Lerp(.105f, .05f, mass); + hullMotion.x = Mathf.SmoothDamp(hullMotion.x, target.x, ref hullMotionVelocity.x, + Mathf.Lerp(.30f, .77f, mass), Mathf.Infinity, delta); + hullMotion.y = Mathf.SmoothDamp(hullMotion.y, target.y, ref hullMotionVelocity.y, + Mathf.Lerp(.32f, 1.03f, mass), Mathf.Infinity, delta); + hullMotion.z = Mathf.SmoothDamp(hullMotion.z, target.z, ref hullMotionVelocity.z, + Mathf.Lerp(.38f, 1.12f, mass), Mathf.Infinity, delta); } + passageHeading = heading; if (vessel != null) vessel.SetLocalPositionAndRotation(new Vector3(center.x, hullMotion.x, center.y), - Quaternion.Euler(hullMotion.y, heading, hullMotion.z)); + Quaternion.AngleAxis(heading, Vector3.up) * Quaternion.Euler(hullMotion.y, 0, hullMotion.z)); Vector4 hull = water.GetVector("_HullSpan"); hull.z = center.x; hull.w = center.y; water.SetVector("_HullSpan", hull); - water.SetVector("_HullCourse", new Vector4(cosine, sine, Mathf.Clamp01(speed / 19f), 0)); + water.SetVector("_HullCourse", new Vector4(cosine, sine, Mathf.Clamp01(speed / (river ? 12f : 19f)), 0)); water.SetFloat("_SeaTime", seaTime); water.SetFloat("_Underway", 1); waterSurface.localPosition = new Vector3(center.x, 0, center.y); Shader.SetGlobalFloat("_TycoonSeaTime", seaTime); - wake.Update(center, new Vector2(cosine, -sine), speed, vesselLength, vesselBeam, seaTime, seaSeverity); + wake.Update(center, new Vector2(cosine, -sine), speed, vesselLength, vesselBeam, seaTime, seaSeverity, river); + PresentRiverBanks(center); } - private float WaveHeight(Vector2 point) + internal static Vector3 SampleSeaResponse(Vector2 center, float time, float heading, float length, float halfBeam, + float severity, bool river) { - float amplitude = Mathf.Lerp(.35f, 1.46f, seaSeverity * seaSeverity); - return amplitude * (.65f * Mathf.Sin(.052f * point.x + .115f * point.y - .93f * seaTime) - + .25f * Mathf.Sin(-.073f * point.x + .17f * point.y - 1.22f * seaTime + 1.30f) - + .10f * Mathf.Sin(.217f * point.x - .136f * point.y - 1.64f * seaTime + 2.9f)); + // Measure the same travelling waves as the water material at five points on the waterline. + float radians = heading * Mathf.Deg2Rad; + float sine = Mathf.Sin(radians), cosine = Mathf.Cos(radians); + float bowSpan = length * .32f, beamSpan = halfBeam * .78f; + var bow = new Vector2(cosine, -sine) * bowSpan; + var beam = new Vector2(sine, cosine) * beamSpan; + float fore = WaveHeight(center + bow, time, severity, river), aft = WaveHeight(center - bow, time, severity, river); + float port = WaveHeight(center + beam, time, severity, river), starboard = WaveHeight(center - beam, time, severity, river); + float amidships = WaveHeight(center, time, severity, river); + float mass = Mathf.InverseLerp(28f, 300f, length); + float heave = (amidships * .24f + (fore + aft + port + starboard) * .19f) * Mathf.Lerp(1f, .64f, mass); + float roll = Mathf.Atan2(starboard - port, 2f * beamSpan) * Mathf.Rad2Deg * Mathf.Lerp(1.12f, .78f, mass); + float pitch = Mathf.Atan2(fore - aft, 2f * bowSpan) * Mathf.Rad2Deg * Mathf.Lerp(1.19f, .78f, mass); + return new Vector3(heave, Mathf.Clamp(roll, river ? -3.2f : -9f, river ? 3.2f : 9f), + Mathf.Clamp(pitch, -4.3f, 4.3f)); + } + + private static float WaveHeight(Vector2 point, float time, float severity, bool river) + { + if (river) + return Mathf.Lerp(.22f, .44f, severity) * (.49f * Mathf.Sin(.197f * point.x + .235f * point.y - 1.55f * time) + + .39f * Mathf.Sin(-.088f * point.x + .13f * point.y - 1.02f * time + 1.3f) + + .12f * Mathf.Sin(.40f * point.x - .31f * point.y - 2.03f * time + 2.9f)); + return Mathf.Lerp(.61f, 1.95f, severity * severity) * (.49f * Mathf.Sin(.052f * point.x + .115f * point.y - .93f * time) + + .39f * Mathf.Sin(-.024f * point.x + .054f * point.y - .75f * time + 1.3f) + + .12f * Mathf.Sin(.217f * point.x - .136f * point.y - 1.64f * time + 2.9f)); } public void EndPassage() { sailing = false; + HideRiverBanks(); waterSurface.localPosition = Vector3.zero; wake.Reset(); Shader.SetGlobalFloat("_TycoonSeaSailing", 0); + Shader.SetGlobalFloat("_TycoonRiverWater", 0); if (vessel != null) vessel.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); Vector4 hull = water.GetVector("_HullSpan"); @@ -458,7 +491,14 @@ namespace BigShipTycoon private Vector3 OrbitFocus(Vector3 offset) { Vector3 local = OverviewFocus() + offset; - return vessel != null ? vessel.TransformPoint(local) : local; + if (vessel == null || !sailing) + return vessel != null ? vessel.TransformPoint(local) : local; + + // Follow the track with a level camera. Close inspections follow more of the point on the deck. + Vector3 level = vessel.localPosition - Vector3.up * hullMotion.x + + Quaternion.AngleAxis(passageHeading, Vector3.up) * local; + float tracking = Mathf.Lerp(.21f, .89f, 1f - Mathf.InverseLerp(.17f, .78f, zoom)); + return Vector3.Lerp(transform.TransformPoint(level), vessel.TransformPoint(local), tracking); } private Vector3 FilmToShip(Vector2 filmOffset, float aspect, float height) @@ -554,8 +594,11 @@ namespace BigShipTycoon viewCamera.orthographic = false; viewCamera.nearClipPlane = .095f; viewCamera.fieldOfView = freeFov; + float follow = cameraMode == CameraMode.Bridge ? .73f : cameraMode == CameraMode.OutdoorWalk ? .61f : .87f; + Quaternion comfort = transform.rotation * Quaternion.AngleAxis(passageHeading, Vector3.up) + * Quaternion.Euler(hullMotion.y * follow, 0, hullMotion.z * follow); viewCamera.transform.SetPositionAndRotation(vessel.TransformPoint(freePosition), - vessel.rotation * Quaternion.Euler(freePitch, freeYaw, 0)); + comfort * Quaternion.Euler(freePitch, freeYaw, 0)); } FitViewport(); } @@ -673,7 +716,10 @@ namespace BigShipTycoon vesselLength = ship.Hull.Length; float beam = vesselBeam = ship.Hull.Beam * .5f; - vesselTop = VesselExterior.DeckBase + deckCount * VesselExterior.DeckSpacing + (ship.HasAftTerrace ? 10.5f : 5.95f); + vesselTop = MegaDeckGeometry.RoofHeight(deckCount, SunDeckZone.Sky, ship) + (hullIndex switch + { + Market.River => 3.5f, Market.Ocean => 7.35f, Market.Mega => 10.5f, _ => 5.95f + }); water.SetVector("_HullSpan", new Vector4(vesselLength, beam, 0, 0)); hullBounds = new Bounds(new Vector3(0, (vesselTop - 2.65f) * .5f, 0), new Vector3(vesselLength * 1.05f, vesselTop + 2.65f, beam * 2.26f)); @@ -740,6 +786,11 @@ namespace BigShipTycoon VesselExterior.Paint.AtriumGlass => ("154450", .16f, .53f, 0f, .07f), VesselExterior.Paint.DeckTrack => ("A85E4E", .83f, .02f, 0f, .21f), VesselExterior.Paint.FritGlass => ("6F8794", .25f, .38f, 0f, .08f), + VesselExterior.Paint.CoastalHull => ("CEDAD8", .43f, .14f, 0f, .39f), + VesselExterior.Paint.CoastalBlue => ("29608C", .39f, .16f, 0f, .31f), + VesselExterior.Paint.RegionalHull => ("DCE3DB", .36f, .19f, 0f, .26f), + VesselExterior.Paint.RegionalTeal => ("076B70", .33f, .21f, 0f, .24f), + VesselExterior.Paint.OceanRed => ("8A3B34", .53f, .08f, 0f, .29f), _ => ("318994", .16f, .40f, .05f, .13f) }; ColorUtility.TryParseHtmlString("#" + hex, out Color color); @@ -749,7 +800,8 @@ namespace BigShipTycoon material.SetFloat("_Emissive", emissive); material.SetFloat("_Weather", weather); material.SetFloat("_Waterline", paint is VesselExterior.Paint.Navy or VesselExterior.Paint.Antifouling - or VesselExterior.Paint.Black or VesselExterior.Paint.MegaHull ? 1f : 0f); + or VesselExterior.Paint.Black or VesselExterior.Paint.MegaHull or VesselExterior.Paint.OceanRed + or VesselExterior.Paint.CoastalHull or VesselExterior.Paint.RegionalHull ? 1f : 0f); SurfaceFinish finish = paint switch { VesselExterior.Paint.Teak or VesselExterior.Paint.TeakSeam => SurfaceFinish.Timber, @@ -757,7 +809,8 @@ namespace BigShipTycoon or VesselExterior.Paint.Lounge or VesselExterior.Paint.AtriumGlass => SurfaceFinish.Glass, VesselExterior.Paint.DeckCanvas => SurfaceFinish.Fabric, VesselExterior.Paint.Steel or VesselExterior.Paint.Gold => SurfaceFinish.Alloy, - VesselExterior.Paint.Navy or VesselExterior.Paint.Antifouling or VesselExterior.Paint.MegaHull => SurfaceFinish.Hull, + VesselExterior.Paint.Navy or VesselExterior.Paint.Antifouling or VesselExterior.Paint.MegaHull + or VesselExterior.Paint.CoastalHull or VesselExterior.Paint.RegionalHull or VesselExterior.Paint.OceanRed => SurfaceFinish.Hull, VesselExterior.Paint.Ivory => SurfaceFinish.Panel, VesselExterior.Paint.Pool => SurfaceFinish.Pool, VesselExterior.Paint.Turf or VesselExterior.Paint.Fringe => SurfaceFinish.Turf, @@ -803,6 +856,7 @@ namespace BigShipTycoon ReleaseFrame(); ReleaseShip(); ReleasePortQuay(); + ReleaseRiverBanks(); wake?.Dispose(); foreach (Material material in materials.Values) Destroy(material); diff --git a/Assets/BigShipTycoon/Runtime/HarborCinematic.cs b/Assets/BigShipTycoon/Runtime/HarborCinematic.cs index 333f0d3..f78c132 100644 --- a/Assets/BigShipTycoon/Runtime/HarborCinematic.cs +++ b/Assets/BigShipTycoon/Runtime/HarborCinematic.cs @@ -34,6 +34,7 @@ namespace BigShipTycoon return false; ShowDeck(-1); + HideRiverBanks(); cinematicPort = port; portArrival = arriving; portFrame = 0; @@ -43,7 +44,7 @@ namespace BigShipTycoon resumeHull = water.GetVector("_HullSpan"); resumeCourse = water.GetVector("_HullCourse"); - float berthLength = MegaPortBerth ? vesselLength + 44f : RegionalQuayLength; + float berthLength = MegaPortBerth ? vesselLength + 44f : displayedShip?.HullIndex == Market.River ? 44f : RegionalQuayLength; if (portQuay == null || !Mathf.Approximately(quayLength, berthLength)) { ReleaseCinematicQuay(); @@ -79,8 +80,9 @@ namespace BigShipTycoon portFrame = Mathf.Clamp01(elapsed / PortCinematicDuration); var (center, heading, knots) = PortMotion(portFrame); float heave = Mathf.Sin(elapsed * 1.87f + .7f) * .052f; - float roll = Mathf.Sin(elapsed * 1.24f + 1.1f) * .29f; - vessel.SetLocalPositionAndRotation(new Vector3(center.x, heave, center.y), Quaternion.Euler(roll, heading, 0)); + float roll = Mathf.Sin(elapsed * 1.24f + 1.1f) * (displayedShip?.HullIndex == Market.River ? .65f : .29f); + vessel.SetLocalPositionAndRotation(new Vector3(center.x, heave, center.y), + Quaternion.AngleAxis(heading, Vector3.up) * Quaternion.AngleAxis(roll, Vector3.right)); water.SetVector("_HullSpan", new Vector4(vesselLength, vesselBeam, center.x, center.y)); Vector2 course = PortBow(heading); water.SetVector("_HullCourse", new Vector4(course.x, -course.y, Mathf.Clamp01(knots / 19f), 0)); diff --git a/Assets/BigShipTycoon/Runtime/HarborMesh.cs b/Assets/BigShipTycoon/Runtime/HarborMesh.cs index 9c7bce9..3213220 100644 --- a/Assets/BigShipTycoon/Runtime/HarborMesh.cs +++ b/Assets/BigShipTycoon/Runtime/HarborMesh.cs @@ -161,11 +161,11 @@ namespace BigShipTycoon } } - public void Radome(Vector3 center, float radius) + public void Radome(Vector3 center, float radius) => Ellipsoid(center, Vector3.one * radius); + + internal void Ellipsoid(Vector3 center, Vector3 radii, int bands = 8, int slices = 12) { int start = vertices.Count; - const int bands = 8; - const int slices = 12; for (int j = 0; j <= bands; j++) { float elevation = Mathf.Lerp(-Mathf.PI * .5f, Mathf.PI * .5f, j / (float)bands); @@ -174,7 +174,7 @@ namespace BigShipTycoon float rotation = i * Mathf.PI * 2 / slices; Vector3 normal = new Vector3(Mathf.Cos(rotation) * Mathf.Cos(elevation), Mathf.Sin(elevation), Mathf.Sin(rotation) * Mathf.Cos(elevation)); - vertices.Add(center + normal * radius); + vertices.Add(center + Vector3.Scale(normal, radii)); } } for (int j = 0; j < bands; j++) diff --git a/Assets/BigShipTycoon/Runtime/HarborPortLandmarks.cs b/Assets/BigShipTycoon/Runtime/HarborPortLandmarks.cs index e96e91f..9b9b86f 100644 --- a/Assets/BigShipTycoon/Runtime/HarborPortLandmarks.cs +++ b/Assets/BigShipTycoon/Runtime/HarborPortLandmarks.cs @@ -143,6 +143,19 @@ namespace BigShipTycoon Tower(town + new Vector3(36, 0, 35), 12, 13, 31, Coat.Trim); Tower(town + new Vector3(49, 0, 42), 9, 10, 21, Coat.WallCool); break; + case 22: + House(fore + new Vector3(11, 0, -1), 17, 9, 4.8f, Coat.WallWarm); + Gable(fore + new Vector3(11, 4.8f, -1), 17.5f, 9.8f, 2.3f, Coat.Trim); + FingerPier(fore + new Vector3(-5, 0, -7), 11); + Pavilions(fore + new Vector3(-21, 0, 2), 2, 9, 2.6f); + break; + case 23: + Pavilions(fore + new Vector3(-18, 0, 3), 3, 13, 2.9f); + Lighthouse(fore + new Vector3(19, 0, 1), 1.7f, 7f); + FingerPier(fore + new Vector3(6, 0, -7), 10); + for (int i = 0; i < 4; i++) + Palm(fore + new Vector3(-33 + i * 11, 0, 5), 4.4f + .3f * i, i * .8f); + break; } } diff --git a/Assets/BigShipTycoon/Runtime/HarborPortProfiles.cs b/Assets/BigShipTycoon/Runtime/HarborPortProfiles.cs index 7e1d2be..3e04616 100644 --- a/Assets/BigShipTycoon/Runtime/HarborPortProfiles.cs +++ b/Assets/BigShipTycoon/Runtime/HarborPortProfiles.cs @@ -32,7 +32,9 @@ namespace BigShipTycoon new(PortTerrain.Mountains, PortArchitecture.Colonial, height: 75, density: .56f, trees: .66f, ground: "6B8865", facade: "E2BC9A", roof: "A76751", sky: "EEC5A1"), // Balboa, Cartagena new(PortTerrain.Mountains, PortArchitecture.Industrial, height: 49, density: .43f, trees: .77f, ground: "668A69", facade: "C4BDA7", roof: "87918B", sky: "BEC2AC"), - new(PortTerrain.LowHills, PortArchitecture.Colonial, height: 24, density: .78f, trees: .43f, ground: "8D9369", facade: "EBC496", roof: "AB6A4F", sky: "F6C49F") + new(PortTerrain.LowHills, PortArchitecture.Colonial, height: 24, density: .78f, trees: .43f, ground: "8D9369", facade: "EBC496", roof: "AB6A4F", sky: "F6C49F"), + new(PortTerrain.Flat, PortArchitecture.Maritime, height: 3.6f, density: .27f, trees: .79f, ground: "788D5B", facade: "D0BF9A", roof: "526A59", sky: "F0BC92"), + new(PortTerrain.Flat, PortArchitecture.Tropical, height: 3f, density: .18f, trees: .89f, ground: "657D54", facade: "C7D5B0", roof: "526B67", sky: "E9C6A7") }; } } diff --git a/Assets/BigShipTycoon/Runtime/HarborPortScenery.cs b/Assets/BigShipTycoon/Runtime/HarborPortScenery.cs index 9c6601b..4630e3d 100644 --- a/Assets/BigShipTycoon/Runtime/HarborPortScenery.cs +++ b/Assets/BigShipTycoon/Runtime/HarborPortScenery.cs @@ -112,6 +112,8 @@ namespace BigShipTycoon this.profile = profile; root = new GameObject(Market.Ports[port].Name + " waterfront"); root.transform.SetParent(parent, false); + if (port is 22 or 23) + root.transform.localPosition = Vector3.back * 19f; BuildCoast(); BuildDistrict(); BuildLandmarks(); diff --git a/Assets/BigShipTycoon/Runtime/HarborRiver.cs b/Assets/BigShipTycoon/Runtime/HarborRiver.cs new file mode 100644 index 0000000..c57fa45 --- /dev/null +++ b/Assets/BigShipTycoon/Runtime/HarborRiver.cs @@ -0,0 +1,203 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace BigShipTycoon +{ + public sealed partial class Harbor + { + private const float RiverReachLength = 240f; + private static readonly float[] RiverTerrainDistances = { 2.2f, 13f, 29f, 60f, 110f, 220f, 460f, 930f }; + private GameObject riverBanks; + private readonly Transform[] riverReaches = new Transform[5]; + private readonly List riverMeshes = new(); + private readonly List riverMaterials = new(); + private int riverReach = int.MinValue; + + internal bool RiverBanksVisible => riverBanks != null && riverBanks.activeSelf; + + private void PresentRiverBanks(Vector2 shipPosition) + { + if (!sailing || displayedShip?.HullIndex != Market.River || PortCinematicActive) + { + HideRiverBanks(); + return; + } + if (riverBanks == null) + BuildRiverBanks(); + + int reach = Mathf.FloorToInt(shipPosition.x / RiverReachLength); + if (reach != riverReach) + { + riverReach = reach; + for (int index = 0; index < riverReaches.Length; index++) + riverReaches[index].localPosition = Vector3.right * ((reach + index - 2) * RiverReachLength); + } + riverBanks.SetActive(true); + } + + private void HideRiverBanks() + { + if (riverBanks != null && riverBanks.activeSelf) + riverBanks.SetActive(false); + } + + private void ReleaseRiverBanks() + { + foreach (Mesh mesh in riverMeshes) + Destroy(mesh); + foreach (Material material in riverMaterials) + Destroy(material); + if (riverBanks != null) + Destroy(riverBanks); + } + + private void BuildRiverBanks() + { + riverBanks = new GameObject("River channel and banks"); + riverBanks.transform.SetParent(transform, false); + for (int i = 0; i < riverReaches.Length; i++) + { + riverReaches[i] = new GameObject("River reach").transform; + riverReaches[i].SetParent(riverBanks.transform, false); + } + + var grass = new HarborMesh(); + var bank = new HarborMesh(); + var foliage = new HarborMesh(); + var canopyTips = new HarborMesh(); + var undergrowth = new HarborMesh(); + var timber = new HarborMesh(); + var building = new HarborMesh(); + var green = new HarborMesh(); + var red = new HarborMesh(); + + for (int side = -1; side <= 1; side += 2) + { + const int divisions = 28; + for (int i = 0; i < divisions; i++) + { + float x = i * RiverReachLength / divisions, next = (i + 1) * RiverReachLength / divisions; + float edge = BankWidth(x, side), nextEdge = BankWidth(next, side); + Surface(bank, new(x, -.37f, edge * side), new(next, -.37f, nextEdge * side), + new(next, 1.18f, (nextEdge + 2.2f) * side), new(x, 1.18f, (edge + 2.2f) * side), side); + for (int strip = 1; strip < RiverTerrainDistances.Length; strip++) + { + float near = RiverTerrainDistances[strip - 1], far = RiverTerrainDistances[strip]; + Surface(grass, RiverGround(x, edge, near, side), RiverGround(next, nextEdge, near, side), + RiverGround(next, nextEdge, far, side), RiverGround(x, edge, far, side), side); + } + float shrub = .62f + .78f * Variation(i * 19 + side * 7); + float brushX = x + 1.2f + Variation(i * 7 - side) * 4.4f; + undergrowth.Ellipsoid(new Vector3(brushX, 1.46f, (edge + 2.9f) * side), new Vector3(1.9f, .52f, .82f) * shrub, 5, 9); + undergrowth.Ellipsoid(new Vector3(brushX + 1.16f, 1.56f, (edge + 3.4f) * side), new Vector3(1.23f, .83f, 1.03f) * shrub, 5, 8); + for (int reed = 0; reed < 4; reed++) + { + float jitter = Variation(i * 51 + reed * 11 + side * 6); + Vector3 root = new(brushX + reed * .44f, .45f, (edge + .98f + jitter * .34f) * side); + Vector3 leaf = new(.16f + jitter * .13f, .91f + jitter * .52f, side * -.32f); + canopyTips.Quad(root - Vector3.right * .08f, root + Vector3.right * .10f, + root + leaf + Vector3.right * .022f, root + leaf - Vector3.right * .036f); + } + } + + for (int i = 0; i < 25; i++) + { + float x = i * 9.3f + 2.1f * Variation(35 + i * 21 + side * 12); + float edge = BankWidth(x, side); + for (int line = 0; line < 2; line++) + { + float offset = 6.1f + 14.5f * line + 8.8f * Variation(i * 14 + line + side * 3); + Vector3 foot = RiverGround(x, edge, offset, side); + float height = 1.9f + 3.9f * Variation(i * 12 + line * 17 + side); + float canopy = 1.3f + 1.53f * Variation(i * 18 + line * 3); + Vector3 fork = foot + new Vector3(.32f * side, height * .77f, .27f); + Vector3 crown = foot + new Vector3(.45f * side, height + .24f, .07f); + timber.Rod(foot, fork, .122f + canopy * .022f, 6, true); + timber.Rod(fork, crown, .087f, 5); + timber.Rod(fork, crown + new Vector3(-.61f, -.38f, .29f) * canopy, .061f, 5); + foliage.Ellipsoid(crown, new Vector3(1.12f, .73f, .88f) * canopy, 6, 9); + foliage.Ellipsoid(crown + new Vector3(-.72f, -.12f, .37f) * canopy, new Vector3(.71f, .51f, .64f) * canopy, 5, 9); + canopyTips.Ellipsoid(crown + new Vector3(.48f, .27f, -.43f) * canopy, new Vector3(.77f, .52f, .65f) * canopy, 5, 9); + } + } + + for (int i = 0; i < 3; i++) + { + float x = 31f + i * 80f + side * 9f; + Vector3 pylon = new(x, -.08f, side * 24); + HarborMesh signal = side < 0 ? green : red; + timber.Rod(pylon, pylon + Vector3.up * 2.7f, .105f, 7, true); + signal.Box(pylon + Vector3.up * 2.19f, new Vector3(.54f, .68f, .38f)); + signal.Radome(pylon + Vector3.up * 2.65f, .15f); + } + + float dockX = side < 0 ? 69f : 154f; + float dockEdge = BankWidth(dockX, side); + var wharf = new Vector3(dockX, .67f, (dockEdge - 3f) * side); + timber.Box(wharf, new Vector3(17, .32f, 8.4f)); + for (int i = -2; i <= 2; i++) + { + Vector3 pile = wharf + new Vector3(i * 3.4f, -.8f, -side * 3.1f); + timber.Rod(pile, pile + Vector3.up * 1.5f, .15f, 7, true); + building.Box(pile + Vector3.up * 1.5f, new Vector3(.31f, .075f, .31f)); + } + var shed = new Vector3(dockX + 2.2f, 2.22f, (dockEdge + 8.1f) * side); + building.Box(shed, new Vector3(10.8f, 2.48f, 5.5f)); + timber.Box(shed + Vector3.up * 1.25f, new Vector3(11.25f, .19f, 6.0f)); + for (int i = -2; i <= 2; i++) + green.Box(shed + new Vector3(i * 1.8f, .35f, -side * 2.77f), new Vector3(.96f, .81f, .048f)); + } + + RiverBatch(grass, "Wetland grass", new Color(.30f, .39f, .22f), 8); + RiverBatch(bank, "Exposed banks", new Color(.33f, .29f, .22f), 1); + RiverBatch(foliage, "Canopy", new Color(.19f, .35f, .23f), 4); + RiverBatch(canopyTips, "Young leaves and reeds", new Color(.31f, .44f, .219f), 4); + RiverBatch(undergrowth, "Reeds and shrubs", new Color(.38f, .49f, .28f), 4); + RiverBatch(timber, "Timber docks and trees", new Color(.47f, .35f, .22f), 5); + RiverBatch(building, "River boathouses", new Color(.78f, .76f, .59f), 2); + RiverBatch(green, "Green marks and shutters", new Color(.20f, .57f, .37f), 0); + RiverBatch(red, "Red channel markers", new Color(.77f, .22f, .19f), 0); + } + + private void RiverBatch(HarborMesh batch, string name, Color tone, int detail) + { + var mesh = batch.Bake(); + var material = new Material(Resources.Load("PortScenerySurface")) { name = name, color = tone }; + material.SetFloat("_Detail", detail); + riverMeshes.Add(mesh); + riverMaterials.Add(material); + foreach (Transform reach in riverReaches) + { + var model = new GameObject(name, typeof(MeshFilter), typeof(MeshRenderer)) { layer = 8 }; + model.transform.SetParent(reach, false); + model.GetComponent().sharedMesh = mesh; + model.GetComponent().sharedMaterial = material; + } + } + + private static void Surface(HarborMesh mesh, Vector3 a, Vector3 b, Vector3 c, Vector3 d, int side) + { + if (side < 0) + mesh.Quad(a, b, c, d); + else + mesh.Quad(d, c, b, a); + } + + private static float BankWidth(float x, int side) + { + float cycle = x * (2 * Mathf.PI / RiverReachLength); + return 40f + 4.8f * Mathf.Sin(cycle + side * .52f) + 2.2f * Mathf.Cos(cycle * 2 + side * .91f); + } + + private static Vector3 RiverGround(float x, float width, float inland, int side) + { + float phase = x * (2 * Mathf.PI / RiverReachLength); + float inlandRise = Mathf.Clamp01((inland - 2.2f) / 23f); + float height = 1.18f + inlandRise * (1.25f + .70f * Mathf.Sin(phase * 2 + inland * .061f + side) + + .44f * Mathf.Cos(phase * 5 - inland * .11f)); + return new Vector3(x, height, (width + inland) * side); + } + + private static float Variation(int seed) => Mathf.Repeat(Mathf.Sin(seed * 37.17f) * 1627.31f, 1f); + } +} diff --git a/Assets/BigShipTycoon/Runtime/HarborRiver.cs.meta b/Assets/BigShipTycoon/Runtime/HarborRiver.cs.meta new file mode 100644 index 0000000..196b848 --- /dev/null +++ b/Assets/BigShipTycoon/Runtime/HarborRiver.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 0487f9eae7afed2018027e30892b172a \ No newline at end of file diff --git a/Assets/BigShipTycoon/Runtime/HelmControls.cs b/Assets/BigShipTycoon/Runtime/HelmControls.cs index 1d331a8..0c1db8b 100644 --- a/Assets/BigShipTycoon/Runtime/HelmControls.cs +++ b/Assets/BigShipTycoon/Runtime/HelmControls.cs @@ -8,6 +8,7 @@ namespace BigShipTycoon private static readonly string[] HelmOrders = { "Stop", "Economy", "Cruise", "Power" }; private readonly Button[] helmOrderButtons = new Button[HelmOrders.Length]; private Label helmReadout; + private Label helmPracticeReadout; private float courseBearing; private int HelmOrder => passageHelm.PropulsionStopped ? -1 : livePassage.EngineMode; @@ -15,6 +16,7 @@ namespace BigShipTycoon private void DrawHelmControls(VisualElement overlay) { helmReadout = null; + helmPracticeReadout = null; if (!passageBridge && !passageHelm.Manual) return; @@ -33,6 +35,8 @@ namespace BigShipTycoon } AddText(station, "A / D rudder · W / S throttle", "helm-help"); } + if (company.IsCaptainCareer) + helmPracticeReadout = AddText(station, "", "helm-practice-readout"); station.Add(Action(passageHelm.Manual ? "Return to autopilot H" : "Take the helm H", ToggleHelm, "helm-toggle", "helm-toggle")); UpdateHelmControls(); @@ -43,7 +47,14 @@ namespace BigShipTycoon if (passageHelm.Manual) ReleaseHelm(); else if (passageBridge) + { passageHelm.Manual = true; + if (company.IsCaptainCareer && passageSpeed != 1) + { + SetPassageSpeed(1); + return; + } + } Render(); } @@ -60,6 +71,8 @@ namespace BigShipTycoon passageHelm.PropulsionStopped = order == -1; if (order >= 0) livePassage.SetEngineMode(order); + if (order == 0 && company.IsCaptainCareer) + passageHelm.Practice.OrderEconomy(passageHelm); UpdateHelmControls(); } @@ -70,7 +83,11 @@ namespace BigShipTycoon int heading = Mathf.RoundToInt(Mathf.Repeat(courseBearing + passageHelm.Heading, 360)) % 360; int rudder = Mathf.RoundToInt(passageHelm.Rudder); string rudderText = rudder == 0 ? "Centered" : $"{Mathf.Abs(rudder)}° {(rudder < 0 ? "Port" : "Stbd")}"; - SetPassageText(helmReadout, $"{heading:000}° true · {passageHelm.Speed:0.0} kn\nRudder {rudderText}"); + string channel = passageHelm.AtChannelEdge ? "\nShallow water · steer back toward the channel" : ""; + SetPassageText(helmReadout, $"{heading:000}° true · {passageHelm.Speed:0.0} kn\nRudder {rudderText}{channel}"); + if (helmPracticeReadout != null) + SetPassageText(helmPracticeReadout, passageHelm.Manual || passageHelm.Practice.Qualified + ? passageHelm.Practice.Instruction(passageHelm, courseBearing) : "Take the helm to work through the check for this class."); if (!passageHelm.Manual) return; for (int i = 0; i < helmOrderButtons.Length; i++) diff --git a/Assets/BigShipTycoon/Runtime/HelmNavigation.cs b/Assets/BigShipTycoon/Runtime/HelmNavigation.cs index a112cbc..594355e 100644 --- a/Assets/BigShipTycoon/Runtime/HelmNavigation.cs +++ b/Assets/BigShipTycoon/Runtime/HelmNavigation.cs @@ -9,14 +9,17 @@ namespace BigShipTycoon public Vector2 Position, ApproachWaypoint; public float RouteDuration, Heading, Rudder, Speed, Progress, TurnRate; public bool Manual, PropulsionStopped, Arrived, ExtendingApproach; + public HelmPracticeSnapshot Practice; } internal sealed class HelmNavigation { + private const float MetresPerKnot = .514444f; private const float RudderLimit = 35f; private const float RudderSlew = 15f; private const float IntegrationStep = .1f; private readonly float duration, cruiseKnots, turnRateLimit, inertia, arrivalRadius; + private readonly HullSpec riverHull; private float turnRate; private Vector2 approachWaypoint; private bool extendingApproach; @@ -24,9 +27,12 @@ namespace BigShipTycoon public HelmNavigation(float duration, int hullIndex) { this.duration = Mathf.Max(1, duration); - cruiseKnots = 17f + 2f * hullIndex; - turnRateLimit = 4.2f - .5f * hullIndex; - inertia = 1f + .16f * hullIndex; + bool river = hullIndex == Market.River; + riverHull = river ? Market.Hulls[hullIndex] : null; + cruiseKnots = river ? 10f : 17f + 2f * hullIndex; + turnRateLimit = river ? 8.5f : 4.2f - .5f * hullIndex; + inertia = river ? .62f : 1f + .16f * hullIndex; + Practice = new HelmPractice(hullIndex); arrivalRadius = Mathf.Min(this.duration * .15f, Mathf.Clamp(this.duration * .006f, .6f, 1.8f)); } @@ -38,7 +44,10 @@ namespace BigShipTycoon public float Progress { get; private set; } public Vector2 Position { get; private set; } public bool Arrived { get; private set; } + public bool AtChannelEdge { get; private set; } public float RemainingSeconds => Arrived ? 0 : (new Vector2(duration, 0) - Position).magnitude; + internal float CourseToDestination => Mathf.Atan2(-Position.y, duration - Position.x) * Mathf.Rad2Deg; + internal HelmPractice Practice { get; } public void Advance(float seconds, float rudderInput, float engineSpeedFactor, WeatherCondition weather) { @@ -74,7 +83,17 @@ namespace BigShipTycoon Heading = Mathf.Repeat(Heading + yawStep + 180f, 360f) - 180f; float distance = (previousSpeed + Speed) * .5f / cruising * delta; - Position += new Vector2(Mathf.Cos(course), Mathf.Sin(course)) * distance; + Vector2 position = Position + new Vector2(Mathf.Cos(course), Mathf.Sin(course)) * distance; + AtChannelEdge = false; + if (riverHull != null) + { + float hullReach = Mathf.Abs(Mathf.Sin(course)) * riverHull.Length * .45f + + Mathf.Abs(Mathf.Cos(course)) * riverHull.Beam * .5f; + float sideLimit = (33f - hullReach) / (cruising * MetresPerKnot); + AtChannelEdge = Mathf.Abs(position.y) > sideLimit; + position.y = Mathf.Clamp(position.y, -sideLimit, sideLimit); + } + Position = position; Arrived = RemainingSeconds <= arrivalRadius; Progress = Arrived ? 1 : Mathf.Max(Progress, Mathf.Clamp01(1 - RemainingSeconds / duration)); } @@ -116,7 +135,8 @@ namespace BigShipTycoon { Position = Position, ApproachWaypoint = approachWaypoint, RouteDuration = duration, Heading = Heading, Rudder = Rudder, Speed = Speed, Progress = Progress, TurnRate = turnRate, Manual = Manual, - PropulsionStopped = PropulsionStopped, Arrived = Arrived, ExtendingApproach = extendingApproach + PropulsionStopped = PropulsionStopped, Arrived = Arrived, ExtendingApproach = extendingApproach, + Practice = Practice.Capture() }; internal bool RestoreState(HelmSnapshot state) @@ -128,7 +148,7 @@ namespace BigShipTycoon || !Finite(state.Rudder) || Mathf.Abs(state.Rudder) > RudderLimit || !Finite(state.Speed) || state.Speed < 0 || state.Speed > 120 || !Finite(state.Progress) || state.Progress < 0 || state.Progress > 1 || (state.Arrived && state.Progress != 1) - || !Finite(state.TurnRate) || Mathf.Abs(state.TurnRate) > 40) + || !Finite(state.TurnRate) || Mathf.Abs(state.TurnRate) > 40 || !Practice.Restore(state.Practice)) return false; float scale = duration / state.RouteDuration; diff --git a/Assets/BigShipTycoon/Runtime/HelmPractice.cs b/Assets/BigShipTycoon/Runtime/HelmPractice.cs new file mode 100644 index 0000000..eedb3f9 --- /dev/null +++ b/Assets/BigShipTycoon/Runtime/HelmPractice.cs @@ -0,0 +1,105 @@ +using System; +using UnityEngine; + +namespace BigShipTycoon +{ + internal enum HelmExercise { EconomyOrder, ChangeHeading, ReturnToCourse, HoldCourse, Qualified } + + [Serializable] + internal sealed class HelmPracticeSnapshot + { + public HelmExercise Exercise; + public float Target, SteadySeconds; + } + + internal sealed class HelmPractice + { + private readonly float turnDegrees, holdSeconds; + private float target, steadySeconds; + + internal HelmPractice(int hullIndex) + { + (turnDegrees, holdSeconds) = hullIndex switch + { + Market.River => (12f, 6f), Market.Coastal => (16f, 8f), Market.Regional => (19f, 9f), + Market.Ocean => (22f, 10f), _ => (24f, 12f) + }; + } + + internal HelmExercise Exercise { get; private set; } + internal bool Qualified => Exercise == HelmExercise.Qualified; + + internal void OrderEconomy(HelmNavigation helm) + { + if (!helm.Manual || Exercise != HelmExercise.EconomyOrder) + return; + target = Mathf.DeltaAngle(0, helm.Heading + turnDegrees); + Exercise = HelmExercise.ChangeHeading; + } + + internal void Advance(HelmNavigation helm, float delta, float rudderInput) + { + if (!helm.Manual || helm.PropulsionStopped || helm.Speed < 2 || delta <= 0 || Qualified) + return; + float courseError = Mathf.Abs(Mathf.DeltaAngle(helm.Heading, helm.CourseToDestination)); + switch (Exercise) + { + case HelmExercise.ChangeHeading when Mathf.Abs(Mathf.DeltaAngle(helm.Heading, target)) <= 3f: + Exercise = HelmExercise.ReturnToCourse; + break; + case HelmExercise.ReturnToCourse when courseError <= 4f: + Exercise = HelmExercise.HoldCourse; + break; + case HelmExercise.HoldCourse: + if (courseError > 8f) + { + steadySeconds = 0; + Exercise = HelmExercise.ReturnToCourse; + } + else if (courseError <= 6f && Mathf.Abs(helm.Rudder) <= 6f && Mathf.Abs(rudderInput) < .2f) + { + steadySeconds = Mathf.Min(holdSeconds, steadySeconds + Mathf.Min(.1f, delta)); + if (steadySeconds >= holdSeconds) + Exercise = HelmExercise.Qualified; + } + break; + } + } + + internal string Instruction(HelmNavigation helm, float trueBearing) + { + int TrueHeading(float relative) => Mathf.RoundToInt(Mathf.Repeat(trueBearing + relative, 360)) % 360; + string Turn(float desired) + { + float error = Mathf.DeltaAngle(helm.Heading, desired); + return Mathf.Abs(error) <= 3f ? "Center the rudder" : error > 0 ? "D to starboard" : "A to port"; + } + + return Exercise switch + { + HelmExercise.EconomyOrder => "1/3 · Select Economy on the throttle to start.", + HelmExercise.ChangeHeading => $"2/3 · Steer to {TrueHeading(target):000}° true\n{Turn(target)}", + HelmExercise.ReturnToCourse => $"3/3 · Return to {TrueHeading(helm.CourseToDestination):000}° true\n{Turn(helm.CourseToDestination)}", + HelmExercise.HoldCourse => $"3/3 · Center rudder and hold course\n{Mathf.FloorToInt(steadySeconds)} / {holdSeconds:0} s", + _ => "Helm check passed. Bring the voyage to port to log it." + }; + } + + internal HelmPracticeSnapshot Capture() => new() { Exercise = Exercise, Target = target, SteadySeconds = steadySeconds }; + + internal bool Restore(HelmPracticeSnapshot snapshot) + { + if (snapshot == null) + return true; + if ((uint)snapshot.Exercise > (uint)HelmExercise.Qualified || !(snapshot.Target >= -180 && snapshot.Target <= 180) + || !(snapshot.SteadySeconds >= 0 && snapshot.SteadySeconds <= holdSeconds) + || snapshot.Exercise == HelmExercise.Qualified && snapshot.SteadySeconds != holdSeconds + || (int)snapshot.Exercise < (int)HelmExercise.HoldCourse && snapshot.SteadySeconds != 0) + return false; + Exercise = snapshot.Exercise; + target = snapshot.Target; + steadySeconds = snapshot.SteadySeconds; + return true; + } + } +} diff --git a/Assets/BigShipTycoon/Runtime/HelmPractice.cs.meta b/Assets/BigShipTycoon/Runtime/HelmPractice.cs.meta new file mode 100644 index 0000000..9a5f26a --- /dev/null +++ b/Assets/BigShipTycoon/Runtime/HelmPractice.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ee38977f57a91820c8158583d61c2971 \ No newline at end of file diff --git a/Assets/BigShipTycoon/Runtime/Market.cs b/Assets/BigShipTycoon/Runtime/Market.cs index 552897f..9fb8b2b 100644 --- a/Assets/BigShipTycoon/Runtime/Market.cs +++ b/Assets/BigShipTycoon/Runtime/Market.cs @@ -132,14 +132,17 @@ namespace BigShipTycoon public static class Market { public const int StarterPortCount = 8; - public static int UsedPrice(int hull) => hull == 0 ? 105000 : 245000; + public static int UsedPrice(int hull) => hull switch { River => 54000, Coastal => 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 Mega = 3; + public const int River = 4; public const int Bermuda = 5; public const int Lisbon = 7; + public const int Brickell = 22; + public const int Mangrove = 23; public const int MinFare = 150; public const int MaxFare = 4000; @@ -214,7 +217,9 @@ namespace BigShipTycoon 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), new HullSpec("MEGA Ocean Liner", "A 300-meter flagship with split outdoor decks and space for full-scale venues and utilities.", - 16, 4, 12, 15, 2350000, 18, 65, 1160, .255, 42200, 12800, 300, 48) + 16, 4, 12, 15, 2350000, 18, 65, 1160, .255, 42200, 12800, 300, 48), + new HullSpec("Riverboat", "A shallow-draft passenger boat for local Miami River trips.", 4, 2, 1, 2, + 78000, 0, 0, 18, .041, 1650, 420, 32, 8) }; public static readonly IReadOnlyList Ports = new[] @@ -240,7 +245,9 @@ namespace BigShipTycoon 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) + new PortSpec("Cartagena", "Colombia", "South America", 599, 14600, 45000, 58, 2, 1.35, 1.12, 0, 0, -75.5f, 10.4f), + new PortSpec("Brickell Landing", "United States", "Miami River", 648, 240, 0, 0, River, .89, .72, 0, 0, -80.216f, 25.773f), + new PortSpec("Mangrove Landing", "United States", "Miami River", 619, 310, 0, 0, River, 1.04, .58, 0, 0, -80.302f, 25.754f) }; public static readonly IReadOnlyList Lanes = new[] @@ -251,9 +258,26 @@ namespace BigShipTycoon 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) + new Lane(18, 19, 1110), new Lane(19, 20, 1585), new Lane(20, 21, 265), new Lane(21, 0, 1080), + new Lane(0, Brickell, 4), new Lane(0, Mangrove, 11), new Lane(Brickell, Mangrove, 8) }; + public static int HullRank(int index) => index switch { River => 0, >= Coastal and <= Mega => index + 1, _ => -1 }; + + public static bool MeetsHullRequirement(int index, int minimum) => HullRank(index) >= 0 + && (minimum == Coastal || HullRank(index) >= HullRank(minimum)); + + public static bool IsRiverPort(int port) => port is Brickell or Mangrove; + + public static bool CanVisit(int hullIndex, int port) + { + if ((uint)port >= (uint)Ports.Count || HullRank(hullIndex) < 0) + return false; + if (hullIndex == River) + return port == 0 || IsRiverPort(port); + return !IsRiverPort(port) && MeetsHullRequirement(hullIndex, Ports[port].MinimumHull); + } + public static int FuelPrice(int port, int day) { int weeklyMove = ((day / 7 * 13 + port * 9) % 31) - 15; diff --git a/Assets/BigShipTycoon/Runtime/MegaDeckGeometry.cs b/Assets/BigShipTycoon/Runtime/MegaDeckGeometry.cs index b47da04..09b7645 100644 --- a/Assets/BigShipTycoon/Runtime/MegaDeckGeometry.cs +++ b/Assets/BigShipTycoon/Runtime/MegaDeckGeometry.cs @@ -37,7 +37,7 @@ namespace BigShipTycoon return offset + length * .285f; } - internal static float RoofHeight(int count, SunDeckZone zone) => VesselExterior.DeckBase + internal static float RoofHeight(int count, SunDeckZone zone, Ship ship = null) => VesselExterior.BaseDeck(ship) + (count - (zone == SunDeckZone.AftTerrace ? 1 : 0)) * VesselExterior.DeckSpacing; } } diff --git a/Assets/BigShipTycoon/Runtime/MegaVesselExterior.cs b/Assets/BigShipTycoon/Runtime/MegaVesselExterior.cs index 28c77d1..8d1cfe7 100644 --- a/Assets/BigShipTycoon/Runtime/MegaVesselExterior.cs +++ b/Assets/BigShipTycoon/Runtime/MegaVesselExterior.cs @@ -178,6 +178,7 @@ namespace BigShipTycoon Coat(side > 0 ? Paint.StarboardLight : Paint.PortLight).Box(wing + Vector3.forward * (side * 1.13f), new Vector3(.26f, .14f, .055f)); } + BuildObservationArches(bridge, halfWidth, y); Vector3 mast = new Vector3(bridge + 2.18f, y + 4.79f, 0); Coat(Paint.Pearl).Rod(mast, mast + new Vector3(-.21f, 1.03f, 0), .10f, 8); Coat(Paint.Steel).Rod(mast + new Vector3(-.13f, .65f, -1.24f), @@ -185,6 +186,32 @@ namespace BigShipTycoon Coat(Paint.LitGlass).Radome(mast + new Vector3(-.21f, 1.05f, 0), .115f); } + private void BuildObservationArches(float bridge, float halfWidth, float y) + { + const int segments = 18; + for (int step = 1; step <= segments; step++) + { + Vector3 left = Point(step, -1), right = Point(step, 1); + Vector3 oldLeft = Point(step - 1, -1), oldRight = Point(step - 1, 1); + Coat(Paint.Pearl).Rod(oldLeft, left, .28f, 8, true); + Coat(Paint.Pearl).Rod(oldRight, right, .28f, 8, true); + if (step is > 2 and < segments - 1) + { + Coat(Paint.FritGlass).Quad(oldRight, oldLeft, left, right); + Coat(Paint.FritGlass).Quad(oldLeft, oldRight, right, left); + Coat(Paint.Steel).Rod(left, right, .095f, 6); + } + } + + Vector3 Point(int step, int side) + { + float span = Mathf.Lerp(-1, 1, step / (float)segments); + float rise = Mathf.Cos(span * Mathf.PI * .5f); + return new Vector3(bridge + side * (4.65f - 1.45f * rise), + y + 2.78f + 6.58f * rise, span * halfWidth * .55f); + } + } + private void BuildMegaFunnelPavilion(float x, float halfWidth, float y) { Vector2 center = new Vector2(x, 0); diff --git a/Assets/BigShipTycoon/Runtime/OnboardEconomy.cs b/Assets/BigShipTycoon/Runtime/OnboardEconomy.cs index 3a999ea..b7c8254 100644 --- a/Assets/BigShipTycoon/Runtime/OnboardEconomy.cs +++ b/Assets/BigShipTycoon/Runtime/OnboardEconomy.cs @@ -109,6 +109,7 @@ namespace BigShipTycoon for (int i = 0; i < ServiceKinds; i++) prices[i] = Market.Clamp(prices[i], 0, Defaults[i] * 4); InitializeSystems(); + SetEngineMode(PortPlanning.EngineMode(quote.Plan?.Order ?? PassageOrder.Cruise)); Measure(false); } diff --git a/Assets/BigShipTycoon/Runtime/OnboardSessionSave.cs b/Assets/BigShipTycoon/Runtime/OnboardSessionSave.cs index 0687ea4..bcaaef6 100644 --- a/Assets/BigShipTycoon/Runtime/OnboardSessionSave.cs +++ b/Assets/BigShipTycoon/Runtime/OnboardSessionSave.cs @@ -123,7 +123,7 @@ namespace BigShipTycoon || state.FeaturedService < -1 || state.FeaturedService >= state.Prices.Length || state.AdditionalCapacity < 0 || state.EventBenefitUntil < 0 || state.Decisions < 0 || state.Decisions > offerCount || state.Revenue < 0 || state.Expenses < 0 || state.CasinoPayouts < 0 || state.CasinoPayouts > state.Expenses - || state.EngineMode < 0 || state.EngineMode >= FuelRates.Length + || state.EngineMode is < 0 or > 2 || state.RepairCredit < 0 || state.RepairCredit > 6 || state.GalleyUntil < 0 || state.PumpsUntil < 0 || state.LaundryUntil < 0 || state.LaundryUntil > ticks + 7 || state.TreatmentUntil < 0 || state.NextCrewCall < 0 || state.NextCrewCall > CrewCallSchedule.Length diff --git a/Assets/BigShipTycoon/Runtime/OnboardSystems.cs b/Assets/BigShipTycoon/Runtime/OnboardSystems.cs index 7257f74..4db2b05 100644 --- a/Assets/BigShipTycoon/Runtime/OnboardSystems.cs +++ b/Assets/BigShipTycoon/Runtime/OnboardSystems.cs @@ -6,8 +6,6 @@ namespace BigShipTycoon { private const double PortionPerMeal = .26; private const int WaterPerLaundryLoad = 10; - private static readonly double[] FuelRates = { .78, 1, 1.22 }; - private static readonly float[] ShipSpeeds = { .82f, 1, 1.22f }; private double provisions, water, waste, fuelIntegrated, health = 99, hydration = 1; private double laundryBacklog, laundryCleaned; private int galleyUntil, pumpsUntil, treatmentUntil, laundryUntil; @@ -15,7 +13,7 @@ namespace BigShipTycoon private readonly double[] crewCoverage = new double[CrewMarket.Roles.Count]; public bool Assisted { get; set; } = true; public int EngineMode { get; private set; } = 1; - public float SpeedFactor => ShipSpeeds[EngineMode] * (float)(.86 + .14 * Coverage(CrewRole.Bridge)); + public float SpeedFactor => PortPlanning.SpeedRate(EngineMode) * (float)(.86 + .14 * Coverage(CrewRole.Bridge)); public int Health => (int)Math.Round(health); public int WaterPercent => (int)Math.Round(100 * water / Ship.WaterCapacity); public int SewagePercent => (int)Math.Round(100 * waste / Ship.WasteCapacity); @@ -37,7 +35,7 @@ namespace BigShipTycoon public int StoreCost => 180 + Quote.Guests * 3; public int PumpCost => 410; public int TreatmentCost => 360; - public int RepairCost => 780 + Ship.HullIndex * 490; + public int RepairCost => Ship.HullIndex == Market.River ? 480 : 780 + Ship.HullIndex * 490; public bool CanOpenStores => !StoresOpened && provisions < Ship.FoodCapacity * .85 && CanSpend(StoreCost); public bool CanExtendLaundry => !LaundryBoost && AssignedCrew(CrewRole.Laundry) > 0 && CanSpend(LaundryShiftCost); @@ -46,8 +44,8 @@ namespace BigShipTycoon public bool CanSpend(int cost) => tick < ticks && Expenses + cost <= Quote.TicketSales / 4; public bool CanSetEngineMode(int mode) => - mode >= 0 && mode < FuelRates.Length - && (mode < 2 || (Coverage(CrewRole.Engineering) >= .85 && FuelForMode(mode) + Quote.Reserve <= Ship.Fuel)); + mode is >= 0 and <= 2 && (mode < 2 || Coverage(CrewRole.Engineering) >= .85) + && (mode <= EngineMode || FuelForMode(mode) + Quote.Reserve <= Ship.Fuel); public void SetEngineMode(int mode) { @@ -129,8 +127,8 @@ namespace BigShipTycoon private int FuelForMode(int mode) { - double expected = Quote.FuelBurn * (fuelIntegrated + (ticks - tick) * FuelRates[mode]) / ticks; - return Math.Max(1, (int)Math.Round(expected, MidpointRounding.AwayFromZero)); + double expected = Quote.FuelBurn * (fuelIntegrated + (ticks - tick) * PortPlanning.FuelRate(mode)) / ticks; + return PortPlanning.RoundFuel(expected); } private void AdvanceSystems() @@ -145,7 +143,7 @@ namespace BigShipTycoon BoostTreatment(); } - fuelIntegrated += FuelRates[EngineMode]; + fuelIntegrated += PortPlanning.FuelRate(EngineMode); double portionOfDay = (double)Quote.Days / ticks; double engineering = .35 + .65 * Coverage(CrewRole.Engineering); water = Math.Min(Ship.WaterCapacity, water + Ship.WaterProduction * engineering * (PumpsBoost ? 1.9 : 1) * portionOfDay); diff --git a/Assets/BigShipTycoon/Runtime/OperationsPage.cs b/Assets/BigShipTycoon/Runtime/OperationsPage.cs index 27e7b73..658dc76 100644 --- a/Assets/BigShipTycoon/Runtime/OperationsPage.cs +++ b/Assets/BigShipTycoon/Runtime/OperationsPage.cs @@ -28,13 +28,15 @@ namespace BigShipTycoon ChartLine(folio, $"{quote.SuiteGuests:N0} / {ship.SuiteBerths:N0} suite berths booked", $"+{Money(quote.SuitePremium)}"); DrawPortOrdersLink(folio, quote.Plan); + if (company.IsCaptainCareer) + AddText(folio, "Helm practice · Take command on the bridge, complete the check and let the boat reach port.", "chart-paper-note"); DrawChartBunkering(folio, ship, quote); string blocker = company.DepartureBlock(ship, quote); if (!string.IsNullOrEmpty(blocker)) AddText(folio, blocker, "chart-paper-note chart-departure-blocker"); else { - int seconds = Mathf.RoundToInt(PassageDuration(quote)); + int seconds = Mathf.RoundToInt(PassageDuration(quote) / PortPlanning.SpeedRate(PortPlanning.EngineMode(quote.Plan.Order))); AddText(folio, $"Cleared for departure · {seconds / 60}m {seconds % 60:00}s at 1×", "chart-cleared"); } Button launch = Action("Cast off →", () => BeginVoyage(quote), "chart-ink-button chart-wide-button chart-cast-off", "dispatch"); @@ -52,7 +54,7 @@ namespace BigShipTycoon var tank = Add(folio, "chart-tank"); Add(tank, "chart-tank-fill").style.width = Length.Percent(100f * ship.Fuel / ship.Tank); if (quote != null) - ChartLine(folio, "Burn + reserve", $"{quote.FuelBurn} + {quote.Reserve} t"); + ChartLine(folio, "Burn + reserve", $"{quote.DepartureFuelBurn} + {quote.Reserve} t"); else ChartLine(folio, "Indicative safe range", $"{ship.SafeRange:N0} nm"); ChartLine(folio, $"Price in {dock.Name}", $"{Money(Market.FuelPrice(ship.Port, company.Day))} / t"); diff --git a/Assets/BigShipTycoon/Runtime/PassageInterface.cs b/Assets/BigShipTycoon/Runtime/PassageInterface.cs index 42c55a0..af14386 100644 --- a/Assets/BigShipTycoon/Runtime/PassageInterface.cs +++ b/Assets/BigShipTycoon/Runtime/PassageInterface.cs @@ -86,7 +86,8 @@ namespace BigShipTycoon footer.pickingMode = PickingMode.Ignore; var controls = Add(footer, "voyage-deckbar"); controls.pickingMode = PickingMode.Ignore; - controls.Add(Action("Bridge", ViewPassageBridge, PassageViewClass(passageBridge), "passage-bridge")); + controls.Add(Action(company.IsCaptainCareer ? "Bridge & helm practice" : "Bridge", ViewPassageBridge, + PassageViewClass(passageBridge), "passage-bridge")); controls.Add(Action("Explore", ExplorePassageDeck, PassageViewClass(passageExploring && passageServiceArea < 0), "passage-explore")); controls.Add(Action("Service deck", () => ExploreServiceArea(0), PassageViewClass(passageServiceArea >= 0), "passage-service")); controls.Add(Action("Crew on duty", ToggleCrewManifest, PassageViewClass(crewManifestOpen), "passage-crew-manifest")); @@ -112,8 +113,9 @@ namespace BigShipTycoon string sea = underway.Weather switch { WeatherCondition.Storm => "Storm · Open decks closed", + WeatherCondition.Swell when Ship.HullIndex == Market.River => "Choppy river", WeatherCondition.Swell => "Swell · Limited outdoor service", - _ => "Calm seas" + _ => Ship.HullIndex == Market.River ? "Calm river" : "Calm seas" }; var routeContext = Add(route, "voyage-route-context"); string leg = Ship.Itinerary is { HasNext: true } itinerary ? $"LEG {itinerary.CompletedStops + 1} OF {itinerary.TotalStops}" : "UNDERWAY"; @@ -134,9 +136,11 @@ namespace BigShipTycoon foreach (int multiplier in new[] { 1, 2, 4 }) { int requested = multiplier; - speeds.Add(Action($"{requested}×", () => SetPassageSpeed(requested), + Button speedButton = Action($"{requested}×", () => SetPassageSpeed(requested), requested == passageSpeed ? "voyage-view-button voyage-control-active" : "voyage-view-button", - $"passage-speed-{requested}")); + $"passage-speed-{requested}"); + speedButton.SetEnabled(requested == 1 || !company.IsCaptainCareer || !passageHelm.Manual); + speeds.Add(speedButton); } var camera = Add(rail, "voyage-camera"); @@ -145,7 +149,10 @@ namespace BigShipTycoon : passageBridge || passageExploring ? "WASD to walk · Q / E to turn" : "Drag or Q / E to orbit · Wheel to zoom · Middle-drag to pan"; AddText(camera, cameraHelp, "voyage-camera-help"); - rail.Add(Action("Skip to arrival", FinishVoyage, "voyage-view-button voyage-skip", "dock-now")); + Button skip = Action("Skip to arrival", FinishVoyage, "voyage-view-button voyage-skip", "dock-now"); + if (company.IsCaptainCareer) + skip.tooltip = "Skipping finishes the trip without logging helm practice. Let the boat reach port to qualify."; + rail.Add(skip); DrawHelmControls(overlay); DrawStationInteractions(overlay); DrawVoyageMap(overlay); diff --git a/Assets/BigShipTycoon/Runtime/PassageWake.cs b/Assets/BigShipTycoon/Runtime/PassageWake.cs index ba837c1..3a2fed2 100644 --- a/Assets/BigShipTycoon/Runtime/PassageWake.cs +++ b/Assets/BigShipTycoon/Runtime/PassageWake.cs @@ -65,12 +65,14 @@ namespace BigShipTycoon root.SetActive(false); } - internal void Update(Vector2 center, Vector2 bow, float speed, float length, float beam, float time, float storm) + internal void Update(Vector2 center, Vector2 bow, float speed, float length, float beam, float time, float storm, + bool sheltered = false) { Vector2 propellers = center - bow * (length * .476f); - float thrust = Mathf.SmoothStep(0, 1, Mathf.InverseLerp(.9f, 14, speed)); + float thrust = Mathf.SmoothStep(0, 1, Mathf.InverseLerp(.9f, sheltered ? 9f : 14f, speed)); var newest = new Station(propellers, bow, time, thrust); - while (trail.Count > 0 && time - trail[0].Time > TrackAge) + float trackAge = sheltered ? 15f : TrackAge; + while (trail.Count > 0 && time - trail[0].Time > trackAge) trail.RemoveAt(0); if (trail.Count == 0) @@ -95,7 +97,8 @@ namespace BigShipTycoon int row = 0; float distance = 0; Vector2 prior = propellers; - WriteRow(row++, newest, time, 0, beam); + float spread = sheltered ? .14f : .34f; + WriteRow(row++, newest, time, 0, beam, spread); for (int i = trail.Count - 1; i >= 0; i--) { Station sample = trail[i]; @@ -103,7 +106,7 @@ namespace BigShipTycoon if (section < .19f) continue; distance += section; - WriteRow(row++, sample, time, distance, beam); + WriteRow(row++, sample, time, distance, beam, spread); prior = sample.Center; } if (distance < 1) @@ -136,10 +139,10 @@ namespace BigShipTycoon } } - private void WriteRow(int row, Station station, float time, float distance, float beam) + private void WriteRow(int row, Station station, float time, float distance, float beam, float spread) { float age = time - station.Time; - float width = beam * .62f + distance * .34f; + float width = beam * .62f + distance * spread; Vector2 right = new Vector2(-station.Forward.y, station.Forward.x); for (int col = 0; col < Columns; col++) { diff --git a/Assets/BigShipTycoon/Runtime/PortPlanning.cs b/Assets/BigShipTycoon/Runtime/PortPlanning.cs index 3502539..f9be7bb 100644 --- a/Assets/BigShipTycoon/Runtime/PortPlanning.cs +++ b/Assets/BigShipTycoon/Runtime/PortPlanning.cs @@ -3,19 +3,28 @@ using System; namespace BigShipTycoon { public enum EntertainmentProgram { Shipboard, LiveMusic, Headline } + public enum PassageOrder { Cruise, Economy, Express } [Serializable] public sealed class DeparturePlan { public int FoodUnits, FoodCost, ProgramCost; public EntertainmentProgram Program; + public PassageOrder Order; } public static class PortPlanning { + internal static int EngineMode(PassageOrder order) => order switch { PassageOrder.Economy => 0, PassageOrder.Express => 2, _ => 1 }; + internal static double FuelRate(int mode) => mode switch { 0 => .78, 2 => 1.22, _ => 1 }; + internal static float SpeedRate(int mode) => mode switch { 0 => .82f, 2 => 1.22f, _ => 1 }; + internal static int RoundFuel(double expected) => Math.Max(1, (int)Math.Round(expected, MidpointRounding.AwayFromZero)); + internal static int PlannedFuel(int cruiseBurn, PassageOrder order) => RoundFuel(cruiseBurn * FuelRate(EngineMode(order))); + private static readonly int[] FoodMarket = { - 462, 590, 477, 338, 423, 635, 514, 397, 452, 302, 350, 311, 475, 326, 539, 535, 658, 610, 496, 318, 372, 332 + 462, 590, 477, 338, 423, 635, 514, 397, 452, 302, 350, 311, 475, 326, 539, 535, 658, 610, 496, 318, 372, 332, + 438, 407 }; public static int FoodPriceCents(int port, int day) @@ -79,7 +88,8 @@ namespace BigShipTycoon internal static double ShowTime(EntertainmentProgram program) => program == EntertainmentProgram.LiveMusic ? .42 : .63; - public static void Apply(Ship ship, Voyage quote, int day, int? foodUnits, EntertainmentProgram program) + public static void Apply(Ship ship, Voyage quote, int day, int? foodUnits, EntertainmentProgram program, + PassageOrder order = PassageOrder.Cruise) { int ordered = Market.Clamp(foodUnits ?? RecommendedFood(ship, quote), 0, ship.FoodCapacity); if (!CanBook(ship, program)) @@ -90,9 +100,15 @@ namespace BigShipTycoon FoodUnits = ordered, FoodCost = (ordered * FoodPriceCents(quote.Origin, day) + 50) / 100, Program = program, - ProgramCost = ProgramPrice(program, quote, day) + ProgramCost = ProgramPrice(program, quote, day), + Order = order }; + int fuel = PlannedFuel(quote.FuelBurn, order); + double unitCost = ship.Fuel > 0 ? ship.FuelValue / ship.Fuel : Market.FuelPrice(quote.Origin, day); + quote.FuelExpense = (int)Math.Round(Math.Min(fuel, ship.Fuel) * unitCost + + Math.Max(0, fuel - ship.Fuel) * Market.FuelPrice(quote.Origin, day)); + // The port invoice replaces the food share of baseline catering. Labor and other supplies still matter. quote.Catering = quote.Guests * quote.Days * 15; double shows = Math.Min(1, (double)ship.Entertainment / Math.Max(1, ship.Capacity)); diff --git a/Assets/BigShipTycoon/Runtime/PortPlanningPage.cs b/Assets/BigShipTycoon/Runtime/PortPlanningPage.cs index 8394b7b..d671bcc 100644 --- a/Assets/BigShipTycoon/Runtime/PortPlanningPage.cs +++ b/Assets/BigShipTycoon/Runtime/PortPlanningPage.cs @@ -10,6 +10,7 @@ namespace BigShipTycoon private int portOrdersOrigin = -1, portOrdersDestination = -1, portOrdersDay = -1; private int? portFoodOrder; private EntertainmentProgram portProgram; + private PassageOrder portPassageOrder; private void PreparePortOrders(Ship ship, Voyage quote) { @@ -23,8 +24,9 @@ namespace BigShipTycoon portOrdersOpen = false; portFoodOrder = null; portProgram = EntertainmentProgram.Shipboard; + portPassageOrder = PassageOrder.Cruise; } - PortPlanning.Apply(ship, quote, company.Day, portFoodOrder, portProgram); + PortPlanning.Apply(ship, quote, company.Day, portFoodOrder, portProgram, portPassageOrder); } private string FoodUnitPrice(int port) => (PortPlanning.FoodPriceCents(port, company.Day) / 100m).ToString("C2"); @@ -34,7 +36,7 @@ namespace BigShipTycoon var row = Add(folio, "port-orders-link"); var copy = Add(row, "port-orders-link-copy"); AddText(copy, "PORT ORDERS", "chart-paper-kicker"); - AddText(copy, $"{plan.FoodUnits:N0} portions · {PortPlanning.ProgramLabel(plan.Program)}", "port-orders-summary"); + AddText(copy, $"{plan.FoodUnits:N0} portions · {PortPlanning.ProgramLabel(plan.Program)} · {plan.Order}", "port-orders-summary"); row.Add(Action(portOrdersOpen ? "Close" : "Edit", TogglePortOrders, "chart-ink-button port-orders-edit", "port-plan-open")); } @@ -58,6 +60,7 @@ namespace BigShipTycoon AddDisplay(headingCopy, "Dockside orders", "port-orders-title"); heading.Add(Action("Back to chart", TogglePortOrders, "chart-ink-button", "port-plan-close")); + DrawSailingOrder(paper, quote); DrawFoodOrder(paper, ship, quote); DrawEntertainmentOrder(paper, ship, quote); @@ -68,6 +71,27 @@ namespace BigShipTycoon AddDisplay(total, Money(quote.Plan.FoodCost + quote.Plan.ProgramCost), "port-orders-total-value"); } + private void DrawSailingOrder(VisualElement paper, Voyage quote) + { + AddDisplay(paper, "Sailing order", "port-orders-section"); + var options = Add(paper, "port-orders-food"); + foreach (PassageOrder option in Enum.GetValues(typeof(PassageOrder))) + { + int mode = PortPlanning.EngineMode(option); + int seconds = (int)Math.Round(PassageDuration(quote) / PortPlanning.SpeedRate(mode)); + int burn = PortPlanning.PlannedFuel(quote.FuelBurn, option); + Button button = Action($"{option} · {burn} t · {seconds / 60}:{seconds % 60:00}", () => + { + portPassageOrder = option; + bunkerTons = Market.Clamp(burn + quote.Reserve - Ship.Fuel, 0, Ship.Tank - Ship.Fuel); + Render(); + }, "chart-ink-button", $"port-order-{option.ToString().ToLowerInvariant()}"); + button.EnableInClassList("port-sailing-selected", option == portPassageOrder); + options.Add(button); + } + AddText(paper, "Estimated fuel burn and crossing time at 1×. Throttle changes underway update the plan.", "port-orders-note"); + } + private void DrawFoodOrder(VisualElement paper, Ship ship, Voyage quote) { int ordered = quote.Plan.FoodUnits; diff --git a/Assets/BigShipTycoon/Runtime/RiverVesselExterior.cs b/Assets/BigShipTycoon/Runtime/RiverVesselExterior.cs new file mode 100644 index 0000000..7530cf8 --- /dev/null +++ b/Assets/BigShipTycoon/Runtime/RiverVesselExterior.cs @@ -0,0 +1,78 @@ +using UnityEngine; + +namespace BigShipTycoon +{ + internal sealed partial class VesselExterior + { + private void BuildRiverVessel() + { + float baseY = BaseDeck(ship); + Vector2[] hull = Outline(length, beam, 0, 36); + Coat(Paint.Antifouling).Loft(hull, Vector2.zero, false, + new Vector3(.79f, -.82f, .69f), new Vector3(.93f, -.50f, .84f), new Vector3(1f, -.17f, .965f)); + Coat(Paint.Navy).Loft(hull, Vector2.zero, false, new Vector3(1f, -.18f, .97f), new Vector3(1.002f, .86f, 1.02f)); + Coat(Paint.Gold).Loft(hull, Vector2.zero, false, new Vector3(1.006f, .615f, 1.025f), new Vector3(1.006f, .70f, 1.026f)); + Coat(Paint.Ivory).Loft(hull, Vector2.zero, false, new Vector3(1.002f, .87f, 1.02f), new Vector3(.994f, baseY, .995f)); + Coat(Paint.Teak).Loft(hull, Vector2.zero, true, new Vector3(.994f, baseY, .995f)); + Rails(hull, baseY, baseY + .66f, 1.65f); + + for (int deck = 0; deck < ship.Decks.Count; deck++) + { + float deckY = baseY + DeckSpacing * deck; + bool top = deck == ship.Decks.Count - 1; + float cabinLength = length * (top ? .68f : .76f); + float cabinHalfWidth = beam * (top ? .73f : .78f); + var center = new Vector2(-length * .047f, 0); + Vector2[] cabin = RoundedRectangle(center, cabinLength * .5f, cabinHalfWidth, .75f); + Coat(Paint.Ivory).Loft(cabin, center, false, + new Vector3(1, deckY, .98f), new Vector3(1, deckY + .58f, 1)); + Coat(Paint.AtriumGlass).Loft(cabin, center, false, + new Vector3(1, deckY + .57f, 1), new Vector3(.998f, deckY + 2.13f, .992f)); + Coat(Paint.Ivory).Loft(cabin, center, false, + new Vector3(.998f, deckY + 2.13f, .992f), new Vector3(.999f, deckY + 2.42f, 1.01f)); + Coat(Paint.Pearl).Loft(cabin, center, false, + new Vector3(1.018f, deckY + 2.40f, 1.047f), new Vector3(1.022f, deckY + DeckSpacing, 1.061f)); + Coat(Paint.Teak).Loft(cabin, center, true, new Vector3(1.023f, deckY + DeckSpacing, 1.063f)); + Rails(cabin, deckY + DeckSpacing, deckY + DeckSpacing + .69f, 1.52f); + + for (int side = -1; side <= 1; side += 2) + { + float z = side * cabinHalfWidth; + for (int pane = 0; pane < 8; pane++) + { + float x = center.x + Mathf.Lerp(-cabinLength * .405f, cabinLength * .405f, pane / 7f); + Coat(Paint.Pearl).Box(new Vector3(x, deckY + 1.38f, z), new Vector3(.088f, 1.64f, .102f)); + Coat(Paint.Steel).Box(new Vector3(x, deckY + .68f, z + side * .045f), new Vector3(.24f, .031f, .099f)); + } + Coat(Paint.Steel).Box(new Vector3(center.x, deckY + .69f, z + side * .034f), new Vector3(cabinLength * .88f, .05f, .088f)); + Coat(Paint.Pearl).Box(new Vector3(center.x, deckY + 2.18f, z + side * .034f), new Vector3(cabinLength * .91f, .077f, .092f)); + Coat(Paint.Gold).Box(new Vector3(center.x, deckY + 2.28f, z - side * .025f), new Vector3(cabinLength * .92f, .046f, .052f)); + } + } + + float roof = MegaDeckGeometry.RoofHeight(ship.Decks.Count, SunDeckZone.Sky, ship); + float bridge = MegaDeckGeometry.BridgeCenter(ship, ship.Decks.Count); + var bridgeCenter = new Vector2(bridge, 0); + Vector2[] wheelhouse = RoundedRectangle(bridgeCenter, Mathf.Min(4.21f, length * .17f), beam * .63f, .59f); + Coat(Paint.Ivory).Loft(wheelhouse, bridgeCenter, false, new Vector3(1, roof, 1), new Vector3(1, roof + .83f, 1)); + Coat(Paint.Glass).Loft(wheelhouse, bridgeCenter, false, + new Vector3(1, roof + .83f, 1), new Vector3(.92f, roof + 2.39f, .96f)); + Coat(Paint.Pearl).Loft(wheelhouse, bridgeCenter, true, + new Vector3(.965f, roof + 2.39f, 1.025f), new Vector3(1.015f, roof + 2.57f, 1.06f)); + for (int side = -1; side <= 1; side += 2) + { + Coat(Paint.Pearl).Box(new Vector3(bridge, roof + 1.6f, side * beam * .62f), new Vector3(.092f, 1.6f, .10f)); + Coat(side < 0 ? Paint.PortLight : Paint.StarboardLight).Box(new Vector3(bridge + 2.93f, roof + 1.55f, side * beam * .61f), + new Vector3(.29f, .18f, .13f)); + float stern = -length * .245f; + Vector3 upright = new(stern, roof, side * beam * .51f); + Coat(Paint.Steel).Rod(upright, upright + Vector3.up * 1.64f, .055f, 7, true); + Coat(Paint.Steel).Rod(upright - Vector3.right * 1.68f, upright - Vector3.right * 1.68f + Vector3.up * 1.63f, .055f, 7, true); + Coat(Paint.Ivory).Box(new Vector3(stern - .75f, roof + .38f, side * beam * .47f), new Vector3(2.68f, .22f, .52f)); + } + Coat(Paint.DeckCanvas).Box(new Vector3(-length * .245f - .84f, roof + 1.65f, 0), new Vector3(2.07f, .15f, beam * 1.19f)); + Coat(Paint.Steel).Rod(new Vector3(bridge + .2f, roof + 2.51f, 0), new Vector3(bridge + .2f, roof + 3.42f, 0), .045f, 8); + Coat(Paint.Pearl).Box(new Vector3(bridge + .2f, roof + 3.3f, 0), new Vector3(.125f, .061f, 1.56f)); + } + } +} diff --git a/Assets/BigShipTycoon/Runtime/RiverVesselExterior.cs.meta b/Assets/BigShipTycoon/Runtime/RiverVesselExterior.cs.meta new file mode 100644 index 0000000..db615e8 --- /dev/null +++ b/Assets/BigShipTycoon/Runtime/RiverVesselExterior.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 2865fcc2c53339223b2ddb8d069f5a95 \ No newline at end of file diff --git a/Assets/BigShipTycoon/Runtime/ShoreExcursionInterface.cs b/Assets/BigShipTycoon/Runtime/ShoreExcursionInterface.cs index a3cb4da..84193b3 100644 --- a/Assets/BigShipTycoon/Runtime/ShoreExcursionInterface.cs +++ b/Assets/BigShipTycoon/Runtime/ShoreExcursionInterface.cs @@ -77,13 +77,18 @@ namespace BigShipTycoon AddText(place, Market.Ports[quote.Destination].Name.ToUpperInvariant(), "shore-kicker"); AddDisplay(place, "Shore excursions", "shore-planning-title"); heading.Add(Action("Close Esc", CloseShorePlanning, "shore-planning-close", "shore-planning-close")); + IReadOnlyList catalog = ShoreExcursions.Catalog(quote.Destination); string passengers = quote == underway ? $"{quote.Guests:N0} guests aboard" : $"{quote.Guests:N0} guests expected"; - AddText(sheet, $"Set prices and seats before docking. {passengers} · {quote.Weather} forecast.", "shore-planning-intro"); + AddText(sheet, $"{catalog.Count} local tours · {passengers} · {quote.Weather} forecast. Set prices and seats before docking.", + "shore-planning-intro"); - var tours = new ScrollView(ScrollViewMode.Vertical) { horizontalScrollerVisibility = ScrollerVisibility.Hidden }; + var tours = new ScrollView(ScrollViewMode.Vertical) + { + horizontalScrollerVisibility = ScrollerVisibility.Hidden, + verticalScrollerVisibility = ScrollerVisibility.Auto + }; tours.AddToClassList("shore-tour-list"); sheet.Add(tours); - IReadOnlyList catalog = ShoreExcursions.Catalog(quote.Destination); var forecasts = new Label[catalog.Count]; var offerButtons = new Button[catalog.Count]; var tourCards = new VisualElement[catalog.Count]; @@ -137,9 +142,12 @@ namespace BigShipTycoon int guests = 0, net = 0; for (int i = 0; i < forecasts.Length; i++) { - tourCards[i].EnableInClassList("shore-tour-offered", shoreDraft[i].Capacity > 0); - offerButtons[i].text = shoreDraft[i].Capacity > 0 ? "Remove offer" : "Offer tour"; - forecasts[i].text = shoreDraft[i].Capacity > 0 ? "No bookings expected." : $"Set seats to offer this tour · Up to {catalog[i].MaxCapacity:N0}"; + bool offered = shoreDraft[i].Capacity > 0; + tourCards[i].EnableInClassList("shore-tour-offered", offered); + offerButtons[i].text = offered ? "Remove offer" : "Offer tour"; + int margin = shoreDraft[i].Price - catalog[i].OperatorRate; + forecasts[i].text = offered ? "No bookings expected." + : $"{Money(margin)} margin per guest · Up to {catalog[i].MaxCapacity:N0} seats"; } foreach (ShoreBooking booking in bookings) { diff --git a/Assets/BigShipTycoon/Runtime/ShoreExcursions.cs b/Assets/BigShipTycoon/Runtime/ShoreExcursions.cs index 3b51dcc..6e83672 100644 --- a/Assets/BigShipTycoon/Runtime/ShoreExcursions.cs +++ b/Assets/BigShipTycoon/Runtime/ShoreExcursions.cs @@ -149,112 +149,146 @@ namespace BigShipTycoon new ShoreTour[] // Miami { new("Little Havana tasting walk", "Cafecito, bakeries and neighborhood music", 50, 24, 104, 2.5f, .33, 15), - new("Everglades boardwalk", "Wetland trail and wildlife lookout", 82, 39, 84, 4, .49, 30, true) + new("Everglades boardwalk", "Wetland trail and wildlife lookout", 82, 39, 84, 4, .49, 30, true), + new("Biscayne design and skyline ride", "A small-group drive through Art Deco streets and across the bay", 72, 33, 52, 2, .31, 17) }, new ShoreTour[] // Nassau { new("Old Nassau food walk", "Market stalls, local kitchens and Bahamian sweets", 54, 28, 114, 2, .39, 12), - new("Coral reef catamaran", "Sail out to the reef and snorkel with a local guide", 94, 47, 84, 4, .52, 34, true) + new("Coral reef catamaran", "Sail out to the reef and snorkel with a local guide", 94, 47, 84, 4, .52, 34, true), + new("Junkanoo mask workshop", "Make and decorate a festival mask in a studio with a local artist", 68, 34, 46, 2.5f, .34, 8) }, new ShoreTour[] // Key West { new("Old Town porches", "A guide through lanes and shaded historic homes", 44, 18, 92, 2, .37, 12), - new("Mangrove kayak circuit", "Paddle the mangrove channels with a guide", 78, 34, 68, 3.5f, .44, 29, true) + new("Mangrove kayak circuit", "Paddle the mangrove channels with a guide", 78, 34, 68, 3.5f, .44, 29, true), + new("Harbor schooner sail", "A light-afternoon sail past the island waterfront", 96, 48, 40, 2.5f, .41, 25, true) }, new ShoreTour[] // Cozumel { new("Island cacao workshop", "Stone-ground chocolate and a guided tasting", 58, 28, 88, 2.5f, .38, 13), - new("Reef and beach launch", "A small-boat reef trip and time on the beach", 98, 45, 118, 4.5f, .53, 39, true) + new("Reef and beach launch", "A small-boat reef trip and time on the beach", 98, 45, 118, 4.5f, .53, 39, true), + new("San Miguel bike and street art ride", "A guided cycle through painted lanes with a waterfront break", 64, 29, 34, 2, .30, 21, true) }, new ShoreTour[] // San Juan { new("Old San Juan courtyards", "Historic streets and a guided fort visit", 61, 26, 126, 3, .41, 15), - new("Rainforest trails", "A coach transfer to forest trails and waterfalls", 104, 51, 104, 5, .53, 39, true) + new("Rainforest trails", "A coach transfer to forest trails and waterfalls", 104, 51, 104, 5, .53, 39, true), + new("Salsa studio session", "Beginner dance lesson with a live percussion demonstration", 76, 37, 56, 2, .32, 8) }, new ShoreTour[] // Bermuda { new("Dockyard naval history", "Maritime collections and a dockyard guide", 59, 27, 136, 2.5f, .40, 12), - new("Pink-sand coast", "Beach time and a coastal lookout", 85, 42, 116, 4, .56, 30, true) + new("Pink-sand coast", "Beach time and a coastal lookout", 85, 42, 116, 4, .56, 30, true), + new("Limestone cavern visit", "A small-group walk below ground with a geology guide", 94, 43, 66, 3, .43, 16) }, new ShoreTour[] // Ponta Delgada { new("Azorean tea and pastries", "Tea tasting and a small bakery stop", 64, 28, 144, 3.5f, .41, 22), - new("Sete Cidades overlooks", "Volcanic lakes and high viewpoints", 96, 42, 144, 4.5f, .54, 33, true) + new("Sete Cidades overlooks", "Volcanic lakes and high viewpoints", 96, 42, 144, 4.5f, .54, 33, true), + new("Volcanic kitchen lunch", "A small-group meal and a stop at the steaming ground near Furnas", 116, 57, 78, 4, .46, 24, true) }, new ShoreTour[] // Lisbon { new("Belém tile and pastry walk", "A guide through tilework, monuments and pastry shops", 65, 24, 150, 3, .45, 20), - new("Tagus sail", "An open-air sailing circuit along the waterfront", 99, 47, 176, 4, .45, 35, true) + new("Tagus sail", "An open-air sailing circuit along the waterfront", 99, 47, 176, 4, .45, 35, true), + new("Fado rehearsal and supper", "Hear a small acoustic set and share a meal in a neighborhood venue", 110, 54, 60, 3.5f, .47, 12) }, new ShoreTour[] // Barcelona { new("Modernist architecture route", "Architectural interiors and a guide to the city", 88, 40, 176, 3.5f, .52, 20), - new("Montjuïc gardens", "Hilltop views, gardens and outdoor galleries", 73, 32, 148, 4, .37, 29, true) + new("Montjuïc gardens", "Hilltop views, gardens and outdoor galleries", 73, 32, 148, 4, .37, 29, true), + new("Market-to-table tapas class", "Choose ingredients with a cook and prepare a shared lunch in a studio", 105, 54, 72, 3, .44, 11) }, new ShoreTour[] // Port Said { new("Canal quarter and market", "A dockside guide and a covered market visit", 57, 24, 148, 2.5f, .39, 13), - new("Canal lookout circuit", "Coach transfer to waterfront and canal overlooks", 86, 41, 132, 4, .45, 30, true) + new("Canal lookout circuit", "Coach transfer to waterfront and canal overlooks", 86, 41, 132, 4, .45, 30, true), + new("Canal-era photo studio", "Work with a local photographer on prints of old waterfront scenes", 70, 32, 50, 2, .30, 8) }, new ShoreTour[] // Salalah { new("Frankincense souk", "Resins, spices and a guided look at local trade", 61, 26, 132, 3, .41, 19), - new("Wadi and coastal drive", "Mountain roads, a wadi stop and an ocean lookout", 101, 52, 115, 4.5f, .49, 37, true) + new("Wadi and coastal drive", "Mountain roads, a wadi stop and an ocean lookout", 101, 52, 115, 4.5f, .49, 37, true), + new("Incense blending studio", "Blend a small jar of scented resin and learn to identify its ingredients", 74, 37, 46, 2, .33, 8) }, new ShoreTour[] // Mumbai { new("Market kitchens", "Street snacks and a small-group cookery stop", 66, 30, 132, 3.5f, .47, 24), - new("Elephanta ferry visit", "An island ferry and a guided walk to cave temples", 106, 49, 170, 5, .59, 35, true) + new("Elephanta ferry visit", "An island ferry and a guided walk to cave temples", 106, 49, 170, 5, .59, 35, true), + new("Art Deco sketch walk", "Sketch seafront façades and finish with a drawing session under cover", 81, 38, 65, 3, .35, 19, true) }, new ShoreTour[] // Singapore { new("Hawker food circuit", "Covered food stalls and a tasting itinerary", 72, 32, 164, 3, .49, 15), - new("Harbor gardens at dusk", "Open garden paths and skyline overlooks", 104, 48, 200, 4.5f, .55, 26, true) + new("Harbor gardens at dusk", "Open garden paths and skyline overlooks", 104, 48, 200, 4.5f, .55, 26, true), + new("Peranakan beadwork studio", "An instructor-led beadwork lesson and a look at the studio's textile collection", 90, 46, 62, 2.5f, .38, 8) }, new ShoreTour[] // Benoa { new("Balinese craft workshop", "Woodcarving and textile demonstrations", 78, 36, 144, 3.5f, .43, 21), - new("Rice terrace footpaths", "A coach journey and guided terrace walk", 114, 55, 136, 5, .55, 42, true) + new("Rice terrace footpaths", "A coach journey and guided terrace walk", 114, 55, 136, 5, .55, 42, true), + new("Gamelan music session", "Try the instruments in a guided group rehearsal at a covered pavilion", 94, 45, 74, 3, .40, 14) }, new ShoreTour[] // Sydney { new("Opera House backstage", "A guided look into waterfront performance spaces", 94, 45, 160, 3, .49, 15), - new("Harbour headlands", "Outdoor footpaths and panoramic harbor views", 118, 50, 176, 4.5f, .51, 32, true) + new("Harbour headlands", "Outdoor footpaths and panoramic harbor views", 118, 50, 176, 4.5f, .51, 32, true), + new("Harbour ferry and fish market", "Cross the harbor by ferry and sample seafood with a market guide", 89, 40, 122, 3.5f, .48, 24, true) }, new ShoreTour[] // Auckland { new("Waterfront museum", "A guided maritime history and design visit", 71, 31, 142, 3, .44, 14), - new("Volcanic rim walk", "Hilltop tracks and views across the harbors", 105, 48, 136, 4.5f, .50, 32, true) + new("Volcanic rim walk", "Hilltop tracks and views across the harbors", 105, 48, 136, 4.5f, .50, 32, true), + new("Island vineyard and lunch", "A ferry transfer and a seated tasting with a vineyard lunch", 148, 76, 62, 5.5f, .50, 40, true) }, new ShoreTour[] // Papeete { new("Island market and pearl studio", "A covered market visit and a pearl workshop", 74, 34, 118, 2.5f, .44, 18), - new("Lagoon outrigger", "Outrigger trip with a reef-side swim stop", 126, 58, 120, 4.5f, .58, 41, true) + new("Lagoon outrigger", "Outrigger trip with a reef-side swim stop", 126, 58, 120, 4.5f, .58, 41, true), + new("Tahiti printmaking studio", "Cut and print a textile motif with a local instructor", 92, 44, 44, 2, .30, 9) }, new ShoreTour[] // Honolulu { new("Chinatown flavors", "Markets, neighborhood history and local food", 82, 35, 136, 3, .44, 18), - new("Diamond Head walk", "A crater trail and a high coastal lookout", 116, 51, 172, 4.5f, .56, 34, true) + new("Diamond Head walk", "A crater trail and a high coastal lookout", 116, 51, 172, 4.5f, .56, 34, true), + new("Hula and lei workshop", "A beginner lesson in a covered studio and a take-home lei", 96, 48, 76, 2.5f, .40, 9) }, new ShoreTour[] // San Diego { new("Balboa Park collections", "A guided selection of museums and architecture", 69, 29, 160, 3, .43, 17), - new("La Jolla coastal walk", "Clifftops, tidal pools and shoreline wildlife", 92, 41, 142, 4, .48, 34, true) + new("La Jolla coastal walk", "Clifftops, tidal pools and shoreline wildlife", 92, 41, 142, 4, .48, 34, true), + new("Carrier flight deck and hangar", "Explore aircraft displays and the ship's hangar with a guide", 83, 34, 112, 3.5f, .46, 15) }, new ShoreTour[] // Puerto Vallarta { new("Old Town cooking school", "A market ingredient stop and a kitchen lesson", 72, 36, 126, 3.5f, .48, 18), - new("Bay wildlife boat", "A guided boat trip along the bay and reefs", 110, 55, 156, 4.5f, .53, 39, true) + new("Bay wildlife boat", "A guided boat trip along the bay and reefs", 110, 55, 156, 4.5f, .53, 39, true), + new("Malecón sculpture and evening food", "Walk the waterfront sculptures and sample food around the old town", 81, 36, 70, 2.5f, .42, 18, true) }, new ShoreTour[] // Balboa { new("Canal locks and exhibits", "A guide to ship traffic and the lock exhibits", 81, 36, 184, 3.5f, .55, 20), - new("Rainforest canopy circuit", "Forest trails and a canopy viewing platform", 124, 54, 138, 5, .48, 40, true) + new("Rainforest canopy circuit", "Forest trails and a canopy viewing platform", 124, 54, 138, 5, .48, 40, true), + new("Panama City rooftop coffee", "Sample regional coffees after a coach ride to a neighborhood roastery", 86, 40, 88, 3, .41, 16) }, new ShoreTour[] // Cartagena { new("Walled city kitchens", "Market ingredients, courtyards and regional cooking", 63, 27, 144, 3, .48, 18), - new("Island beach launch", "A boat transfer to an offshore beach stop", 102, 51, 140, 4.5f, .54, 39, true) + new("Island beach launch", "A boat transfer to an offshore beach stop", 102, 51, 140, 4.5f, .54, 39, true), + new("Getsemaní mural studio", "See neighborhood murals with a guide and print a small souvenir", 79, 36, 66, 2.5f, .38, 14) + }, + new ShoreTour[] // Brickell Landing + { + new("Brickell riverwalk sketch tour", "Draw tugboats, bridges and the Brickell skyline with a local guide", 25, 10, 32, 1.5f, .43, 13, true), + new("Drawbridge heritage room", "Explore scale bridge models and a riverside photo archive", 20, 8, 26, 1.25f, .39, 6), + new("Riverside tasting counter", "A seated tasting of pastries and seasonal fruit in a riverside kitchen", 43, 22, 18, 2, .45, 10) + }, + new ShoreTour[] // Mangrove Landing + { + new("Tidal creek bird hide", "Follow a guide along the mangrove boardwalk to birdwatching blinds", 29, 12, 30, 1.5f, .43, 16, true), + new("Estuary field station", "Sort shells and examine the tidal life on display in the boathouse", 22, 10, 38, 1.25f, .37, 7), + new("Twilight skiff circuit", "A small boat follows the tidal creek to a sunset lookout", 52, 25, 16, 2.5f, .49, 30, true) } }; diff --git a/Assets/BigShipTycoon/Runtime/SunDeckEditor.cs b/Assets/BigShipTycoon/Runtime/SunDeckEditor.cs index 2bb42f8..547327d 100644 --- a/Assets/BigShipTycoon/Runtime/SunDeckEditor.cs +++ b/Assets/BigShipTycoon/Runtime/SunDeckEditor.cs @@ -27,6 +27,13 @@ namespace BigShipTycoon private void DrawSunDeckEditor(VisualElement work, Ship ship) { + if (ship.HullIndex == Market.River) + { + var fixedRoof = Add(work, "work-draft"); + AddDisplay(fixedRoof, "Fixed canopy", "work-section-title"); + AddText(fixedRoof, "Outdoor fittings begin with the Coastal command. The passenger deck is available to refit.", "work-caption"); + return; + } if (sunPlanningShip != ship) { sunPlanningShip = ship; diff --git a/Assets/BigShipTycoon/Runtime/SunDeckPlan.cs b/Assets/BigShipTycoon/Runtime/SunDeckPlan.cs index 09e97a3..8402e21 100644 --- a/Assets/BigShipTycoon/Runtime/SunDeckPlan.cs +++ b/Assets/BigShipTycoon/Runtime/SunDeckPlan.cs @@ -114,17 +114,21 @@ namespace BigShipTycoon internal int OutdoorAmenityCapacity => sunDeckPlan.AddedAmenities + (HasAftTerrace ? aftSunDeckPlan.AddedAmenities : 0); internal int OutdoorShowCapacity => sunDeckPlan.AddedShows + (HasAftTerrace ? aftSunDeckPlan.AddedShows : 0); internal int SunDeckPlanCode => HasAftTerrace ? unchecked(sunDeckPlan.Code * 109 + aftSunDeckPlan.Code) : sunDeckPlan.Code; - internal bool HasValidSunDeckPlan => sunDeckPlan.ValidOptions(HullIndex) - && (!HasAftTerrace || SunDeckFor(SunDeckZone.AftTerrace).ValidOptions(HullIndex)) && SunDecksFitAt(Decks.Count); + internal bool HasValidSunDeckPlan => HullIndex == Market.River ? sunDeckPlan.Code == 0 && aftSunDeckPlan.Code == 0 + : sunDeckPlan.ValidOptions(HullIndex) + && (!HasAftTerrace || SunDeckFor(SunDeckZone.AftTerrace).ValidOptions(HullIndex)) && SunDecksFitAt(Decks.Count); public SunDeckPlan SunDeckFor(SunDeckZone zone) { + if (HullIndex == Market.River) + return new SunDeckPlan { CustomLayout = true, Pool = SunPoolStyle.Compact, Attraction = SunAttraction.None, NoShade = true }; SunDeckPlan stored = zone == SunDeckZone.AftTerrace ? aftSunDeckPlan : sunDeckPlan; return stored.CustomLayout || !HasAftTerrace ? stored : new SunDeckPlan { CustomLayout = true, Pool = SunPoolStyle.Compact, Attraction = SunAttraction.None }; } - internal bool SupportsSunDeck(SunDeckZone zone) => zone == SunDeckZone.Sky || zone == SunDeckZone.AftTerrace && HasAftTerrace; + internal bool SupportsSunDeck(SunDeckZone zone) => HullIndex != Market.River + && (zone == SunDeckZone.Sky || zone == SunDeckZone.AftTerrace && HasAftTerrace); internal bool SunDecksFitAt(int count) => (!sunDeckPlan.CustomLayout || new SunDeckGrid(this, count).Valid(sunDeckPlan)) && (!HasAftTerrace || new SunDeckGrid(this, count, SunDeckZone.AftTerrace).Valid(SunDeckFor(SunDeckZone.AftTerrace))); @@ -161,6 +165,8 @@ namespace BigShipTycoon { if (ship == null || !Fleet.Contains(ship)) return "Choose a ship from your fleet."; + if (ship.HullIndex == Market.River) + return "Riverboats have fixed roofs. Build deck attractions on Coastal ships and larger."; if (!ship.SupportsSunDeck(zone)) return "The split aft terrace requires a MEGA Ocean Liner."; if (!next.ValidOptions(ship.HullIndex)) @@ -200,6 +206,8 @@ namespace BigShipTycoon { if (ship == null || !Fleet.Contains(ship)) return "Choose a ship from your fleet."; + if (ship.HullIndex == Market.River) + return "Riverboats have fixed roofs. Build deck attractions on Coastal ships and larger."; if (!ship.SupportsSunDeck(zone)) return "The split aft terrace requires a MEGA Ocean Liner."; var grid = new SunDeckGrid(ship, zone: zone); diff --git a/Assets/BigShipTycoon/Runtime/TycoonApp.cs b/Assets/BigShipTycoon/Runtime/TycoonApp.cs index 93d15a1..19bca20 100644 --- a/Assets/BigShipTycoon/Runtime/TycoonApp.cs +++ b/Assets/BigShipTycoon/Runtime/TycoonApp.cs @@ -20,7 +20,8 @@ namespace BigShipTycoon private Font displayFont; private Texture2D titleArt; private bool title = true, guidedCareer = true, paused, fleetOpen, shipActionsOpen; - private bool? pendingStart; + private enum CareerStart { Captain, Used, Financed } + private CareerStart? pendingStart; private int page, deckIndex, destination = -1, bunkerTons, yardSelection; private Facility tool = Facility.Cabin; private string shipName = "Peregrine"; @@ -79,20 +80,24 @@ namespace BigShipTycoon StartCoroutine(VisualSmoke()); } - private void StartCompany(bool financed, string name = null) + private void StartCompany(bool financed, string name = null) => + StartCompany(financed ? CareerStart.Financed : CareerStart.Used, name); + + private void StartCompany(CareerStart start, string name = null) { + bool financed = start == CareerStart.Financed; ResetShorePlanning(); ResetFleetPassages(); - company = Company.Start(financed); + company = start == CareerStart.Captain ? Company.StartCaptain() : Company.Start(financed); careerId = Guid.NewGuid().ToString("N"); - careerName = name ?? AvailableCareerName(financed ? "Shipyard career" : "Meridian Line"); + careerName = name ?? AvailableCareerName(DefaultCareerName(start)); careerMenu = CareerMenu.Closed; careerError = null; title = paused = fleetOpen = shipActionsOpen = false; page = financed ? 2 : 0; yardSelection = 1; deckIndex = 0; - inspectedPort = 1; + inspectedPort = company.IsCaptainCareer ? Market.Brickell : 1; selectedVoyage = 0; ledgerRecordOffset = 0; ledgerAccounts = false; @@ -104,7 +109,8 @@ namespace BigShipTycoon pendingStart = null; harbor.ResetView(true); ResetItinerary(); - Notify(financed && !guidedCareer ? "Choose your first hull." : null); + Notify(financed && !guidedCareer ? "Choose your first hull." : company.IsCaptainCareer + ? "Plan a river run to Brickell Landing and practice piloting from the bridge." : null); if (guidedCareer) StartGuide(financed); Save(); @@ -126,7 +132,7 @@ namespace BigShipTycoon foreach (Lane lane in Market.Lanes) { int other = lane.Other(Ship.Port); - if (other >= 0 && company.Permits[other] && Ship.HullIndex >= Market.Ports[other].MinimumHull) + if (other >= 0 && company.Permits[other] && Market.CanVisit(Ship.HullIndex, other)) { destination = other; break; @@ -251,8 +257,9 @@ namespace BigShipTycoon intro.Add(Action("Load game", () => OpenCareerMenu(CareerMenu.Load), "title-command", "career-load-open")); } - StartOption(intro, "Take the helm", "Used coastal ship / $135,000 cash / No debt", false); - StartOption(intro, "Start from the shipyard", "Empty fleet / $580,000 cash / $500,000 loan", true); + StartOption(intro, "Captain career", "Riverboat / Learn the helm and earn larger commands", CareerStart.Captain, "start-captain"); + StartOption(intro, "Take the helm", "Used coastal ship / $135,000 cash / No debt", CareerStart.Used, "start-used"); + StartOption(intro, "Start from the shipyard", "Empty fleet / $580,000 cash / $500,000 loan", CareerStart.Financed, "start-financed"); intro.Add(Action($"First voyage guide: {(guidedCareer ? "On" : "Off")}", () => { guidedCareer = !guidedCareer; @@ -265,16 +272,23 @@ namespace BigShipTycoon intro.Add(Action("Quit game", () => Application.Quit(), "title-quit", "title-quit")); } - private void StartOption(VisualElement parent, string titleText, string description, bool financed) + private static string DefaultCareerName(CareerStart start) => start switch + { + CareerStart.Captain => "River Captain", + CareerStart.Financed => "Shipyard career", + _ => "Meridian Line" + }; + + private void StartOption(VisualElement parent, string titleText, string description, CareerStart start, string id) { Button option = Action("", () => { - pendingStart = financed; - careerNameDraft = AvailableCareerName(financed ? "Shipyard career" : "Meridian Line"); + pendingStart = start; + careerNameDraft = AvailableCareerName(DefaultCareerName(start)); careerError = null; Notify(null); Render(); - }, "career-option", financed ? "start-financed" : "start-used"); + }, "career-option", id); AddText(option, titleText, "career-option-name"); AddText(option, description, "career-option-balance"); parent.Add(option); diff --git a/Assets/BigShipTycoon/Runtime/VesselClassHull.cs b/Assets/BigShipTycoon/Runtime/VesselClassHull.cs new file mode 100644 index 0000000..fe71c28 --- /dev/null +++ b/Assets/BigShipTycoon/Runtime/VesselClassHull.cs @@ -0,0 +1,195 @@ +using UnityEngine; + +namespace BigShipTycoon +{ + internal sealed partial class VesselExterior + { + private static float HullWidth(float station, int hull) + { + (float sternWidth, float sternEnd, float bowStart, float taper) = hull switch + { + Market.Coastal => (.78f, .115f, .74f, .71f), + Market.Regional => (.46f, .205f, .70f, 1.02f), + Market.Ocean => (.23f, .23f, .615f, 1.39f), + _ => (0, 0, 0, 0) + }; + if (sternEnd == 0) + return SideWidth(station); + if (station < sternEnd) + return Mathf.Lerp(sternWidth, 1, Mathf.Sin(station / sternEnd * Mathf.PI * .5f)); + if (station < bowStart) + return 1; + if (station >= 1) + return 0; + return Mathf.Pow(Mathf.Max(0, Mathf.Cos((station - bowStart) / (1 - bowStart) * Mathf.PI * .5f)), taper); + } + + private void BuildClassHullMarkings(int hull, int samples) + { + if (hull == Market.Ocean) + { + Vector2[] outline = Outline(length, beam, 0, samples, hullStyle: hull); + Coat(Paint.OceanRed).Loft(outline, Vector2.zero, false, new Vector3(.995f, .31f, .973f), new Vector3(.997f, .93f, .987f)); + Coat(Paint.Gold).Loft(outline, Vector2.zero, false, new Vector3(1.009f, 3.54f, 1.022f), new Vector3(1.01f, 3.61f, 1.023f)); + return; + } + + bool coastal = hull == Market.Coastal; + HarborMesh paint = Coat(coastal ? Paint.CoastalBlue : Paint.RegionalTeal); + for (int side = -1; side <= 1; side += 2) + { + for (int section = 1; section < samples - 1; section++) + { + float t0 = section / (float)samples, t1 = (section + 1f) / samples; + var (y0, width0) = Stripe(t0); + var (y1, width1) = Stripe(t1); + Vector3 a = HullMark(t0, y0, side, hull); + Vector3 b = HullMark(t1, y1, side, hull); + Vector3 c = HullMark(t1, y1 + width1, side, hull); + Vector3 d = HullMark(t0, y0 + width0, side, hull); + if (side > 0) + paint.Quad(a, b, c, d); + else + paint.Quad(b, a, d, c); + } + } + + (float Lower, float Width) Stripe(float station) + { + float sweep = Mathf.SmoothStep(0, 1, Mathf.InverseLerp(.51f, .96f, station)); + return coastal ? (1.28f + sweep * .27f, .64f) + : (.62f + 2.99f * sweep, Mathf.Lerp(.70f, .17f, sweep)); + } + } + + private Vector3 HullMark(float station, float height, int side, int hull) + { + (float x, float z) = height switch + { + < 1.22f => (Mathf.Lerp(.991f, .996f, Mathf.InverseLerp(.27f, 1.22f, height)), + Mathf.Lerp(.969f, .988f, Mathf.InverseLerp(.27f, 1.22f, height))), + < 2.39f => (Mathf.Lerp(.996f, 1, Mathf.InverseLerp(1.22f, 2.39f, height)), + Mathf.Lerp(.988f, 1, Mathf.InverseLerp(1.22f, 2.39f, height))), + _ => (Mathf.Lerp(1, 1.01f, Mathf.InverseLerp(2.39f, 4.65f, height)), + Mathf.Lerp(1, 1.03f, Mathf.InverseLerp(2.39f, 4.65f, height))) + }; + return new Vector3((station - .5f) * length * x, height, side * (beam * z * HullWidth(station, hull) + .045f)); + } + + private void BuildClassDeckGlazing(int deck, float floor, float deckLength, float halfBeam, float offset, int side) + { + bool liner = ship.HullIndex == Market.Ocean; + if (!liner && (ship.HullIndex != Market.Regional || deck < ship.Decks.Count - 3)) + return; + + float start = liner ? .716f + deck * .0045f : .105f + deck * .004f; + float end = liner ? .921f : .267f; + const int panes = 8; + for (int pane = 0; pane < panes; pane++) + { + float a = Mathf.Lerp(start, end, pane / (float)panes); + float b = Mathf.Lerp(start, end, (pane + 1f) / panes); + var (lowA, _, normalA) = SideFrame(a, floor + .48f, deckLength * .993f, halfBeam * .957f, offset, side, DeckStations); + var (lowB, _, normalB) = SideFrame(b, floor + .48f, deckLength * .993f, halfBeam * .957f, offset, side, DeckStations); + lowA += normalA * .045f; + lowB += normalB * .045f; + Vector3 highA = lowA + Vector3.up * 1.76f; + Vector3 highB = lowB + Vector3.up * 1.76f; + HarborMesh glass = Coat(liner ? Paint.AtriumGlass : Paint.BlueGlass); + if (side > 0) + glass.Quad(lowA, lowB, highB, highA); + else + glass.Quad(lowB, lowA, highA, highB); + Coat(liner ? Paint.Gold : Paint.RegionalTeal).Rod(lowA, lowB, .059f, 6); + Coat(Paint.Pearl).Rod(lowA, highA, .045f, 5); + } + } + + private void BuildClassFunnel(float top, float stack) + { + if (ship.HullIndex == Market.Coastal) + { + var foot = new Vector3(stack, top, 0); + Coat(Paint.Ivory).Box(foot + Vector3.up * .26f, new Vector3(3.70f, .52f, 2.54f)); + Vector3 collar = foot + Vector3.up * 2.06f; + Vector3 cap = collar + new Vector3(-.18f, .45f, 0); + FunnelCourse(foot + Vector3.up * .49f, collar, new Vector2(1.03f, .79f), new Vector2(.91f, .74f), Paint.Lifeboat); + FunnelCourse(collar, cap, new Vector2(1.01f, .82f), new Vector2(.85f, .72f), Paint.Black); + Coat(Paint.Black).Disc(cap, Vector3.right * .85f, Vector3.back * .72f, 24); + ExhaustOutlet(cap, .27f); + return; + } + + if (ship.HullIndex == Market.Regional) + { + float deckBeam = DeckFootprint(ship.Decks.Count - 1).Beam; + for (int side = -1; side <= 1; side += 2) + { + var foot = new Vector3(stack + side * .41f, top, side * deckBeam * .22f); + Vector3 collar = foot + new Vector3(-.57f, side < 0 ? 4.28f : 3.54f, side * .09f); + Vector3 cap = collar + new Vector3(-.22f, .61f, side * .05f); + FunnelCourse(foot, foot + Vector3.up * .56f, new Vector2(1.26f, .87f), new Vector2(1.13f, .76f), Paint.Ivory); + FunnelCourse(foot + Vector3.up * .56f, collar, new Vector2(1.13f, .76f), new Vector2(.96f, .65f), Paint.RegionalTeal); + FunnelCourse(collar, cap, new Vector2(.98f, .67f), new Vector2(.86f, .57f), Paint.Black); + Coat(Paint.Black).Disc(cap, Vector3.right * .86f, Vector3.back * .57f, 24); + ExhaustOutlet(cap, .21f); + } + return; + } + + var basePoint = new Vector3(stack + .11f, top, 0); + var waist = basePoint + new Vector3(-.33f, .93f, 0); + var shoulders = basePoint + new Vector3(-.59f, 5.76f, 0); + var crown = basePoint + new Vector3(-.95f, 6.86f, 0); + FunnelCourse(basePoint, waist, new Vector2(2.08f, 1.94f), new Vector2(1.90f, 1.84f), Paint.Ivory); + FunnelCourse(waist, shoulders, new Vector2(1.90f, 1.84f), new Vector2(1.57f, 1.47f), Paint.OceanRed); + FunnelCourse(shoulders, crown, new Vector2(1.61f, 1.51f), new Vector2(1.28f, 1.31f), Paint.Black); + Coat(Paint.Black).Disc(crown, Vector3.right * 1.28f, Vector3.back * 1.31f, 24); + ExhaustOutlet(crown + Vector3.forward * .36f, .27f); + ExhaustOutlet(crown - Vector3.forward * .36f, .27f); + } + + private void FunnelCourse(Vector3 low, Vector3 high, Vector2 bottomRadii, Vector2 topRadii, Paint paint) + { + const int segments = 24; + HarborMesh mesh = Coat(paint); + Vector3 Point(Vector3 center, Vector2 radii, int index) + { + float angle = index * Mathf.PI * 2 / segments; + return center + new Vector3(Mathf.Cos(angle) * radii.x, 0, Mathf.Sin(angle) * radii.y); + } + for (int side = 0; side < segments; side++) + mesh.Quad(Point(low, bottomRadii, side), Point(high, topRadii, side), + Point(high, topRadii, side + 1), Point(low, bottomRadii, side + 1)); + } + + private void ExhaustOutlet(Vector3 cap, float radius) + { + Coat(Paint.Steel).Rod(cap, cap + Vector3.up * .24f, radius, 14); + Coat(Paint.Black).Disc(cap + Vector3.up * .20f, Vector3.right * (radius - .022f), Vector3.back * (radius - .022f), 14); + } + + private void BuildLinerBreakwater() + { + if (ship.HullIndex != Market.Ocean) + return; + + var forward = new[] + { + new Vector2(.404f, -.17f), new Vector2(.447f, -.065f), new Vector2(.467f, 0), + new Vector2(.447f, .065f), new Vector2(.404f, .17f) + }; + for (int segment = 1; segment < forward.Length; segment++) + { + Vector2 a = forward[segment - 1], b = forward[segment]; + Vector3 lowA = new(a.x * length, DeckBase - .06f, a.y * beam); + Vector3 lowB = new(b.x * length, DeckBase - .06f, b.y * beam); + Vector3 highA = lowA + Vector3.up * Mathf.Lerp(.29f, 1.43f, Mathf.InverseLerp(.40f, .467f, a.x)); + Vector3 highB = lowB + Vector3.up * Mathf.Lerp(.29f, 1.43f, Mathf.InverseLerp(.40f, .467f, b.x)); + Coat(Paint.Navy).Quad(lowA, lowB, highB, highA); + Coat(Paint.Navy).Quad(lowB, lowA, highA, highB); + Coat(Paint.Pearl).Rod(highA, highB, .12f, 7); + } + } + } +} diff --git a/Assets/BigShipTycoon/Runtime/VesselClassHull.cs.meta b/Assets/BigShipTycoon/Runtime/VesselClassHull.cs.meta new file mode 100644 index 0000000..53e6d3b --- /dev/null +++ b/Assets/BigShipTycoon/Runtime/VesselClassHull.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: b6a316009c1e027e2947239c133f2044 \ No newline at end of file diff --git a/Assets/BigShipTycoon/Runtime/VesselExterior.cs b/Assets/BigShipTycoon/Runtime/VesselExterior.cs index 7548a88..1083063 100644 --- a/Assets/BigShipTycoon/Runtime/VesselExterior.cs +++ b/Assets/BigShipTycoon/Runtime/VesselExterior.cs @@ -6,6 +6,7 @@ namespace BigShipTycoon internal sealed partial class VesselExterior { internal const float DeckBase = 5.38f, DeckSpacing = 2.62f; + internal static float BaseDeck(Ship ship) => ship?.HullIndex == Market.River ? 1.82f : DeckBase; internal const float PoolHalfLength = 2.61f, PoolHalfWidth = 1.43f, PoolWaterHeight = .24f; internal const float LoungerSeatHeight = .32f, LoungerBeamFraction = .67f; private const int HullStations = 36, DeckStations = 28, BridgeStations = 20; @@ -13,7 +14,8 @@ namespace BigShipTycoon { Navy, Ivory, Pearl, Gold, Teak, TeakSeam, Steel, Black, Glass, BlueGlass, LitGlass, Lounge, Lifeboat, Pool, Antifouling, DeckCanvas, PortLight, StarboardLight, Turf, Fringe, - MegaHull, AtriumGlass, DeckTrack, FritGlass + MegaHull, AtriumGlass, DeckTrack, FritGlass, + CoastalHull, CoastalBlue, RegionalHull, RegionalTeal, OceanRed } private readonly Dictionary batches = new Dictionary(); @@ -31,6 +33,11 @@ namespace BigShipTycoon public IReadOnlyDictionary Meshes() { + if (ship.HullIndex == Market.River) + { + BuildRiverVessel(); + return batches; + } BuildHull(); for (int deck = 0; deck < ship.Decks.Count; deck++) BuildPassengerDeck(deck); @@ -58,10 +65,12 @@ namespace BigShipTycoon { bool mega = ship.HullIndex == Market.Mega; int samples = ExteriorHullStations; - Vector2[] outline = Outline(length, beam, 0, samples); + int hull = ship.HullIndex; + Vector2[] outline = Outline(length, beam, 0, samples, hullStyle: hull); Vector2 center = Vector2.zero; - Coat(Paint.Antifouling).Loft(outline, center, false, new Vector3(.875f, -2.65f, .53f), - new Vector3(.936f, -1.78f, .73f), new Vector3(.967f, -.83f, .87f), + Coat(hull == Market.Ocean ? Paint.OceanRed : Paint.Antifouling).Loft(outline, center, false, + new Vector3(hull == Market.Ocean ? .79f : .875f, -2.65f, .53f), + new Vector3(hull == Market.Ocean ? .89f : .936f, -1.78f, .73f), new Vector3(.967f, -.83f, .87f), new Vector3(.984f, -.13f, .933f)); Coat(Paint.Black).Loft(outline, center, false, new Vector3(.984f, -.13f, .933f), new Vector3(.991f, .27f, .969f)); @@ -75,14 +84,14 @@ namespace BigShipTycoon } else { - Coat(Paint.Navy).Loft(outline, center, false, new Vector3(.991f, .27f, .969f), + Paint plating = hull == Market.Coastal ? Paint.CoastalHull : hull == Market.Regional ? Paint.RegionalHull : Paint.Navy; + Coat(plating).Loft(outline, center, false, new Vector3(.991f, .27f, .969f), new Vector3(.996f, 1.22f, .988f), new Vector3(1, 2.39f, 1), new Vector3(1.01f, 4.65f, 1.03f)); - Coat(Paint.Gold).Loft(outline, center, false, new Vector3(1.013f, 3.54f, 1.025f), - new Vector3(1.013f, 3.61f, 1.026f)); + BuildClassHullMarkings(hull, samples); } Coat(Paint.Ivory).Loft(outline, center, true, new Vector3(.998f, 4.47f, 1.015f), new Vector3(1.013f, 5.14f, 1.027f), new Vector3(1.003f, 5.32f, 1.015f)); - Vector2[] promenade = Outline(length * .971f, beam * .979f, 0, samples); + Vector2[] promenade = Outline(length * .971f, beam * .979f, 0, samples, hullStyle: hull); Coat(Paint.Teak).Loft(promenade, center, true, new Vector3(.997f, 5.32f, 1), new Vector3(1, DeckBase, 1)); Rails(promenade, DeckBase, DeckBase + .77f, 2.1f); @@ -95,7 +104,7 @@ namespace BigShipTycoon { float station = Mathf.Lerp(.105f, .837f, i / (float)(portholes - 1)); var (at, along, outward) = SideFrame(station, 2.76f, length * 1.002f, - beam * 1.006f, 0, side, samples); + beam * 1.006f, 0, side, samples, hull); Coat(Paint.Steel).Disc(at + outward * .043f, along * (side * .22f), Vector3.up * .238f, 12); Coat(Paint.Black).Disc(at + outward * .048f, along * (side * .178f), Vector3.up * .194f, 12); Paint pane = (i + 5 * side) % 7 == 0 ? Paint.Lounge : Paint.Glass; @@ -103,13 +112,14 @@ namespace BigShipTycoon } var (door, hinge, face) = SideFrame(.56f, 3.22f, length * 1.004f, beam * 1.016f, 0, side, - samples); + samples, hull); SidePanel(Coat(Paint.Black), door + face * .027f, hinge, side, 2.22f, 1.66f); SidePanel(Coat(Paint.Navy), door + face * .032f, hinge, side, 2.10f, 1.53f); SidePanel(Coat(Paint.Steel), door + face * .04f + hinge * .82f, hinge, side, .21f, .08f); } BuildForecastle(); + BuildLinerBreakwater(); if (mega) BuildMegaHullDetail(); } @@ -162,7 +172,8 @@ namespace BigShipTycoon Vector2[] outline = Outline(deckLength, deckBeam, offset, DeckStations); Coat(Paint.Ivory).Loft(outline, center, false, new Vector3(.97f, y, .77f), new Vector3(.99f, y + .24f, .83f), new Vector3(.99f, roof - .37f, .83f)); - Coat(Paint.Black).Loft(outline, center, false, new Vector3(.992f, roof - .39f, .835f), + Paint fascia = ship.HullIndex == Market.Coastal ? Paint.CoastalBlue : ship.HullIndex == Market.Regional ? Paint.RegionalTeal : Paint.Black; + Coat(fascia).Loft(outline, center, false, new Vector3(.992f, roof - .39f, .835f), new Vector3(.995f, roof - .34f, .946f)); Coat(Paint.Pearl).Loft(outline, center, false, new Vector3(.995f, roof - .34f, .946f), new Vector3(1.008f, roof - .26f, 1.005f), new Vector3(1.008f, roof - .11f, 1.008f), @@ -190,7 +201,8 @@ namespace BigShipTycoon bool occupied = (i * 3 + deck * 5 + row * 7) % 11 < 3; BuildWindow(floor, along, outward, side, width * .76f, 1.03f, 1.73f, 2, occupied ? Paint.Lounge : Paint.Glass); - BuildBalcony(floor, along, outward, width, Mathf.Abs(floor.z) * .23f); + if (ship.HullIndex != Market.Coastal) + BuildBalcony(floor, along, outward, width, Mathf.Abs(floor.z) * .23f); break; case Facility.Dining: case Facility.Entertainment: @@ -224,6 +236,7 @@ namespace BigShipTycoon for (int side = -1; side <= 1; side += 2) { + BuildClassDeckGlazing(deck, y, deckLength, deckBeam, offset, side); for (int i = 0; i < 3; i++) { var (floor, along, outward) = SideFrame(.845f + i * .039f, y, deckLength * .99f, @@ -282,10 +295,17 @@ namespace BigShipTycoon float top = DeckBase + ship.Decks.Count * DeckSpacing; float bridge = BridgeCenter(length, ship.Decks.Count); Vector2 center = new Vector2(bridge, 0); - Vector2[] capsule = Outline(9.15f, beam * .67f, bridge, BridgeStations); + Vector2[] capsule = ship.HullIndex switch + { + Market.Coastal => RoundedRectangle(center, 4.21f, beam * .65f, .82f), + Market.Regional => RoundedRectangle(center, 4.51f, beam * .68f, 2.25f), + _ => Outline(9.15f, beam * .67f, bridge, BridgeStations, hullStyle: Market.Ocean) + }; Coat(Paint.Ivory).Loft(capsule, center, false, new Vector3(.91f, top, .91f), new Vector3(1, top + .88f, 1)); - Coat(Paint.Black).Loft(capsule, center, false, new Vector3(1.002f, top + .80f, 1.006f), + Paint bridgeTrim = ship.HullIndex == Market.Regional ? Paint.RegionalTeal + : ship.HullIndex == Market.Coastal ? Paint.CoastalBlue : Paint.Black; + Coat(bridgeTrim).Loft(capsule, center, false, new Vector3(1.002f, top + .80f, 1.006f), new Vector3(1.002f, top + .91f, 1.006f)); Coat(Paint.Glass).Loft(capsule, center, false, new Vector3(1, top + .88f, 1), new Vector3(.90f, top + 2.62f, .95f)); @@ -316,28 +336,10 @@ namespace BigShipTycoon Coat(Paint.Black).Box(new Vector3(mast - .16f, top + 4.03f, 0), new Vector3(.07f, .066f, 2.30f)); float stack = offset - deckLength * .24f; + BuildClassFunnel(top, stack); for (int side = -1; side <= 1; side += 2) { BuildBridgeWing(bridge, top, side); - float z = side * deckBeam * .23f; - Vector2 foot = new Vector2(stack, z); - Vector2[] funnel = Outline(3.85f, .94f, stack, 14, z); - Coat(Paint.Ivory).Loft(funnel, foot, false, new Vector3(1.13f, top, 1.12f), - new Vector3(.99f, top + .82f, .985f)); - Coat(Paint.Navy).Loft(funnel, foot, false, new Vector3(.99f, top + .82f, .985f), - new Vector3(.95f, top + 2.37f, .86f)); - Coat(Paint.Gold).Loft(funnel, foot, false, new Vector3(.95f, top + 2.37f, .86f), - new Vector3(.90f, top + 2.91f, .80f)); - Coat(Paint.Black).Loft(funnel, foot, true, new Vector3(.90f, top + 2.91f, .80f), - new Vector3(.87f, top + 3.23f, .77f)); - for (int exhaust = -1; exhaust <= 1; exhaust++) - { - Vector3 pipe = new Vector3(stack + exhaust * .65f, top + 3.22f, z); - Coat(Paint.Steel).Rod(pipe, pipe + Vector3.up * .21f, .185f, 10); - Coat(Paint.Black).Disc(pipe + Vector3.up * .142f, Vector3.right * .17f, Vector3.back * .17f, 10); - } - var (vent, along, outward) = SideFrame(.29f, top + 1.45f, 3.67f, .82f, stack, side, 14); - BuildVent(vent + Vector3.forward * z + outward * .027f, along, outward, side, .64f); Vector3 radome = new Vector3(stack + 6.10f, top, side * deckBeam * .50f); Coat(Paint.Steel).Rod(radome, radome + Vector3.up * .68f, .16f, 9, true); Coat(Paint.Pearl).Radome(radome + Vector3.up * .90f, .54f); @@ -366,7 +368,7 @@ namespace BigShipTycoon private void BuildSunDeck(SunDeckLayout plan, float top) { - var starts = new int[(int)Paint.FritGlass + 1]; + var starts = new int[(int)Paint.OceanRed + 1]; foreach (SunDeckVenue venue in plan.Venues) { System.Array.Clear(starts, 0, starts.Length); @@ -676,26 +678,32 @@ namespace BigShipTycoon private void BuildLifeboats() { - for (int i = 0; i < 5 + ship.HullIndex * 2; i++) + bool coastal = ship.HullIndex == Market.Coastal; + bool regional = ship.HullIndex == Market.Regional; + int count = coastal ? 3 : regional ? 7 : 9; + float boatLength = coastal ? 3.52f : regional ? 4.05f : 4.67f; + float rackSpacing = coastal ? 5.78f : regional ? 4.79f : 5.03f; + Paint rescuePaint = regional ? Paint.RegionalTeal : Paint.Lifeboat; + for (int i = 0; i < count; i++) for (int side = -1; side <= 1; side += 2) { - float x = -length * .31f + i * (ship.HullIndex == 0 ? 5.52f : 4.7f); + float x = -length * (coastal ? .285f : .31f) + i * rackSpacing; float z = side * beam * .974f; Vector2 center = new Vector2(x, z); - Vector2[] capsule = Outline(4.31f, .60f, x, 12, z); - Coat(Paint.Lifeboat).Loft(capsule, center, false, new Vector3(.86f, 6.27f, .59f), + Vector2[] capsule = Outline(boatLength, .60f, x, 12, z); + Coat(rescuePaint).Loft(capsule, center, false, new Vector3(.86f, 6.27f, .59f), new Vector3(1, 6.49f, .99f), new Vector3(1, 6.65f, 1)); Coat(Paint.Pearl).Loft(capsule, center, true, new Vector3(1, 6.65f, 1), new Vector3(.875f, 6.94f, .82f), new Vector3(.78f, 7.04f, .65f)); for (int window = 0; window < 3; window++) { - var (at, along, outward) = SideFrame(.42f + window * .115f, 6.91f, 3.63f, .50f, x, side, 12); + var (at, along, outward) = SideFrame(.42f + window * .115f, 6.91f, boatLength * .842f, .50f, x, side, 12); Vector3 pane = at + Vector3.forward * z + outward * .018f; SidePanel(Coat(Paint.Glass), pane, along, side, .32f, .14f); } for (int arm = -1; arm <= 1; arm += 2) { - float mount = x + arm * 1.73f; + float mount = x + arm * boatLength * .40f; Vector3 from = new Vector3(mount, 6.15f, z - side * .67f); Vector3 elbow = new Vector3(mount, 7.47f, z - side * .52f); Vector3 tip = new Vector3(mount, 7.53f, z + side * .20f); @@ -743,12 +751,12 @@ namespace BigShipTycoon (DeckLength(length, deck), DeckHalfBeam(beam, deck), DeckOffset(length, deck)); private static (Vector3 Position, Vector3 Along, Vector3 Outward) SideFrame(float station, float y, - float length, float halfBeam, float offset, int side, int samples) + float length, float halfBeam, float offset, int side, int samples, int hullStyle = -1) { float sample = station * samples; int first = Mathf.Min(samples - 1, Mathf.FloorToInt(sample)); - float startWidth = SideWidth(first / (float)samples); - float endWidth = SideWidth((first + 1f) / samples); + float startWidth = HullWidth(first / (float)samples, hullStyle); + float endWidth = HullWidth((first + 1f) / samples, hullStyle); float z = side * halfBeam * Mathf.Lerp(startWidth, endWidth, sample - first); Vector3 along = new Vector3(length / samples, 0, side * halfBeam * (endWidth - startWidth)).normalized; return (new Vector3(offset + (station - .5f) * length, y, z), along, @@ -771,13 +779,13 @@ namespace BigShipTycoon return Mathf.Cos(Mathf.Clamp01((t - .69f) / .31f) * Mathf.PI * .5f); } - private static Vector2[] Outline(float length, float beam, float x, int intervals, float z = 0) + private static Vector2[] Outline(float length, float beam, float x, int intervals, float z = 0, int hullStyle = -1) { var outline = new Vector2[intervals * 2 + 1]; for (int i = 0; i < intervals; i++) { float position = i / (float)intervals; - float width = beam * SideWidth(position); + float width = beam * HullWidth(position, hullStyle); float station = (position - .5f) * length + x; outline[i] = new Vector2(station, z - width); outline[outline.Length - 1 - i] = new Vector2(station, z + width); diff --git a/Assets/BigShipTycoon/Runtime/VesselFittings.cs b/Assets/BigShipTycoon/Runtime/VesselFittings.cs index 328b59c..39d63dd 100644 --- a/Assets/BigShipTycoon/Runtime/VesselFittings.cs +++ b/Assets/BigShipTycoon/Runtime/VesselFittings.cs @@ -6,23 +6,25 @@ namespace BigShipTycoon { private void BuildHullFittings(int side) { + int hull = ship.HullIndex; + Paint marking = hull is Market.Coastal or Market.Regional ? Paint.Navy : Paint.Pearl; // The bow marks are painted on the changing cross-section just above the waterline. for (int mark = 0; mark < 6; mark++) { float y = .51f + mark * .247f; var (at, along, outward) = SideFrame(.895f, y, length * 1.001f, - beam * Mathf.Lerp(.977f, 1f, mark / 5f), 0, side, ExteriorHullStations); + beam * Mathf.Lerp(.977f, 1f, mark / 5f), 0, side, ExteriorHullStations, hull); at += outward * .038f; - SidePanel(Coat(Paint.Pearl), at, along, side, mark % 3 == 0 ? .32f : .18f, .046f); + SidePanel(Coat(marking), at, along, side, mark % 3 == 0 ? .32f : .18f, .046f); if (mark % 3 == 0) - SidePanel(Coat(Paint.Pearl), at + Vector3.up * .047f - along * .136f, along, side, .047f, .116f); + SidePanel(Coat(marking), at + Vector3.up * .047f - along * .136f, along, side, .047f, .116f); } for (int position = 0; position < 2; position++) { float station = position == 0 ? .113f : .835f; var (at, along, outward) = SideFrame(station, 4.52f, length * 1.010f, beam * 1.029f, - 0, side, ExteriorHullStations); + 0, side, ExteriorHullStations, hull); Coat(Paint.Steel).Disc(at + outward * .046f, along * (side * .47f), Vector3.up * .21f, 12); Coat(Paint.Black).Disc(at + outward * .054f, along * (side * .367f), Vector3.up * .136f, 12); Coat(Paint.Steel).Rod(at + outward * .062f + along * .085f - Vector3.up * .121f, @@ -30,7 +32,7 @@ namespace BigShipTycoon } // Frames and a cabling run break up the flush embarkation hatch. - var (door, hinge, face) = SideFrame(.56f, 3.22f, length * 1.004f, beam * 1.016f, 0, side, ExteriorHullStations); + var (door, hinge, face) = SideFrame(.56f, 3.22f, length * 1.004f, beam * 1.016f, 0, side, ExteriorHullStations, hull); Vector3 center = door + face * .046f; SidePanel(Coat(Paint.Steel), center + Vector3.up * .718f, hinge, side, 2.08f, .034f); SidePanel(Coat(Paint.Steel), center - Vector3.up * .724f, hinge, side, 2.08f, .034f); diff --git a/Assets/BigShipTycoon/Runtime/VisualSmoke.cs b/Assets/BigShipTycoon/Runtime/VisualSmoke.cs index 397cd29..02bb54d 100644 --- a/Assets/BigShipTycoon/Runtime/VisualSmoke.cs +++ b/Assets/BigShipTycoon/Runtime/VisualSmoke.cs @@ -20,6 +20,16 @@ namespace BigShipTycoon string directory = args[index + 1]; Directory.CreateDirectory(directory); + if (Array.IndexOf(args, "-captain-only") >= 0) + { + yield return CaptainSmoke(directory); + yield break; + } + if (Array.IndexOf(args, "-class-lineup-only") >= 0) + { + yield return ClassLineupSmoke(directory); + yield break; + } if (!CheckSmoke(Harbor.AllPortsHaveScenery, "Every destination has a port scenery profile")) yield break; for (int port = 0; port < Market.Ports.Count; port++) @@ -890,6 +900,176 @@ namespace BigShipTycoon Application.Quit(0); } + private IEnumerator ClassLineupSmoke(string directory) + { + StartCompany(CareerStart.Captain); + int[] classes = { Market.River, Market.Coastal, Market.Regional, Market.Ocean, Market.Mega }; + for (int index = 0; index < classes.Length; index++) + { + int hull = classes[index]; + if (hull == Market.Coastal) + StartCompany(false); + else if (hull != Market.River) + { + company.Cash = 20_000_000; + company.Voyages = 30; + company.Reputation = 80; + company.Flagship = true; + if (!CheckSmoke(company.Acquire(hull, false, $"Class {index}") == null, "Prepare the class lineup")) + yield break; + for (int deck = 0; deck < Ship.Decks.Count - 1; deck++) + for (int column = 0; column < Ship.Hull.Columns; column += 2) + { + company.Build(Ship, deck, column, Facility.Cabin); + company.Build(Ship, deck, Ship.Hull.Columns * (Ship.Hull.Rows - 1) + column, Facility.Cabin); + } + ResetItinerary(); + Render(); + } + + harbor.BeginPassage(); + harbor.SetPassage(new Vector2(.12f, 0), 0, hull == Market.River ? 9 : 16, .12f); + harbor.Orbit(new Vector2(-12, 31)); + yield return new WaitForSecondsRealtime(.42f); + yield return new WaitForEndOfFrame(); + RenderTexture frame = harbor.Frame; + if (!CheckSmoke(Ship.HullIndex == hull && frame != null, "Render each distinct vessel class")) + yield break; + var previous = RenderTexture.active; + RenderTexture.active = frame; + var image = new Texture2D(frame.width, frame.height, TextureFormat.RGB24, false); + image.ReadPixels(new Rect(0, 0, frame.width, frame.height), 0, 0); + RenderTexture.active = previous; + File.WriteAllBytes(Path.Combine(directory, $"{index + 1:00}-{Ship.Hull.Name.Replace(' ', '-')}.png"), image.EncodeToPNG()); + Destroy(image); + harbor.EndPassage(); + } + Debug.Log("Big Ship Tycoon class lineup passed for all five hulls."); + Application.Quit(0); + } + + private IEnumerator CaptainSmoke(string directory) + { + Vector3 calm = PeakSeaResponseSmoke(Market.Coastal, 0); + Vector3 storm = PeakSeaResponseSmoke(Market.Coastal, 1); + Vector3 river = PeakSeaResponseSmoke(Market.River, 1); + Vector3 liner = PeakSeaResponseSmoke(Market.Mega, 1); + if (!CheckSmoke(storm.x > calm.x * 2 && storm.y > calm.y * 2 && liner.y < storm.y * .6f + && river.x < storm.x * .5f && river.y <= 3.2f, + "Travelling waves produce stronger storm motion with class-specific vessel response") + || !SubmitSmoke("start-captain") || !SubmitSmoke("replace") + || !CheckSmoke(company.IsCaptainCareer && Ship.HullIndex == Market.River && Ship.Hull.Length < 40 + && company.CommandVoyages(Market.River) == 0 && company.HelmQualifications(Market.River) == 0, + "Start a Captain Career aboard the riverboat")) + yield break; + yield return CaptureSmoke(directory, "01-captain-career"); + if (!SubmitSmoke("plan-voyage") || !CheckSmoke(destination >= 0 && destination != Ship.Port, "A local river departure is available") + || !SubmitSmoke("port-plan-open") || !SubmitSmoke("port-order-economy")) + yield break; + yield return CaptureSmoke(directory, "02-river-sailing-orders"); + if (!SubmitSmoke("port-plan-close") || !SubmitSmoke("dispatch") + || !CheckSmoke(underway != null && underway.Miles <= 30 && livePassage.EngineMode == 0 + && underway.Plan.Order == PassageOrder.Economy && underway.DepartureFuelBurn <= underway.FuelBurn, + "Cast off on a short river trip with the planned economy order")) + yield break; + holdCinematicClock = true; + yield return CapturePortAndSkipSmoke(directory, "03-river-departure", 1.3f); + if (!CheckSmoke(harbor.RiverBanksVisible, "The riverboat sails between visible banks")) + yield break; + yield return CaptureSmoke(directory, "03a-river-underway"); + if (!SubmitSmoke("voyage-map-toggle")) + yield break; + yield return CaptureSmoke(directory, "03b-river-voyage-map"); + if (!SubmitSmoke("voyage-map-close")) + yield break; + if (!SubmitSmoke("passage-bridge") || !SubmitSmoke("helm-toggle") || !SubmitSmoke("helm-order-1") + || !CheckSmoke(passageHelm.Manual && passageHelm.Practice.Exercise == HelmExercise.ChangeHeading, + "Use the bridge throttle to start the practical helm check")) + yield break; + for (int i = 0; i < 32; i++) + StepCaptainSmoke(.1f); + yield return CaptureSmoke(directory, "04-river-helm-practice"); + if (!CheckSmoke(harbor.PassageSeaMotion.sqrMagnitude > .00001f && Mathf.Abs(harbor.HorizonRoll) < 5f + && harbor.FirstPersonPositionIsClear, "The bridge camera follows the vessel with a damped horizon and valid footing")) + yield break; + + HelmPracticeSnapshot before = passageHelm.Practice.Capture(); + if (!SubmitSmoke("company-menu") || !SubmitSmoke("career-save") || !SubmitSmoke("career-load-open") || !SubmitSmoke("career-load-0") + || !CheckSmoke(company.IsCaptainCareer && passageHelm.Manual && livePassage.EngineMode == 0 + && before.Exercise == passageHelm.Practice.Exercise + && Mathf.Abs(before.Target - passageHelm.Practice.Capture().Target) < .01f, + "Resume the same manual manoeuvre and sailing order from a career save")) + yield break; + for (int i = 0; i < 580 && !passageHelm.Practice.Qualified && !passageHelm.Arrived; i++) + StepCaptainSmoke(.1f); + if (!CheckSmoke(passageHelm.Practice.Qualified && !passageHelm.Arrived, + "Steer onto the assigned heading, return to course and hold it") || !SubmitSmoke("helm-toggle")) + yield break; + yield return CaptureSmoke(directory, "05-river-helm-passed"); + + int voyages = company.Voyages; + int helmChecks = company.HelmQualifications(Market.River); + for (int i = 0; i < 2000 && !passageHelm.Arrived; i++) + passageHelm.Advance(.1f, 0, livePassage.SpeedFactor, underway.Weather); + if (!CheckSmoke(passageHelm.Arrived, "The riverboat reaches port under navigation") || !SubmitSmoke("dock-now") + || !SubmitSmoke("port-cinematic-skip") || !CheckSmoke(company.Voyages == voyages + 1 && company.History[0].Miles <= 30 + && company.CommandVoyages(Market.River) == 1 && company.HelmQualifications(Market.River) == helmChecks + 1, + "A qualifying river crossing settles and continues the career")) + yield break; + yield return CaptureSmoke(directory, "06-captain-arrival"); + + var shallowWater = new HelmNavigation(103, Market.River) { Manual = true }; + bool encounteredEdge = false; + for (int i = 0; i < 320; i++) + { + shallowWater.Advance(.1f, 1, 1, WeatherCondition.Calm); + encounteredEdge |= shallowWater.AtChannelEdge; + } + if (!CheckSmoke(encounteredEdge && Mathf.Abs(shallowWater.Position.y) < 6, "The riverboat stays inside the river navigation channel")) + yield break; + OpenVoyageChart(); + if (!SubmitSmoke("dispatch") || !SubmitSmoke("port-cinematic-skip") || !SubmitSmoke("dock-now") + || !SubmitSmoke("port-cinematic-skip") || !CheckSmoke(company.CommandVoyages(Market.River) == 2 + && company.HelmQualifications(Market.River) == 1 && company.ShipyardBlock(Market.Coastal, true) == null, + "Two river trips with one practical check unlock the Coastal command")) + yield break; + if (!SubmitSmoke("nav-2") || !SubmitSmoke("yard-0")) + yield break; + yield return CaptureSmoke(directory, "07a-coastal-shipyard"); + if (!SubmitSmoke("buy-ship") || !CheckSmoke(Ship.HullIndex == Market.Coastal + && company.ShipyardBlock(Market.Regional, true) != null, + "The Coastal command starts a fresh qualification path to Regional")) + yield break; + yield return CaptureSmoke(directory, "07-coastal-command"); + Debug.Log($"Big Ship Tycoon Captain Career smoke passed at {Screen.width} × {Screen.height}."); + Application.Quit(0); + } + + private static Vector3 PeakSeaResponseSmoke(int hullIndex, float severity) + { + HullSpec hull = Market.Hulls[hullIndex]; + var peak = Vector3.zero; + for (int sample = 0; sample < 90; sample++) + { + Vector3 motion = Harbor.SampleSeaResponse(new Vector2(sample * 2.5f, 7), sample * .3f, 26, + hull.Length, hull.Beam * .5f, severity, hullIndex == Market.River); + peak = Vector3.Max(peak, new Vector3(Mathf.Abs(motion.x), Mathf.Abs(motion.y), Mathf.Abs(motion.z))); + } + return peak; + } + + private void StepCaptainSmoke(float delta) + { + HelmPractice practice = passageHelm.Practice; + float desired = practice.Exercise == HelmExercise.ChangeHeading ? practice.Capture().Target : passageHelm.CourseToDestination; + float difference = Mathf.DeltaAngle(passageHelm.Heading, desired); + float rudder = Mathf.Abs(difference) > 2.2f ? Mathf.Clamp(difference * .13f - passageHelm.Rudder * .015f, -1f, 1f) : 0; + passageHelm.Advance(delta, rudder, livePassage.SpeedFactor, underway.Weather); + practice.Advance(passageHelm, delta, rudder); + livePassage.AdvanceTo(passageHelm.Progress); + PresentVessel(delta); + } + private static bool SameSavedCrossing(FleetPassageSnapshot before, FleetPassageSnapshot after) => before.ShipIndex == after.ShipIndex && before.Voyage.Destination == after.Voyage.Destination && JsonUtility.ToJson(before.Helm) == JsonUtility.ToJson(after.Helm) diff --git a/Assets/BigShipTycoon/Runtime/VoyageMap.cs b/Assets/BigShipTycoon/Runtime/VoyageMap.cs index 3919807..0ac9eda 100644 --- a/Assets/BigShipTycoon/Runtime/VoyageMap.cs +++ b/Assets/BigShipTycoon/Runtime/VoyageMap.cs @@ -37,7 +37,8 @@ namespace BigShipTycoon else ports[1] = underway.Destination; - Vector2[][] paths = MapPaths(ports); + bool river = Ship.HullIndex == Market.River; + Vector2[][] paths = MapPaths(ports, river); var chart = Add(overlay, "voyage-map"); var header = Add(chart, "voyage-map-header"); var heading = Add(header, "voyage-map-heading"); @@ -60,8 +61,8 @@ namespace BigShipTycoon label.AddToClassList("voyage-map-port-next"); labels.Add(port, label); } - plot.generateVisualContent += context => PaintVoyageMap(context, paths, currentLeg); - plot.RegisterCallback(change => PlaceMapLabels(change.newRect.size, paths, ports, labels)); + plot.generateVisualContent += context => PaintVoyageMap(context, paths, currentLeg, river); + plot.RegisterCallback(change => PlaceMapLabels(change.newRect.size, paths, ports, labels, river)); var footer = Add(chart, "voyage-map-footer"); voyageMapReadout = AddText(footer, "", "voyage-map-readout"); @@ -95,17 +96,23 @@ namespace BigShipTycoon voyageMapPlot.MarkDirtyRepaint(); } - private static Vector2[][] MapPaths(int[] ports) + private static Vector2[][] MapPaths(int[] ports, bool river = false) { var paths = new Vector2[ports.Length - 1][]; float longitude = Market.Ports[ports[0]].Longitude; for (int leg = 0; leg < paths.Length; leg++) { + Vector2[] path = paths[leg] = new Vector2[MapSamples + 1]; + if (river) + { + for (int sample = 0; sample <= MapSamples; sample++) + path[sample] = Vector2.Lerp(RiverChartPoint(ports[leg]), RiverChartPoint(ports[leg + 1]), (float)sample / MapSamples); + continue; + } PortSpec origin = Market.Ports[ports[leg]], dest = Market.Ports[ports[leg + 1]]; float start = longitude; longitude = start + Mathf.DeltaAngle(start, dest.Longitude); Vector3 a = GlobePoint(origin), b = GlobePoint(dest); - Vector2[] path = paths[leg] = new Vector2[MapSamples + 1]; for (int s = 0; s <= MapSamples; s++) { float t = (float)s / MapSamples; @@ -129,7 +136,7 @@ namespace BigShipTycoon public readonly Vector2 Center, Dimensions; public readonly float Scale; - public MapProjection(Vector2 size, Vector2[][] paths) + public MapProjection(Vector2 size, Vector2[][] paths, bool river = false) { var minimum = paths[0][0]; var maximum = minimum; @@ -140,7 +147,7 @@ namespace BigShipTycoon maximum = Vector2.Max(maximum, point); } Center = (minimum + maximum) * .5f; - Vector2 span = Vector2.Max(maximum - minimum, new Vector2(5.5f, 3.1f)); + Vector2 span = Vector2.Max(maximum - minimum, river ? new Vector2(.94f, .64f) : new Vector2(5.5f, 3.1f)); Scale = Mathf.Max(.01f, Mathf.Min((size.x - 146) / span.x, (size.y - 86) / span.y)); Dimensions = size; } @@ -148,9 +155,9 @@ namespace BigShipTycoon public Vector2 Pixel(Vector2 point) => Dimensions * .5f + (point - Center) * Scale; } - private static void PlaceMapLabels(Vector2 size, Vector2[][] paths, int[] ports, Dictionary labels) + private static void PlaceMapLabels(Vector2 size, Vector2[][] paths, int[] ports, Dictionary labels, bool river) { - var projection = new MapProjection(size, paths); + var projection = new MapProjection(size, paths, river); var used = new HashSet(); var rows = new List(ports.Length); for (int i = 0; i < ports.Length; i++) @@ -175,15 +182,18 @@ namespace BigShipTycoon } } - private void PaintVoyageMap(MeshGenerationContext context, Vector2[][] paths, int currentLeg) + private void PaintVoyageMap(MeshGenerationContext context, Vector2[][] paths, int currentLeg, bool river) { Vector2 size = context.visualElement.contentRect.size; if (size.x < 50 || size.y < 50) return; - var projection = new MapProjection(size, paths); + var projection = new MapProjection(size, paths, river); Painter2D pen = context.painter2D; PaintMapGrid(pen, projection); - PaintMapCoast(pen, projection); + if (river) + PaintRiverMapBanks(pen, projection); + else + PaintMapCoast(pen, projection); for (int i = 0; i < paths.Length; i++) { @@ -226,6 +236,23 @@ namespace BigShipTycoon pen.Stroke(); } + private static void PaintRiverMapBanks(Painter2D pen, MapProjection projection) + { + pen.fillColor = new Color(.14f, .27f, .28f); + pen.strokeColor = new Color(.42f, .51f, .47f); + pen.lineWidth = 1.15f; + foreach (Vector2[] bank in RiverBanksOnChart) + { + pen.BeginPath(); + pen.MoveTo(projection.Pixel(bank[0])); + for (int i = 1; i < bank.Length; i++) + pen.LineTo(projection.Pixel(bank[i])); + pen.ClosePath(); + pen.Fill(); + pen.Stroke(); + } + } + private static void PaintMapGrid(Painter2D pen, MapProjection map) { Vector2 reach = map.Dimensions / (2 * map.Scale); diff --git a/Assets/BigShipTycoon/Runtime/VoyagePresentation.cs b/Assets/BigShipTycoon/Runtime/VoyagePresentation.cs index 8977778..072f88a 100644 --- a/Assets/BigShipTycoon/Runtime/VoyagePresentation.cs +++ b/Assets/BigShipTycoon/Runtime/VoyagePresentation.cs @@ -121,6 +121,8 @@ namespace BigShipTycoon rudder = ReadNavigationControls(); passageHelm.Advance(delta * passageSpeed, rudder, livePassage.SpeedFactor, underway.Weather); + if (company.IsCaptainCareer && !fleetOpen && !ShorePlanningOpen && !crewManifestOpen && !voyageMapOpen) + passageHelm.Practice.Advance(passageHelm, delta, rudder); float progress = passageHelm.Progress; UpdatePortApproach(); bool performanceWasActive = livePassage.PerformanceActive; @@ -256,7 +258,8 @@ namespace BigShipTycoon private static float PassageDuration(Voyage voyage) { float weather = voyage.Weather switch { WeatherCondition.Swell => 1.14f, WeatherCondition.Storm => 1.32f, _ => 1 }; - return Mathf.Clamp((135f + voyage.Miles * .18f + voyage.Days * 8f) * weather, 175f, 540f); + return voyage.Miles <= 30 ? Mathf.Clamp((76f + voyage.Miles * 1.5f) * weather, 78f, 135f) + : Mathf.Clamp((135f + voyage.Miles * .18f + voyage.Days * 8f) * weather, 175f, 540f); } private bool EditingText() @@ -279,7 +282,8 @@ namespace BigShipTycoon return; } - var passage = new FleetPassage(ship, quote, company.Voyages < 3 && ship.HullIndex == 0); + bool assisted = ship.HullIndex == Market.River || company.Voyages < 3 && ship.HullIndex == Market.Coastal; + var passage = new FleetPassage(ship, quote, assisted); ResetShorePlanning(); fleetPassages.Add(ship, passage); UpdateVoyageReserves(); @@ -375,6 +379,8 @@ namespace BigShipTycoon { if (underway == null || (speed != 1 && speed != 2 && speed != 4) || speed == passageSpeed) return; + if (speed != 1 && company.IsCaptainCareer && passageHelm.Manual) + return; passageSpeed = speed; if (fleetPassages.TryGetValue(Ship, out FleetPassage passage)) passage.Speed = speed; @@ -387,6 +393,7 @@ namespace BigShipTycoon return; ResetShorePlanning(); Voyage voyage = underway; + bool helmQualified = company.IsCaptainCareer && passageHelm.Arrived && passageHelm.Practice.Qualified; string failure = SettleFleetPassage(Ship, livePassage); if (failure != null) { @@ -408,6 +415,8 @@ namespace BigShipTycoon arrival += Ship.Itinerary is { HasNext: true } itinerary ? $" Next call is {Market.Ports[itinerary.NextPort].Name}." : " Itinerary complete."; + if (helmQualified) + arrival += " Helm qualification logged."; Notify(arrival); Save(); if (fleetOpen) diff --git a/Docs/Design.md b/Docs/Design.md index 94b811c..b76bfc4 100644 --- a/Docs/Design.md +++ b/Docs/Design.md @@ -8,7 +8,7 @@ 4. Review bookings, weather, fuel, and estimated profit before departing. At sea, respond to events, adjust prices, run specials, and use first-person stations. Crew calls identify a department and a deadline. The Logbook records guest outcomes, crew calls answered, and the port invoice. 5. Unlock Regional hulls at three voyages and 24 reputation, then Ocean Class at nine voyages and 42 reputation. Qualify for the MEGA Ocean Liner after the flagship charter, 18 voyages, and 65 reputation. Ships start with two Coastal, four Regional, six Ocean Class, or twelve MEGA decks, with room for further expansion. The MEGA hull includes a separate upper sky deck and lower aft terrace. -The prototype covers 22 ports. A global loop continues from Lisbon through the Mediterranean, Suez, the Indian Ocean and the Pacific, and returns through Panama to the Caribbean. It uses an eight-ship limit, a 30-voyage rolling ledger, one save slot, and player-initiated sailings. A cash shortfall can leave a company unable to dispatch. The financed start has a one-time bridge loan for liquidity. The title menu allows a new start. +The campaign covers 24 ports. A global loop continues from Lisbon through the Mediterranean, Suez, the Indian Ocean and the Pacific, and returns through Panama to the Caribbean. Captain Career starts with a 32 m riverboat and three local connections between Miami and two river landings. The practical helm check uses the current class's steering response. Larger commands require completed voyages and qualifications earned in the preceding class. The simulation uses an eight-ship limit, a 30-voyage rolling ledger, named save slots, and player-initiated sailings. The optional first-voyage guide responds to the current ship and workspace. The used-ship start can go straight to a route and fare. The financed start can commission a hull, fit passenger cabins and dining, and fuel the ship before departing. The guide ends in the Logbook. Players can skip it or restart it for their current fleet. diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 4eb6676..541803d 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -149,7 +149,7 @@ PlayerSettings: loadStoreDebugModeEnabled: 0 visionOSBundleVersion: 1.0 tvOSBundleVersion: 1.0 - bundleVersion: 0.14.0 + bundleVersion: 0.15.0 preloadedAssets: [] metroInputSource: 0 wsaTransparentSwapchain: 0 diff --git a/README.md b/README.md index 1da32bf..8c8014b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,9 @@ Big Ship Tycoon is a Unity cruise-line management game. Start with a secondhand ship and $135,000, or borrow $500,000 and commission your first hull. Lay out cabins, dining, entertainment and bunker tanks deck by deck. Set fares, hire crew, buy fuel locally, and run profitable routes to fund a larger fleet. The [title thumbnail](Branding/BigShipTycoon.png) shows the used-ship start and the flagship you can work toward. -The campaign has 22 ports. Start in Florida and the Caribbean, then extend your network across the Atlantic, Indian Ocean, and Pacific. Coastal ships have two to three buildable decks, Regional ships have four to five, Ocean Class ships have six to eight, and the MEGA Ocean Liner has twelve to fifteen. Complete the Bermuda–Lisbon flagship charter in an Ocean Class ship with at least 320 guest berths and 160 show seats. At 18 completed voyages and 65 reputation, you can commission the 300 m MEGA liner for $2.35 million. +The campaign has 24 destinations, including two river landings. Start in Florida and the Caribbean, then extend your network across the Atlantic, Indian Ocean, and Pacific. Coastal ships have two to three buildable decks, Regional ships have four to five, Ocean Class ships have six to eight, and the MEGA Ocean Liner has twelve to fifteen. Complete the Bermuda–Lisbon flagship charter in an Ocean Class ship with at least 320 guest berths and 160 show seats. At 18 completed voyages and 65 reputation, you can commission the 300 m MEGA liner for $2.35 million. + +Learn the classes by their profiles in Harbor and Shipyard. The riverboat has a square wheelhouse and shallow hull. Coastal ships have a broad transom and a short utility stack. Regional ships have twin funnels and stepped aft glazing. Ocean Class ships carry a fine bow and tall raked funnel, and the MEGA liner has split terraces and a glazed arch over its observation bridge. The bridge and exterior views respond to the same sea state, with more roll and heave in storms. ## Play in Unity @@ -18,13 +20,17 @@ At the **Crew office**, hire or release bridge officers, engineers, galley staff In **Deck Plans → Larger venues** or **Leisure & retail**, select a fitting and point at a bay to preview its footprint. Press **R** or use **Rotate** to turn the plan by 90°. Clearing any occupied bay removes the whole facility. Regional hulls unlock suites, restaurants, resort pools, cocktail lounges, 2×2 spas, and L-shaped shopping arcades after three voyages and 24 reputation. Ocean Class hulls add grand suites, theaters, and 3×2 water parks after nine voyages and 42 reputation. Large outdoor pools and stages fitted on the top deck also appear in the exterior view. -The optional **First voyage guide** starts enabled for both careers. It highlights the relevant controls from the harbor or shipyard through the first arrival and gives contextual tips at sea. Choose **Skip** on the guide at any time, or **Restart first voyage guide** in the pause menu to use it with your current company. +The optional **First voyage guide** starts enabled. It highlights the relevant controls from the harbor or shipyard through the first arrival and gives contextual tips at sea. Choose **Skip** on the guide at any time, or **Restart first voyage guide** in the pause menu to use it with your current company. + +**Captain Career** at the title starts with a 32 m riverboat and $96,000. Sail local routes between Miami, Brickell Landing, and Mangrove Landing. Earn Coastal command with two river trips and one helm qualification. Move on to Regional with three Coastal trips and one Coastal qualification, then earn Ocean Class with four Regional trips and two Regional qualifications. The MEGA license needs six Ocean Class trips and two Ocean Class qualifications in addition to the flagship charter and company requirements. + +On the bridge, take the helm, select **Economy**, then steer to the instructed heading and return to course. Hold the boat steady and reach port to log the check. You can return to autopilot after the check and finish at **4×**. **Skip to arrival** settles the trip without logging a helm qualification. ## During a voyage - For a multi-stop voyage, open **Itinerary** on the Chart and append connected ports in order. Each leg has its own forecast, local fuel and provisions, and arrival statement. After docking, choose **Plan next leg** in the Logbook to review and prepare for the next call. The ship's itinerary stays in the save at each berth. -- Open **Shore excursions** on the Chart or at sea to set prices and seat limits for the two tours at the next port. The forecast shows expected bookings, operator fees, and the chance of a late return. Excursions run while ships are docked, including ships in the background. If a group returns late, hold the berth or pay for onward transport and clear the ship to sail. The Logbook records the result. -- Short routes take about three minutes at **1×**. Longer crossings take up to nine minutes. Use **2×**, **4×**, or **Skip to arrival** to advance faster. +- Open **Shore excursions** on the Chart or at sea to set prices and seat limits for three activities specific to the next port. The forecast shows expected bookings, operator fees, and the chance of a late return. Excursions run while ships are docked, including ships in the background. If a group returns late, hold the berth or pay for onward transport and clear the ship to sail. The Logbook records the result. +- River passages take about one to two minutes at **1×**. Coastal routes start at about three minutes, and longer ocean crossings can take nine. Use **2×**, **4×**, or **Skip to arrival** to advance faster. - Open **Fleet** or press **F2** in port or at sea to see the fleet chart, ship positions, and operating stats. Select another ship to manage it while your other crossings continue on autopilot with their own prices and progress. A voyage reserves its operating funds until arrival. The pause menu stops all crossings together. - Drag or use **Q/E** to orbit the ship. Scroll over a deck or room to inspect it up close, middle-drag to pan while zoomed in, and press **Home** to reset the camera. Local sounds grow clearer as you get closer and change with the venue. The deck view stack lists the highest deck first. Use **0** for the exterior, **1–9** for the first nine decks, and the on-screen deck controls for higher levels. - Cast-off and arrival play a short live-rendered cinematic with your ship in the port's own waterfront setting. Press **Esc** or select **Skip** to return to gameplay immediately. @@ -33,6 +39,7 @@ The optional **First voyage guide** starts enabled for both careers. It highligh - On the bridge, choose **Take the helm** (**H**). Use **A/D** for the rudder and **W/S** to step through throttle orders. The ship gathers speed, coasts, and takes time to turn. Press **H** again to resume autopilot. The exterior view lets you watch the ship respond while you steer. - Onboard prices apply to future service while passenger bookings stay fixed for the crossing. Limited-time specials and event decisions affect service, takings, and the arrival report. - Dockside orders lock at cast off and appear itemized on arrival. Food runs down as meals are served. Paid acts run during their booked service window and add show places and demand. +- In **Dockside orders**, compare **Economy**, **Cruise**, and **Express** for estimated fuel and crossing time. The selected order sets the initial throttle. Express also needs fuel reserve and sufficient engineering crew. - Press **M** or choose **Voyage map** at sea to see the ship's live position and heading, the current leg, and the rest of the itinerary. - The ship's PA names the next port at cast off and again on approach. It also announces selected specials, extra service, and performances. Spoken announcements have matching captions. - Your first three Coastal voyages default to assisted operations. The crew can release reserve provisions and boost utilities. Choose **Operations: Assisted** at any service station to switch to manual operation. Later voyages default to manual operation with assisted mode still available. Use **Deck Plans → Ship systems** to fit additional capacity for longer or busier crossings.