Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
 public static String TypeToString(JSON.TroopType troopType) => troopType.ToString().ToLower();
Ejemplo n.º 5
0
 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);