C# 클래스 SimpleSoccer.Net.SoccerTeam

Defines a Team of SoccerBasePlayers for the Soccer game simulation
파일 보기 프로젝트 열기: soshimozi/SimpleSoccer.Net 1 사용 예제들

공개 메소드들

메소드 설명
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