Changeset 12149 for code/branches/TixyTaxyTorxy_HS18/src/modules
- Timestamp:
- Dec 5, 2018, 11:43:36 AM (6 years ago)
- Location:
- code/branches/TixyTaxyTorxy_HS18/src/modules/TixyTaxyTorxy
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/TixyTaxyTorxy_HS18/src/modules/TixyTaxyTorxy/TixyTaxyTorxy.cc
r12086 r12149 83 83 #include "core/CoreIncludes.h" 84 84 #include "Highscore.h" 85 #include <iostream> 86 #include "TixyTaxyTorxyField.h" 87 using namespace std; 85 88 86 89 namespace orxonox 87 90 { 91 88 92 RegisterUnloadableClass(TixyTaxyTorxy); 93 94 89 95 90 96 … … 103 109 this->waveSize_ = 0; 104 110 offset_ = Vector3(0,0,10); 111 105 112 } 106 113 107 114 TixyTaxyTorxy::~TixyTaxyTorxy() 108 115 { 116 117 109 118 if (this->isInitialized()) 110 119 { … … 186 195 void TixyTaxyTorxy::addTower(int x,int y) 187 196 { 197 int mini; 198 188 199 TixyTaxyTorxyCoordinate* coord = new TixyTaxyTorxyCoordinate(x,y); 189 200 x = coord->GetX(); 190 201 y = coord->GetY(); 191 202 mini = coord->Getmini(); 203 204 orxout() <<"addTower("<<x<<", "<<y<<") "<<mini<<"" <<endl; 192 205 int cost = center_->getTowerCost(1); 193 206 194 if (fields_[x][y]->isFree() == true && getCredit() >= cost)207 if (fields_[x][y]->isFree()) 195 208 { 196 209 payCredit(cost); 197 210 fields_[x][y]->createTower(1); 198 211 } 199 } 212 213 bool player1=player2=0; 214 int A1,B1,C1,D1,E1,F1,G1,H1,I1; 215 int A2,B2,C2,D2,E2,F2,G2,H2,I2; 216 A1=B1=C1=D1=E1=F1=G1=H1=I1=0; 217 A2=B2=C2=D2=E2=F2=G2=H2=I2=0; 218 219 220 221 if (checkMinigame(0,10) == 1) A1=1; 222 if (checkMinigame(4,10) == 1) B1=2; 223 if (checkMinigame(8,10) == 1) C1=4; 224 if (checkMinigame(0,6) == 1) D1=8; 225 if (checkMinigame(4,6) == 1) E1=16; 226 if (checkMinigame(8,6) == 1) F1=32; 227 if (checkMinigame(0,2) == 1) G1=64; 228 if (checkMinigame(4,2) == 1) H1=128; 229 if (checkMinigame(8,2) == 1) I1=256; 230 231 if (checkMinigame(0,10) == 2) A2=1; 232 if (checkMinigame(4,10) == 2) B2=2; 233 if (checkMinigame(8,10) == 2) C2=4; 234 if (checkMinigame(0,6) == 2) D2=8; 235 if (checkMinigame(4,6) == 2) E2=16; 236 if (checkMinigame(8,6) == 2) F2=32; 237 if (checkMinigame(0,2) == 2) G2=64; 238 if (checkMinigame(4,2) == 2) H2=128; 239 if (checkMinigame(8,2) == 2) I2=256; 240 241 orxout()<<"A1: "<<A1<<"B1: "<<B1<<endl; 242 243 if(A1+B1+C1 == 7 || D1+E1+F1 == 56 || G1+H1+I1 == 448 || A1+D1+G1 == 73 || B1+E1+H1 == 146 || C1+F1+I1 == 294 || A1+E1+I1 == 273 || C1+E1+G1 == 84){ 244 245 player1=1; 246 orxout()<<"player1 has won" << endl; 247 } 248 249 if(A2+B2+C2 == 7 || D2+E2+F2 == 56 || G2+H2+I2 == 448 || A2+D2+G2 == 73 || B2+E2+H2 == 146 || C2+F2+I2 == 294 || A2+E2+I2 == 273 || C2+E2+G2 == 84){ 250 251 player2=1; 252 orxout()<<"player1 has won" << endl; 253 } 254 } 255 256 int TixyTaxyTorxy::checkMinigame(int x, int y){ 257 if (checkRow(x,y)==1 || checkColumn(x,y)==1 || checkDiagLtR(x,y)==1 ||checkDiagRtL(x,y)==1) return 1; 258 else if (checkRow(x,y)==2 || checkColumn(x,y)==2 || checkDiagLtR(x,y)==2 || checkDiagRtL (x,y)==2) return 2; 259 return 0; 260 } 261 262 int TixyTaxyTorxy::checkRow(int x, int y){ 263 for(int i=0; i<2; i++){ 264 265 if(fields_[x+i][y]-> isTower1() && fields_[x+i][y-1]-> isTower1() && fields_[x+i][y-2]-> isTower1()){ 266 return 1; 267 268 }else if(fields_[x+i][y]-> isTower2() && fields_[x+i][y-1]-> isTower2() && fields_[x+i][y-2]-> isTower2()){ 269 return 2;} 270 } 271 return 0; 272 273 } 274 int TixyTaxyTorxy::checkColumn(int x, int y){ 275 for(int i=0; i<2; i++){ 276 277 if(fields_[x][y-i]-> isTower1() && fields_[x+1][y-i]-> isTower1() && fields_[x+2][y-i]-> isTower1()){ 278 return 1; 279 280 }else if (fields_[x][y-i]-> isTower2() && fields_[x+1][y-i]-> isTower2() && fields_[x+2][y-i]-> isTower2()){ 281 return 2; } 282 } 283 return 0; 284 285 286 } 287 //Cheeck the diagonal achsis from top left to bottom right 288 int TixyTaxyTorxy::checkDiagLtR(int x, int y){ 289 290 if (fields_[x][y]-> isTower1() && fields_[x+1][y-1]-> isTower1() && fields_[x+2][y-2]-> isTower1()){ 291 return 1; 292 } 293 else if (fields_[x][y]-> isTower2() && fields_[x+1][y-1]-> isTower2() && fields_[x+2][y-2]-> isTower2()){ 294 return 2; 295 } 296 return 0; 297 298 } 299 //Cheeck the diagonal achsis from top right to bottom left 300 int TixyTaxyTorxy::checkDiagRtL (int x, int y){ 301 302 if(fields_[x+2][y]-> isTower1() && fields_[x+1][y-1]-> isTower1() && fields_[x][y-2]-> isTower1()){ 303 return 1; 304 } 305 else if(fields_[x+2][y]-> isTower2() && fields_[x+1][y-1]-> isTower2() && fields_[x][y-2]-> isTower2()){ 306 return 2; 307 } 308 309 else return 0; 310 } 311 312 bool TixyTaxyTorxy::getPlayer1Value(){ 313 return player1; 314 } 315 bool TixyTaxyTorxy::getPlayer2Value(){ 316 return player2; 317 } 318 319 320 321 322 323 200 324 201 325 /*adds Tower at Position (x,y) and reduces credit and adds the point to the towermatrix. template ("towerturret") … … 253 377 std::string fields = center_->getFields(); 254 378 int pos = 0; 255 for (int j = 1 5; j >= 0; --j)256 { 257 for (int i = 0; i < 1 6; ++i)379 for (int j = 10; j >= 0; --j) 380 { 381 for (int i = 0; i < 11; ++i) 258 382 { 259 383 coord.Set(i,j); -
code/branches/TixyTaxyTorxy_HS18/src/modules/TixyTaxyTorxy/TixyTaxyTorxy.h
r12064 r12149 72 72 void addTower(int x, int y); 73 73 void upgradeTower(int x, int y); 74 int checkRow(int x, int y); 75 int checkColumn(int x, int y); 76 int checkMinigame(int x, int y); 77 int checkDiagLtR(int x, int y); 78 int checkDiagRtL(int x, int y); 79 bool getPlayer2Value(); 80 bool getPlayer1Value(); 74 81 75 82 TixyTaxyTorxySelecter* selecter; … … 86 93 int waveNumber_; 87 94 int lifes_; 88 TixyTaxyTorxyField* fields_[16][16]; 95 bool player1; 96 bool player2; 97 TixyTaxyTorxyField* fields_[11][11]; 89 98 std::vector<orxonox::WeakPtr<TixyTaxyTorxyField>> waypoints_; 90 99 Vector3 endpoint_; -
code/branches/TixyTaxyTorxy_HS18/src/modules/TixyTaxyTorxy/TixyTaxyTorxyCenterpoint.cc
r12064 r12149 56 56 RegisterObject(TixyTaxyTorxyCenterpoint); 57 57 58 this->width_ = 1 5;59 this->height_ = 1 5;58 this->width_ = 10; 59 this->height_ = 10; 60 60 61 61 //this->setCollisionType(Static); -
code/branches/TixyTaxyTorxy_HS18/src/modules/TixyTaxyTorxy/TixyTaxyTorxyCoordinate.cc
r12064 r12149 20 20 { 21 21 Set(x,y); 22 22 23 } 23 24 … … 28 29 _x = 0; 29 30 } 30 else if (x > 1 5)31 else if (x > 10) 31 32 { 32 _x = 1 5;33 _x = 10; 33 34 } 34 35 else … … 41 42 _y = 0; 42 43 } 43 else if (y > 1 5)44 else if (y > 10) 44 45 { 45 _y = 1 5;46 _y = 10; 46 47 } 47 48 else … … 49 50 _y = y; 50 51 } 52 53 //Defniert die Positionen der einzelnen Minigames 54 55 if( _x <= 2 && _y >= 8 ) _mini = 1; 56 57 if( _x>= 4 &&_x <= 6 && _y >= 8 ) _mini = 2; 58 59 if( _x>= 8 && _y >= 8 ) _mini = 3; 60 61 if( _x <= 2 && _y >= 4 && _y<=6 ) _mini = 4; 62 63 if(_x>=4 &&_x <= 6 && _y>=4 &&_y <= 6 ) _mini = 5; 64 65 if( _x >=8 && _y >= 4 && _y<=6 ) _mini = 6; 66 67 if( _x <= 2 && _y <=2 ) _mini = 7; 68 69 if( _x >=4 &&_x <= 6 && _y <=2 ) _mini = 8; 70 71 if( _x >= 8 && _y <=2 ) _mini = 9; 51 72 } 52 73 … … 60 81 return _y; 61 82 } 62 83 int TixyTaxyTorxyCoordinate::Getmini() 84 { 85 return _mini; 86 } 63 87 64 88 Vector3 TixyTaxyTorxyCoordinate::get3dcoordinate() -
code/branches/TixyTaxyTorxy_HS18/src/modules/TixyTaxyTorxy/TixyTaxyTorxyCoordinate.h
r12064 r12149 21 21 virtual int GetX(); 22 22 virtual int GetY(); 23 virtual int Getmini(); 23 24 virtual Vector3 get3dcoordinate(); 24 25 … … 26 27 int _x; 27 28 int _y; 29 int _mini; 28 30 }; 29 31 -
code/branches/TixyTaxyTorxy_HS18/src/modules/TixyTaxyTorxy/TixyTaxyTorxyField.cc
r12086 r12149 38 38 #include "core/XMLPort.h" 39 39 #include "TixyTaxyTorxy.h" 40 #include <iostream> 41 42 using namespace std; 40 43 41 44 namespace orxonox … … 85 88 center_ = center; 86 89 } 87 88 90 // void TixyTaxyTorxyField::upgrade() 89 91 // { … … 184 186 } 185 187 188 186 189 int TixyTaxyTorxyField::getAngle() 187 190 { … … 256 259 void TixyTaxyTorxyField::createTower(int upgrade) 257 260 { 258 counter++;261 259 262 if (tower_ == nullptr) 260 263 { 264 counter++; 261 265 if(counter%2==0){ 262 266 modelGround_->setMeshSource("TD_T1.mesh"); 263 267 tower_ = new TixyTaxyTorxyTower(center_->getContext()); 264 268 attach(tower_); 269 type_ = TixyTaxyTorxyFieldType::TOWER1; 265 270 266 271 }else{ … … 268 273 tower_ = new TixyTaxyTorxyTower(center_->getContext()); 269 274 attach(tower_); 270 } 271 272 273 // type_ = TixyTaxyTorxyFieldType::TOWER; 274 // setUpgrade(upgrade); 275 // if (upgrade_ > 0 && modelObject_ != nullptr) 276 // { 277 // modelObject_->setMeshSource("TD_T2.mesh"); 278 // tower_->addTemplate(center_->getTower1Template()); 279 // switch (counter%2 +1) 280 // { 281 // case 1: 282 // modelObject_->setMeshSource("TD_T1.mesh"); 283 // tower_->addTemplate(center_->getTower1Template()); 284 // break; 285 // case 2: 286 // modelObject_->setMeshSource("TD_T2.mesh"); 287 // tower_->addTemplate(center_->getTower2Template()); 288 // break; 289 // case 3: 290 // modelObject_->setMeshSource("TD_T3.mesh"); 291 // tower_->addTemplate(center_->getTower3Template()); 292 // break; 293 // case 4: 294 // modelObject_->setMeshSource("TD_T4.mesh"); 295 // tower_->addTemplate(center_->getTower4Template()); 296 // break; 297 // case 5: 298 // modelObject_->setMeshSource("TD_T5.mesh"); 299 // tower_->addTemplate(center_->getTower5Template()); 300 // break; 301 // } 302 // } 275 type_ = TixyTaxyTorxyFieldType::TOWER2; 276 } 277 303 278 } 304 279 } -
code/branches/TixyTaxyTorxy_HS18/src/modules/TixyTaxyTorxy/TixyTaxyTorxyField.h
r12086 r12149 48 48 END, 49 49 OBSTACLE, 50 TOWER1, 51 TOWER2, 50 52 TOWER 51 53 }; … … 66 68 const bool isFree() const 67 69 { return type_==TixyTaxyTorxyFieldType::FREE; } 70 const bool isTower1() const 71 { return type_==TixyTaxyTorxyFieldType::TOWER1; } 72 const bool isTower2() const 73 { return type_==TixyTaxyTorxyFieldType::TOWER2; } 68 74 virtual void create(char object, char param); 69 75 virtual void setCenterpoint(TixyTaxyTorxyCenterpoint* center); … … 81 87 virtual void createObstacle(int orientation); 82 88 virtual void createTower(int upgrade); 83 virtual int getAngle(); 89 virtual int getAngle(); 84 90 private: 91 85 92 virtual void setAngle(int newAngle); 86 93 virtual void destroyTower(); -
code/branches/TixyTaxyTorxy_HS18/src/modules/TixyTaxyTorxy/TixyTaxyTorxyHUDController.cc
r12064 r12149 31 31 #include "core/XMLPort.h" 32 32 #include "util/Convert.h" 33 #include "TixyTaxyTorxy.h" 33 34 34 35 namespace orxonox -
code/branches/TixyTaxyTorxy_HS18/src/modules/TixyTaxyTorxy/TixyTaxyTorxySelecter.cc
r12064 r12149 53 53 boostPressed_ = false; 54 54 buildTower_ = false; 55 setSelectedPosition( 0,0);55 setSelectedPosition(5,5); 56 56 } 57 57
Note: See TracChangeset
for help on using the changeset viewer.