Esempio n. 1
0
        public AFacility(AFacility facility)
        {
            X                  = facility.X;
            Y                  = facility.Y;
            Id                 = facility.Id;
            IsMy               = facility.IsMy;
            IsOpp              = facility.IsOpp;
            Type               = facility.Type;
            CapturePoints      = facility.CapturePoints;
            ProductionProgress = facility.ProductionProgress;
            VehicleType        = facility.VehicleType;

            X2 = X + G.FacilitySize;
            Y2 = Y + G.FacilitySize;
        }
Esempio n. 2
0
        public static AMove ChangeFactoryProduction(AFacility factory)
        {
            VehicleType requiredType;

            var myFighters  = Environment.GetVehicles(true, VehicleType.Fighter).Count;
            var oppFighters = Environment.GetVehicles(false, VehicleType.Fighter).Count +
                              VehiclesObserver.OppUncheckedVehicles.Values.Count(x => x.Type == VehicleType.Fighter) * 0.8 +
                              VehiclesObserver.OppCheckedVehicles.Values.Count(x => x.Type == VehicleType.Fighter) * 0.6;

            var nearest = Environment.OppVehicles.Concat(VehiclesObserver.OppUncheckedVehicles.Values).ArgMin(x => x.GetDistanceTo2(factory.Center));

            if (nearest?.Type == VehicleType.Fighter && factory.Center.GetDistanceTo(nearest) < 200)
            {
                requiredType = VehicleType.Ifv;
            }
            else if (nearest?.Type == VehicleType.Ifv && factory.Center.GetDistanceTo(nearest) < 200)
            {
                requiredType = VehicleType.Tank;
            }
            else if (myFighters < oppFighters)
            {
                requiredType = VehicleType.Fighter;
            }
            else if (oppFighters < 10 && Environment.MyVehicleFactories.Count(x => x.VehicleType == VehicleType.Helicopter) - (factory.VehicleType == VehicleType.Helicopter ? 1 : 0) == 0)
            {
                requiredType = VehicleType.Helicopter;
            }
            else
            {
                requiredType = VehicleType.Tank;
            }

            if (requiredType == factory.VehicleType)
            {
                return(null);
            }

            return(new AMove
            {
                Action = ActionType.SetupVehicleProduction,
                VehicleType = requiredType,
                FacilityId = factory.Id,
            });
        }
Esempio n. 3
0
        private static AVehicle _doFacilityProd(Sandbox env, AFacility facility)
        {
            var vehicleType = facility.VehicleType.Value;
            var isMy        = facility.IsMy;

            var pt = new ACircularUnit();

            pt.Radius = G.VehicleRadius;

            for (var j = 0; j < 11; j++)
            {
                for (var i = 0; i < 11; i++)
                {
                    if (facility.IsMy)
                    {
                        pt.X = facility.X + i * 6 + G.VehicleRadius;
                        pt.Y = facility.Y + j * 6 + G.VehicleRadius;
                    }
                    else
                    {
                        pt.X = facility.X2 - i * 6 - G.VehicleRadius;
                        pt.Y = facility.Y2 - j * 6 - G.VehicleRadius;
                    }

                    var nearby = env.GetFirstIntersector(pt, Utility.IsAerial(vehicleType));
                    if (nearby == null && !facility.IsMy)
                    {
                        nearby = OppUncheckedVehicles.Values
                                 .Where(x => Utility.IsAerial(x.Type) == Utility.IsAerial(vehicleType))
                                 .ArgMin(x => x.GetDistanceTo2(pt));
                    }

                    if (nearby == null || !nearby.IntersectsWith(pt) || nearby.Id == _nextFreeId && Geom.PointsEquals(nearby, pt))
                    {
                        return(new AVehicle(pt, _nextFreeId++, vehicleType, isMy));
                    }
                }
            }
            return(null);
        }