void Attacking::Enter(SoccerTeam* team) { #ifdef DEBUG_TEAM_STATES debug_con << team->Name() << " entering Attacking state" << ""; #endif //these define the home regions for this state of each of the players const int BlueRegions[TeamSize] = {1,12,14,6,4}; const int RedRegions[TeamSize] = {16,3,5,9,13}; //set up the player's home regions if (team->Color() == SoccerTeam::blue) { ChangePlayerHomeRegions(team, BlueRegions); } else { ChangePlayerHomeRegions(team, RedRegions); } //if a player is in either the Wait or ReturnToHomeRegion states, its //steering target must be updated to that of its new home region to enable //it to move into the correct position. team->UpdateTargetsOfWaitingPlayers(); }
void Defending::Enter(BallTeam* team) { #ifdef DEBUG_TEAM_STATES debug_con << team->Name() << " entering Defending state" << "\n"; #endif //these define the home regions for this state of each of the players const int RedRegions[TeamSize] = {16,20,23,21,13}; // const int RedRegions[TeamSize] = {16,9,11,12,14}; const int BlueRegions[TeamSize] = {1,6,8,3,5}; //set up the player's home regions if (team->Color() == BallTeam::blue) { ChangePlayerHomeRegions(team, BlueRegions); } else { ChangePlayerHomeRegions(team, RedRegions); } //if a player is in either the Wait or ReturnToHomeRegion states, its //steering target must be updated to that of its new home region team->UpdateTargetsOfWaitingPlayers(); }
void PrepareForKickOff::Enter(BallTeam* team) { //reset key player pointers team->SetControllingPlayer(NULL); team->SetSupportingPlayer(NULL); team->SetReceiver(NULL); team->SetPlayerClosestToBall(NULL); int color = team->GetGame()->GetScored(); if(color == BallTeam::blue) printf("blue get scored\n"); else printf("red get scored\n"); if(team->Color() == BallTeam::blue){ if(team->GetGame()->GetScored() == BallTeam::blue){ const int BlueRegions[TeamSize] = {1,6,8,3,5}; ChangePlayerHomeRegions(team, BlueRegions); } else {//red team get score const int BlueRegions[TeamSize] = {16,20,23,21,13}; ChangePlayerHomeRegions(team, BlueRegions); } } else //red team { if(team->GetGame()->GetScored() == BallTeam::red){ const int RedRegions[TeamSize] = {16,20,23,21,13}; ChangePlayerHomeRegions(team, RedRegions); } else{ const int RedRegions[TeamSize] = {1,6,8,3,5}; ChangePlayerHomeRegions(team, RedRegions); } } team->UpdateTargetsOfWaitingPlayers(); if(team->GetGame()->GetScored() == BallTeam::blue) { double x = team->GetGame()->PlayingArea()->Left(); double top = team->GetGame()->PlayingArea()->Top(); double y = RandInRange(-top, top); team->GetGame()->GetBall()->PlaceAtPosition(Vector2D(x,y)); } else if(team->GetGame()->GetScored() == BallTeam::red) { double x = team->GetGame()->PlayingArea()->Right(); double top = team->GetGame()->PlayingArea()->Top(); double y = RandInRange(-top, top); team->GetGame()->GetBall()->PlaceAtPosition(Vector2D(x,y)); } if(team->GetGame()->GetScored() != team->Color()){ PlayerBase* it = team->GetPreparePlayer(); FieldPlayer* plyr = static_cast<FieldPlayer*>(it); plyr->GetFSM()->ChangeState(ChaseBall::Instance()); printf("I let player:%d to get ball\n",plyr->ID()); //getchar(); } }
void Defending::Enter(FootBallTeam* team) { const int BlueRegions[TeamSize] = {1,22,19,16,11,8,6}; const int RedRegions[TeamSize] = {45,25,28,31,32,35,41}; if (team->Color() == FootBallTeam::blue) { ChangePlayerHomeRegions(team, BlueRegions); } else { ChangePlayerHomeRegions(team, RedRegions); } team->UpdateWaitingPlayers(); }