[Orxonox-commit 1980] r6697 - code/branches/dynamicmatch/src/orxonox/gametypes
jo at orxonox.net
jo at orxonox.net
Mon Apr 12 17:04:07 CEST 2010
Author: jo
Date: 2010-04-12 17:04:07 +0200 (Mon, 12 Apr 2010)
New Revision: 6697
Modified:
code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.cc
code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.h
Log:
boost feature added
Modified: code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.cc
===================================================================
--- code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.cc 2010-04-12 14:52:01 UTC (rev 6696)
+++ code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.cc 2010-04-12 15:04:07 UTC (rev 6697)
@@ -33,10 +33,12 @@
#include "network/Host.h"
#include "infos/PlayerInfo.h"
#include "worldentities/pawns/Pawn.h"
+#include "worldentities/pawns/SpaceShip.h"
#include "core/ConfigValueIncludes.h"
#include "interfaces/TeamColourable.h"
-//#include "Engine.h"
-//timer mit new erstellen
+#include "items/Engine.h"
+#include "tools/Timer.h"
+
namespace orxonox
{
CreateUnloadableFactory(Dynamicmatch);
@@ -54,6 +56,21 @@
this->friendlyfire=true;
}
+ void Dynamicmatch::setConfigValues()
+ {
+ SetConfigValue(gameTime_, 180);//just for test cases
+ SetConfigValue(friendlyfire, true);
+ static ColourValue colours[] =
+ {
+ ColourValue(0.3f, 0.3f, 1.0f),
+ ColourValue(1.0f, 0.3f, 0.3f)
+
+ };
+ static std::vector<ColourValue> defaultcolours(colours, colours + sizeof(colours) / sizeof(ColourValue));
+
+ SetConfigValue(partyColours_, defaultcolours);
+ }
+
void Dynamicmatch::setPlayerColour(PlayerInfo* player) // not sure if this is the right place - helper function
{
std::map<PlayerInfo*, int>::const_iterator it_player = this->playerParty_.find(player);
@@ -81,22 +98,6 @@
}
-
-void Dynamicmatch::setConfigValues()
- {
- SetConfigValue(gameTime_, 180);//just for test cases
- SetConfigValue(friendlyfire, true);
- static ColourValue colours[] =
- {
- ColourValue(0.3f, 0.3f, 1.0f),
- ColourValue(1.0f, 0.3f, 0.3f)
-
- };
- static std::vector<ColourValue> defaultcolours(colours, colours + sizeof(colours) / sizeof(ColourValue));
-
- SetConfigValue(partyColours_, defaultcolours);
- }
-
bool Dynamicmatch::allowPawnDamage(Pawn* victim, Pawn* originator)//tested - works fine
{
@@ -119,10 +120,20 @@
const std::string& messageVictim = victim->getPlayer()->getName() + " is victim";
COUT(0) << messageVictim << std::endl;
Host::Broadcast(messageVictim);
- //party switch -> colour switch
-
- setPlayerColour(victim->getPlayer()); //victim colour
- setPlayerColour(originator->getPlayer());//orginator colour
+
+ //party switch -> colour switch
+ setPlayerColour(victim->getPlayer()); //victim colour
+ setPlayerColour(originator->getPlayer());//orginator colour
+
+ //Give new pig boost
+ SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
+ if (spaceship && spaceship->getEngine())
+ {
+ spaceship->getEngine()->setSpeedFactor(5);
+ WeakPtr<Engine>* ptr = new WeakPtr<Engine>(spaceship->getEngine());
+ new Timer(10, false, &createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this))->setDefaultValue(0, ptr), true);
+ }
+
}
//Case 3: there are only chasers -> new piggy is needed
else if (onlyChasers){
@@ -130,8 +141,17 @@
playerParty_[victim->getPlayer()]=piggy;
onlyChasers=false;
setPlayerColour(victim->getPlayer()); //victim colour
- //victim - Boost ueber setBoostFactor(float factor) //vermutlich muss victim gecastet werden
- // timer aufrufen - nach 5 Sekunden wieder auf normalgeschwindigkeit setzen
+
+ //Give new pig boost
+ SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
+ if (spaceship && spaceship->getEngine())
+ {
+ spaceship->getEngine()->setSpeedFactor(5);
+ WeakPtr<Engine>* ptr = new WeakPtr<Engine>(spaceship->getEngine());
+ new Timer(10, false, &createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this))->setDefaultValue(0, ptr), true);
+ }
+
+
std::string message("First victim.");
COUT(0) << message << std::endl;
Host::Broadcast(message);
@@ -149,8 +169,14 @@
return false;
}
-
-
+void Dynamicmatch::resetSpeedFactor(WeakPtr<Engine>* ptr)
+{
+ if (*ptr)
+ {
+ (*ptr)->setSpeedFactor(1.0f);
+ }
+ delete ptr;
+}
bool Dynamicmatch::allowPawnDeath(Pawn* victim, Pawn* originator)//
{
@@ -191,9 +217,8 @@
{
if (!player)
return;
- playerParty_[player]=chaser;//playerparty
- // Set the playercolour
- Dynamicmatch::setPlayerColour(player);
+ playerParty_[player]=chaser;//playerparty
+ Dynamicmatch::setPlayerColour(player); //Set playercolour
}
void Dynamicmatch::playerEntered(PlayerInfo* player) //standardfunction
Modified: code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.h
===================================================================
--- code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.h 2010-04-12 14:52:01 UTC (rev 6696)
+++ code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.h 2010-04-12 15:04:07 UTC (rev 6697)
@@ -57,6 +57,8 @@
virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);//is used to initialize the player's party and colour
virtual bool playerLeft(PlayerInfo* player);//ToDo: extract the player's party record - done?
virtual bool playerChangedName(PlayerInfo* player);//unchanged
+
+ void resetSpeedFactor(WeakPtr<Engine>* ptr);
void tick (float dt);// used to end the game
More information about the Orxonox-commit
mailing list