コード例 #1
0
        //
        internal string[] Collect(Area area)
        {
            StrongholdProduction production = new StrongholdProduction();
            bool collectTax = false;

            if ((NextTaxCollection - DateTime.UtcNow).TotalMilliseconds <= 0)
            {
                collectTax        = true;
                NextTaxCollection = DateTime.UtcNow.AddDays(1);
            }

            AreaExtentions.Population population = area.GetPopulation(AreaExtentions.Population.Type.Population);

            for (int i = 0; i < buildings.Count ||
                 i < population.Count; i++)
            {
                if (i < buildings.Count)
                {
                    production = buildings[i].Cycle(this, production);
                }
                if (collectTax && i < population.Count)
                {
                    var  npc          = population[i];
                    long taxCollected = Verify.Max(tax, npc.KCoins);
                    production.KoinProfit += taxCollected;
                    npc.KCoins            -= taxCollected;
                }
            }
            treasury += production.KoinProfit - production.KoinCost;
            return(production.FinalResult());
        }
コード例 #2
0
        //
        internal StrongholdProduction Cycle(OldSandBox sandbox,
                                            StrongholdProduction sp)
        {
            if (role != BuildingRole.Production || DateTime.UtcNow < Ready)
            {
                return(sp);
            }
            StackedItems product = Produce();

            if (product != null &&
                sandbox.stock.Add(product, sandbox.stats.StorageSpace))
            {
                sp.results.Add($"{this} Produced: {product}");
                sp.KoinProfit += profit;
                sp.KoinCost   += cost;
                Ready          = DateTime.UtcNow.AddHours(HoursToReady);
            }
            else
            {
                sp.results.Add($"{this}'s Produced {product} could not be collected. Storage full");
            }
            return(sp);
        }