Пример #1
0
        public void findclosestzone(List <Missile> missiles, Radar r, PointF location, PointF targetpos, float orientation, List <Entity> EntityList)
        {
            //takes a look at the pos and current location to determine if it is in the radar's zone
            //start with the infared, then to radar
            //if inside that zone then locked = true
            //check short range infared radar
            if (location.CreateHitTriangle(r.SRInfaredRange, orientation, r.SRInfaredSightAngle / 2).IsPointInPolygon(targetpos))
            {
                //is inside short range infared radar
                if (missiles.Any(p => p.Type == MissileType.srir & p.Active == true)) //ensure that the plane has a weapon to use
                {
                    Status = AutoEngageStatus.Locked;
                    //loose missile
                    Missile m = missiles.First(p => p.Type == MissileType.srir);
                    missiles.Remove(m);
                    //give it the data it needs to keep tracking
                    m.Orientation = orientation;
                    m.Location    = location;
                    m.lockID      = 0;
                    EntityList.Add(m);
                }
                SRIRlock = true;
            }
            else
            {
                SRIRlock = false;
            }

            if (location.CreateHitTriangle(r.SRRadarRange, orientation, r.SRRadarSightAngle / 2).IsPointInPolygon(targetpos))
            {
                //is inside short range infared radar
                if (missiles.Any(p => p.Type == MissileType.srr & p.Active == true)) //ensure that the plane has a weapon to use
                {
                    Status = AutoEngageStatus.Locked;
                    //loose missile
                    //give it the data it needs to keep tracking
                }
                SRRlock = true;
            }
            else
            {
                SRRlock = false;
            }

            if (location.CreateHitTriangle(r.MRRadarRange, orientation, r.MRRadarSightAngle / 2).IsPointInPolygon(targetpos))
            {
                //is inside short range infared radar
                if (missiles.Any(p => p.Type == MissileType.mrr & p.Active == true)) //ensure that the plane has a weapon to use
                {
                    Status = AutoEngageStatus.Locked;
                    //loose missile
                    //give it the data it needs to keep tracking
                }
                MRRlock = true;
            }
            else
            {
                MRRlock = false;
            }
        }