Esempio n. 1
0
void Player::think()
{    
  static int count=0;
  static int counter=0;
  if(mustBeam())
  {
    
   if( (count % 10)==0 )
       beam();
   
   count++;
   if(count>10)
       count=0;
  }
  
  if(mustBeforKickOfBeam())
  {  
       if( (counter % 10)==0 )
          beforKickOfBeam();
   
       counter++;
       if(counter>10)
           counter=0;
  }
  
  
    switch ( WorldModel::instance().getPlayMode() )
    {
        case PM_BeforeKickOff :
            return playBeforeKickOff();
            break;
        case PM_KickOff_Left:
        case PM_KickOff_Right:
            return playKickOff();
            break;
        case PM_PlayOn:
            return playPlayOn();
            break;
        case PM_KickIn_Left:
        case PM_KickIn_Right:
            return playKickIn();
            break;
        case PM_CORNER_KICK_LEFT:
        case PM_CORNER_KICK_RIGHT:
            return playCornerKick();
            break;
        case PM_GOAL_KICK_LEFT:
        case PM_GOAL_KICK_RIGHT:
            return playGoalKick();
            break;
        case PM_OFFSIDE_LEFT:
        case PM_OFFSIDE_RIGHT:
            return playOffSide();
            break;       
        case PM_GameOver:
            return playGameOver();
            break;
        case PM_Goal_Left:
        case PM_Goal_Right:
            return playGoal();
            break;
        case PM_FREE_KICK_LEFT:
        case PM_FREE_KICK_RIGHT:
            return playFreeKick();
            break;
        default:
            cerr<<"[WARNING] Player can not handle this Play Mode!\n";
            break;
    }
}
Esempio n. 2
0
    /**
     * the entry of "Think" thread
     * 1-GK shout
     * 2-different play mode
     * 3-CameraMotion
     *
     * @author Xu Yuan
     *
     * @return boost::shared_ptr<Action>
     */
    boost::shared_ptr<Action> Player::think() {
        boost::shared_ptr<Actions> actions(new Actions());
        if (SHM.IsCanSay()) {
            shared_ptr<Say> SHMsay(new Say(SHM.getSayString()));
            actions->add(SHMsay);
        }
        //TT add for controling CameraMotion
        mCameraMotionMode = -1; //mCameraMotionMode will be changed in "play mode"
        //play mode
        switch (WM.getPlayMode()) {
            case PM_BEFORE_KICK_OFF:
                actions->add(playBeforeKickOff());
                break;
            case PM_KICK_OFF_LEFT:
            case PM_KICK_OFF_RIGHT:
                actions->add(playKickOff());
                break;
            case PM_PLAY_ON:
                actions->add(playPlayOn());
                break;
            case PM_KICK_IN_LEFT:
            case PM_KICK_IN_RIGHT:
                actions->add(playKickIn());
                break;
            case PM_CORNER_KICK_LEFT:
            case PM_CORNER_KICK_RIGHT:
                actions->add(playCornerKick());
                break;
            case PM_GOAL_KICK_LEFT:
            case PM_GOAL_KICK_RIGHT:
                actions->add(playGoalKick());
                break;
            case PM_OFFSIDE_LEFT:
            case PM_OFFSIDE_RIGHT:
                actions->add(playOffSide());
                break;
            case PM_GAME_OVER:
                actions->add(playGameOver());
                break;
            case PM_GOAL_LEFT:
            case PM_GOAL_RIGHT:
                actions->add(playGoal());
                break;
            case PM_FREE_KICK_LEFT:
            case PM_FREE_KICK_RIGHT:
                actions->add(playFreeKick());
                break;
            default:
                cerr << "[WARNING] Player can not handle this Play Mode!\n";
                actions->add(playPlayOn());
                break;
        }

        //camera motion
        shared_ptr<JointAction> jact(new JointAction(false));
        if (NULL == WM.lastPerception().vision().get()) {
            jact->setForCamera(0, WM.getSearchSpeed().x());
            jact->setForCamera(1, WM.getSearchSpeed().y());
            actions->add(jact);
        } else {
            shared_ptr<CameraMotion> cm(new CameraMotion(mCameraMotionMode));
            actions->add(cm->perform());
        }
        return actions;
    }