Changeset 11495 for code/trunk/src/modules
- Timestamp:
- Oct 23, 2017, 12:23:21 AM (7 years ago)
- Location:
- code/trunk
- Files:
-
- 2 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/tgidronFS16 removed
- Property svn:mergeinfo changed
-
code/trunk/src/modules/hover/CMakeLists.txt
r11493 r11495 8 8 FlagHUD.cc 9 9 MazeGenerator.cc 10 TFlagsLivesLevelHUD.cc11 10 ) 12 11 … … 18 17 objects 19 18 overlays 20 pickup21 19 SOURCE_FILES ${Hover_SRC_FILES} 22 20 ) -
code/trunk/src/modules/hover/Hover.cc
r11493 r11495 24 24 * Co-authors: 25 25 * Cyrill Burgener 26 * Tomer Gidron27 26 * 28 27 */ … … 34 33 35 34 #include "Hover.h" 36 #include "chat/ChatManager.h" 35 37 36 #include "HoverOrigin.h" 38 37 #include "HoverWall.h" … … 40 39 #include "MazeGenerator.h" 41 40 #include "core/CoreIncludes.h" 42 #include "gamestates/GSLevel.h"43 #include "HoverShip.h"44 45 #include "pickup/PickupSpawner.h"46 #include "pickup/Pickup.h"47 41 48 42 namespace orxonox … … 57 51 this->numberOfFlags_ = 1; 58 52 this->firstTick_ = true; 59 level = 1; //start at level 160 flagsTaken = 0;// took 0 flags in the beginning61 lives = 3;62 63 numCells = 0;64 cellSize = 0;65 cellHeight = 0;66 67 bLevelUpgradeHUD = false;68 69 totFlags = 0;70 53 71 54 this->setHUDTemplate("HoverHUD"); 72 73 55 } 74 56 75 void Hover:: start()57 void Hover::tick(float dt) 76 58 { 77 Gametype::start(); 59 SUPER(Hover, tick, dt); 60 78 61 if(this->firstTick_ && this->origin_) 79 62 { 80 63 this->firstTick_ = false; 81 64 82 numCells = this->origin_->getNumCells(); 83 cellSize = this->origin_->getCellSize(); 84 cellHeight = this->origin_->getCellHeight(); 85 86 //TODO 87 //create boolean array/vector to assert that no two objects are placed in the same way 88 65 int numCells = this->origin_->getNumCells(); 66 int cellSize = this->origin_->getCellSize(); 67 int cellHeight = this->origin_->getCellHeight(); 89 68 90 69 MazeGenerator generator(numCells); … … 102 81 } 103 82 104 105 //Ground106 for(int i = 0; i<numCells; i++){107 for(int j = 0; j<numCells; j++){108 StaticEntity* groundCell = new StaticEntity(origin_->getContext());109 110 groundCell->addTemplate(origin_->getGroundTemplate());111 groundCell->setPosition(get3dCoordinates(i,j,-60));112 }113 114 }115 116 117 118 83 //Generate inner Walls according to levelcode 119 84 for(int y=0; y<numCells; y++){ 120 85 for(int x=0; x<numCells; x++){ 121 switch(levelcode[ y * numCells + x ]) 122 { 86 switch(levelcode[ y * numCells + x ]){ 123 87 case 1: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 1); 124 break;88 break; 125 89 case 3: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 1); 126 90 case 2: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 0); 127 default: 128 break; 91 default: break; 129 92 } 130 } 93 } 131 94 } 132 95 133 createFlags(); 134 135 //Generate 3 PickupSpawners randomly (destroy hover pickup) 136 for (int i = 0; i<3; i++) 96 //Generate 5 flags randomly 97 for ( int i = 0; i < 5; i++ ) 137 98 { 138 PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext()); 139 140 pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 0.0f)); 141 pickupSpawner->setPickupTemplateName(origin_->getPickupTemplate()); 142 pickupSpawner->setMaxSpawnedItems(3); 143 pickupSpawner->setRespawnTime(30); 144 pickupSpawner->setTriggerDistance(40); 145 // Add pickup spawner to the pickup spawner list 146 pickupSpawners_.push_back(pickupSpawner); 147 } 148 149 //Generate 3 PickupSpawners randomly (speed pickup) 150 for (int i = 0; i<3; i++) 151 { 152 PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext()); 153 154 pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 0.0f)); 155 pickupSpawner->setPickupTemplateName(origin_->getPickupTemplateSpeed()); 156 pickupSpawner->setMaxSpawnedItems(3); 157 pickupSpawner->setRespawnTime(30); 158 pickupSpawner->setTriggerDistance(40); 159 // Add pickup spawner to the pickup spawner list 160 pickupSpawners_.push_back(pickupSpawner); 99 HoverFlag* flag = new HoverFlag(origin_->getContext()); 100 flag->init(rand()%numCells, rand()%numCells, cellSize); 101 flags_.push_back(flag); 161 102 } 162 103 163 //Generate 3 PickupSpawners randomly (shrink pickup) 164 for (int i = 0; i<3; i++) 165 { 166 PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext()); 104 }//firsttick end 167 105 168 pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 0.0f)); 169 pickupSpawner->setPickupTemplateName(origin_->getPickupTemplateShrink()); 170 pickupSpawner->setMaxSpawnedItems(3); 171 pickupSpawner->setRespawnTime(30); 172 pickupSpawner->setTriggerDistance(40); 173 // Add pickup spawner to the pickup spawner list 174 pickupSpawners_.push_back(pickupSpawner); 175 } 176 177 //***************************************************************************** 178 179 //Generate destroyable crates randomly on field 180 181 for (int i = 0; i<10; i++){ 182 183 Pawn* crate = new Pawn(origin_->getContext()); 184 185 crate->addTemplate(origin_->getObstacleTemplate()); 186 crate->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 43.0f)); 187 188 189 } 190 191 192 193 194 //If no lives are left, end game 195 if(lives <= 0) 196 { 197 GSLevel::startMainMenu(); 198 } 199 200 } 201 } 202 203 204 // generate new Flags 205 void Hover::createFlags() 206 { 207 //TODO 208 //Generate flags randomly using bool array 209 210 //Generate 5 flags randomly on field 211 for ( int i = 0; i < 5; i++ ) 212 { 213 HoverFlag* flag = new HoverFlag(origin_->getContext()); 214 flag->init(rand()%numCells, rand()%numCells, cellSize); 215 flags_.push_back(flag); 216 217 218 219 if(flags_[i]->getPosition() == get3dCoordinates(0,0,-60)) 220 { 106 // Check if ship collided with one of the flags 107 for ( unsigned int i = 0; i < flags_.size(); i++ ){ 108 if(flags_[i]->getCollided()){ 221 109 flags_[i]->destroyLater(); 222 flags_.erase (flags_.begin()+i);110 flags_.erase (flags_.begin()+i); 223 111 } 224 112 } 225 226 }227 228 void Hover::tick(float dt)229 {230 SUPER(Hover, tick, dt);231 232 233 // Check if ship collided with one of the flags234 for ( unsigned int i = 0; i < flags_.size(); i++ )235 {236 if(flags_[i]->getCollided())237 {238 flags_[i]->destroyLater();239 flags_.erase (flags_.begin()+i);240 totFlags++;241 if(flags_.size()<=0){242 //ChatManager::message("Level Up!");243 244 levelUp();245 }246 }247 248 }249 113 numberOfFlags_ = flags_.size(); 250 251 if(lives <= 0){252 GSLevel::startMainMenu();253 }254 }255 256 //start new level - call to create new flags257 void Hover::levelUp()258 {259 level++;260 //increment lives after every 4 levels261 if(level%4 == 0)262 {263 lives++;264 }265 createFlags();266 toggleShowLevel();267 showLevelTimer.setTimer(2.0f, false, createExecutor(createFunctor(&Hover::toggleShowLevel, this)));268 269 //spawn one additional crate randomly270 Pawn* crate = new Pawn(origin_->getContext());271 crate->addTemplate(origin_->getObstacleTemplate());272 crate->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 43.0f));273 274 }275 276 Vector3 Hover::get3dCoordinates(int x, int y, float heightOffset)277 {278 return Vector3(x*cellSize*1.0f + cellSize/2, heightOffset, y*cellSize*1.0f + cellSize/2);279 }280 281 //if killed, subtract number of lives. If lives == 0, end game282 void Hover::costLife()283 {284 lives--;285 if (lives <= 0)286 GSLevel::startMainMenu();287 114 } 288 115 } -
code/trunk/src/modules/hover/Hover.h
r11493 r11495 24 24 * Co-authors: 25 25 * Cyrill Burgener 26 * Tomer Gidron27 26 * 28 27 */ … … 38 37 39 38 #include "HoverPrereqs.h" 40 #include "HoverShip.h"41 39 42 40 #include <vector> … … 44 42 #include "gametypes/Gametype.h" 45 43 #include "HoverOrigin.h" 46 #include "pickup/PickupSpawner.h"47 44 48 45 namespace orxonox … … 58 55 { this->origin_ = origin; } 59 56 60 void start();61 void createFlags();62 void levelUp();63 void endLevel();64 void costLife();65 66 57 inline int getNumberOfFlags() const 67 58 { return this->numberOfFlags_; } 68 59 69 virtual Vector3 get3dCoordinates(int x, int y, float heightOffset);70 71 inline int getTotFlags() const72 { return this->totFlags; }73 74 inline int getLives() const75 { return this->lives; }76 77 inline int getLevel() const78 { return this->level; }79 80 bool bLevelUpgradeHUD;81 82 60 private: 83 84 61 WeakPtr<HoverOrigin> origin_; 85 62 std::vector<HoverFlag*> flags_; 86 63 int numberOfFlags_; 87 64 bool firstTick_; 88 int level;89 int lives;90 int flagsTaken;91 92 int cellSize;93 int cellHeight;94 int numCells;95 96 int totFlags;97 98 std::vector<PickupSpawner*> pickupSpawners_;99 100 void toggleShowLevel(){bLevelUpgradeHUD = !bLevelUpgradeHUD;}101 102 Timer showLevelTimer;103 65 }; 104 66 } -
code/trunk/src/modules/hover/HoverFlag.cc
r11493 r11495 87 87 model_ = new Model(this->getContext()); 88 88 model_->setMeshSource("ss_flag_eu.mesh"); 89 model_->setScale3D(Vector3( 30, 30, 30));90 model_->setPosition(Vector3(xCoordinate*cellSize*1.0f + cellSize/2, 50.0f,yCoordinate*cellSize*1.0f + cellSize/2));89 model_->setScale3D(Vector3(5, 5, 5)); 90 model_->setPosition(Vector3(xCoordinate*cellSize*1.0f + cellSize/2,10.0f,yCoordinate*cellSize*1.0f + cellSize/2)); 91 91 92 92 this->attach(model_); 93 93 94 94 cs_ = new BoxCollisionShape(this->getContext()); 95 cs_->setHalfExtents(Vector3( 30, 30, 30));95 cs_->setHalfExtents(Vector3(5, 5, 5)); 96 96 cs_->setPosition(Vector3(xCoordinate*cellSize*1.0f + cellSize/2,0.0f,yCoordinate*cellSize*1.0f + cellSize/2)); 97 97 -
code/trunk/src/modules/hover/HoverOrigin.cc
r11493 r11495 23 23 * Manuel Meier 24 24 * Co-authors: 25 * Tomer Gidron25 * ... 26 26 * 27 27 */ … … 45 45 RegisterObject(HoverOrigin); 46 46 checkGametype(); 47 48 //Initialization of variables (not really needed)49 50 pickupTemplate_ = "";51 pickupRepresentationTemplate_ = "";52 53 pickupTemplateSpeed_ = "";54 pickupRepresentationTemplateSpeed_ = "";55 56 57 pickupTemplateShrink_ = "";58 pickupRepresentationTemplateShrink_ = "";59 47 } 60 48 … … 66 54 XMLPortParam(HoverOrigin, "cellSize", setCellSize, getCellSize, xmlelement, mode); 67 55 XMLPortParam(HoverOrigin, "cellHeight", setCellHeight, getCellHeight, xmlelement, mode); 68 XMLPortParam(HoverOrigin, "wallThickness", setWallThickness, getWallThickness, xmlelement, mode);69 XMLPortParam(HoverOrigin, "pickuptemplate", setPickupTemplate, getPickupTemplate, xmlelement, mode);70 XMLPortParam(HoverOrigin, "pickuprepresentationtemplate", setPickupRepresentationTemplate, getPickupRepresentationTemplate, xmlelement, mode);71 XMLPortParam(HoverOrigin, "pickuptemplatespeed", setPickupTemplateSpeed, getPickupTemplateSpeed, xmlelement, mode);72 XMLPortParam(HoverOrigin, "pickuprepresentationtemplatespeed", setPickupRepresentationTemplateSpeed, getPickupRepresentationTemplateSpeed, xmlelement, mode);73 XMLPortParam(HoverOrigin, "obstacletemplate", setObstacleTemplate, getObstacleTemplate, xmlelement, mode);74 XMLPortParam(HoverOrigin, "pickuptemplateshrink", setPickupTemplateShrink, getPickupTemplateShrink, xmlelement, mode);75 XMLPortParam(HoverOrigin, "pickuprepresentationtemplateshrink", setPickupRepresentationTemplateShrink, getPickupRepresentationTemplateShrink, xmlelement, mode);76 XMLPortParam(HoverOrigin, "groundtemplate", setGroundTemplate, getGroundTemplate, xmlelement, mode);77 56 } 78 79 57 80 58 void HoverOrigin::checkGametype() -
code/trunk/src/modules/hover/HoverOrigin.h
r11493 r11495 23 23 * Manuel Meier 24 24 * Co-authors: 25 * Tomer Gidron25 * ... 26 26 * 27 27 */ … … 66 66 { return this->cellHeight_; } 67 67 68 inline void setWallThickness(int wallThickness)69 { this->wallThickness_ = wallThickness; }70 inline int getWallThickness() const71 { return this->wallThickness_; }72 73 //pickup template set and get for destroy hover pickup74 75 inline void setPickupTemplate(std::string pickupTemplate)76 { this->pickupTemplate_ = pickupTemplate; }77 inline std::string getPickupTemplate() const78 { return this->pickupTemplate_; }79 80 inline void setPickupRepresentationTemplate(std::string pickupRepresenationaTemplate)81 { this->pickupRepresentationTemplate_ = pickupRepresenationaTemplate; }82 inline std::string getPickupRepresentationTemplate() const83 { return this->pickupRepresentationTemplate_; }84 85 //pickup template get and set for damage hover pickup86 87 inline void setPickupTemplateSpeed(std::string pickupTemplateSpeed)88 { this->pickupTemplateSpeed_ = pickupTemplateSpeed; }89 inline std::string getPickupTemplateSpeed() const90 { return this->pickupTemplateSpeed_; }91 92 inline void setPickupRepresentationTemplateSpeed(std::string pickupRepresenationaTemplateSpeed)93 { this->pickupRepresentationTemplateSpeed_ = pickupRepresenationaTemplateSpeed; }94 inline std::string getPickupRepresentationTemplateSpeed() const95 { return this->pickupRepresentationTemplateSpeed_; }96 97 98 //pickup template get and set for shrink hover pickup99 100 inline void setPickupTemplateShrink(std::string pickupTemplateShrink)101 { this->pickupTemplateShrink_ = pickupTemplateShrink; }102 inline std::string getPickupTemplateShrink() const103 { return this->pickupTemplateShrink_; }104 105 inline void setPickupRepresentationTemplateShrink(std::string pickupRepresenationaTemplateShrink)106 { this->pickupRepresentationTemplateShrink_ = pickupRepresenationaTemplateShrink; }107 inline std::string getPickupRepresentationTemplateShrink() const108 { return this->pickupRepresentationTemplateShrink_; }109 110 //get and set for obstacle template111 112 inline void setObstacleTemplate(std::string obstacleTemplate)113 { this->obstacleTemplate_ = obstacleTemplate; }114 inline std::string getObstacleTemplate() const115 { return this->obstacleTemplate_; }116 117 //get and set for ground template118 119 inline void setGroundTemplate(std::string groundTemplate)120 { this->groundTemplate_ = groundTemplate; }121 inline std::string getGroundTemplate() const122 { return this->groundTemplate_; }123 124 68 private: 125 69 void checkGametype(); 126 127 70 128 71 int numCells_; 129 72 int cellSize_; 130 73 int cellHeight_; 131 int wallThickness_;132 133 // Tempaltes for the destroy hover pickup134 std::string pickupTemplate_;135 std::string pickupRepresentationTemplate_;136 137 // Tempaltes for the damage hover pickup138 std::string pickupTemplateSpeed_;139 std::string pickupRepresentationTemplateSpeed_;140 141 // Tempaltes for the shrink hover pickup142 std::string pickupTemplateShrink_;143 std::string pickupRepresentationTemplateShrink_;144 145 //Template for crate obstacle146 std::string obstacleTemplate_;147 148 //Template for ground cell149 std::string groundTemplate_;150 74 }; 151 75 } -
code/trunk/src/modules/hover/HoverShip.cc
r11493 r11495 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/XMLPort.h" 35 #include "Hover.h"36 //#include "NewHumanController.h"37 35 38 36 #include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h> … … 114 112 if (bBoost && this->isFloor_) 115 113 { 116 117 114 this->setVelocity( 118 115 this->getVelocity().x, … … 123 120 } 124 121 } 125 126 Hover* HoverShip::getGame()127 {128 if (game == nullptr)129 {130 for (Hover* hover : ObjectList<Hover>())131 game = hover;132 }133 return game;134 }135 136 void HoverShip::death()137 {138 getGame()->costLife();139 SpaceShip::death();140 }141 122 } -
code/trunk/src/modules/hover/HoverShip.h
r11493 r11495 34 34 35 35 #include "HoverPrereqs.h" 36 #include "Hover.h"37 36 38 37 #include "worldentities/pawns/SpaceShip.h" … … 70 69 virtual void boost(bool bBoost) override; 71 70 72 protected:73 virtual void death() override;74 75 71 private: 76 Hover* getGame();77 WeakPtr<Hover> game;78 72 float jumpBoost_; 79 73 bool isFloor_; -
code/trunk/src/modules/weapons/weaponmodes/HsW01.cc
r11493 r11495 85 85 XMLPortParam(HsW01, "projectileMesh", setMesh, getMesh, xmlelement, mode); 86 86 XMLPortParam(HsW01, "sound", setSound, getSound, xmlelement, mode); 87 XMLPortParam(HsW01, "speed", setSpeed, getSpeed, xmlelement, mode);88 87 } 89 88 -
code/trunk/src/modules/weapons/weaponmodes/HsW01.h
r11493 r11495 112 112 void muzzleflash(); 113 113 114 /**115 @brief Set the firing speed.116 @param speed The speed of the shot117 */118 119 void setSpeed(const float speed)120 { this->speed_ = speed; }121 122 /**123 @brief Get the firing speed.124 @return Returns the speed of the shot125 */126 127 const float getSpeed() const128 { return this->speed_; }129 130 114 std::string material_; //!< The material. 131 115 std::string mesh_; //!< The mesh.
Note: See TracChangeset
for help on using the changeset viewer.