Beispiel #1
0
        // Gets resource counts from board demand/supply
        public EntityStatsTuple GetOnBoardResourceCount()
        {
            EntityStats netDemand = new EntityStats();
            EntityStats netSupply = new EntityStats();

            foreach (var tile in tiles)
            {
                if (tile.Entity != null)
                {
                    EntityStats stats = tile.Entity.Stats;
                    if (stats.food > 0)
                    {
                        netSupply.food += stats.food;
                    }
                    else
                    {
                        netDemand.food -= stats.food;
                    }

                    if (stats.environment > 0)
                    {
                        netSupply.environment += stats.environment;
                    }
                    else
                    {
                        netDemand.environment -= stats.environment;
                    }

                    if (stats.shelter > 0)
                    {
                        netSupply.shelter += stats.shelter;
                    }
                    else
                    {
                        netDemand.shelter -= stats.shelter;
                    }

                    if (stats.power > 0)
                    {
                        netSupply.power += stats.power;
                    }
                    else
                    {
                        netDemand.power -= stats.power;
                    }
                }
            }

            EntityStatsTuple tuple = new EntityStatsTuple();

            tuple.supply = netSupply;
            tuple.demand = netDemand;

            return(tuple);
        }
Beispiel #2
0
    // Calculates and updates current resource balance based on GameBoard, Population
    private void CalculateResources()
    {
        EntityStatsTuple totalStats = gameBoard.GetOnBoardResourceCount();

        totalStats.demand.food    += resources.Population * populationFoodMultiplier;
        totalStats.demand.shelter += resources.Population * populationShelterMultiplier;
        totalStats.demand.power   += resources.Population * populationPowerMultiplier;

        resources.totalDemand = totalStats.demand;
        resources.totalSupply = totalStats.supply;
    }