Changeset 12130 for code/branches/wagnis_HS18
- Timestamp:
- Nov 28, 2018, 11:17:41 PM (6 years ago)
- Location:
- code/branches/wagnis_HS18
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/wagnis_HS18/data/levels/Wagnis.oxw
r12129 r12130 38 38 39 39 40 <Level plugins="wagnis" gametype=" Deathmatch">40 <Level plugins="wagnis" gametype="Wagnis"> 41 41 <templates> 42 42 <Template link=lodtemplate_default /> -
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 } -
code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h
r12124 r12130 38 38 void start(); 39 39 void tick(float); 40 void playerFinishedStage(WagnisPlayer*); 40 41 41 42 … … 44 45 45 46 private: 47 int active_player; 46 48 GameStage gameStage; 47 49 std::vector<WagnisPlayer*> players; -
code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.cc
r12124 r12130 12 12 WagnisGameboard::WagnisGameboard(Context* context) : StaticEntity(context){ 13 13 RegisterObject(WagnisGameboard); 14 this->connections_string = ""; 14 15 } 16 WagnisGameboard::~WagnisGameboard(){} 15 17 16 WagnisGameboard::~WagnisGameboard(){17 for(WagnisProvince* prov:this->provs){18 prov->destroy();19 }20 }21 18 void WagnisGameboard::XMLPort(Element& xmlelement,XMLPort::Mode mode){ 22 19 SUPER(WagnisGameboard, XMLPort, xmlelement, mode); … … 63 60 //Syntax: 32=7-8-4 , 2=33+5+7+1+4 64 61 void WagnisGameboard::initializeNeighbors(){ 62 65 63 std::string str = this->connections_string; 66 64 orxout() << "inizializing started" << endl; … … 69 67 unsigned int n = 0; 70 68 while(n < str.size()){ 71 orxout() << "test1" << endl;72 69 int tmp = parse_int(str,n); 73 n = tmp |0x0000FFFF;74 int origin_ID = tmp / (2<<16);70 n = tmp & 0x0000FFFF; 71 int origin_ID = tmp >> 16; 75 72 if(n == str.size() || str[n] != '='){ 76 73 orxout() << "Error while parsing neighbors-string: '=' expected at position: "<< n << endl; … … 81 78 n++; 82 79 tmp = parse_int(str,n); 83 n = tmp |0x0000FFFF;84 other_ID = tmp / (2<<16);80 n = tmp & 0x0000FFFF; 81 other_ID = tmp >> 16; 85 82 86 83 for(WagnisProvince* orig:this->provs){ … … 96 93 break; 97 94 } 98 }while( n < str.size() && str[n] == '+');95 }while((n < str.size()) && (str[n] == '+')); 99 96 if(n == str.size()) return; 100 while( n < str.size() && str[n] == ' ') n++;97 while((n < str.size()) && (str[n] == ' ')) n++; 101 98 if(n == str.size()) return; 102 99 if(str[n] != ','){ -
code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
r12127 r12130 30 30 SUPER(WagnisPlayer, tick, dt); 31 31 32 ///////////TEST////////////// 33 /** 34 if(this->is_active){ 35 (master ->* ((orxonox::WagnisPlayer*)this)->orxonox::WagnisPlayer::finishedStageCallback) (this); 36 } 37 38 **/ 39 ///////////TEST////////////// 40 41 42 32 43 if(this->is_active) 33 44 { … … 45 56 46 57 if((this->province_selection_changed && this->origin_province != nullptr && this->target_province != nullptr) 47 ||(this->province_selection_changed && this->target_province != nullptr && ((game stage == CHOOSE_PROVINCE_STAGE)||(gamestage == REINFORCEMENT_STAGE)))){58 ||(this->province_selection_changed && this->target_province != nullptr && ((gameStage == CHOOSE_PROVINCE_STAGE)||(gameStage == REINFORCEMENT_STAGE)))){ 48 59 49 60 this->province_selection_changed = false; 50 switch(game stage){61 switch(gameStage){ 51 62 case CHOOSE_PROVINCE_STAGE: 52 63 { … … 107 118 break; 108 119 } 120 121 default: break; 109 122 } 110 123 } -
code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h
r12127 r12130 39 39 40 40 41 GameStage gamestage; 41 //void (Wagnis::*finishedStageCallback) (WagnisPlayer*); 42 Wagnis* master; 43 GameStage gameStage; 42 44 bool province_selection_changed; 43 45 bool is_active;
Note: See TracChangeset
for help on using the changeset viewer.