Changeset 9142
- Timestamp:
- Apr 29, 2012, 5:22:56 PM (13 years ago)
- Location:
- code/branches/newlevel2012
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/newlevel2012/data/levels/towerDefense.oxw
r9141 r9142 65 65 <!-- Spawns the camera, attached to a crate --> 66 66 <SpawnPoint team=0 position="0,0,0" spawnclass=Pawn pawndesign=centerpointmark /> 67 <!--TeamSpawnPoint team=1 position="-7,7,4" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff /--> 67 68 68 69 <!--SpawnPoint team=1 position="0,0,10" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /--> 69 70 <!--SpawnPoint team=0 position="0,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /--> 70 71 71 <!--SpaceShip position="-10,0,20" lookat="0,0,0" >72 <!--SpaceShip position="-10,0,20" lookat="0,0,0" scale=0.3> 72 73 <templates> 73 74 <Template link=spaceshipassff /> … … 76 77 <WaypointController accuracy=3> 77 78 <waypoints> 78 <Model mesh="cube.mesh" scale= 1 position="110,90,20" />79 <Model mesh="cube.mesh" scale= 2 position="290,90,20" />80 <Model mesh="cube.mesh" scale= 3 position="290,-90,20" />81 <Model mesh="cube.mesh" scale= 4 position="110,-90,20" />79 <Model mesh="cube.mesh" scale=0.2 position="-8,-8,3" /> 80 <Model mesh="cube.mesh" scale=0.2 position="8,8,3" /> 81 <Model mesh="cube.mesh" scale=0.2 position="8,-8,3" /> 82 <Model mesh="cube.mesh" scale=0.2 position="-8,8,3" /> 82 83 </waypoints> 83 84 </WaypointController> -
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.