Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12130


Ignore:
Timestamp:
Nov 28, 2018, 11:17:41 PM (6 years ago)
Author:
stadlero
Message:

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

Location:
code/branches/wagnis_HS18
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/wagnis_HS18/data/levels/Wagnis.oxw

    r12129 r12130  
    3838
    3939
    40 <Level plugins="wagnis" gametype="Deathmatch">
     40<Level plugins="wagnis" gametype="Wagnis">
    4141  <templates>
    4242    <Template link=lodtemplate_default />
  • code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc

    r12124 r12130  
    1515    this->gameBoard = nullptr;
    1616    this->gameStage = NOT_READY;
     17    this->active_player = 1;
    1718
    1819    int n = 3;
     20    this->players.push_back(nullptr);
    1921    for(int i = 1;i <= n;i++){
    2022        WagnisPlayer* p = new WagnisPlayer(context);
    2123        p->gameBoard = this->gameBoard;
     24        p->Player_ID = i;
     25        p->master = this;
     26        //p->finishedStageCallback = &Wagnis::playerFinishedStage;
    2227        this->players.push_back(p);
    2328    }
     
    2934//Runs the game
    3035void 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;
    3344}
    3445
     
    3849}
    3950
     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
    4097//Creates and links all needed classes
    41 void Wagnis::createGame(){\
    42     orxout() << "Game creation started";
     98void Wagnis::createGame(){
     99    orxout() << "Game creation started" << endl;
    43100
    44101    if(!findGameBoard()){
    45         orxout() << "Error: GameBoard not found";
     102        orxout() << "Error: GameBoard not found" << endl;
    46103    }
    47104
    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;
    50112}
    51113
     
    54116    for (WagnisGameboard* gb : ObjectList<WagnisGameboard>()){
    55117        this->gameBoard = gb;
    56         orxout()<<"Gameboard pointer found and added";
     118        orxout()<<"Gameboard pointer found and added"<<endl;
    57119        return true;
    58120    }
  • code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h

    r12124 r12130  
    3838        void start();
    3939        void tick(float);
     40        void playerFinishedStage(WagnisPlayer*);
    4041
    4142
     
    4445
    4546        private:
     47        int active_player;
    4648        GameStage gameStage;
    4749        std::vector<WagnisPlayer*> players;
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.cc

    r12124 r12130  
    1212    WagnisGameboard::WagnisGameboard(Context* context) : StaticEntity(context){
    1313        RegisterObject(WagnisGameboard);
     14        this->connections_string = "";
    1415    }
     16    WagnisGameboard::~WagnisGameboard(){}
    1517
    16     WagnisGameboard::~WagnisGameboard(){
    17         for(WagnisProvince* prov:this->provs){
    18             prov->destroy();
    19         }
    20     }
    2118    void WagnisGameboard::XMLPort(Element& xmlelement,XMLPort::Mode mode){
    2219        SUPER(WagnisGameboard, XMLPort, xmlelement, mode);
     
    6360    //Syntax: 32=7-8-4  , 2=33+5+7+1+4
    6461    void WagnisGameboard::initializeNeighbors(){
     62       
    6563        std::string str = this->connections_string;
    6664        orxout() << "inizializing started" << endl;
     
    6967        unsigned int n = 0;
    7068        while(n < str.size()){
    71             orxout() << "test1" << endl;
    7269            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;
    7572            if(n == str.size() || str[n] != '='){
    7673                orxout() << "Error while parsing neighbors-string: '=' expected at position: "<< n << endl;
     
    8178                n++;
    8279                tmp = parse_int(str,n);
    83                 n = tmp | 0x0000FFFF;
    84                 other_ID = tmp / (2<<16);
     80                n = tmp & 0x0000FFFF;
     81                other_ID = tmp >> 16;
    8582
    8683                for(WagnisProvince* orig:this->provs){
     
    9693                    break;
    9794                }
    98             }while(n < str.size() && str[n] == '+');
     95            }while((n < str.size()) && (str[n] == '+'));
    9996            if(n == str.size()) return;
    100             while(n < str.size() && str[n] == ' ') n++;
     97            while((n < str.size()) && (str[n] == ' ')) n++;
    10198            if(n == str.size()) return;
    10299            if(str[n] != ','){
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc

    r12127 r12130  
    3030        SUPER(WagnisPlayer, tick, dt);
    3131
     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
    3243        if(this->is_active)
    3344        {
     
    4556
    4657            if((this->province_selection_changed && this->origin_province != nullptr && this->target_province != nullptr)
    47             ||(this->province_selection_changed && this->target_province != nullptr && ((gamestage == CHOOSE_PROVINCE_STAGE)||(gamestage == REINFORCEMENT_STAGE)))){
     58            ||(this->province_selection_changed && this->target_province != nullptr && ((gameStage == CHOOSE_PROVINCE_STAGE)||(gameStage == REINFORCEMENT_STAGE)))){
    4859               
    4960                this->province_selection_changed = false;
    50                 switch(gamestage){
     61                switch(gameStage){
    5162                    case CHOOSE_PROVINCE_STAGE:
    5263                    {   
     
    107118                        break;
    108119                    }
     120
     121                    default: break;
    109122                }
    110123            }
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h

    r12127 r12130  
    3939
    4040
    41         GameStage gamestage;
     41        //void (Wagnis::*finishedStageCallback) (WagnisPlayer*);
     42        Wagnis* master;
     43        GameStage gameStage;
    4244        bool province_selection_changed;
    4345        bool is_active;
Note: See TracChangeset for help on using the changeset viewer.