コード例 #1
0
    public void UpdateDisplay()
    {
        List <SpaceshipTemplate> queue = GameController.Instance.GetSelectedLogic().ShipQueue;

        if (ShipIndex < queue.Count)
        {
            SpaceshipTemplate template = GameController.Instance.GetSelectedLogic().ShipQueue[ShipIndex];
            ShipName.text = template.DisplayName;
        }
        else
        {
            ShipName.text = "";
        }
    }
コード例 #2
0
    public void CancelConstruction()
    {
        CelestialBodyLogic logic    = GameController.Instance.GetSelectedLogic();
        SpaceshipTemplate  template = logic.ShipQueue[ShipIndex];

        logic.ShipQueue.RemoveAt(ShipIndex);
        // Refund
        foreach (ShipCost cost in template.Costs)
        {
            logic.Resources[cost.Resource] += cost.Amount;
        }

        Controller.UpdateDisplay();
        ConstructionUI.UpdateDisplay();
    }
コード例 #3
0
    private void ConstructShip(SpaceshipTemplate template)
    {
        CelestialBodyResources resources = GetSelectedResources();

        if (!CanAfford(resources, template))
        {
            Debug.LogError($"Tried to construct {template.DisplayName} but can't afford!");
            return;
        }

        foreach (ShipCost cost in template.Costs)
        {
            resources[cost.Resource] -= cost.Amount;
        }

        GameController.Instance.GetSelectedLogic().ShipQueue.Add(template);

        UpdateDisplay();
        QueueUI.UpdateDisplay();
    }
コード例 #4
0
 private static bool CanAfford(CelestialBodyResources resources, SpaceshipTemplate template)
 {
     return(template.Costs.All(cost => resources[cost.Resource] >= cost.Amount));
 }
コード例 #5
0
 public Spaceship(SpaceshipTemplate template, CelestialBody orbitingBody)
 {
     Template     = template;
     OrbitingBody = orbitingBody;
 }