public static void AppendAllyUnitsToDodge(MyLivingUnit[] selectedUnits)
        {
            var currentSelectedGroup = GroupHelper.CurrentGroup;

            MyLivingUnit[] allyUnitsToDodge = new MyLivingUnit[0];

            if (currentSelectedGroup.VehicleType == VehicleType.Fighter ||
                currentSelectedGroup.VehicleType == VehicleType.Helicopter)
            {
                var selectedUnitIds = selectedUnits.Select(x => x.Id).ToArray();
                allyUnitsToDodge = UnitHelper.Units.Values
                                   .Where(
                    x => x.Side == Side.Our &&
                    (x.Type == VehicleType.Fighter || x.Type == VehicleType.Helicopter) &&
                    !selectedUnitIds.Contains(x.Id)).ToArray();
            }
            else if (currentSelectedGroup.VehicleType == VehicleType.Tank ||
                     currentSelectedGroup.VehicleType == VehicleType.Ifv ||
                     currentSelectedGroup.VehicleType == VehicleType.Arrv)
            {
                var selectedUnitIds = selectedUnits.Select(x => x.Id).ToArray();
                allyUnitsToDodge = UnitHelper.Units.Values
                                   .Where(
                    x => x.Side == Side.Our &&
                    (x.Type == VehicleType.Tank || x.Type == VehicleType.Ifv || x.Type == VehicleType.Arrv) &&
                    !selectedUnitIds.Contains(x.Id)).ToArray();
            }

            foreach (var allyDodgeUnit in allyUnitsToDodge)
            {
                var cellX = (int)allyDodgeUnit.X / PpSize;
                var cellY = (int)allyDodgeUnit.Y / PpSize;

                ApplyPower(PotentialFields, cellX, cellY, RangePowerMask5, AllyDodgePower);
            }
        }
Пример #2
0
        public static double GetVisionRangeByWeather(MyLivingUnit livingUnit)
        {
            var x = (int)livingUnit.X / PotentialFieldsHelper.PpSize;
            var y = (int)livingUnit.Y / PotentialFieldsHelper.PpSize;

            double airScale    = 1;
            double groundScale = 1;

            var weaterType = GlobalHelper.World.WeatherByCellXY[x][y];

            if (weaterType == WeatherType.Clear)
            {
                airScale = GlobalHelper.Game.ClearWeatherVisionFactor;
            }
            else if (weaterType == WeatherType.Cloud)
            {
                airScale = GlobalHelper.Game.CloudWeatherVisionFactor;
            }
            else if (weaterType == WeatherType.Rain)
            {
                airScale = GlobalHelper.Game.RainWeatherVisionFactor;
            }

            var terrainType = GlobalHelper.World.TerrainByCellXY[x][y];

            if (terrainType == TerrainType.Plain)
            {
                groundScale = GlobalHelper.Game.PlainTerrainVisionFactor;
            }
            else if (terrainType == TerrainType.Forest)
            {
                groundScale = GlobalHelper.Game.ForestTerrainVisionFactor;
            }
            else if (terrainType == TerrainType.Swamp)
            {
                groundScale = GlobalHelper.Game.SwampTerrainVisionFactor;
            }

            if (livingUnit.Type == VehicleType.Fighter)
            {
                var visionRange = GlobalHelper.Game.FighterVisionRange * airScale;
                return(visionRange);
            }
            else if (livingUnit.Type == VehicleType.Helicopter)
            {
                var visionRange = GlobalHelper.Game.HelicopterVisionRange * airScale;
                return(visionRange);
            }
            else if (livingUnit.Type == VehicleType.Tank)
            {
                var visionRange = GlobalHelper.Game.TankVisionRange * groundScale;
                return(visionRange);
            }
            else if (livingUnit.Type == VehicleType.Ifv)
            {
                var visionRange = GlobalHelper.Game.IfvVisionRange * groundScale;
                return(visionRange);
            }
            else if (livingUnit.Type == VehicleType.Arrv)
            {
                var visionRange = GlobalHelper.Game.ArrvVisionRange * groundScale;
                return(visionRange);
            }

            throw new NotImplementedException();
        }