www.pudn.com > Product_Submit2004.rar > TestDudeV2.cc, change:2004-10-12,size:3919b


 
#include "TestDudeV2.h" 
#include "../Common/Common.h" 
#include "../TOOLS/BallTricks.h" 
#include "../TOOLS/BasicTricks.h" 
#include "../TOOLS/HeadTricks.h" 
#include "../TOOLS/ComplexTricks.h" 
#include "../TOOLS/MovementTricks.h" 
 
// Simple chaser that tries to score goals :). 
TestDudeV2::TestDudeV2() { 
  configuration_.ParseFile("/ms/open-r/mw/data/tdv2.cfg"); 
 
  debugOutput = configuration_.GetAsBool("DebugOutput"); 
 
  currentTrick = new BasicTricks::NullBody(); 
  headTrick = new BasicTricks::NullHead(); 
  inPlaying = false; 
} 
 
TestDudeV2::~TestDudeV2() { 
  delete currentTrick; 
  delete headTrick; 
} 
 
void TestDudeV2::NewGoHomeModel() { 
  if (inPlaying) { 
    delete headTrick; 
    headTrick = new HeadTricks::HeadPan(85,-85,3,50);   // MQ 19/6 .. changed from (70,-70,0,12) 
    headTrick->Start(); 
    delete currentTrick; 
    currentTrick = new BasicTricks::NullBody(); 
    currentTrick->Start(); 
  } 
 
  int hC = headTrick->Continue(); 
  if (hC < 1) { 
    delete headTrick; 
    headTrick = new HeadTricks::HeadPan(85,-85,3,50);   // MQ 19/6 .. changed from (70,-70,0,12) 
    headTrick->Start(); 
  } 
  inPlaying = false; 
 
/*  if (frame_ % 300 == 0) { 
    delete headTrick; 
    headTrick = new HeadTricks::FixateOnBeacon(75); 
    headTrick->Start(); 
  }*/ 
} 
 
void TestDudeV2::NewReadyModel() { 
  if (inPlaying) { 
    delete headTrick; 
    headTrick = new HeadTricks::HeadPan(85,-85,3,50);   // MQ 19/6 .. changed from (70,-70,0,12) 
    headTrick->Start(); 
    delete currentTrick; 
    currentTrick = new BasicTricks::NullBody(); 
    currentTrick->Start(); 
  } 
 
  int hC=headTrick->Continue(); 
//char* hMsg = headTrick->GetErrorMsg(hC); 
  if (!currentTrick->IsUsingHead() && (hC < 1)) { 
    headTrick = new HeadTricks::HeadPan(85,-85,3,50);   // MQ 19/6 .. changed from (70,-70,0,12) 
    headTrick->Start(); 
  } else if (vo_ball_ != NULL && strcmp(headTrick->GetName(),"HeadPan")==0) { 
    delete headTrick; 
    headTrick = new HeadTricks::FollowBallWithHeadSticky(10); 
    headTrick->Start(); 
  } 
 
  inPlaying = false; 
} 
 
void TestDudeV2::NewPlayingModel() { 
  if (!inPlaying) { 
    delete headTrick; 
    headTrick = new BasicTricks::NullHead(); 
    headTrick->Start(); 
 
    delete currentTrick; 
    currentTrick = new BasicTricks::NullBody(); 
    currentTrick->Start(); 
  } 
  inPlaying=true; 
 
  int hC = headTrick->Continue(); 
  if (hC < 1) { 
    delete headTrick; 
    headTrick = new BasicTricks::NullHead(); 
    headTrick->Start(); 
  } 
 
  int cC = currentTrick->Continue(); 
  if (cC < 1) { 
    if (vo_ball_ != NULL) { 
      if (debugOutput) 
        cout << "TestDudeV2: Ball visible. Chase !" << endl << flush; 
      delete currentTrick; 
      currentTrick = new ComplexTricks::AdvancedChaseWithKick(); 
      currentTrick->Start(); 
 
      headTrick->Abort(); 
      delete headTrick; 
      headTrick = new BasicTricks::NullHead(); 
      headTrick->Start(); 
    } else if (strcmp(currentTrick->GetName(),"AdvancedChaseWithKick") == 0){ 
      if (debugOutput) 
        cout << "TestDudeV2: Ball not visible, and was chasing/kicking. PostKickSearch !" << endl << flush; 
 
      delete currentTrick; 
     // if (cC == 0) currentTrick = new ComplexTricks::PostChaseSearchForBall(true,60.0); 
    //  else currentTrick = new ComplexTricks::PostChaseSearchForBall(false,60.0); 
      currentTrick = new BasicTricks::NullBody(); 
      currentTrick->Start(); 
 
      delete headTrick; 
      headTrick = new BasicTricks::NullHead(); 
      headTrick->Start(); 
    } else { 
      if (debugOutput) 
        cout << "TestDudeV2: Ball not visible" << endl << flush; 
 
      delete currentTrick; 
      currentTrick = new MovementTricks::SearchForBall(360.0); 
      currentTrick->Start(); 
 
      delete headTrick; 
      headTrick = new BasicTricks::NullHead(); 
      headTrick->Start(); 
    } 
  } 
 
}