Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc @ 12130

Last change on this file since 12130 was 12130, checked in by stadlero, 5 years ago

changed gametype from Deathmatch to Wagnis in Wagnis.oxw + some wip in Wagnis.cc

File size: 3.1 KB
Line 
1
2
3
4#include "Wagnis.h"
5
6
7
8namespace orxonox{
9
10RegisterClass(Wagnis);
11
12//Constructor
13Wagnis::Wagnis(Context* context) : Deathmatch(context){
14    RegisterObject(Wagnis);
15    this->gameBoard = nullptr;
16    this->gameStage = NOT_READY;
17    this->active_player = 1;
18
19    int n = 3;
20    this->players.push_back(nullptr);
21    for(int i = 1;i <= n;i++){
22        WagnisPlayer* p = new WagnisPlayer(context);
23        p->gameBoard = this->gameBoard;
24        p->Player_ID = i;
25        p->master = this;
26        //p->finishedStageCallback = &Wagnis::playerFinishedStage;
27        this->players.push_back(p);
28    }
29}
30//Destructor
31Wagnis::~Wagnis(){}
32
33
34//Runs the game
35void Wagnis::start(){
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;
44}
45
46//Tick
47void Wagnis::tick(float dt){
48    SUPER(Wagnis,tick,dt);
49}
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 **/
59void 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
97//Creates and links all needed classes
98void Wagnis::createGame(){
99    orxout() << "Game creation started" << endl;
100
101    if(!findGameBoard()){
102        orxout() << "Error: GameBoard not found" << endl;
103    }
104
105    //this->gameBoard->initializeNeighbors();
106
107    //for(WagnisPlayer* p: this->players){
108        //this->playerEntered(p);
109    //}
110   
111    orxout() << "Game creation finished" << endl;
112}
113
114//Finds the pointer to the gameBoard
115bool Wagnis::findGameBoard(){
116    for (WagnisGameboard* gb : ObjectList<WagnisGameboard>()){
117        this->gameBoard = gb;
118        orxout()<<"Gameboard pointer found and added"<<endl;
119        return true;
120    }
121    return false;
122}
123
124
125
126
127
128
129
130
131
132
133
134
135
136}
137
138
139       
140   
Note: See TracBrowser for help on using the repository browser.