Пример #1
0
        /* Returns all player from the team who have another vertical direction to the target */
        public List<Player> PlayersWithOtherVerticalDirection(Point targetPoint, int verticalDirection, Team team)
        {
            Pathfinding pathfinding = new Pathfinding();
            List<Player> validPlayers = new List<Player>();

            foreach (Player player in team.Players)
            {
                int movementDirection = pathfinding.CalculateVerticalDirection(player.Location, targetPoint);
                if (movementDirection != verticalDirection)
                {
                    validPlayers.Add(player);
                }
            }

            return validPlayers;
        }
Пример #2
0
        /// <summary>
        /// For the case that the own team controls the ball and the player stands close to the enemy's goal.
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public virtual PlayerAction ActionGoalClose(Player player)
        {
            Pathfinding pathfinding = new Pathfinding();
            Goal enemyTeamGoal = GameAI.GetEnemyTeam(GameAI.PlayersTeam(player)).TeamGoal;

            Point ballNextRoundLocation = GameAI.BallNextRoundLocation();
            int ballDistanceToEnemyGoal = Math.Abs(enemyTeamGoal.XCoordinate - ballNextRoundLocation.X);

            Point targetPoint = player.Location;

            targetPoint.Y = enemyTeamGoal.MiddlePoint.Y + pathfinding.CalculateVerticalDirection(player.Location, enemyTeamGoal.MiddlePoint) * 3;
            if (ballDistanceToEnemyGoal > player.MaxSpeed * 2)
            {
                targetPoint.X = ballNextRoundLocation.X + (pathfinding.CalculateHorizontalDirection(player.Location, enemyTeamGoal.MiddlePoint) * 5);
            }

            Point freePoint = SearchFreeTargetPoint(player, RunRoom(GameAI.PlayersTeam(player)), targetPoint, 5, 3);

            return new PlayerAction(null, freePoint, ActionType.Run);
        }