#include "PacmanRed.h" //#include "Pacman.h" #include "core/CoreIncludes.h" #include "BulletDynamics/Dynamics/btRigidBody.h" namespace orxonox{ RegisterClass(PacmanRed); PacmanRed::PacmanRed(Context* context) : PacmanGhost(context){ RegisterObject(PacmanRed); this->target_x=0; this->target_z=15; this->lastPlayerPassedPoint=Vector3(0,0,0); //Vector3(70,10,-135); this->isNearPlayer=false; } /** @brief Method for creating a ghost through XML. */ void PacmanRed::XMLPort(Element& xmlelement, XMLPort::Mode mode) { SUPER(PacmanRed, XMLPort, xmlelement, mode); } /*void PacmanRed::setPlayerPos(Vector3 _playerPos) { this->playerPos = _playerPos; }*/ void PacmanRed::tick(float dt) { //std::cout<<"LemanExpress5"<actuelposition = this->getPosition(); for(int u=0; u < 67; u++){//always check if player passed a point //if(possibleposition[u]!=Vector3(0,10,15)){ if(jeanfindpos(this->getPlayerPos(), possibleposition[u])){ //if(!findpos(possibleposition[u],Vector3(0,10,15))){ this->lastPlayerPassedPoint=possibleposition[u]; } //} //} } /*if((playerFindPos(this->actuelposition, this->getPlayerPos()))&&(isNearPlayer==false)){ isNearPlayer=true; setNewTargetRed(this->getPlayerPos()); } else if (!(playerFindPos(this->actuelposition, this->getPlayerPos())&&(isNearPlayer==true))){ isNearPlayer=false; setNewTargetRed(this->pointInFrontOfPlayer); }*/ std::cout<lastPlayerPassedPoint<pointInFrontOfPlayer<actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){ //std::cout<<"LemanExpress1"<ismoving = false; } //Move, if ghost hasn't arrived yet if(this->ismoving){ //std::cout<<"LemanExpress2"<actuelposition.z-target_z)<0.5)) { velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z)); move(dt, actuelposition, velocity); } if(!(abs(this->actuelposition.x-target_x)<0.5)){ velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,0); move(dt, actuelposition, velocity); } //std::cout<<"LemanExpress4"<lastPlayerPassedPoint==Vector3(0,0,0)){ //as long as the player has not started the game, //i.e. lastPlayerPastPoint is (0,0,0), red pacman //cannot possibly move, because it needs the position //of the player to move accordingly this->ismoving=false; } //Check on which position the ghost has arrived and set new target else{ std::cout<<"LemanExpress3"<target_x, 10, this->target_z); //nextMove(this->getPlayerPos(), redPos); int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos()); this->pointInFrontOfPlayer=frontPosition(); //getPointInFrontOfPacman(lastPlayerPassedPoint, directionV); if(!findpos(this->actuelposition, lastPlayerPassedPoint)){ /*std::cout<getPlayerPos()<lastPlayerPassedPoint<pointInFrontOfPlayer<actuelposition<actuelposition, lastPlayerPassedPoint)){// red pacman is at lastPlayerPassedPoint /*std::cout<<"dhdidjop"<getPlayerPos()<lastPlayerPassedPoint<pointInFrontOfPlayer<actuelposition<