float getInitialFormationWidth(Team team, FormationClass fc)
        {
            var bp                   = this.CaptureTheBannerLordParams;
            var formation            = team.GetFormation(fc);
            var mounted              = fc == FormationClass.Cavalry || fc == FormationClass.HorseArcher;
            var unitDiameter         = Formation.GetDefaultUnitDiameter(mounted);
            var unitSpacing          = 1;
            var interval             = mounted ? Formation.CavalryInterval(unitSpacing) : Formation.InfantryInterval(unitSpacing);
            var actualSoldiersPerRow = System.Math.Min(bp.soldiersPerRow, bp.playerSoldierCount);
            var width                = (actualSoldiersPerRow - 1) * (unitDiameter + interval) + unitDiameter + 0.1f;

            return(width);
        }
Ejemplo n.º 2
0
        public static (float, float) GetFormationSpawnWidthAndDepth(
            FormationClass formationNo,
            int troopCount,
            bool considerCavalryAsInfantry = false)
        {
            bool  isMounted           = !considerCavalryAsInfantry && formationNo.IsMounted();
            float defaultUnitDiameter = Formation.GetDefaultUnitDiameter(isMounted);
            int   unitSpacing         = 1;
            float num1 = isMounted ? Formation.CavalryInterval(unitSpacing) : Formation.InfantryInterval(unitSpacing);
            float num2 = isMounted ? Formation.CavalryDistance(unitSpacing) : Formation.InfantryDistance(unitSpacing);
            int   num3 = Math.Max(1, (int)(((double)Math.Max(0, troopCount - 1) * ((double)num1 + (double)defaultUnitDiameter) + (double)defaultUnitDiameter) / Math.Sqrt((isMounted ? 24.0 : 12.0) * (double)troopCount + 1.0)));

            return(Math.Max(0.0f, (float)troopCount / (float)num3 - 1f) * (num1 + defaultUnitDiameter) + defaultUnitDiameter, (float)(num3 - 1) * (num2 + defaultUnitDiameter) + defaultUnitDiameter);
        }