예제 #1
0
        private State FindCurState()
        {
            List <IEyeableInfo> eyeableInfo = orderServer.GetEyeableInfo();

            if (eyeableInfo.Count != 0)
            {
                IEyeableInfo first = eyeableInfo[0];
                if (first is TankSinTur.TankCommonEyeableInfo)
                {
                    TankSinTur.TankCommonEyeableInfo enemyInfo = (TankSinTur.TankCommonEyeableInfo)first;
                    enemyPos = enemyInfo.Pos;
                    float Distance = Vector2.Distance(enemyPos, orderServer.Pos);
                    if (Distance > maxGuardFactor * raderRadius)
                    {
                        return(State.Far);
                    }
                    else if (Distance < minGuardFactor * raderRadius)
                    {
                        return(State.Near);
                    }
                    else
                    {
                        return(State.Mid);
                    }
                }
            }
            return(State.Mid);
        }
예제 #2
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();
        }
예제 #3
0
        public void Observe()
        {
            List <IEyeableInfo> eyeableInfo = orderServer.GetEyeableInfo();

            if (eyeableInfo.Count != 0)
            {
                IEyeableInfo first = eyeableInfo[0];
                if (first is TankSinTur.TankCommonEyeableInfo)
                {
                    TankSinTur.TankCommonEyeableInfo enemyInfo = (TankSinTur.TankCommonEyeableInfo)first;
                    enemyPos = enemyInfo.Pos;
                    float Distance = Vector2.Distance(enemyPos, orderServer.Pos);

                    Vector2 curPos   = orderServer.Pos;
                    Vector2 enemyVec = Vector2.Normalize(curPos - enemyPos);
                    Vector2 curDir   = orderServer.Direction;

                    Vector2 lineVec = new Vector2(enemyVec.Y, -enemyVec.X);
                    if (Vector2.Dot(lineVec, curDir) < 0)
                    {
                        lineVec = -lineVec;
                    }
                    if (Distance > maxGuardFactor * raderRadius || Distance < minGuardFactor * raderRadius ||
                        Vector2.Dot(curDir, lineVec) < 0.8)
                    {
                        curPriority = ConsiderPriority.Urgency;
                        return;
                    }
                }
            }

            curPriority = ConsiderPriority.Vacancy;
        }
예제 #4
0
        internal bool Combine ( EyeableBorderObjInfo borderObjInfo )
        {
            bool objUpdated = false;

            if (borderObjInfo.eyeableInfo.Pos != this.eyeableInfo.Pos)
                objUpdated = true;

            this.eyeableInfo = borderObjInfo.eyeableInfo;
            if (this.border.Combine( borderObjInfo.border.VisiBorder ))
                objUpdated = true;

            isDisappeared = false;

            return objUpdated;
        }
예제 #5
0
        internal bool Combine(EyeableBorderObjInfo borderObjInfo)
        {
            bool objUpdated = false;

            if (borderObjInfo.eyeableInfo.Pos != this.eyeableInfo.Pos)
            {
                objUpdated = true;
            }

            this.eyeableInfo = borderObjInfo.eyeableInfo;
            if (this.border.Combine(borderObjInfo.border.VisiBorder))
            {
                objUpdated = true;
            }

            isDisappeared = false;

            return(objUpdated);
        }
예제 #6
0
        public void Observe()
        {
            List <IEyeableInfo> eyeableInfo = orderServer.GetEyeableInfo();

            if (eyeableInfo.Count != 0)
            {
                curPriority = ConsiderPriority.High;
                IEyeableInfo first = eyeableInfo[0];
                if (first is TankSinTur.TankCommonEyeableInfo)
                {
                    TankSinTur.TankCommonEyeableInfo enemyInfo = (TankSinTur.TankCommonEyeableInfo)first;
                    enemyPos = enemyInfo.Pos;
                }
            }
            else
            {
                curPriority = ConsiderPriority.Vacancy;
            }
        }
예제 #7
0
        public void Observe()
        {
            List <IEyeableInfo> eyeableInfo = orderServer.GetEyeableInfo();

            if (eyeableInfo.Count != 0)
            {
                IEyeableInfo first = eyeableInfo[0];
                if (first is TankSinTur.TankCommonEyeableInfo)
                {
                    enemyInfo = (TankSinTur.TankCommonEyeableInfo)first;
                    float selfToEnemyAzi = MathTools.AziFromRefPos(orderServer.Pos - enemyInfo.Pos);
                    float enemyTurretAzi = enemyInfo.TurretAimAzi;
                    if (Math.Abs(MathTools.AngTransInPI(enemyTurretAzi - selfToEnemyAzi)) < guardAng)
                    {
                        curPriority = ConsiderPriority.High;
                        return;
                    }
                }
            }

            curPriority = ConsiderPriority.Vacancy;
        }
예제 #8
0
 public EyeableBorderObjInfo ( IEyeableInfo eyeableInfo, ObjVisiBorder border )
 {
     this.eyeableInfo = eyeableInfo;
     this.border = border;
 }
예제 #9
0
 public EyeableBorderObjInfo(IEyeableInfo eyeableInfo, ObjVisiBorder border)
 {
     this.eyeableInfo = eyeableInfo;
     this.border      = border;
 }