Example #1
0
    public Ship SpawnShip(string shipName)
    {
        Ship spawnedShip = null;

        try
        {
            Ship shipPrefab = null;
            if (cachedShipPrefabs.ContainsKey(shipName))
            {
                shipPrefab = cachedShipPrefabs[shipName];
            }
            else
            {
                shipPrefab = Resources.Load <Ship>($"Ships/{shipName}");
                cachedShipPrefabs.Add(shipName, shipPrefab);
            }

            spawnedShip = Instantiate(shipPrefab, transform.position, transform.rotation);
            if (ShipLibrary.HasSpecForShip(shipPrefab.name))
            {
                spawnedShip.LoadSpecs(ShipLibrary.GetSpecForShip(shipPrefab.name));
            }
            else
            {
                Debug.LogError($"Did not find specs for {shipPrefab.name}");
            }
        }
        catch
        {
            Debug.LogError($"Could not find ship prefab \"{shipName}\"");
        }

        return(spawnedShip);
    }
Example #2
0
 private void Start()
 {
     if (LoadSpecOnStartup)
     {
         LoadSpecs(ShipLibrary.GetSpecForShip(name));
     }
 }
Example #3
0
 public void SubmitDesign()
 {
     ShipLibrary.AddShipToDevelopment(ship);
 }