Changeset 12130 for code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc
- Timestamp:
- Nov 28, 2018, 11:17:41 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc
r12124 r12130 15 15 this->gameBoard = nullptr; 16 16 this->gameStage = NOT_READY; 17 this->active_player = 1; 17 18 18 19 int n = 3; 20 this->players.push_back(nullptr); 19 21 for(int i = 1;i <= n;i++){ 20 22 WagnisPlayer* p = new WagnisPlayer(context); 21 23 p->gameBoard = this->gameBoard; 24 p->Player_ID = i; 25 p->master = this; 26 //p->finishedStageCallback = &Wagnis::playerFinishedStage; 22 27 this->players.push_back(p); 23 28 } … … 29 34 //Runs the game 30 35 void Wagnis::start(){ 31 //SUPER(Wagnis,start); 32 this->createGame(); 36 Deathmatch::start(); 37 if(this->gameStage == NOT_READY){ 38 this->createGame(); 39 } 40 41 //this->gameStage = CHOOSE_PROVINCE_STAGE; 42 //this->players[1]->gameStage = this->gameStage; 43 //this->players[1]->is_active = true; 33 44 } 34 45 … … 38 49 } 39 50 51 52 53 /** 54 * Callback function for Player classes. Needs to be called for the game to go on. 55 * arg: player: pointer to the player which finished his stage. 56 * (used to deactivate player after finishing) 57 * enum GameStage { NOT_READY, CHOOSE_PROVINCE_STAGE, REINFORCEMENT_STAGE, ATTACK_STAGE, MOVE_STAGE }; 58 **/ 59 void Wagnis::playerFinishedStage(WagnisPlayer* player){ 60 61 /////////////////TEST//////////// 62 orxout()<<"juhuuuuuuuuuuuuuuuuuuu"<<endl; 63 /////////////////TEST//////////// 64 65 if(this->active_player != player->Player_ID){ 66 orxout()<<"shit happend. This player should not be activ. Wagnis::playerFinishedStage was called from wrong player"<<endl; 67 } 68 switch(this->gameStage){ 69 case CHOOSE_PROVINCE_STAGE:{ 70 player->is_active = false; 71 if(this->active_player+1 < this->players.size()){ 72 this->active_player++; 73 this->players[this->active_player]->gameStage = CHOOSE_PROVINCE_STAGE; 74 this->players[this->active_player]->is_active = true; 75 }else{ 76 this->active_player = 1; 77 this->players[this->active_player]->gameStage = REINFORCEMENT_STAGE; 78 this->players[this->active_player]->is_active = true; 79 } 80 break; 81 } 82 case REINFORCEMENT_STAGE:{ 83 84 } 85 case ATTACK_STAGE:{ 86 87 } 88 case MOVE_STAGE:{ 89 90 } 91 } 92 } 93 94 95 96 40 97 //Creates and links all needed classes 41 void Wagnis::createGame(){ \42 orxout() << "Game creation started" ;98 void Wagnis::createGame(){ 99 orxout() << "Game creation started" << endl; 43 100 44 101 if(!findGameBoard()){ 45 orxout() << "Error: GameBoard not found" ;102 orxout() << "Error: GameBoard not found" << endl; 46 103 } 47 104 48 this->gameBoard->initializeNeighbors(); 49 orxout() << "Game creation finished"; 105 //this->gameBoard->initializeNeighbors(); 106 107 //for(WagnisPlayer* p: this->players){ 108 //this->playerEntered(p); 109 //} 110 111 orxout() << "Game creation finished" << endl; 50 112 } 51 113 … … 54 116 for (WagnisGameboard* gb : ObjectList<WagnisGameboard>()){ 55 117 this->gameBoard = gb; 56 orxout()<<"Gameboard pointer found and added" ;118 orxout()<<"Gameboard pointer found and added"<<endl; 57 119 return true; 58 120 }
Note: See TracChangeset
for help on using the changeset viewer.