private int IsPopulationCapped(int value) { var pop = Mathf.FloorToInt(StartingVillage.GetInfo()[Supplies.Population]) - 1; if (pop < value) { value = pop; } return(value); }
public void StartRaid() { if (_startingItems[Supplies.Population] == 0) { ThrowErrorText("Need atleast 1 person"); return; } var population = (int)_startingItems[Supplies.Population]; float required = GetFoodRequire(_travelTime, population); if (_startingItems[Supplies.Food] < required) { ThrowErrorText($"Not enough food, need atleast {(required - _startingItems[Supplies.Food]).ToString("0.0kc")} more food"); return; } required = WaterRequired(_travelTime, population); if (_startingItems[Supplies.Water] < required) { ThrowErrorText($"Not enough water, need atleast {(required - _startingItems[Supplies.Water]).ToString("0.0L")} more water"); return; } var temp = new List <Troop.TroopEntity>(); for (int i = 0; i < _startingItems[Supplies.Population]; i++) { temp.Add(new Troop.TroopEntity( _startingItems[Supplies.Food] / population, _startingItems[Supplies.Water] / population, _startingItems[Supplies.Stone] / population, _startingItems[Supplies.Wood] / population)); } foreach (var data in _startingItems) { StartingVillage.ModifyVillage(data); } _gameMaster.TroopSystem.AddGroup(Mathf.FloorToInt(_travelTime / 2f), temp, _withdrawItems, _depositItems, Destination, StartingVillage); Destroy(this.gameObject); }