예제 #1
0
파일: Engine.cs 프로젝트: knexer/Apophis
 public void Apply(Simulation sim, ResourceCollection resources)
 {
     if (resources.CanApplyNextCycle(OperatingCost))
     {
         resources.ApplyNextCycle(OperatingCost);
         resources.GetResource(ResourceType.Deflection).ChangeNextCycle += sim.MaxTime - sim.CurrentTime;
     }
 }
예제 #2
0
 public ResourceCollection(ResourceCollection other) : this()
 {
     foreach (Resource resource in Resources)
     {
         Resource otherResource = other.GetResource(resource.Type);
         resource.Amount          = otherResource.Amount;
         resource.ChangeNextCycle = otherResource.ChangeNextCycle;
     }
 }
예제 #3
0
 public void Apply(Simulation sim, ResourceCollection resources)
 {
     resources.GetResource(Type).ChangeNextCycle += Growth;
 }
예제 #4
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();
    }