Ejemplo n.º 1
0
        //[Obsolete]
        //private static void CheckVisible ( BinGroup group, IRaderOwner raderOwner )
        //{
        //    List<IEyeableInfo> inRaderObjInfos = new List<IEyeableInfo>();

        //    //List<IHasBorderObj> inRaderHasBorderNonShelterObjs = new List<IHasBorderObj>();

        //    List<EyeableBorderObjInfo> EyeableBorderObjs = new List<EyeableBorderObjInfo>();

        //    foreach (KeyValuePair<IEyeableObj, GetEyeableInfoHandler> set in group.eyeableSets)
        //    {
        //        if (raderOwner == set.Key)
        //            continue;

        //        // 检查是否为当前雷达的遮挡物体

        //        bool isShelter = false;
        //        foreach (ObjVisiBorder objBorder in raderOwner.Rader.ShelterVisiBorders)
        //        {
        //            if (objBorder.Obj == set.Key)
        //            {
        //                IEyeableInfo eyeableInfo = set.Value( raderOwner, set.Key );
        //                inRaderObjInfos.Add( eyeableInfo );

        //                EyeableBorderObjs.Add( new EyeableBorderObjInfo( eyeableInfo, objBorder ) );

        //                isShelter = true;
        //                break;
        //            }
        //        }

        //        // 检查非遮挡物体是否可见
        //        if (!isShelter)
        //        {
        //            foreach (Vector2 keyPoint in set.Key.KeyPoints)
        //            {
        //                if (raderOwner.Rader.PointInRader( Vector2.Transform( keyPoint, set.Key.TransMatrix ) ))
        //                {
        //                    IEyeableInfo eyeableInfo = set.Value( raderOwner, set.Key );
        //                    inRaderObjInfos.Add( eyeableInfo );

        //                    if (set.Key is IHasBorderObj)
        //                    {
        //                        ObjVisiBorder border = CalNonShelterVisiBorder( (IHasBorderObj)set.Key, raderOwner.Rader );
        //                        if (border != null)
        //                            EyeableBorderObjs.Add( new EyeableBorderObjInfo( eyeableInfo, border ) );
        //                    }
        //                    break;
        //                }
        //            }
        //        }
        //    }

        //    raderOwner.Rader.CurEyeableObjs = inRaderObjInfos;
        //    raderOwner.Rader.EyeableBorderObjInfos = EyeableBorderObjs.ToArray();
        //}

        /*
         * 将作为CheckVisible的替代,尚未测试。
         * */
        private static void CheckVisible(BinGroup group, IRaderOwner raderOwner)
        {
            List <IEyeableInfo> inRaderObjInfos = new List <IEyeableInfo>();

            List <EyeableBorderObjInfo> EyeableBorderObjs = new List <EyeableBorderObjInfo>();

            foreach (IEnumerable <IEyeableObj> eyeGroup in group.eyeableObjs)
            {
                foreach (IEyeableObj obj in eyeGroup)
                {
                    if (raderOwner == obj)
                    {
                        continue;
                    }

                    // 检查是否为当前雷达的遮挡物体

                    bool isShelter = false;
                    foreach (ObjVisiBorder objBorder in raderOwner.Rader.ShelterVisiBorders)
                    {
                        if (objBorder.Obj == obj)
                        {
                            IEyeableInfo eyeableInfo = obj.GetEyeableInfoHandler(raderOwner, obj);
                            inRaderObjInfos.Add(eyeableInfo);

                            EyeableBorderObjs.Add(new EyeableBorderObjInfo(eyeableInfo, objBorder));

                            isShelter = true;
                            break;
                        }
                    }

                    // 检查非遮挡物体是否可见
                    if (!isShelter)
                    {
                        foreach (Vector2 keyPoint in obj.KeyPoints)
                        {
                            if (raderOwner.Rader.PointInRader(Vector2.Transform(keyPoint, obj.TransMatrix)))
                            {
                                IEyeableInfo eyeableInfo = obj.GetEyeableInfoHandler(raderOwner, obj);
                                inRaderObjInfos.Add(eyeableInfo);

                                if (obj is IHasBorderObj)
                                {
                                    ObjVisiBorder border = CalNonShelterVisiBorder((IHasBorderObj)obj, raderOwner.Rader);
                                    if (border != null)
                                    {
                                        EyeableBorderObjs.Add(new EyeableBorderObjInfo(eyeableInfo, border));
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
            }

            raderOwner.Rader.CurEyeableObjs        = inRaderObjInfos;
            raderOwner.Rader.EyeableBorderObjInfos = EyeableBorderObjs.ToArray();
        }
Ejemplo n.º 2
0
        public void CalSheltersVisiBorder()
        {
            Dictionary <IShelterObj, List <VisiBordPoint> > temp = new Dictionary <IShelterObj, List <VisiBordPoint> >();

            int index = 0;

            foreach (IShelterObj obj in objMap)
            {
                if (obj != null)
                {
                    if (!temp.ContainsKey(obj))
                    {
                        temp.Add(obj, new List <VisiBordPoint>());
                    }
                    temp[obj].Add(objBordIndexMap[index]);
                }
                index++;
            }

            curObjVisiBorders = new ObjVisiBorder[temp.Count];

            curShelters = new IShelterObj[temp.Count];

            int i = 0;

            foreach (KeyValuePair <IShelterObj, List <VisiBordPoint> > pair in temp)
            {
                pair.Value.Sort(
                    delegate(VisiBordPoint p1, VisiBordPoint p2)
                {
                    if (p1.index < p2.index)
                    {
                        return(-1);
                    }
                    else if (p1.index == p2.index)
                    {
                        return(0);
                    }
                    else
                    {
                        return(1);
                    }
                });

                CircleList <VisiBordPoint> points = new CircleList <VisiBordPoint>();

                foreach (VisiBordPoint p in pair.Value)
                {
                    if (points.Last == null || points.Last.value.index != p.index)
                    {
                        points.AddLast(p);
                    }
                }

                curObjVisiBorders[i] = new ObjVisiBorder((IHasBorderObj)pair.Key, points);
                curShelters[i]       = pair.Key;

                i++;
            }
        }