Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12132 for code/branches


Ignore:
Timestamp:
Nov 29, 2018, 7:22:46 PM (6 years ago)
Author:
stadlero
Message:

Wagnis runs without crashing on startup

Location:
code/branches/wagnis_HS18
Files:
6 edited

Legend:

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

    r12130 r12132  
    5656
    5757  <Provinces>
    58  
    59     <WagnisProvince ID="1" health=10000 collisionType=dynamic mass=100 continent="1" position="0,<?lua print((10+7))?>,<?lua print((135-6))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
     58
     59    <WagnisProvince ID="1" health = 10000000 maxhealth = 10000000 initialhealth = 10000000 collisionType=dynamic mass=100 continent="1" position="0,<?lua print((10+7))?>,<?lua print((135-6))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
    6060      <attached>
    6161        <Model position="0,0,0" mesh="ast1.mesh" scale3D="1.4,1.4,1.4" />
     
    6565      </collisionShapes>
    6666    </WagnisProvince>
     67
     68    <WagnisProvince ID="1000" health = 10000000 maxhealth = 10000000 initialhealth = 10000000 collisionType=dynamic mass=100 continent="1" position="0,<?lua print((50+7))?>,<?lua print((135-6))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
     69      <attached>
     70        <Model position="0,0,0" mesh="ast1.mesh" scale3D="3,3,3" />
     71      </attached>
     72      <collisionShapes>
     73        <SphereCollisionShape   position="0,0,0" radius="2" />
     74      </collisionShapes>
     75    </WagnisProvince>
     76 
    6777<!--
    6878    <WagnisProvince ID="2" continent="1" position="0,<?lua print((10-7))?>,<?lua print((135-10))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
  • code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc

    r12130 r12132  
    1818
    1919    int n = 3;
    20     this->players.push_back(nullptr);
    21     for(int i = 1;i <= n;i++){
     20    for(int i = 0;i < n;i++){
    2221        WagnisPlayer* p = new WagnisPlayer(context);
    23         p->gameBoard = this->gameBoard;
    24         p->Player_ID = i;
     22        p->Player_ID = i+1;
    2523        p->master = this;
    26         //p->finishedStageCallback = &Wagnis::playerFinishedStage;
    2724        this->players.push_back(p);
    2825    }
     
    3734    if(this->gameStage == NOT_READY){
    3835        this->createGame();
     36
     37        for(WagnisPlayer* ptr: this->players){
     38            ptr->gameBoard = this->gameBoard;
     39        }
    3940    }
    4041
    41     //this->gameStage = CHOOSE_PROVINCE_STAGE;
    42     //this->players[1]->gameStage = this->gameStage;
    43     //this->players[1]->is_active = true;
     42    this->gameStage = CHOOSE_PROVINCE_STAGE;
     43    this->players.at(0)->gameStage = this->gameStage;
     44    this->players.at(0)->is_active = true;
    4445}
    4546
     
    5758 * enum GameStage { NOT_READY, CHOOSE_PROVINCE_STAGE, REINFORCEMENT_STAGE, ATTACK_STAGE, MOVE_STAGE };
    5859 **/
    59 void Wagnis::playerFinishedStage(WagnisPlayer* player){
    60 
    61     /////////////////TEST////////////
    62     orxout()<<"juhuuuuuuuuuuuuuuuuuuu"<<endl;
    63     /////////////////TEST////////////
     60void Wagnis::playerFinishedStageCallback(WagnisPlayer* player){
    6461
    6562    if(this->active_player != player->Player_ID){
     
    6966        case CHOOSE_PROVINCE_STAGE:{
    7067            player->is_active = false;
    71             if(this->active_player+1 < this->players.size()){
     68            if(this->active_player < this->players.size()){
    7269                this->active_player++;
    73                 this->players[this->active_player]->gameStage = CHOOSE_PROVINCE_STAGE;
    74                 this->players[this->active_player]->is_active = true;
     70                WagnisPlayer* next = this->players[this->active_player-1];
     71                next->gameStage = CHOOSE_PROVINCE_STAGE;
     72                next->is_active = true;
     73                orxout()<<"Player "<<next->Player_ID<<"\'s turn. Please choose province"<<endl;
    7574            }else{
    7675                this->active_player = 1;
    77                 this->players[this->active_player]->gameStage = REINFORCEMENT_STAGE;
    78                 this->players[this->active_player]->is_active = true;
     76                WagnisPlayer* next = this->players[this->active_player-1];
     77                next->gameStage = REINFORCEMENT_STAGE;
     78                this->gameStage = REINFORCEMENT_STAGE;
     79                next->is_active = true;
     80                orxout()<<"Player "<<next->Player_ID<<"\'s turn. Reinforcement"<<endl;
    7981            }
    8082            break;
    8183        }
    8284        case REINFORCEMENT_STAGE:{
    83            
     85            break;
    8486        }
    8587        case ATTACK_STAGE:{
    86            
     88            break;
    8789        }
    8890        case MOVE_STAGE:{
    89            
     91            break;
    9092        }
     93        default:{}
    9194    }
    9295}
  • code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h

    r12130 r12132  
    3838        void start();
    3939        void tick(float);
    40         void playerFinishedStage(WagnisPlayer*);
     40        void playerFinishedStageCallback(WagnisPlayer*);
    4141
    4242
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.cc

    r12130 r12132  
    3434        orxout() << "added" << endl;
    3535        orxout() << province->getID() << endl;
    36        
    3736        this->provs.push_back(province);
    3837    }
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc

    r12130 r12132  
    2121        this->target_province = nullptr;
    2222        this->province_selection_changed = false;
     23        this->gameStage = NOT_READY;
    2324    }
    2425    //Destructor
     
    3031        SUPER(WagnisPlayer, tick, dt);
    3132
    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 
    4333        if(this->is_active)
    4434        {
     35           
    4536            for(WagnisProvince* prov:this->gameBoard->provs){
     37                //orxout()<<"province health: "<<prov->getHealth()<<endl;
    4638                if(prov->getHealth() < prov->getMaxHealth()){
     39                    //Check if next-player-button was hit
     40                    if(prov->getID() == 1000){
     41                        master->playerFinishedStageCallback(this);
     42                        break;
     43                    }
     44                    //Check left/right click
    4745                    if(prov->getHealth() <= prov->getMaxHealth()-1000.0f){
    4846                        this->target_province = prov;
     
    5250                        this->province_selection_changed = true;
    5351                    }
     52                    prov->setHealth(prov->getMaxHealth());
    5453                }
    5554            }
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc

    r12119 r12132  
    2828        this->neighbors = std::vector<WagnisProvince*>();
    2929        this->markerBillboard = nullptr;
     30       
     31        this->initialHealth_ = WAGNIS_PROVINCE_MAX_HEALTH;
    3032        this->maxHealth_ = WAGNIS_PROVINCE_MAX_HEALTH;
    3133        this->health_ = WAGNIS_PROVINCE_MAX_HEALTH;
    32        
    3334    }
    3435    //Destructor
Note: See TracChangeset for help on using the changeset viewer.