[Orxonox-commit 7526] r12132 - in code/branches/wagnis_HS18: data/levels src/modules/wagnis
stadlero at orxonox.net
stadlero at orxonox.net
Thu Nov 29 19:22:46 CET 2018
Author: stadlero
Date: 2018-11-29 19:22:46 +0100 (Thu, 29 Nov 2018)
New Revision: 12132
Modified:
code/branches/wagnis_HS18/data/levels/Wagnis.oxw
code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc
code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h
code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.cc
code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc
Log:
Wagnis runs without crashing on startup
Modified: code/branches/wagnis_HS18/data/levels/Wagnis.oxw
===================================================================
--- code/branches/wagnis_HS18/data/levels/Wagnis.oxw 2018-11-29 08:12:53 UTC (rev 12131)
+++ code/branches/wagnis_HS18/data/levels/Wagnis.oxw 2018-11-29 18:22:46 UTC (rev 12132)
@@ -55,8 +55,8 @@
<Provinces>
-
- <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)?>">
+
+ <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)?>">
<attached>
<Model position="0,0,0" mesh="ast1.mesh" scale3D="1.4,1.4,1.4" />
</attached>
@@ -64,6 +64,16 @@
<SphereCollisionShape position="0,0,0" radius="2" />
</collisionShapes>
</WagnisProvince>
+
+ <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)?>">
+ <attached>
+ <Model position="0,0,0" mesh="ast1.mesh" scale3D="3,3,3" />
+ </attached>
+ <collisionShapes>
+ <SphereCollisionShape position="0,0,0" radius="2" />
+ </collisionShapes>
+ </WagnisProvince>
+
<!--
<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)?>">
<attached>
Modified: code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc 2018-11-29 08:12:53 UTC (rev 12131)
+++ code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc 2018-11-29 18:22:46 UTC (rev 12132)
@@ -17,13 +17,10 @@
this->active_player = 1;
int n = 3;
- this->players.push_back(nullptr);
- for(int i = 1;i <= n;i++){
+ for(int i = 0;i < n;i++){
WagnisPlayer* p = new WagnisPlayer(context);
- p->gameBoard = this->gameBoard;
- p->Player_ID = i;
+ p->Player_ID = i+1;
p->master = this;
- //p->finishedStageCallback = &Wagnis::playerFinishedStage;
this->players.push_back(p);
}
}
@@ -36,11 +33,15 @@
Deathmatch::start();
if(this->gameStage == NOT_READY){
this->createGame();
+
+ for(WagnisPlayer* ptr: this->players){
+ ptr->gameBoard = this->gameBoard;
+ }
}
- //this->gameStage = CHOOSE_PROVINCE_STAGE;
- //this->players[1]->gameStage = this->gameStage;
- //this->players[1]->is_active = true;
+ this->gameStage = CHOOSE_PROVINCE_STAGE;
+ this->players.at(0)->gameStage = this->gameStage;
+ this->players.at(0)->is_active = true;
}
//Tick
@@ -56,12 +57,8 @@
* (used to deactivate player after finishing)
* enum GameStage { NOT_READY, CHOOSE_PROVINCE_STAGE, REINFORCEMENT_STAGE, ATTACK_STAGE, MOVE_STAGE };
**/
-void Wagnis::playerFinishedStage(WagnisPlayer* player){
+void Wagnis::playerFinishedStageCallback(WagnisPlayer* player){
- /////////////////TEST////////////
- orxout()<<"juhuuuuuuuuuuuuuuuuuuu"<<endl;
- /////////////////TEST////////////
-
if(this->active_player != player->Player_ID){
orxout()<<"shit happend. This player should not be activ. Wagnis::playerFinishedStage was called from wrong player"<<endl;
}
@@ -68,26 +65,32 @@
switch(this->gameStage){
case CHOOSE_PROVINCE_STAGE:{
player->is_active = false;
- if(this->active_player+1 < this->players.size()){
+ if(this->active_player < this->players.size()){
this->active_player++;
- this->players[this->active_player]->gameStage = CHOOSE_PROVINCE_STAGE;
- this->players[this->active_player]->is_active = true;
+ WagnisPlayer* next = this->players[this->active_player-1];
+ next->gameStage = CHOOSE_PROVINCE_STAGE;
+ next->is_active = true;
+ orxout()<<"Player "<<next->Player_ID<<"\'s turn. Please choose province"<<endl;
}else{
this->active_player = 1;
- this->players[this->active_player]->gameStage = REINFORCEMENT_STAGE;
- this->players[this->active_player]->is_active = true;
+ WagnisPlayer* next = this->players[this->active_player-1];
+ next->gameStage = REINFORCEMENT_STAGE;
+ this->gameStage = REINFORCEMENT_STAGE;
+ next->is_active = true;
+ orxout()<<"Player "<<next->Player_ID<<"\'s turn. Reinforcement"<<endl;
}
break;
}
case REINFORCEMENT_STAGE:{
-
+ break;
}
case ATTACK_STAGE:{
-
+ break;
}
case MOVE_STAGE:{
-
+ break;
}
+ default:{}
}
}
Modified: code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h 2018-11-29 08:12:53 UTC (rev 12131)
+++ code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h 2018-11-29 18:22:46 UTC (rev 12132)
@@ -37,7 +37,7 @@
virtual ~Wagnis();
void start();
void tick(float);
- void playerFinishedStage(WagnisPlayer*);
+ void playerFinishedStageCallback(WagnisPlayer*);
Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.cc 2018-11-29 08:12:53 UTC (rev 12131)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.cc 2018-11-29 18:22:46 UTC (rev 12132)
@@ -33,7 +33,6 @@
void WagnisGameboard::addProvince(WagnisProvince* province){
orxout() << "added" << endl;
orxout() << province->getID() << endl;
-
this->provs.push_back(province);
}
//XML get province
Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc 2018-11-29 08:12:53 UTC (rev 12131)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc 2018-11-29 18:22:46 UTC (rev 12132)
@@ -20,6 +20,7 @@
this->origin_province = nullptr;
this->target_province = nullptr;
this->province_selection_changed = false;
+ this->gameStage = NOT_READY;
}
//Destructor
WagnisPlayer::~WagnisPlayer(){
@@ -29,21 +30,18 @@
void WagnisPlayer::tick(float dt){
SUPER(WagnisPlayer, tick, dt);
- ///////////TEST//////////////
- /**
- if(this->is_active){
- (master ->* ((orxonox::WagnisPlayer*)this)->orxonox::WagnisPlayer::finishedStageCallback) (this);
- }
-
- **/
- ///////////TEST//////////////
-
-
-
if(this->is_active)
{
+
for(WagnisProvince* prov:this->gameBoard->provs){
+ //orxout()<<"province health: "<<prov->getHealth()<<endl;
if(prov->getHealth() < prov->getMaxHealth()){
+ //Check if next-player-button was hit
+ if(prov->getID() == 1000){
+ master->playerFinishedStageCallback(this);
+ break;
+ }
+ //Check left/right click
if(prov->getHealth() <= prov->getMaxHealth()-1000.0f){
this->target_province = prov;
this->province_selection_changed = true;
@@ -51,6 +49,7 @@
this->origin_province = prov;
this->province_selection_changed = true;
}
+ prov->setHealth(prov->getMaxHealth());
}
}
Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc 2018-11-29 08:12:53 UTC (rev 12131)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc 2018-11-29 18:22:46 UTC (rev 12132)
@@ -27,9 +27,10 @@
this->continent = -1;
this->neighbors = std::vector<WagnisProvince*>();
this->markerBillboard = nullptr;
+
+ this->initialHealth_ = WAGNIS_PROVINCE_MAX_HEALTH;
this->maxHealth_ = WAGNIS_PROVINCE_MAX_HEALTH;
this->health_ = WAGNIS_PROVINCE_MAX_HEALTH;
-
}
//Destructor
WagnisProvince::~WagnisProvince(){
More information about the Orxonox-commit
mailing list