private decimal GetItemBoost(BoostTypes boostType, List <BoostItem> boostItems, decimal allocation, int population) { var boost = 0.0m; // get highest item boosts first e.g. if 100 people allocated, get 50 1.5% items, then 50 1% items, and weight boost var peopleAllocated = allocation * population; var peopleWithItems = 0; var itemsLeft = boostItems.Count(); var index = 0; // try to have each person use an item while (peopleWithItems < peopleAllocated && itemsLeft > 0 && boostItems.Count() > index) { var boostItem = boostItems.ElementAt(index++); var quantity = boostItem.Quantity; // this many people still need an item var canAllocateQty = peopleAllocated - peopleWithItems; // add the fewest items allowed var peopleToGiveItem = Math.Min(quantity, canAllocateQty); var percentOfMaxBoost = peopleToGiveItem / peopleAllocated; // calculate relative boost e.g. if they have enough items to fill half allocated pop. then they get half max boost // add to existing boost (so far, just technology above) boost += percentOfMaxBoost * boostItem.MaxBoost / 100; } return(boost); }
protected Booster(int id, BoostTypes typeOfBoost, BoosterTypes boosterType, int damageBoost, int shieldBoost, int healthBoost, int boxRewardBoost) { Id = id; BoostType = typeOfBoost; Type = boosterType; DamageBoost = damageBoost; ShieldBoost = shieldBoost; HealthBoost = healthBoost; BoxRewardBoost = boxRewardBoost; }
public Boost(Texture2D texture, Vector2 location, Rectangle gameBoundries, BoostTypes boostTypes) : base(texture, location, gameBoundries) { this.boostTypes = boostTypes; }