[Orxonox-commit 5164] r9829 - in code/branches/invaders: data/overlays src/modules/invader
zifloria at orxonox.net
zifloria at orxonox.net
Mon Nov 25 18:51:40 CET 2013
Author: zifloria
Date: 2013-11-25 18:51:39 +0100 (Mon, 25 Nov 2013)
New Revision: 9829
Modified:
code/branches/invaders/data/overlays/InvaderHUD.oxo
code/branches/invaders/src/modules/invader/Invader.cc
code/branches/invaders/src/modules/invader/Invader.h
code/branches/invaders/src/modules/invader/InvaderEnemy.cc
code/branches/invaders/src/modules/invader/InvaderEnemy.h
code/branches/invaders/src/modules/invader/InvaderShip.cc
code/branches/invaders/src/modules/invader/InvaderShip.h
Log:
points, level up, hud
Modified: code/branches/invaders/data/overlays/InvaderHUD.oxo
===================================================================
--- code/branches/invaders/data/overlays/InvaderHUD.oxo 2013-11-25 16:35:30 UTC (rev 9828)
+++ code/branches/invaders/data/overlays/InvaderHUD.oxo 2013-11-25 17:51:39 UTC (rev 9829)
@@ -29,7 +29,7 @@
textsize = 0.04
colour = "1.0, 1.0, 1.0, 1.0"
align = "left"
- caption = "Players: "
+ caption = "Level: "
/>
<InvaderHUDinfo
Modified: code/branches/invaders/src/modules/invader/Invader.cc
===================================================================
--- code/branches/invaders/src/modules/invader/Invader.cc 2013-11-25 16:35:30 UTC (rev 9828)
+++ code/branches/invaders/src/modules/invader/Invader.cc 2013-11-25 17:51:39 UTC (rev 9829)
@@ -63,7 +63,13 @@
//this->context = context;
this->setHUDTemplate("InvaderHUD");
+ lives = 3;
+ level = 1;
+ point = 0;
+ multiplier = 1;
+ b_combo = false;
enemySpawnTimer.setTimer(2.0f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));
+ comboTimer.setTimer(2.5f, true, createExecutor(createFunctor(&Invader::comboControll, this)));
}
Invader::~Invader()
@@ -86,6 +92,15 @@
newPawn->setPosition(player->getPosition() + Vector3(1000, 0, 0)); // BUG:
}
+ void Invader::comboControll()
+ {
+ if (b_combo)
+ multiplier++;
+ else
+ multiplier = 1;
+ b_combo = false;
+ }
+
// inject custom player controller
/** void Invader::spawnPlayer(PlayerInfo* player)
{
Modified: code/branches/invaders/src/modules/invader/Invader.h
===================================================================
--- code/branches/invaders/src/modules/invader/Invader.h 2013-11-25 16:35:30 UTC (rev 9828)
+++ code/branches/invaders/src/modules/invader/Invader.h 2013-11-25 17:51:39 UTC (rev 9829)
@@ -65,16 +65,24 @@
int getLives(){return this->lives;}
int getLevel(){return this->level;}
int getPoints(){return this->point;}
+
+ void costLife(){lives--; if (lives == 0) orxout() << "end<<<<<<<<<<<<<<<<<" << endl;};
+ void levelUp(){level++;}
+ void addPoints(int numPoints){point += numPoints * multiplier; b_combo = true;}
+ void comboControll();
private:
WeakPtr<InvaderCenterPoint> center_;
WeakPtr<InvaderShip> player;
ConsoleCommand* console_addEnemy;
Timer enemySpawnTimer;
+ Timer comboTimer;
//Context* context;
int lives;
int level;
int point;
+ bool b_combo;
+ int multiplier;
};
}
Modified: code/branches/invaders/src/modules/invader/InvaderEnemy.cc
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderEnemy.cc 2013-11-25 16:35:30 UTC (rev 9828)
+++ code/branches/invaders/src/modules/invader/InvaderEnemy.cc 2013-11-25 17:51:39 UTC (rev 9829)
@@ -57,4 +57,21 @@
setVelocity(Vector3(0,0,1000));
return false;
}
+
+ WeakPtr<Invader> InvaderEnemy::getGame()
+ {
+ if (game == NULL)
+ {
+ for (ObjectList<Invader>::iterator it = ObjectList<Invader>::begin(); it != ObjectList<Invader>::end(); ++it)
+ game = *it;
+ }
+ return game;
+ }
+
+ void InvaderEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
+ {
+ if (getGame())
+ getGame()->addPoints(42);
+ // SUPER(InvaderEnemy, damage, damage, healthdamage, shielddamage, originator);
+ }
}
\ No newline at end of file
Modified: code/branches/invaders/src/modules/invader/InvaderEnemy.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderEnemy.h 2013-11-25 16:35:30 UTC (rev 9828)
+++ code/branches/invaders/src/modules/invader/InvaderEnemy.h 2013-11-25 17:51:39 UTC (rev 9829)
@@ -48,8 +48,11 @@
virtual void tick(float dt);
virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
+ virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator);
private:
+ WeakPtr<Invader> getGame();
+ WeakPtr<Invader> game;
Camera* camera;
bool isFireing;
float speed, damping;
Modified: code/branches/invaders/src/modules/invader/InvaderShip.cc
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderShip.cc 2013-11-25 16:35:30 UTC (rev 9828)
+++ code/branches/invaders/src/modules/invader/InvaderShip.cc 2013-11-25 17:51:39 UTC (rev 9829)
@@ -35,6 +35,7 @@
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
+#include "Invader.h"
namespace orxonox
{
@@ -119,6 +120,12 @@
void InvaderShip::updateLevel()
{
lastTime = 0;
+ if (getGame())
+ {
+ getGame()->levelUp();
+ // SmartPtr<Invader> game = orxonox_cast<Invader>(getGametype());
+
+ }
//level++
}
@@ -150,10 +157,26 @@
if (getHealth() <= 0)
{
orxout() << "DIED!!!! " << endl;
+ if (getGame())
+ {
+ getGame()->costLife();
+ // SmartPtr<Invader> game = orxonox_cast<Invader>(getGametype());
+
+ }
}
return false;
}
return false;
// SUPER(InvaderShip, collidesAgainst, otherObject, contactPoint);
}
+
+ WeakPtr<Invader> InvaderShip::getGame()
+ {
+ if (game == NULL)
+ {
+ for (ObjectList<Invader>::iterator it = ObjectList<Invader>::begin(); it != ObjectList<Invader>::end(); ++it)
+ game = *it;
+ }
+ return game;
+ }
}
Modified: code/branches/invaders/src/modules/invader/InvaderShip.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderShip.h 2013-11-25 16:35:30 UTC (rev 9828)
+++ code/branches/invaders/src/modules/invader/InvaderShip.h 2013-11-25 17:51:39 UTC (rev 9829)
@@ -64,6 +64,9 @@
// *InvaderShip getShip(){return this;}
virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
private:
+
+ WeakPtr<Invader> getGame();
+ WeakPtr<Invader> game;
Camera* camera;
bool isFireing;
float speed, damping, posforeward;
More information about the Orxonox-commit
mailing list