Changeset 9142 for code/branches/newlevel2012/src
- Timestamp:
- Apr 29, 2012, 5:22:56 PM (13 years ago)
- Location:
- code/branches/newlevel2012/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.cc
r9139 r9142 62 62 #include "worldentities/pawns/Pawn.h" 63 63 #include "worldentities/pawns/SpaceShip.h" 64 64 #include "controllers/WaypointController.h" 65 66 #include "graphics/Model.h" 67 #include "infos/PlayerInfo.h" 68 65 69 #include "chat/ChatManager.h" 66 70 … … 78 82 /* Temporary hack to allow the player to add towers */ 79 83 this->dedicatedAddTower_ = createConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) ); 80 84 85 // Quick hack to test waypoints 86 createConsoleCommand( "aw", createExecutor( createFunctor(&TowerDefense::addWaypointsAndFirstEnemy, this) ) ); 81 87 } 82 88 … … 149 155 SUPER(TowerDefense, tick, dt); 150 156 151 static bool test = false;152 if ( !test)157 static int test = 0; 158 if (++test == 10) 153 159 { 154 orxout()<< "First tick." <<endl; 160 orxout()<< "10th tick." <<endl; 161 /* 162 for (std::set<SpawnPoint*>::iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); it++) 163 { 164 orxout() << "checking spawnpoint with name " << (*it)->getSpawnClass()->getName() << endl; 165 } 166 */ 167 168 //addWaypointsAndFirstEnemy(); 169 155 170 } 156 test = true;157 171 } 172 173 // Function to test if we can add waypoints using code only. Doesn't work yet 174 175 // THE PROBLEM: WaypointController's getControllableEntity() returns null, so it won't track. How do we get the controlableEntity to NOT BE NULL??? 176 177 void TowerDefense::addWaypointsAndFirstEnemy() 178 { 179 SpaceShip *newShip = new SpaceShip(this->center_); 180 newShip->addTemplate("spaceshipassff"); 181 182 WaypointController *newController = new WaypointController(newShip); 183 newController->setAccuracy(3); 184 185 Model *wayPoint1 = new Model(newController); 186 wayPoint1->setMeshSource("crate.mesh"); 187 wayPoint1->setPosition(7,-7,5); 188 wayPoint1->setScale(0.2); 189 190 Model *wayPoint2 = new Model(newController); 191 wayPoint2->setMeshSource("crate.mesh"); 192 wayPoint2->setPosition(7,7,5); 193 wayPoint2->setScale(0.2); 194 195 newController->addWaypoint(wayPoint1); 196 newController->addWaypoint(wayPoint2); 197 198 // The following line causes the game to crash 199 // newController -> getPlayer() -> startControl(newShip); 200 newShip->setController(newController); 201 newShip->setPosition(-7,-7,5); 202 newShip->setScale(0.1); 203 newShip->addSpeed(1); 204 205 206 207 // this->center_->attach(newShip); 208 } 158 209 159 210 /* -
code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.h
r9141 r9142 58 58 //virtual void playerScored(PlayerInfo* player); 59 59 60 60 61 /* Called by TowerDefenseCenterpoint upon game start 61 62 The centerpoint is used to create towers … … 72 73 // WeakPtr<TowerDefenseCenterpoint> center_; 73 74 TowerDefenseCenterpoint *center_; 75 76 void addWaypointsAndFirstEnemy(); 74 77 }; 75 78 } -
code/branches/newlevel2012/src/orxonox/controllers/WaypointController.cc
r8891 r9142 62 62 void WaypointController::tick(float dt) 63 63 { 64 64 if (!this->isActive()) 65 65 return; 66 67 orxout() << "(" << this->waypoints_.size() << ") entity: " << this->getControllableEntity() << endl; 68 66 69 67 70 if (this->waypoints_.size() == 0 || !this->getControllableEntity()) 68 71 return; 69 72 73 printf("3"); 74 70 75 if (this->waypoints_[this->currentWaypoint_]->getWorldPosition().squaredDistance(this->getControllableEntity()->getPosition()) <= this->squaredaccuracy_) 71 76 this->currentWaypoint_ = (this->currentWaypoint_ + 1) % this->waypoints_.size(); 77 78 printf("4"); 72 79 73 80 this->moveToPosition(this->waypoints_[this->currentWaypoint_]->getWorldPosition());
Note: See TracChangeset
for help on using the changeset viewer.