- Timestamp:
- Apr 29, 2012, 11:08:26 AM (13 years ago)
- Location:
- code/branches/newlevel2012/src/modules/towerdefense
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.cc
r9133 r9136 60 60 #include "worldentities/pawns/SpaceShip.h" 61 61 62 /* Part of a temporary hack to allow the player to add towers */ 63 #include "core/command/ConsoleCommand.h" 64 62 65 namespace orxonox 63 66 { 64 67 CreateUnloadableFactory(TowerDefense); 65 66 68 69 TowerDefense::TowerDefense(BaseObject* creator) : Deathmatch(creator) 67 70 { 68 71 RegisterObject(TowerDefense); 69 72 73 /* Temporary hack to allow the player to add towers */ 74 this->dedicatedAddTower_ = createConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) ); 75 70 76 } 71 77 78 TowerDefense::~TowerDefense() 79 { 80 if (this->isInitialized()) 81 { 82 if( this->dedicatedAddTower_ ) 83 delete this->dedicatedAddTower_; 84 } 85 } 86 87 void TowerDefense::setCenterpoint(TowerDefenseCenterpoint *centerpoint) 88 { 89 orxout() << "got a centerpoint..." << endl; 90 91 this->center_ = centerpoint; 92 } 93 72 94 void TowerDefense::start() 73 95 { 74 96 Deathmatch::start(); 75 97 orxout()<< "This is a way to display output on the terminal." <<endl; 76 //Tipp: Fenster-Modus über die Grafikeinstellungen einstellen.77 //(dazu den Bulletpoint 'Fullscreen' entfernen, eine kleine Auflösung auswählen und auf 'Apply' klicken.)78 98 } 79 /* 80 void TowerDefense::end() 81 { 82 Deathmatch::end(); 83 84 std::string message("The match has ended."); 85 ChatManager::message(message); 86 } 87 */ 88 89 99 100 /* 101 void TowerDefense::end() 102 { 103 Deathmatch::end(); 104 105 std::string message("The match has ended."); 106 ChatManager::message(message); 107 } 108 */ 109 110 void TowerDefense::addTower(int x, int y) 111 { 112 orxout()<< "Should add tower at (" << x << "," << y << ")" << endl; 113 114 if (x > 16 || y > 16) 115 { 116 orxout() << "x and y should be between 1 and 16" << endl; 117 return; 118 } 119 120 121 122 // TODO: create Tower mesh 123 // TODO: load Tower mesh 124 } 125 90 126 void TowerDefense::tick(float dt) 91 127 { 92 128 SUPER(TowerDefense, tick, dt); 93 129 94 130 static bool test = false; 95 131 if (!test) 96 132 { 97 133 orxout()<< "First tick." <<endl; 98 spawnEnemy();99 134 } 100 135 test = true; 101 136 } 102 103 void TowerDefense::spawnEnemy() 104 { 105 //SpawnPoint *sp = *this->spawnpoints_.begin(); 106 107 //Pawn* p = sp->spawn(); 108 } 109 110 /* 111 void TowerDefense::playerEntered(PlayerInfo* player) 112 { 113 Deathmatch::playerEntered(player); 114 115 const std::string& message = player->getName() + " entered the game"; 116 ChatManager::message(message); 117 } 118 119 bool TowerDefense::playerLeft(PlayerInfo* player) 120 { 121 bool valid_player = Deathmatch::playerLeft(player); 122 123 if (valid_player) 124 { 125 const std::string& message = player->getName() + " left the game"; 126 ChatManager::message(message); 127 } 128 129 return valid_player; 130 } 131 132 133 void TowerDefense::pawnKilled(Pawn* victim, Pawn* killer) 134 { 135 if (victim && victim->getPlayer()) 136 { 137 std::string message; 138 if (killer) 139 { 140 if (killer->getPlayer()) 141 message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName(); 142 else 143 message = victim->getPlayer()->getName() + " was killed"; 144 } 145 else 146 message = victim->getPlayer()->getName() + " died"; 147 148 ChatManager::message(message); 149 } 150 151 Deathmatch::pawnKilled(victim, killer); 152 } 153 154 void TowerDefense::playerScored(PlayerInfo* player) 155 { 156 Gametype::playerScored(player); 157 158 }*/ 137 138 /* 139 void TowerDefense::playerEntered(PlayerInfo* player) 140 { 141 Deathmatch::playerEntered(player); 142 143 const std::string& message = player->getName() + " entered the game"; 144 ChatManager::message(message); 145 } 146 147 bool TowerDefense::playerLeft(PlayerInfo* player) 148 { 149 bool valid_player = Deathmatch::playerLeft(player); 150 151 if (valid_player) 152 { 153 const std::string& message = player->getName() + " left the game"; 154 ChatManager::message(message); 155 } 156 157 return valid_player; 158 } 159 160 161 void TowerDefense::pawnKilled(Pawn* victim, Pawn* killer) 162 { 163 if (victim && victim->getPlayer()) 164 { 165 std::string message; 166 if (killer) 167 { 168 if (killer->getPlayer()) 169 message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName(); 170 else 171 message = victim->getPlayer()->getName() + " was killed"; 172 } 173 else 174 message = victim->getPlayer()->getName() + " died"; 175 176 ChatManager::message(message); 177 } 178 179 Deathmatch::pawnKilled(victim, killer); 180 } 181 182 void TowerDefense::playerScored(PlayerInfo* player) 183 { 184 Gametype::playerScored(player); 185 186 }*/ 159 187 } -
code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.h
r9122 r9136 37 37 class _OrxonoxExport TowerDefense : public Deathmatch 38 38 { 39 public: 40 TowerDefense(BaseObject* creator); 41 virtual ~TowerDefense() {} 42 43 virtual void start(); //<! The function is called when the gametype starts 44 //virtual void end(); 45 virtual void tick(float dt); 46 //virtual void playerEntered(PlayerInfo* player); 47 //virtual bool playerLeft(PlayerInfo* player); 48 49 //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0); 50 //virtual void playerScored(PlayerInfo* player); 51 private: 52 void spawnEnemy(); 39 public: 40 TowerDefense(BaseObject* creator); 41 virtual ~TowerDefense(); 42 43 virtual void start(); //<! The function is called when the gametype starts 44 //virtual void end(); 45 virtual void tick(float dt); 46 //virtual void playerEntered(PlayerInfo* player); 47 //virtual bool playerLeft(PlayerInfo* player); 48 49 //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0); 50 //virtual void playerScored(PlayerInfo* player); 51 52 void setCenterpoint(TowerDefenseCenterpoint *centerpoint); 53 54 /* Part of a temporary hack to allow the player to add towers */ 55 void addTower(int x, int y); 56 ConsoleCommand* dedicatedAddTower_; 57 58 private: 59 // WeakPtr<TowerDefenseCenterpoint> center_; 60 TowerDefenseCenterpoint *center_; 53 61 }; 54 62 } -
code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseCenterpoint.cc
r9112 r9136 51 51 RegisterObject(TowerDefenseCenterpoint); 52 52 53 54 53 55 this->width_ = 10; 54 56 this->height_ = 11; … … 89 91 void TowerDefenseCenterpoint::checkGametype() 90 92 { 91 93 if (this->getGametype() != NULL && this->getGametype()->isA(Class(TowerDefense))) 92 94 { 93 //TowerDefense* TowerDefenseGametype = orxonox_cast<TowerDefense*>(this->getGametype().get()); 94 //TowerDefenseGametype->setCenterpoint(this); 95 // Sets the centerpoint of the gametype. The gametype uses this to later spawn in towers, he needs the tower template stored in the center point 96 TowerDefense* towerDefenseGametype = orxonox_cast<TowerDefense*>(this->getGametype().get()); 97 towerDefenseGametype->setCenterpoint(this); 95 98 } 96 99 }
Note: See TracChangeset
for help on using the changeset viewer.