public TimeSpan CalculateTravelTime(JSON.TroopType unitType, int startx, int starty, int endx, int endy) { int sqr(int val) { return(val * val); } var distance = Math.Sqrt(sqr(endx - startx) + sqr(endy - starty)); var minutesPerField = Native.ArmyStats.TravelSpeed[unitType]; var minutes = distance * minutesPerField / (worldSpeed * unitSpeed); return(TimeSpan.FromMinutes(minutes)); }
public JSON.TroopType TravelTroopType(JSON.Army army) { JSON.TroopType slowestType = JSON.TroopType.Spy; foreach (var type in army.Where(kvp => kvp.Value > 0).Select(kvp => kvp.Key)) { if (Native.ArmyStats.TravelSpeed[type] > Native.ArmyStats.TravelSpeed[slowestType]) { slowestType = type; } } return(slowestType); }
public int CalculatePossibleUnitRecruitment(JSON.TroopType troopType, TimeSpan timeSpan) { var baseBuildTime = Native.ArmyStats.BaseRecruitTime[troopType]; var unitSource = Native.ArmyStats.UnitSource[troopType]; var buildingLevel = this.buildingLevels[unitSource]; if (buildingLevel == 0) { return(0); } var recruitSpeedFactor = Native.BuildingStats.RecruitmentSpeedFactors[unitSource][buildingLevel - 1]; var finalBuildTime = baseBuildTime * recruitSpeedFactor / this.worldSpeed; return((int)Math.Floor(timeSpan.TotalSeconds / finalBuildTime.TotalSeconds)); }
public static String TypeToString(JSON.TroopType troopType) => troopType.ToString().ToLower();
public TimeSpan CalculateTravelTime(JSON.TroopType unitType, Scaffold.Village startVillage, Scaffold.Village endVillage) => CalculateTravelTime(unitType, startVillage.X.Value, startVillage.Y.Value, endVillage.X.Value, endVillage.Y.Value);