Changeset 11720 for code/trunk
- Timestamp:
- Feb 4, 2018, 4:58:37 PM (7 years ago)
- Location:
- code/trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/gametypes/SpaceRace.cc
r11358 r11720 80 80 RegisterObject(SpaceRace); 81 81 82 this->botclass_ = Class(SpaceRaceBot); //ClassByString("")82 this->botclass_ = Class(SpaceRaceBot); 83 83 this->cantMove_ = false; 84 84 this->bTimeIsUp_ = false; 85 this->setConfigValues();86 85 87 86 this->numberOfBots_ = 5; // quick fix: don't allow default-bots to enter the race … … 89 88 } 90 89 91 void SpaceRace::setConfigValues()92 {93 94 95 }96 97 90 void SpaceRace::start() 98 91 { 99 // define spawn positions of the 5 bots92 // define spawn positions of the 5 bots 100 93 101 94 int startpos[15]; … … 120 113 startpos[13] =-40; 121 114 startpos[14] =80; 122 123 124 125 115 126 116 Gametype::start(); 127 if (true) 128 { 129 this->spawnPlayersIfRequested(); 130 this->cantMove_ = true; 131 //players are unable to move while countdown is running 132 for (Engine* engine : ObjectList<Engine>()){ 133 engine->setActive(false); 134 135 136 } 137 //append spawn positions to bots 138 int a,b,c; 139 a=0; 140 b=1; 141 c=2; 142 for (SpaceRaceBot* bot : ObjectList<SpaceRaceBot>()){ 143 bot->getControllableEntity()->setPosition(startpos[a],startpos[b],startpos[c]); 144 a= a+3; 145 b = b+3; 146 c+= 3; 147 } 148 149 150 } 151 152 117 118 this->spawnPlayersIfRequested(); 119 this->cantMove_ = true; 120 //players are unable to move while countdown is running 121 for (Engine* engine : ObjectList<Engine>()) 122 { 123 engine->setActive(false); 124 } 125 126 //append spawn positions to bots 127 int a,b,c; 128 a=0; 129 b=1; 130 c=2; 131 132 for (SpaceRaceBot* bot : ObjectList<SpaceRaceBot>()) 133 { 134 bot->getControllableEntity()->setPosition(startpos[a], startpos[b], startpos[c]); 135 a += 3; 136 b += 3; 137 c += 3; 138 } 153 139 154 140 std::string message("Use headphones to hear the countdown!"); … … 156 142 ChatManager::message(message); 157 143 158 //after 11 seconds , countdownFinished function is called to activate bots` engines159 Timer* countdownTimer = new Timer();144 //after 11 seconds , countdownFinished function is called to activate bots` engines 145 Timer* countdownTimer = new Timer(); 160 146 countdownTimer->setTimer(11, false, createExecutor(createFunctor(&SpaceRace::countdownFinished, this))); 161 147 } … … 189 175 } 190 176 191 192 void SpaceRace::tick(float dt)193 {194 SUPER(SpaceRace,tick,dt);195 }196 197 177 void SpaceRace::newCheckpointReached(RaceCheckPoint* checkpoint, PlayerInfo* player) 198 178 { … … 207 187 const std::string& message = player->getName() + " reached the checkpoint " + multi_cast<std::string>(checkpoint->getCheckpointIndex() + 1) 208 188 + "after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds."; 209 this->getGametypeInfo()->sendAnnounceMessage(message);210 ChatManager::message(message); 211 212 } 213 214 void SpaceRace::countdownFinished()//activates the engines of all players189 this->getGametypeInfo()->sendAnnounceMessage(message); 190 ChatManager::message(message); 191 192 } 193 194 void SpaceRace::countdownFinished()//activates the engines of all players 215 195 { 216 196 … … 220 200 221 201 222 for (Engine* engine : ObjectList<Engine>()) 223 engine->setActive(true); 224 225 226 227 } 228 229 void SpaceRace::playerEntered(PlayerInfo* player) 202 for (Engine* engine : ObjectList<Engine>()) 203 engine->setActive(true); 204 } 205 206 void SpaceRace::playerEntered(PlayerInfo* player) 230 207 { 231 208 Gametype::playerEntered(player); … … 236 213 237 214 238 void SpaceRace::addBots(unsigned int amount) //function that add the bots to the game215 void SpaceRace::addBots(unsigned int amount) //function that add the bots to the game 239 216 { 240 217 for (unsigned int i = 1; i <= amount; ++i){ … … 244 221 245 222 246 //set bot configurations223 //set bot configurations 247 224 bool SpaceRace::allowPawnHit(Pawn* victim, Pawn* originator) 248 225 { … … 255 232 } 256 233 257 bool SpaceRace::allowPawnDeath(Pawn* victim, Pawn* originator)// false because the bots can not recognize the objects and die to early 258 //if they can 234 bool SpaceRace::allowPawnDeath(Pawn* victim, Pawn* originator)// false because the bots can not recognize the objects and die to earlyif they can 259 235 { 260 236 return false; -
code/trunk/src/modules/gametypes/SpaceRace.h
r11358 r11720 57 57 virtual ~SpaceRace() {} 58 58 59 void setConfigValues();60 61 virtual void tick(float dt) override;62 59 virtual void start() override; 63 60 virtual void end() override; 64 virtual void countdownFinished();65 61 virtual void countdownFinished(); 62 virtual void addBots(unsigned int amount) override; //<! overwrite function in order to bypass the addbots command. 66 63 67 64 68 65 69 66 virtual void playerEntered(PlayerInfo* player) override; 70 67 71 68 //virtual void newCheckpointReached(); -
code/trunk/src/modules/gametypes/SpaceRaceBot.cc
r11358 r11720 23 23 * Author: purgham 24 24 */ 25 #include <vector>26 25 27 26 #include "SpaceRaceBot.h" 28 #include "core/GameMode.h"29 27 #include "core/CoreIncludes.h" 30 #include "core/config/ConfigValueIncludes.h"31 #include "gametypes/Gametype.h"32 #include "controllers/AIController.h"33 #include "gametypes/SpaceRaceController.h"34 35 36 37 28 38 29 namespace orxonox … … 42 33 SpaceRaceBot::SpaceRaceBot(Context* context) : Bot(context){ 43 34 RegisterObject(SpaceRaceBot); 44 this->defaultController_ = Class(SpaceRaceController); // ClassByString("")35 this->defaultController_ = Class(SpaceRaceController); 45 36 this->createController(); 46 47 }48 49 SpaceRaceBot::~SpaceRaceBot(){50 51 }52 53 void SpaceRaceBot::setConfigValues()54 {55 static const std::string names[] =56 {57 "Dr. Julius No",58 "Berkay Berabi",59 "Louis Meile"60 "Yo mama"61 };62 static std::vector<std::string> defaultnames(names, names + sizeof(names) / sizeof(std::string));63 64 SetConfigValue(names_, defaultnames);65 37 } 66 38 } -
code/trunk/src/modules/gametypes/SpaceRaceBot.h
r11718 r11720 30 30 #include "gametypes/GametypesPrereqs.h" 31 31 #include "gametypes/SpaceRaceController.h" 32 #include <vector>33 32 34 33 … … 40 39 public: 41 40 SpaceRaceBot(Context* context); 42 virtual ~SpaceRaceBot(); 43 44 void setConfigValues(); 45 46 47 48 virtual inline bool isInitialized() const override 49 { return true; } 50 virtual inline float getPing() const override 51 { return 0; } 52 virtual inline float getPacketLossRatio() const override 53 { return 0; } 54 55 56 private: 57 std::vector<std::string> names_; 58 59 41 virtual ~SpaceRaceBot() {} 60 42 }; 61 43 } -
code/trunk/src/modules/gametypes/SpaceRaceController.cc
r11358 r11720 16 16 * GNU General Public License for more details. 17 17 * 18 * You should have 18 * You should have received a copy of the GNU General Public License 19 19 * along with this program; if not, write to the Free Software 20 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. … … 327 327 lastPositionSpaceship = this->getControllableEntity()->getPosition(); 328 328 329 this->boostControl();329 this->boostControl(); 330 330 this->moveToPosition(nextRaceCheckpoint_->getPosition()); 331 331 this->boostControl(); -
code/trunk/src/orxonox/controllers/HumanController.h
r11358 r11720 92 92 //friend class, for mouselook 93 93 friend class Map; 94 static HumanController* localController_s;95 94 96 95 protected: 96 static HumanController* localController_s; 97 97 bool controlPaused_; 98 98 -
code/trunk/src/orxonox/infos/Bot.cc
r11358 r11720 68 68 static const std::string names[] = 69 69 { 70 "Dr. Julius No", 71 "Rosa Klebb", 72 "Auric Goldfinger", 73 "Emilio Largo", 74 "Ernst Stavro Blofeld", 75 "Dr. Kananga", 76 "Francisco Scaramanga", 77 "Karl Stromberg", 78 "Sir Hugo Drax", 79 "Aris Kristatos", 80 "Kamal Khan", 81 "General Orlov", 82 "Max Zorin", 83 "Brad Whitaker", 84 "General Georgi Koskov", 85 "Franz Sanchez", 86 "Alec Trevelyan", 87 "Elliot Carver", 88 "Elektra King", 89 "Viktor Zokas", 90 "Gustav Graves", 91 "Le Chiffre", 92 "Mr. White", 93 "Dominic Greene", 70 94 "Berkay Berabi", 71 "Louis Meile" 95 "Louis Meile", 72 96 "Muten Roshi", 73 97 "Abradolf Lincler", 74 98 "Lionel Messi", 75 "Kamal Khan",76 99 "Karl the Llama", 77 100 "Thomas the Tankengine", -
code/trunk/src/orxonox/infos/GametypeInfo.h
r11358 r11720 83 83 inline bool isStartCountdownRunning() const 84 84 { return this->bStartCountdownRunning_; } 85 86 85 void changedStartCountdownRunning(void); // Is called when the start countdown has been either started or stopped. 87 86 … … 133 132 void dispatchStaticMessage(const std::string& message,const ColourValue& colour) const; 134 133 void dispatchFadingMessage(const std::string& message) const; 135 void setStartCountdown(float countdown); // Set the start countdown to the input value.136 137 134 138 135 protected: 139 136 void start(void); // Inform the GametypeInfo that the game has started. 140 137 void end(void); // Inform the GametypeInfo that the game has ended. 138 void setStartCountdown(float countdown); // Set the start countdown to the input value. 141 139 void countdownStartCountdown(float countDown); // Count down the start countdown by the specified value. 142 140 void countDown(); // Count down the start countdown counter.
Note: See TracChangeset
for help on using the changeset viewer.