Add riverboat captain career and distinct ship classes
Add class-specific vessel geometry and sea motion, a guided helm qualification path, dockside sailing orders, and local excursions at all 24 ports.
This commit is contained in:
68
Assets/BigShipTycoon/Runtime/CaptainCareer.cs
Normal file
68
Assets/BigShipTycoon/Runtime/CaptainCareer.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user