C# Класс SimpleSoccer.Net.SoccerTeam

Defines a Team of SoccerBasePlayers for the Soccer game simulation
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
AllPlayersAtHome ( ) : bool

Determines if any of the team are not located within their home region

CalculateClosestOpponentToGoal ( ) : void

Calculates the closest opponent to this teams goal

CalculateClosestPlayerToBall ( ) : void

sets _playerClosestToBall to the player closest to the ball

CanShoot ( Vector2D BallPos, double power ) : bool
CanShoot ( Vector2D BallPos, double power, Vector2D &ShotTarget ) : bool

Given a ball position, a kicking power and a reference to a vector2D this function will sample random positions along the opponent's goal- mouth and check to see if a goal can be scored if the ball was to be kicked in that direction with the given power. If a possible shot is found, the function will immediately return true, with the target position stored in the vector ShotTarget.

DetermineBestSupportingAttacker ( ) : PlayerBase

calculate the closest player to the SupportSpot

DetermineBestSupportingPosition ( ) : void

Calculates the best supporting position

FindPass ( PlayerBase passer, PlayerBase &receiver, Vector2D &PassTarget, double power, double MinPassingDistance ) : bool

The best pass is considered to be the pass that cannot be intercepted by an opponent and that is as far forward of the receiver as possible

FindPlayerById ( int playerId ) : PlayerBase

Finds a player by its id

GetBestPassToReceiver ( PlayerBase passer, PlayerBase receiver, Vector2D &PassTarget, double power ) : bool

Three potential passes are calculated. One directly toward the receiver's current position and two that are the tangents from the ball position to the circle of radius 'range' from the receiver. These passes are then tested to see if they can be intercepted by an opponent and to make sure they terminate within the playing area. If all the passes are invalidated the function returns false. Otherwise the function returns the pass that takes the ball closest to the opponent's goal area.

GetSupportSpot ( ) : Vector2D
IsOpponentWithinRadius ( Vector2D pos, double rad ) : bool

returns true if an opposing player is within the radius of the position given as a parameter

IsPassSafeFromAllOpponents ( Vector2D from, Vector2D target, PlayerBase receiver, double PassingForce ) : bool

Tests a pass from position 'from' to position 'target' against each member of the opposing team. Returns true if the pass can be made without getting intercepted

IsPassSafeFromOpponent ( Vector2D from, Vector2D target, PlayerBase receiver, PlayerBase opp, double PassingForce ) : bool

test if a pass from 'from' to 'to' can be intercepted by an opposing player

Render ( Graphics g ) : void

Render the soccer team

RequestPass ( FieldPlayer requester ) : void

This tests to see if a pass is possible between the requester and the controlling player. If it is possible a message is sent to the controlling player to pass the ball asap.

ReturnAllFieldPlayersToHome ( ) : void

sends a message to all players to return to their home areas forthwith

SetPlayerHomeRegion ( int playerId, int region ) : void

Sets a particular players home region index

SoccerTeam ( SoccerGoal homeGoal, SoccerGoal opponentsGoal, SoccerPitch pitch, SoccerTeamColor color ) : System
Update ( ) : void

Called every tick to update the team state

UpdateTargetsOfWaitingPlayers ( ) : void

Finds targets for waiting players

Приватные методы

Метод Описание
CreatePlayers ( ) : void

Create the players for the team

LostControl ( ) : void

Описание методов

AllPlayersAtHome() публичный Метод

Determines if any of the team are not located within their home region
public AllPlayersAtHome ( ) : bool
Результат bool

CalculateClosestOpponentToGoal() публичный Метод

Calculates the closest opponent to this teams goal
public CalculateClosestOpponentToGoal ( ) : void
Результат void

CalculateClosestPlayerToBall() публичный Метод

sets _playerClosestToBall to the player closest to the ball
public CalculateClosestPlayerToBall ( ) : void
Результат void

CanShoot() публичный Метод

public CanShoot ( Vector2D BallPos, double power ) : bool
BallPos Vector2D
power double
Результат bool

CanShoot() публичный Метод

Given a ball position, a kicking power and a reference to a vector2D this function will sample random positions along the opponent's goal- mouth and check to see if a goal can be scored if the ball was to be kicked in that direction with the given power. If a possible shot is found, the function will immediately return true, with the target position stored in the vector ShotTarget.
public CanShoot ( Vector2D BallPos, double power, Vector2D &ShotTarget ) : bool
BallPos Vector2D
power double
ShotTarget Vector2D
Результат bool

DetermineBestSupportingAttacker() публичный Метод

calculate the closest player to the SupportSpot
public DetermineBestSupportingAttacker ( ) : PlayerBase
Результат PlayerBase

DetermineBestSupportingPosition() публичный Метод

Calculates the best supporting position
public DetermineBestSupportingPosition ( ) : void
Результат void

FindPass() публичный Метод

The best pass is considered to be the pass that cannot be intercepted by an opponent and that is as far forward of the receiver as possible
public FindPass ( PlayerBase passer, PlayerBase &receiver, Vector2D &PassTarget, double power, double MinPassingDistance ) : bool
passer PlayerBase
receiver PlayerBase
PassTarget Vector2D
power double
MinPassingDistance double
Результат bool

FindPlayerById() публичный Метод

Finds a player by its id
public FindPlayerById ( int playerId ) : PlayerBase
playerId int
Результат PlayerBase

GetBestPassToReceiver() публичный Метод

Three potential passes are calculated. One directly toward the receiver's current position and two that are the tangents from the ball position to the circle of radius 'range' from the receiver. These passes are then tested to see if they can be intercepted by an opponent and to make sure they terminate within the playing area. If all the passes are invalidated the function returns false. Otherwise the function returns the pass that takes the ball closest to the opponent's goal area.
public GetBestPassToReceiver ( PlayerBase passer, PlayerBase receiver, Vector2D &PassTarget, double power ) : bool
passer PlayerBase
receiver PlayerBase
PassTarget Vector2D
power double
Результат bool

GetSupportSpot() публичный Метод

public GetSupportSpot ( ) : Vector2D
Результат Vector2D

IsOpponentWithinRadius() публичный Метод

returns true if an opposing player is within the radius of the position given as a parameter
public IsOpponentWithinRadius ( Vector2D pos, double rad ) : bool
pos Vector2D
rad double
Результат bool

IsPassSafeFromAllOpponents() публичный Метод

Tests a pass from position 'from' to position 'target' against each member of the opposing team. Returns true if the pass can be made without getting intercepted
public IsPassSafeFromAllOpponents ( Vector2D from, Vector2D target, PlayerBase receiver, double PassingForce ) : bool
from Vector2D
target Vector2D
receiver PlayerBase
PassingForce double
Результат bool

IsPassSafeFromOpponent() публичный Метод

test if a pass from 'from' to 'to' can be intercepted by an opposing player
public IsPassSafeFromOpponent ( Vector2D from, Vector2D target, PlayerBase receiver, PlayerBase opp, double PassingForce ) : bool
from Vector2D
target Vector2D
receiver PlayerBase
opp PlayerBase
PassingForce double
Результат bool

Render() публичный Метод

Render the soccer team
public Render ( Graphics g ) : void
g System.Drawing.Graphics
Результат void

RequestPass() публичный Метод

This tests to see if a pass is possible between the requester and the controlling player. If it is possible a message is sent to the controlling player to pass the ball asap.
public RequestPass ( FieldPlayer requester ) : void
requester FieldPlayer
Результат void

ReturnAllFieldPlayersToHome() публичный Метод

sends a message to all players to return to their home areas forthwith
public ReturnAllFieldPlayersToHome ( ) : void
Результат void

SetPlayerHomeRegion() публичный Метод

Sets a particular players home region index
public SetPlayerHomeRegion ( int playerId, int region ) : void
playerId int
region int
Результат void

SoccerTeam() публичный Метод

public SoccerTeam ( SoccerGoal homeGoal, SoccerGoal opponentsGoal, SoccerPitch pitch, SoccerTeamColor color ) : System
homeGoal SoccerGoal
opponentsGoal SoccerGoal
pitch SoccerPitch
color SoccerTeamColor
Результат System

Update() публичный Метод

Called every tick to update the team state
public Update ( ) : void
Результат void

UpdateTargetsOfWaitingPlayers() публичный Метод

Finds targets for waiting players
public UpdateTargetsOfWaitingPlayers ( ) : void
Результат void