C# Class SimpleSoccer.Net.SoccerTeam

Defines a Team of SoccerBasePlayers for the Soccer game simulation
Afficher le fichier Open project: soshimozi/SimpleSoccer.Net Class Usage Examples

Méthodes publiques

Méthode Description
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

Private Methods

Méthode Description
CreatePlayers ( ) : void

Create the players for the team

LostControl ( ) : void

Method Details

AllPlayersAtHome() public méthode

Determines if any of the team are not located within their home region
public AllPlayersAtHome ( ) : bool
Résultat bool

CalculateClosestOpponentToGoal() public méthode

Calculates the closest opponent to this teams goal
public CalculateClosestOpponentToGoal ( ) : void
Résultat void

CalculateClosestPlayerToBall() public méthode

sets _playerClosestToBall to the player closest to the ball
public CalculateClosestPlayerToBall ( ) : void
Résultat void

CanShoot() public méthode

public CanShoot ( Vector2D BallPos, double power ) : bool
BallPos Vector2D
power double
Résultat bool

CanShoot() public méthode

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
Résultat bool

DetermineBestSupportingAttacker() public méthode

calculate the closest player to the SupportSpot
public DetermineBestSupportingAttacker ( ) : PlayerBase
Résultat PlayerBase

DetermineBestSupportingPosition() public méthode

Calculates the best supporting position
public DetermineBestSupportingPosition ( ) : void
Résultat void

FindPass() public méthode

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
Résultat bool

FindPlayerById() public méthode

Finds a player by its id
public FindPlayerById ( int playerId ) : PlayerBase
playerId int
Résultat PlayerBase

GetBestPassToReceiver() public méthode

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
Résultat bool

GetSupportSpot() public méthode

public GetSupportSpot ( ) : Vector2D
Résultat Vector2D

IsOpponentWithinRadius() public méthode

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
Résultat bool

IsPassSafeFromAllOpponents() public méthode

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
Résultat bool

IsPassSafeFromOpponent() public méthode

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
Résultat bool

Render() public méthode

Render the soccer team
public Render ( Graphics g ) : void
g System.Drawing.Graphics
Résultat void

RequestPass() public méthode

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
Résultat void

ReturnAllFieldPlayersToHome() public méthode

sends a message to all players to return to their home areas forthwith
public ReturnAllFieldPlayersToHome ( ) : void
Résultat void

SetPlayerHomeRegion() public méthode

Sets a particular players home region index
public SetPlayerHomeRegion ( int playerId, int region ) : void
playerId int
region int
Résultat void

SoccerTeam() public méthode

public SoccerTeam ( SoccerGoal homeGoal, SoccerGoal opponentsGoal, SoccerPitch pitch, SoccerTeamColor color ) : System
homeGoal SoccerGoal
opponentsGoal SoccerGoal
pitch SoccerPitch
color SoccerTeamColor
Résultat System

Update() public méthode

Called every tick to update the team state
public Update ( ) : void
Résultat void

UpdateTargetsOfWaitingPlayers() public méthode

Finds targets for waiting players
public UpdateTargetsOfWaitingPlayers ( ) : void
Résultat void