Ejemplo n.º 1
0
        public override float GetValue(NavigationCell navCell)
        {
            float distToAssistFallOff   = 200;
            float distToAssistFallOffSq = distToAssistFallOff * distToAssistFallOff;
            float bestDistToAssist      = 250;
            float bestDistToAssistSq    = bestDistToAssist * bestDistToAssist;
            float distToAssistSq        = Vector2.DistanceSquared(navCell.Position, Assistee.Position);
            float fallOff = Math.Abs(distToAssistSq - bestDistToAssistSq) / distToAssistFallOffSq;

            fallOff = 1 - LBE.MathHelper.Clamp(0, 1, fallOff);
            fallOff = LBE.MathHelper.Clamp(0, 1, 2 * fallOff);

            Goal  goal       = null;
            bool  canShoot   = false;
            float shootValue = 0;

            if (Game.Arena.RightGoal.Team == Assistee.Team)
            {
                goal       = Game.Arena.LeftGoal;
                canShoot   = navCell.CanShootLeft;
                shootValue = navCell.CanShootLeftValue;
            }
            else
            {
                goal       = Game.Arena.RightGoal;
                canShoot   = navCell.CanShootRight;
                shootValue = navCell.CanShootRightValue;
            }

            bool canAssist       = navCell.CanSeePlayer[(int)Assistee.PlayerIndex];
            Team otherTeam       = Assistee.Team.TeamID == TeamId.TeamOne ? Game.GameManager.Teams[1] : Game.GameManager.Teams[0];
            bool assistIntercept = true;

            float shootWeight = 0.3f;
            float assistValue = 0.0f;

            if (canAssist && assistIntercept)
            {
                assistValue += 1 - shootWeight;
            }
            if (canAssist && canShoot && assistIntercept)
            {
                assistValue += shootWeight * shootValue;
            }

            Vector2 assistDir = navCell.Position - Assistee.Position;
            Vector2 goalDir   = goal.Position - Assistee.Position;

            if (Vector2.Dot(assistDir, goalDir) < 0)
            {
                assistValue *= 0.5f;
            }

            assistValue *= fallOff;
            return(assistValue);
        }
Ejemplo n.º 2
0
        public void NavigateToBestValue(PotentialMap map)
        {
            Point index = Game.GameManager.Navigation.IndexFromPosition(Player.Position);

            if (Game.GameManager.Navigation.Parameters.Debug)
            {
                Engine.Debug.Screen.ResetBrush(); Engine.Debug.Screen.Brush.DrawSurface = false;
                Engine.Debug.Screen.AddSquare(Game.GameManager.Navigation.NavigationGrid[index].Position, Game.GameManager.Navigation.Parameters.GridSpacing / 2);
            }

            if (map.Grid.TestBounds(index))
            {
                Vector2 grad = map.Gradient(index);

                Engine.Log.Debug("Player " + Player.PlayerIndex + " panic", "no");
                if (grad != Vector2.Zero)
                {
                    Move(grad);
                }
                else
                {
                    NavigationCell bestCell = null;
                    NavigationCell navCell  = Game.GameManager.Navigation.NavigationGrid[index];
                    foreach (var nextCell in navCell.Neighbours)
                    {
                        if (nextCell == null)
                        {
                            continue;
                        }

                        if (map.Grid[nextCell.Index].Value < map.Grid[index].Value)
                        {
                            continue;
                        }

                        if (bestCell != null && map.Grid[nextCell.Index].Value < map.Grid[bestCell.Index].Value)
                        {
                            continue;
                        }

                        Engine.Log.Debug("Player " + Player.PlayerIndex + " panic", "yes");

                        if (NavigationManager.RayCastVisibility(Player.Position, nextCell.Position))
                        {
                            bestCell = nextCell;
                        }
                    }

                    if (bestCell != null)
                    {
                        MoveToPosition(bestCell.Position);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public override float GetValue(NavigationCell navCell)
        {
            float acc      = navCell.CanShootRightValue;
            float accCount = 1;
            int   iNeigh   = 0;

            foreach (var nextCell in navCell.Neighbours)
            {
                if (navCell.CanNavigateToNeighbour[iNeigh])
                {
                    acc += nextCell.CanShootRightValue;
                    accCount++;
                }
                iNeigh++;
            }
            return(acc / accCount);
        }
Ejemplo n.º 4
0
 public override float GetValue(NavigationCell navCell)
 {
     return(GetWeight(navCell.Position) * Value);
 }
Ejemplo n.º 5
0
 public virtual float GetValue(NavigationCell navCell)
 {
     return(0);
 }