Beispiel #1
0
    public void BuyUpgrade(Upgrade upgrade)
    {
        foreach (ResourceDelta cost in upgrade.Cost)
        {
            if (!resources.CanApplyImmediate(cost))
            {
                throw new Exception(
                          $"Expected at least {cost.Amount} of {cost.Type}, found only {resources.GetResource(cost.Type).Amount}." +
                          $"This should not happen, because we should have fastforwarded until there was enough!");
            }
            resources.ApplyImmediate(cost);
        }

        boughtUpgrades.Add(upgrade);
        boughtUpgradeTimes.Add(CurrentTime);

        RecalculateNextCycle();
    }