Ejemplo n.º 1
0
 public ConsiderRaderScan(Rectanglef mapSize)
 {
     this.mapSize        = mapSize;
     curPriority         = ConsiderPriority.Vacancy;
     firstCircleFinished = false;
     lastState           = State.Start;
 }
Ejemplo n.º 2
0
        public void Update(float seconds)
        {
            Area curArea = FindCurArea();

            if (curArea != lastArea && curArea != Area.Middle)
            {
                Authorize();
                return;
            }

            if (turning)
            {
                orderServer.TurnRightSpeed = turnRightSpeed;
                orderServer.ForwardSpeed   = forwardSpeed;
                rotaAng -= orderServer.MaxRotaSpeed * seconds;
                if (rotaAng <= 0)
                {
                    turning = false;
                    orderServer.TurnRightSpeed = 0;
                    orderServer.ForwardSpeed   = orderServer.MaxForwardSpeed;
                }
            }
            if (curArea == Area.Middle)
            {
                curPriority = ConsiderPriority.Vacancy;
                orderServer.ForwardSpeed   = 0;
                orderServer.TurnRightSpeed = 0;
            }
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 4
0
        public ConsiderAwayFromBorder(Rectanglef mapSize, float guardDestance, float spaceForTankWidth)
        {
            this.mapSize           = mapSize;
            this.guardDestance     = guardDestance;
            this.spaceForTankWidth = spaceForTankWidth;

            curPriority = ConsiderPriority.Vacancy;
        }
Ejemplo n.º 5
0
        public void Observe()
        {
            Vector2 curPos = orderServer.Pos;

            if (curPos.X < mapSize.X + guardDestance || curPos.X > mapSize.X + mapSize.Width - guardDestance ||
                curPos.Y < mapSize.Y + guardDestance || curPos.Y > mapSize.Y + mapSize.Height - guardDestance)
            {
                curPriority = ConsiderPriority.Urgency;
            }
        }
Ejemplo n.º 6
0
        public void Observe()
        {
            List <IEyeableInfo> eyeableInfo = orderServer.GetEyeableInfo();

            if (eyeableInfo.Count == 0)
            {
                curPriority = ConsiderPriority.Low;
            }
            else
            {
                curPriority = ConsiderPriority.Vacancy;
            }
        }
Ejemplo n.º 7
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;
            }
        }
Ejemplo n.º 8
0
        public void Observe()
        {
            List <IEyeableInfo> eyeableInfo = orderServer.GetEyeableInfo();

            if (eyeableInfo.Count == 0)
            {
                curPriority = ConsiderPriority.Low;
            }


            Point curGrid = FindCurGrid();

            if (curGrid != LastGrid)
            {
                LastGrid = curGrid;
                UpdateCurGridTime(curGrid);
                enterNewGrid = true;
            }
        }
Ejemplo n.º 9
0
        public void Update(float seconds)
        {
            curTime += seconds;

            if (enterNewGrid)
            {
                Authorize();
                enterNewGrid = false;
            }

            List <IEyeableInfo> eyeableInfo = orderServer.GetEyeableInfo();

            if (eyeableInfo.Count != 0)
            {
                curPriority = ConsiderPriority.Vacancy;
                action.StopMove();
                action.StopRota();
            }

            action.Update(seconds);
        }
Ejemplo n.º 10
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;
        }
Ejemplo n.º 11
0
        public ConsiderSearchEnemy(Rectanglef mapSize, float raderRadius)
        {
            this.mapSize = mapSize;
            curPriority  = ConsiderPriority.Vacancy;

            int gridMaxX = (int)(mapSize.Width / raderRadius) + 1;
            int gridMaxY = (int)(mapSize.Height / raderRadius) + 1;

            grids = new float[gridMaxX, gridMaxY];
            for (int i = 0; i < gridMaxX; i++)
            {
                for (int j = 0; j < gridMaxY; j++)
                {
                    grids[i, j] = initialGridTime;
                }
            }

            gridWidth  = mapSize.Width / gridMaxX;
            gridHeight = mapSize.Height / gridMaxY;


            curTime = 0;
        }
Ejemplo n.º 12
0
        public ConsiderSearchEnemy ( Rectanglef mapSize, float raderRadius )
        {
            this.mapSize = mapSize;
            curPriority = ConsiderPriority.Vacancy;

            int gridMaxX = (int)(mapSize.Width / raderRadius) + 1;
            int gridMaxY = (int)(mapSize.Height / raderRadius) + 1;

            grids = new float[gridMaxX, gridMaxY];
            for (int i = 0; i < gridMaxX; i++)
            {
                for (int j = 0; j < gridMaxY; j++)
                {
                    grids[i, j] = initialGridTime;
                }
            }

            gridWidth = mapSize.Width / gridMaxX;
            gridHeight = mapSize.Height / gridMaxY;


            curTime = 0;
        }
Ejemplo n.º 13
0
        public void Update ( float seconds )
        {
            curTime += seconds;

            if (enterNewGrid)
            {
                Authorize();
                enterNewGrid = false;
            }

            List<IEyeableInfo> eyeableInfo = orderServer.GetEyeableInfo();
            if (eyeableInfo.Count != 0)
            {
                curPriority = ConsiderPriority.Vacancy;
                action.StopMove();
                action.StopRota();
            }

            action.Update( seconds );
        }
Ejemplo n.º 14
0
 public ConsiderAwayFromBorder(Rectanglef mapSize)
 {
     this.mapSize = mapSize;
     curPriority  = ConsiderPriority.Vacancy;
 }
Ejemplo n.º 15
0
 public ConsiderAwayFromEnemyTurret ( Rectanglef mapSize )
 {
     curPriority = ConsiderPriority.Vacancy;
     this.mapSize = mapSize;
 }
Ejemplo n.º 16
0
 public ConsiderKeepDistanceFromEnemy()
 {
     curPriority = ConsiderPriority.Vacancy;
 }
Ejemplo n.º 17
0
 public ConsiderAwayFromEnemyTurret(Rectanglef mapSize)
 {
     curPriority  = ConsiderPriority.Vacancy;
     this.mapSize = mapSize;
 }
Ejemplo n.º 18
0
 public void Observe ()
 {
     List<IEyeableInfo> eyeableInfo = orderServer.GetEyeableInfo();
     if (eyeableInfo.Count == 0)
     {
         curPriority = ConsiderPriority.Low;
     }
     else
     {
         curPriority = ConsiderPriority.Vacancy;
     }
 }
Ejemplo n.º 19
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;

        }
Ejemplo n.º 20
0
 public ConsiderKeepDistanceFromEnemy ()
 {
     curPriority = ConsiderPriority.Vacancy;
 }
Ejemplo n.º 21
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;
 }
Ejemplo n.º 22
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;
        }
Ejemplo n.º 23
0
        public void Observe ()
        {
            List<IEyeableInfo> eyeableInfo = orderServer.GetEyeableInfo();
            if (eyeableInfo.Count == 0)
            {
                curPriority = ConsiderPriority.Low;
            }


            Point curGrid = FindCurGrid();
            if (curGrid != LastGrid)
            {
                LastGrid = curGrid;
                UpdateCurGridTime( curGrid );
                enterNewGrid = true;
            }
        }
Ejemplo n.º 24
0
 public ConsiderRaderScan ( Rectanglef mapSize )
 {
     this.mapSize = mapSize;
     curPriority = ConsiderPriority.Vacancy;
     firstCircleFinished = false;
     lastState = State.Start;
 }