[Orxonox-commit 456] r3033 - in trunk: . src/orxonox src/orxonox/objects/gametypes src/orxonox/objects/quest src/orxonox/objects/worldentities src/orxonox/objects/worldentities/pawns src/orxonox/objects/worldentities/triggers src/orxonox/overlays/hud
landauf at orxonox.net
landauf at orxonox.net
Sat May 23 21:57:52 CEST 2009
Author: landauf
Date: 2009-05-23 21:57:52 +0200 (Sat, 23 May 2009)
New Revision: 3033
Added:
trunk/src/orxonox/objects/gametypes/Asteroids.cc
trunk/src/orxonox/objects/gametypes/Asteroids.h
trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc
trunk/src/orxonox/objects/gametypes/TeamBaseMatch.h
trunk/src/orxonox/objects/gametypes/UnderAttack.cc
trunk/src/orxonox/objects/gametypes/UnderAttack.h
trunk/src/orxonox/objects/worldentities/ForceField.cc
trunk/src/orxonox/objects/worldentities/ForceField.h
trunk/src/orxonox/objects/worldentities/pawns/Destroyer.cc
trunk/src/orxonox/objects/worldentities/pawns/Destroyer.h
trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc
trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.h
trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc
trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.h
trunk/src/orxonox/overlays/hud/HUDTimer.cc
trunk/src/orxonox/overlays/hud/HUDTimer.h
Modified:
trunk/
trunk/src/orxonox/OrxonoxPrereqs.h
trunk/src/orxonox/objects/gametypes/CMakeLists.txt
trunk/src/orxonox/objects/gametypes/Gametype.cc
trunk/src/orxonox/objects/gametypes/Gametype.h
trunk/src/orxonox/objects/gametypes/TeamDeathmatch.cc
trunk/src/orxonox/objects/gametypes/TeamDeathmatch.h
trunk/src/orxonox/objects/quest/QuestEffectBeacon.cc
trunk/src/orxonox/objects/worldentities/CMakeLists.txt
trunk/src/orxonox/objects/worldentities/MobileEntity.cc
trunk/src/orxonox/objects/worldentities/MobileEntity.h
trunk/src/orxonox/objects/worldentities/MovableEntity.cc
trunk/src/orxonox/objects/worldentities/MovableEntity.h
trunk/src/orxonox/objects/worldentities/SpawnPoint.cc
trunk/src/orxonox/objects/worldentities/pawns/CMakeLists.txt
trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc
trunk/src/orxonox/objects/worldentities/triggers/CMakeLists.txt
trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h
trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc
trunk/src/orxonox/objects/worldentities/triggers/Trigger.h
trunk/src/orxonox/overlays/hud/CMakeLists.txt
Log:
merged gametypes branch back to trunk
Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/buildsystem:1875-2277,2279-2401
/branches/buildsystem2:2507-2659
/branches/buildsystem3:2663-2709
/branches/ceguilua:1803-1809
/branches/core3:1573-1740
/branches/gcc43:1581
/branches/gui:1636-1724,2796-2895
/branches/input:1630-1637
/branches/lodfinal:2373-2412
/branches/miniprojects:2755-2825
/branches/network:2357
/branches/network64:2211-2356
/branches/objecthierarchy:1912-2086,2101,2111-2170
/branches/objecthierarchy2:2172-2480
/branches/overlay:2118-2386
/branches/physics:1913-2056,2108-2440
/branches/physics_merge:2437-2458
/branches/pickups:1927-2087,2128
/branches/pickups2:2108-2498
/branches/presentation:2370-2653,2655-2661
/branches/questsystem:1895-2089
/branches/questsystem2:2108-2260
/branches/questsystem5:2777-2906
/branches/script_trigger:1296-1954,1956
/branches/weapon:1926-2095
/branches/weapon2:2108-2489
/branches/weaponsystem:2743-2891
+ /branches/buildsystem:1875-2277,2279-2401
/branches/buildsystem2:2507-2659
/branches/buildsystem3:2663-2709
/branches/ceguilua:1803-1809
/branches/core3:1573-1740
/branches/gametypes:2827-3032
/branches/gcc43:1581
/branches/gui:1636-1724,2796-2895
/branches/input:1630-1637
/branches/lodfinal:2373-2412
/branches/miniprojects:2755-2825
/branches/network:2357
/branches/network64:2211-2356
/branches/objecthierarchy:1912-2086,2101,2111-2170
/branches/objecthierarchy2:2172-2480
/branches/overlay:2118-2386
/branches/physics:1913-2056,2108-2440
/branches/physics_merge:2437-2458
/branches/pickups:1927-2087,2128
/branches/pickups2:2108-2498
/branches/presentation:2370-2653,2655-2661
/branches/questsystem:1895-2089
/branches/questsystem2:2108-2260
/branches/questsystem5:2777-2906
/branches/script_trigger:1296-1954,1956
/branches/weapon:1926-2095
/branches/weapon2:2108-2489
/branches/weaponsystem:2743-2891
Modified: trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- trunk/src/orxonox/OrxonoxPrereqs.h 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/OrxonoxPrereqs.h 2009-05-23 19:57:52 UTC (rev 3033)
@@ -137,6 +137,7 @@
class ControllableEntity;
class MovableEntity;
class Sublevel;
+ class ForceField;
class Model;
class Billboard;
@@ -161,6 +162,8 @@
class Spectator;
class Pawn;
class SpaceShip;
+ class TeamBaseMatchBase;
+ class Destroyer;
class Item;
class Engine;
@@ -171,6 +174,7 @@
class DistanceTrigger;
class EventTrigger;
class PlayerTrigger;
+ class CheckPoint;
class WeaponSystem;
class WeaponSet;
@@ -203,6 +207,9 @@
class Gametype;
class Deathmatch;
class TeamDeathmatch;
+ class Asteroids;
+ class TeamBaseMatch;
+ class UnderAttack;
class Pong;
class Scores;
@@ -235,6 +242,7 @@
class HUDRadar;
class HUDSpeedBar;
class HUDHealthBar;
+ class HUDTimer;
class InGameConsole;
class Notification;
class NotificationManager;
Copied: trunk/src/orxonox/objects/gametypes/Asteroids.cc (from rev 3032, branches/gametypes/src/orxonox/objects/gametypes/Asteroids.cc)
===================================================================
--- trunk/src/orxonox/objects/gametypes/Asteroids.cc (rev 0)
+++ trunk/src/orxonox/objects/gametypes/Asteroids.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -0,0 +1,93 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Aurelian Jaggi
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Asteroids.h"
+
+#include "core/CoreIncludes.h"
+#include "objects/infos/PlayerInfo.h"
+#include "objects/worldentities/pawns/Pawn.h"
+
+#include "network/Host.h"
+
+namespace orxonox
+{
+ CreateUnloadableFactory(Asteroids);
+
+ Asteroids::Asteroids(BaseObject* creator) : Gametype(creator)
+ {
+ RegisterObject(Asteroids);
+ this->firstCheckpointReached_ = false;
+ this->firstTimeSpawned_ = false;
+ }
+
+ void Asteroids::tick(float dt)
+ {
+ SUPER(Asteroids, tick, dt);
+
+ if (firstCheckpointReached_ && !this->timerIsActive_)
+ {
+ this->startTimer();
+ }
+
+ if (this->time_ < 0 && !this->hasEnded() && this->timerIsActive_)
+ {
+ this->end();
+ }
+ }
+
+ void Asteroids::spawnPlayer(PlayerInfo* player)
+ {
+ if (this->timerIsActive_ && this->firstTimeSpawned_)
+ {
+ this->end();
+ return;
+ }
+
+ this->firstTimeSpawned_ = true;
+ Gametype::spawnPlayer(player);
+ }
+
+ void Asteroids::start()
+ {
+ Gametype::start();
+
+ std::string message = "The match has started! Reach the first chekpoint within 60 seconds! But be aware, there may be pirates around...";
+ COUT(0) << message << std::endl;
+ Host::Broadcast(message);
+ }
+
+ void Asteroids::end()
+ {
+ Gametype::end();
+
+ std::string message = "The match has ended.";
+ COUT(0) << message << std::endl;
+ Host::Broadcast(message);
+ }
+}
Copied: trunk/src/orxonox/objects/gametypes/Asteroids.h (from rev 3032, branches/gametypes/src/orxonox/objects/gametypes/Asteroids.h)
===================================================================
--- trunk/src/orxonox/objects/gametypes/Asteroids.h (rev 0)
+++ trunk/src/orxonox/objects/gametypes/Asteroids.h 2009-05-23 19:57:52 UTC (rev 3033)
@@ -0,0 +1,63 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Aurelian Jaggi
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _Asteroids_H__
+#define _Asteroids_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "Gametype.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport Asteroids : public Gametype
+ {
+ public:
+ Asteroids(BaseObject* creator);
+ virtual ~Asteroids() {}
+
+ virtual void tick(float dt);
+
+ virtual void start();
+ virtual void end();
+
+ inline void firstCheckpointReached(bool reached)
+ { this->firstCheckpointReached_ = reached; }
+
+ protected:
+ virtual void spawnPlayer(PlayerInfo* player);
+
+ private:
+ bool firstCheckpointReached_;
+ bool gameEnded_;
+ bool firstTimeSpawned_;
+
+ };
+}
+
+#endif /* _Asteroids_H__ */
Modified: trunk/src/orxonox/objects/gametypes/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/objects/gametypes/CMakeLists.txt 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/gametypes/CMakeLists.txt 2009-05-23 19:57:52 UTC (rev 3033)
@@ -2,5 +2,8 @@
Gametype.cc
Deathmatch.cc
TeamDeathmatch.cc
+ TeamBaseMatch.cc
Pong.cc
+ UnderAttack.cc
+ Asteroids.cc
)
Modified: trunk/src/orxonox/objects/gametypes/Gametype.cc
===================================================================
--- trunk/src/orxonox/objects/gametypes/Gametype.cc 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/gametypes/Gametype.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -59,6 +59,10 @@
this->bForceSpawn_ = false;
this->numberOfBots_ = 0;
+ this->timeLimit_ = 0;
+ this->time_ = 0;
+ this->timerIsActive_ = false;
+
this->initialStartCountdown_ = 3;
this->setConfigValues();
@@ -87,12 +91,21 @@
{
SUPER(Gametype, tick, dt);
+ //count timer
+ if (timerIsActive_)
+ {
+ if (this->timeLimit_ == 0)
+ this->time_ += dt;
+ else
+ this->time_ -= dt;
+ }
+
if (this->gtinfo_.bStartCountdownRunning_ && !this->gtinfo_.bStarted_)
this->gtinfo_.startCountdown_ -= dt;
if (!this->gtinfo_.bStarted_)
this->checkStart();
- else
+ else if (!this->gtinfo_.bEnded_)
this->spawnDeadPlayersIfRequested();
this->assignDefaultPawnsIfNeeded();
@@ -110,6 +123,31 @@
void Gametype::end()
{
this->gtinfo_.bEnded_ = true;
+
+ for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+ {
+ if (it->first->getControllableEntity())
+ {
+ ControllableEntity* oldentity = it->first->getControllableEntity();
+
+ ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity->getCreator());
+ if (oldentity->getCamera())
+ {
+ entity->setPosition(oldentity->getCamera()->getWorldPosition());
+ entity->setOrientation(oldentity->getCamera()->getWorldOrientation());
+ }
+ else
+ {
+ entity->setPosition(oldentity->getWorldPosition());
+ entity->setOrientation(oldentity->getWorldOrientation());
+ }
+
+ it->first->stopControl(oldentity, true);
+ it->first->startControl(entity);
+ }
+ else
+ this->spawnPlayerAsDefaultPawn(it->first);
+ }
}
void Gametype::playerEntered(PlayerInfo* player)
@@ -266,20 +304,8 @@
if (!it->first->isReadyToSpawn() || !this->gtinfo_.bStarted_)
{
- SpawnPoint* spawn = this->getBestSpawnPoint(it->first);
- if (spawn)
- {
- // force spawn at spawnpoint with default pawn
- ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn);
- spawn->spawn(entity);
- it->first->startControl(entity);
- it->second.state_ = PlayerState::Dead;
- }
- else
- {
- COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
- abort();
- }
+ this->spawnPlayerAsDefaultPawn(it->first);
+ it->second.state_ = PlayerState::Dead;
}
}
}
@@ -357,6 +383,23 @@
}
}
+ void Gametype::spawnPlayerAsDefaultPawn(PlayerInfo* player)
+ {
+ SpawnPoint* spawn = this->getBestSpawnPoint(player);
+ if (spawn)
+ {
+ // force spawn at spawnpoint with default pawn
+ ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn);
+ spawn->spawn(entity);
+ player->startControl(entity);
+ }
+ else
+ {
+ COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
+ abort();
+ }
+ }
+
void Gametype::addBots(unsigned int amount)
{
for (unsigned int i = 0; i < amount; ++i)
@@ -375,4 +418,31 @@
}
}
}
+
+ void Gametype::addTime(float t)
+ {
+ if (this->timeLimit_ == 0)
+ this->time_ -= t;
+ else
+ this->time_ += t;
+ }
+
+ void Gametype::removeTime(float t)
+ {
+ if (this->timeLimit_ == 0)
+ this->time_ += t;
+ else
+ this->time_ -= t;
+ }
+
+ void Gametype::resetTimer()
+ {
+ this->resetTimer(timeLimit_);
+ }
+
+ void Gametype::resetTimer(float t)
+ {
+ this->timeLimit_ = t;
+ this->time_ = t;
+ }
}
Modified: trunk/src/orxonox/objects/gametypes/Gametype.h
===================================================================
--- trunk/src/orxonox/objects/gametypes/Gametype.h 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/gametypes/Gametype.h 2009-05-23 19:57:52 UTC (rev 3033)
@@ -127,12 +127,37 @@
inline unsigned int getNumberOfPlayers() const
{ return this->players_.size(); }
+ virtual void addTime(float t);
+ virtual void removeTime(float t);
+
+ inline void startTimer()
+ {
+ this->time_ = this->timeLimit_;
+ this->timerIsActive_ = true;
+ }
+
+ inline void stopTimer()
+ { this->timerIsActive_ = false; }
+
+ inline float getTime()
+ { return this->time_; }
+
+ inline bool getTimerIsActive()
+ { return timerIsActive_; }
+
+ inline void setTimeLimit(float t)
+ { this->timeLimit_ = t; }
+
+ virtual void resetTimer();
+ virtual void resetTimer(float t);
+
protected:
virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
virtual void assignDefaultPawnsIfNeeded();
virtual void checkStart();
virtual void spawnPlayer(PlayerInfo* player);
+ virtual void spawnPlayerAsDefaultPawn(PlayerInfo* player);
virtual void spawnPlayersIfRequested();
virtual void spawnDeadPlayersIfRequested();
@@ -141,6 +166,10 @@
bool bAutoStart_;
bool bForceSpawn_;
+ float time_;
+ float timeLimit_;
+ bool timerIsActive_;
+
float initialStartCountdown_;
unsigned int numberOfBots_;
SubclassIdentifier<Bot> botclass_;
Copied: trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc (from rev 3032, branches/gametypes/src/orxonox/objects/gametypes/TeamBaseMatch.cc)
===================================================================
--- trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc (rev 0)
+++ trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -0,0 +1,201 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Val Mikos
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "TeamBaseMatch.h"
+
+#include "objects/worldentities/pawns/TeamBaseMatchBase.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ CreateUnloadableFactory(TeamBaseMatch);
+
+ TeamBaseMatch::TeamBaseMatch(BaseObject* creator) : TeamDeathmatch(creator)
+ {
+ RegisterObject(TeamBaseMatch);
+
+ this->scoreTimer_.setTimer(10, true, this, createExecutor(createFunctor(&TeamBaseMatch::winPoints)));
+ this->outputTimer_.setTimer(30, true, this, createExecutor(createFunctor(&TeamBaseMatch::showPoints)));
+
+ this->pointsTeam1_ = 0;
+ this->pointsTeam2_ = 0;
+ }
+
+ // Change the control of the defeated base and respawn it with its initial health
+ bool TeamBaseMatch::allowPawnDeath(Pawn* victim, Pawn* originator)
+ {
+ TeamBaseMatchBase* base = dynamic_cast<TeamBaseMatchBase*>(victim);
+ if (base)
+ {
+ std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.find(base);
+ if (it != this->bases_.end())
+ {
+ int teamnr = this->getTeam(originator->getPlayer());
+ if (teamnr == 0)
+ base->setState(BaseState::controlTeam1);
+ if (teamnr == 1)
+ base->setState(BaseState::controlTeam2);
+ }
+
+ victim->setHealth(victim->getInitialHealth());
+ return false;
+ }
+
+ return TeamDeathmatch::allowPawnDeath(victim, originator);
+ }
+
+
+ // if the player is in the same team as the base, he can't make any damage to it
+ bool TeamBaseMatch::allowPawnDamage(Pawn* victim, Pawn* originator)
+ {
+ TeamBaseMatchBase* base = dynamic_cast<TeamBaseMatchBase*>(victim);
+ if (base)
+ {
+ std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.find(base);
+ if (it != this->bases_.end())
+ return (!this->pawnsAreInTheSameTeam(victim, base));
+ }
+ return (!this->pawnsAreInTheSameTeam(victim, originator));
+ }
+
+ bool TeamBaseMatch::pawnsAreInTheSameTeam(Pawn* pawn1, TeamBaseMatchBase* base)
+ {
+ if (pawn1 && base)
+ {
+ std::map<PlayerInfo*, int>::const_iterator it1 = this->teamnumbers_.find(pawn1->getPlayer());
+ int teamnrbase = -1;
+ int teamnrplayer = getTeam(pawn1->getPlayer());
+
+ switch (base->getState())
+ {
+ case BaseState::controlTeam1:
+ teamnrbase = 0;
+ break;
+ case BaseState::controlTeam2:
+ teamnrbase = 1;
+ break;
+ case BaseState::uncontrolled:
+ default:
+ teamnrbase = -1;
+ }
+
+ if (teamnrbase == teamnrplayer)
+ return false;
+ }
+ return true;
+ }
+
+
+
+
+
+ // collect Points for killing oppenents
+ void TeamBaseMatch::playerScored(PlayerInfo* player)
+ {
+ int teamnr = this->getTeam(player);
+ this->addTeamPoints(teamnr, 5);
+ }
+
+ // show points or each interval of time
+ void TeamBaseMatch::showPoints()
+ {
+ COUT(0) << "Points standing:" << std::endl << "Team 1: "<< pointsTeam1_ << std::endl << "Team 2: " << pointsTeam2_ << std::endl;
+ if(pointsTeam1_ >=1700) COUT(0) << "Team 1 is near victory!" << std::endl;
+ if(pointsTeam2_ >=1700) COUT(0) << "Team 2 is near victory!" << std::endl;
+ }
+
+
+ // collect Points while controlling Bases
+ void TeamBaseMatch::winPoints()
+ {
+ int amountControlled = 0;
+ int amountControlled2 = 0;
+
+ for (std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)
+ {
+ if((*it)->getState() == BaseState::controlTeam1)
+ {
+ amountControlled++;
+ }
+ if((*it)->getState() == BaseState::controlTeam2)
+ {
+ amountControlled2++;
+ }
+ }
+
+ this->addTeamPoints(0, (amountControlled * 30));
+ this->addTeamPoints(1, (amountControlled2 * 30));
+ }
+
+
+ // end game if one team reaches 2000 points
+ void TeamBaseMatch::endGame()
+ {
+ if(this->pointsTeam1_>=2000 || this->pointsTeam2_ >=2000)
+ {
+ this->end();
+ }
+ }
+
+
+ // this function is called by the function winPoints() which adds points to the teams for every base and killed openents at a certain time
+ void TeamBaseMatch::addTeamPoints(int team, int points)
+ {
+ if(team == 0)
+ {
+ this->pointsTeam1_ += points;
+ }
+ if(team == 1)
+ {
+ this->pointsTeam2_ += points;
+ }
+
+ this->endGame();
+ }
+
+ void TeamBaseMatch::addBase(TeamBaseMatchBase* base)
+ {
+ this->bases_.insert(base);
+ base->setState(BaseState::uncontrolled);
+ }
+
+ TeamBaseMatchBase* TeamBaseMatch::getBase(unsigned int index) const
+ {
+ unsigned int i = 0;
+ for (std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)
+ {
+ i++;
+ if (i > index)
+ return (*it);
+ }
+ return 0;
+ }
+
+}
+
+
Copied: trunk/src/orxonox/objects/gametypes/TeamBaseMatch.h (from rev 3032, branches/gametypes/src/orxonox/objects/gametypes/TeamBaseMatch.h)
===================================================================
--- trunk/src/orxonox/objects/gametypes/TeamBaseMatch.h (rev 0)
+++ trunk/src/orxonox/objects/gametypes/TeamBaseMatch.h 2009-05-23 19:57:52 UTC (rev 3033)
@@ -0,0 +1,74 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Val Mikos
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _TeamBaseMatch_H__
+#define _TeamBaseMatch_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <set>
+#include "TeamDeathmatch.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport TeamBaseMatch : public TeamDeathmatch
+ {
+ public:
+ TeamBaseMatch(BaseObject* creator);
+ virtual ~TeamBaseMatch() {}
+
+ virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);
+ virtual bool allowPawnDamage(Pawn* victim, Pawn* originator);
+
+ virtual void playerScored(PlayerInfo* player);
+ virtual void showPoints();
+ virtual void endGame();
+
+ void addBase(TeamBaseMatchBase* base);
+ TeamBaseMatchBase* getBase(unsigned int index) const;
+
+ void addTeamPoints(int team, int points);
+
+ protected:
+ void winPoints();
+
+ bool pawnsAreInTheSameTeam(Pawn* pawn1, TeamBaseMatchBase* base);
+ using TeamDeathmatch::pawnsAreInTheSameTeam;
+
+ std::set<TeamBaseMatchBase*> bases_;
+ Timer<TeamBaseMatch> scoreTimer_;
+ Timer<TeamBaseMatch> outputTimer_;
+
+ //points for each team
+ int pointsTeam1_;
+ int pointsTeam2_;
+ };
+}
+
+#endif /* _TeamBaseMatch_H__ */
Modified: trunk/src/orxonox/objects/gametypes/TeamDeathmatch.cc
===================================================================
--- trunk/src/orxonox/objects/gametypes/TeamDeathmatch.cc 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/gametypes/TeamDeathmatch.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -126,7 +126,7 @@
if ((*it)->isA(Class(TeamSpawnPoint)))
{
TeamSpawnPoint* tsp = dynamic_cast<TeamSpawnPoint*>(*it);
- if (tsp && tsp->getTeamNumber() != desiredTeamNr)
+ if (tsp && (int)tsp->getTeamNumber() != desiredTeamNr)
{
teamSpawnPoints.erase(it++);
continue;
@@ -188,4 +188,13 @@
}
return false;
}
+
+ int TeamDeathmatch::getTeam(PlayerInfo* player)
+ {
+ std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);
+ if (it_player != this->teamnumbers_.end())
+ return it_player->second;
+ else
+ return -1;
+ }
}
Modified: trunk/src/orxonox/objects/gametypes/TeamDeathmatch.h
===================================================================
--- trunk/src/orxonox/objects/gametypes/TeamDeathmatch.h 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/gametypes/TeamDeathmatch.h 2009-05-23 19:57:52 UTC (rev 3033)
@@ -54,9 +54,13 @@
virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);
+ inline const ColourValue& getTeamColour(int teamnr) const
+ { return this->teamcolours_[teamnr]; }
+
protected:
virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
bool pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2);
+ int getTeam(PlayerInfo* player);
std::map<PlayerInfo*, int> teamnumbers_;
std::vector<ColourValue> teamcolours_;
Copied: trunk/src/orxonox/objects/gametypes/UnderAttack.cc (from rev 3032, branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.cc)
===================================================================
--- trunk/src/orxonox/objects/gametypes/UnderAttack.cc (rev 0)
+++ trunk/src/orxonox/objects/gametypes/UnderAttack.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -0,0 +1,170 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Matthias Mock
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "UnderAttack.h"
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "util/Convert.h"
+#include "network/Host.h"
+
+#include "objects/worldentities/pawns/Destroyer.h"
+
+namespace orxonox
+{
+ CreateUnloadableFactory(UnderAttack);
+
+ UnderAttack::UnderAttack(BaseObject* creator) : TeamDeathmatch(creator)
+ {
+ RegisterObject(UnderAttack);
+ this->gameTime_ = 90;
+ this->teams_ = 2;
+ this->destroyer_ = 0;
+ this->gameEnded_ = false;
+
+ this->setConfigValues();
+ this->timesequence_ = (int) this->gameTime_;
+ }
+
+ void UnderAttack::setConfigValues()
+ {
+ SetConfigValue(gameTime_, 30);
+ }
+
+ void UnderAttack::addDestroyer(Destroyer* destroyer)
+ {
+ this->destroyer_ = destroyer;
+ }
+
+
+ void UnderAttack::destroyedPawn(Pawn* pawn)
+ {
+ if (pawn == this->destroyer_)
+ {
+ this->end(); //end gametype
+ std::string message = "Ship destroyed! Team 0 has won!";
+ COUT(0) << message << std::endl;
+ Host::Broadcast(message);
+ this->gameEnded_ = true;
+ }
+ }
+
+ bool UnderAttack::allowPawnHit(Pawn* victim, Pawn* originator)
+ {
+ if (victim == this->destroyer_)
+ {
+ if (originator && originator->getPlayer() && !gameEnded_)
+ {
+ if (this->getTeam(originator->getPlayer()) == 0)
+ return true;
+ else
+ return false;
+ }
+
+ return false;
+ }
+
+ return TeamDeathmatch::allowPawnHit(victim, originator);
+ }
+
+ bool UnderAttack::allowPawnDamage(Pawn* victim, Pawn* originator)
+ {
+ if (victim == this->destroyer_)
+ {
+ if (originator && originator->getPlayer() && !gameEnded_)
+ {
+ if (this->getTeam(originator->getPlayer()) == 0)
+ return true;
+ else
+ return false;
+ }
+
+ return false;
+ }
+
+ return TeamDeathmatch::allowPawnDamage(victim, originator);
+ }
+
+ bool UnderAttack::allowPawnDeath(Pawn* victim, Pawn* originator)
+ {
+ if (victim == this->destroyer_)
+ {
+ if (originator && originator->getPlayer() && !gameEnded_)
+ {
+ if (this->getTeam(originator->getPlayer()) == 0)
+ return true;
+ else
+ return false;
+ }
+
+ return false;
+ }
+
+ return TeamDeathmatch::allowPawnDeath(victim, originator);
+ }
+
+
+ void UnderAttack::tick(float dt)
+ {
+ SUPER(UnderAttack, tick, dt);
+
+ if (this->hasStarted() && !gameEnded_)
+ {
+ gameTime_ = gameTime_ - dt;
+ if (gameTime_<= 0)
+ {
+ this->gameEnded_ = true;
+ this->end();
+ std::string message = "Time is up! Team 1 has won!";
+ COUT(0) << message << std::endl;
+ Host::Broadcast(message);
+ }
+
+ //prints gametime
+ if ( gameTime_ <= timesequence_)
+ {
+ std::string message = convertToString(timesequence_) + " sec left!";
+ COUT(0) << message << std::endl;
+ Host::Broadcast(message);
+ if (timesequence_ >= 30 && timesequence_ <= 60)
+ {
+ timesequence_ = timesequence_ - 10;
+ }
+ else if (timesequence_ <= 30)
+ {
+ timesequence_ = timesequence_ - 5;
+ }
+ else
+ {
+ timesequence_ = timesequence_ - 30;
+ }
+ }
+ }
+ }
+}
Copied: trunk/src/orxonox/objects/gametypes/UnderAttack.h (from rev 3032, branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.h)
===================================================================
--- trunk/src/orxonox/objects/gametypes/UnderAttack.h (rev 0)
+++ trunk/src/orxonox/objects/gametypes/UnderAttack.h 2009-05-23 19:57:52 UTC (rev 3033)
@@ -0,0 +1,66 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Matthias Mock
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _UnderAttack_H__
+#define _UnderAttack_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "TeamDeathmatch.h"
+#include "objects/worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport UnderAttack : public TeamDeathmatch, public PawnListener
+ {
+ public:
+ UnderAttack(BaseObject* creator);
+ virtual ~UnderAttack() {}
+
+ void setConfigValues();
+ void tick (float dt);
+ void addDestroyer(Destroyer* destroyer);
+ inline Destroyer* getDestroyer() const
+ { return this->destroyer_; }
+
+ virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);
+ virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);
+ virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);
+
+ protected:
+ virtual void destroyedPawn(Pawn* pawn);
+
+ Destroyer* destroyer_;
+ unsigned int teams_;
+ float gameTime_;
+ int timesequence_;
+ bool gameEnded_;
+ };
+}
+
+#endif /* _TeamDeathmatch_H__ */
Modified: trunk/src/orxonox/objects/quest/QuestEffectBeacon.cc
===================================================================
--- trunk/src/orxonox/objects/quest/QuestEffectBeacon.cc 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/quest/QuestEffectBeacon.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -40,7 +40,7 @@
#include "core/EventIncludes.h"
#include "orxonox/objects/infos/PlayerInfo.h"
-#include "orxonox/objects/worldentities/ControllableEntity.h"
+#include "orxonox/objects/worldentities/pawns/Pawn.h"
#include "orxonox/objects/worldentities/triggers/PlayerTrigger.h"
#include "QuestEffect.h"
@@ -119,16 +119,16 @@
}
//! Extracting the ControllableEntity form the PlayerTrigger.
- ControllableEntity* entity = trigger->getTriggeringPlayer();
+ Pawn* pawn = trigger->getTriggeringPlayer();
- if(entity == NULL)
+ if(pawn == NULL)
{
- COUT(2) << "The QuestEffectBeacon was triggered by an entity other than a ControllableEntity." << std::endl;
+ COUT(2) << "The QuestEffectBeacon was triggered by an entity other than a Pawn." << std::endl;
return false;
}
//! Extract the PlayerInfo from the ControllableEntity.
- PlayerInfo* player = entity->getPlayer();
+ PlayerInfo* player = pawn->getPlayer();
if(player == NULL)
{
Modified: trunk/src/orxonox/objects/worldentities/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/objects/worldentities/CMakeLists.txt 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/worldentities/CMakeLists.txt 2009-05-23 19:57:52 UTC (rev 3033)
@@ -22,6 +22,7 @@
PongCenterpoint.cc
PongBall.cc
PongBat.cc
+ ForceField.cc
)
ADD_SUBDIRECTORY(pawns)
Copied: trunk/src/orxonox/objects/worldentities/ForceField.cc (from rev 3032, branches/gametypes/src/orxonox/objects/worldentities/ForceField.cc)
===================================================================
--- trunk/src/orxonox/objects/worldentities/ForceField.cc (rev 0)
+++ trunk/src/orxonox/objects/worldentities/ForceField.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -0,0 +1,91 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Aurelian Jaggi
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "ForceField.h"
+#include "core/XMLPort.h"
+
+#include "core/CoreIncludes.h"
+#include "objects/worldentities/MobileEntity.h"
+
+namespace orxonox
+{
+ CreateFactory(ForceField);
+
+ ForceField::ForceField(BaseObject* creator) : StaticEntity(creator)
+ {
+ RegisterObject(ForceField);
+
+ //Standard Values
+ this->setDirection(Vector3::ZERO);
+ velocity_ = 100;
+ diameter_ = 500;
+ length_ = 2000;
+ }
+
+ ForceField::~ForceField() {}
+
+ void ForceField::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(ForceField, XMLPort, xmlelement, mode);
+
+ //For correct xml import use: position, direction, velocity, scale
+
+ XMLPortParam(ForceField, "velocity", setVelocity, getVelocity, xmlelement, mode).defaultValues(100);
+ XMLPortParam(ForceField, "diameter", setDiameter, getDiameter, xmlelement, mode).defaultValues(500);
+ XMLPortParam(ForceField, "length" , setLength , getLength , xmlelement, mode).defaultValues(2000);
+ }
+
+ void ForceField::tick(float dt)
+ {
+
+ for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
+ {
+
+ //calculate from
+ Vector3 directionVec = this->getOrientation() * WorldEntity::FRONT;
+ directionVec.normalise();
+
+ Vector3 distanceVec = it->getWorldPosition() - (this->getWorldPosition() + (this->length_ / 2 * directionVec));
+
+ //distance from centervector of the field (
+ float distFromCenterVec = ((it->getWorldPosition() - this->getWorldPosition()).crossProduct(directionVec)).length();
+
+ if (distanceVec.length() < this->length_ / 2 && distFromCenterVec < diameter_ / 2)
+ {
+ //normalize distance from center
+ it->applyCentralForce(((diameter_ / 2 - distFromCenterVec) / (diameter_ / 2)) * directionVec * velocity_);
+ }
+
+ }
+ }
+}
+
+
+
+
+
Copied: trunk/src/orxonox/objects/worldentities/ForceField.h (from rev 3032, branches/gametypes/src/orxonox/objects/worldentities/ForceField.h)
===================================================================
--- trunk/src/orxonox/objects/worldentities/ForceField.h (rev 0)
+++ trunk/src/orxonox/objects/worldentities/ForceField.h 2009-05-23 19:57:52 UTC (rev 3033)
@@ -0,0 +1,72 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Aurelian Jaggi
+ * Co-authors:
+ * ...
+ *
+ */
+
+
+#ifndef _ForceField_H__
+#define _ForceField_H__
+
+#include "StaticEntity.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport ForceField : public StaticEntity, public Tickable
+ {
+ public:
+ ForceField(BaseObject* creator);
+ virtual ~ForceField();
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a CheckPoint object through XML.
+ virtual void tick(float dt);
+
+ inline void setVelocity(float vel)
+ { this->velocity_ = vel; }
+
+ inline float getVelocity()
+ { return velocity_; }
+
+ inline void setDiameter(float diam)
+ { this->diameter_ = diam; }
+
+ inline float getDiameter()
+ { return diameter_; }
+
+ inline void setLength(float l)
+ { this->length_ = l; }
+
+ inline float getLength()
+ { return length_; }
+
+ private:
+ float velocity_;
+ float diameter_;
+ float length_;
+ };
+}
+
+#endif
+
Modified: trunk/src/orxonox/objects/worldentities/MobileEntity.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/MobileEntity.cc 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/worldentities/MobileEntity.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -165,6 +165,12 @@
this->angularAcceleration_ = acceleration;
}
+ void MobileEntity::applyCentralForce(const Vector3& force)
+ {
+ if (this->isDynamic())
+ this->physicalBody_->applyCentralForce(btVector3(force.x * this->getMass(), force.y * this->getMass(), force.z * this->getMass()));
+ }
+
bool MobileEntity::isCollisionTypeLegal(WorldEntity::CollisionType type) const
{
if (type == WorldEntity::Static)
Modified: trunk/src/orxonox/objects/worldentities/MobileEntity.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/MobileEntity.h 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/worldentities/MobileEntity.h 2009-05-23 19:57:52 UTC (rev 3033)
@@ -74,6 +74,10 @@
inline const Vector3& getAngularAcceleration() const
{ return this->angularAcceleration_; }
+ void applyCentralForce(const Vector3& force);
+ inline void applyCentralForce(float x, float y, float z)
+ { this->applyCentralForce(Vector3(x, y, z)); }
+
inline void setRotationRate(Degree rate)
{ this->setAngularVelocity(this->getAngularVelocity().normalisedCopy() * rate.valueRadians()); }
inline Degree getRotationRate() const
Modified: trunk/src/orxonox/objects/worldentities/MovableEntity.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/MovableEntity.cc 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/worldentities/MovableEntity.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -34,6 +34,7 @@
#include "core/XMLPort.h"
#include "core/Executor.h"
#include "core/GameMode.h"
+#include "objects/worldentities/pawns/Pawn.h"
namespace orxonox
{
@@ -66,8 +67,26 @@
void MovableEntity::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(MovableEntity, XMLPort, xmlelement, mode);
+
+ XMLPortParam(MovableEntity, "enablecollisiondamage", setEnableCollisionDamage, getEnableCollisionDamage, xmlelement, mode).defaultValues(false);
+ XMLPortParam(MovableEntity, "collisiondamage", setCollisionDamage, getCollisionDamage, xmlelement, mode).defaultValues(1);
}
+ bool MovableEntity::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
+ {
+ if (GameMode::isMaster() && enableCollisionDamage_)
+ {
+ Pawn* victim = dynamic_cast<Pawn*>(otherObject);
+ if (victim)
+ {
+ victim->damage(this->collisionDamage_ * victim->getVelocity().dotProduct(this->getVelocity()));
+ }
+ }
+
+ return false;
+ }
+
+
void MovableEntity::registerVariables()
{
registerVariable(this->linearVelocity_, variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::processLinearVelocity));
Modified: trunk/src/orxonox/objects/worldentities/MovableEntity.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/MovableEntity.h 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/worldentities/MovableEntity.h 2009-05-23 19:57:52 UTC (rev 3033)
@@ -45,6 +45,7 @@
virtual ~MovableEntity();
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
void registerVariables();
using WorldEntity::setPosition;
@@ -55,6 +56,26 @@
inline void setOrientation(const Quaternion& orientation)
{ MobileEntity::setOrientation(orientation); this->overwrite_orientation_ = this->getOrientation(); }
+ inline void setOwner(Pawn* owner)
+ { this->owner_ = owner; }
+ inline Pawn* getOwner() const
+ { return this->owner_; }
+
+ inline void setCollisionDamage(float c)
+ { this->collisionDamage_ = c; }
+
+ inline float getCollisionDamage()
+ { return this->collisionDamage_; }
+
+ inline void setEnableCollisionDamage(bool c)
+ {
+ this->enableCollisionDamage_ = c;
+ this->enableCollisionCallback();
+ }
+
+ inline bool getEnableCollisionDamage()
+ { return this->enableCollisionDamage_; }
+
private:
void clientConnected(unsigned int clientID);
void clientDisconnected(unsigned int clientID);
@@ -75,6 +96,10 @@
Timer<MovableEntity> resynchronizeTimer_;
Timer<MovableEntity>* continuousResynchroTimer_;
+
+ Pawn* owner_;
+ float collisionDamage_;
+ bool enableCollisionDamage_;
};
}
Modified: trunk/src/orxonox/objects/worldentities/SpawnPoint.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/SpawnPoint.cc 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/worldentities/SpawnPoint.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -94,7 +94,7 @@
void SpawnPoint::spawn(ControllableEntity* entity)
{
- entity->setPosition(this->getPosition());
- entity->setOrientation(this->getOrientation());
+ entity->setPosition(this->getWorldPosition());
+ entity->setOrientation(this->getWorldOrientation());
}
}
Modified: trunk/src/orxonox/objects/worldentities/pawns/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/CMakeLists.txt 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/worldentities/pawns/CMakeLists.txt 2009-05-23 19:57:52 UTC (rev 3033)
@@ -2,4 +2,6 @@
Spectator.cc
Pawn.cc
SpaceShip.cc
+ TeamBaseMatchBase.cc
+ Destroyer.cc
)
Copied: trunk/src/orxonox/objects/worldentities/pawns/Destroyer.cc (from rev 3032, branches/gametypes/src/orxonox/objects/worldentities/pawns/Destroyer.cc)
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/Destroyer.cc (rev 0)
+++ trunk/src/orxonox/objects/worldentities/pawns/Destroyer.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -0,0 +1,49 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Matthias Mock
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Destroyer.h"
+
+#include "core/CoreIncludes.h"
+#include "objects/gametypes/UnderAttack.h"
+
+namespace orxonox
+{
+ CreateFactory(Destroyer);
+
+ Destroyer::Destroyer(BaseObject* creator) : SpaceShip(creator)
+ {
+ RegisterObject(Destroyer);
+
+ UnderAttack* gametype = dynamic_cast<UnderAttack*>(this->getGametype());
+ if (gametype)
+ {
+ gametype->addDestroyer(this);
+ }
+ }
+}
Copied: trunk/src/orxonox/objects/worldentities/pawns/Destroyer.h (from rev 3032, branches/gametypes/src/orxonox/objects/worldentities/pawns/Destroyer.h)
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/Destroyer.h (rev 0)
+++ trunk/src/orxonox/objects/worldentities/pawns/Destroyer.h 2009-05-23 19:57:52 UTC (rev 3033)
@@ -0,0 +1,47 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Matthias Mock
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _Destroyer_H__
+#define _Destroyer_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "SpaceShip.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport Destroyer : public SpaceShip
+ {
+ public:
+ Destroyer(BaseObject* creator);
+ virtual ~Destroyer() {};
+
+ };
+}
+
+#endif /* _Destroyer_H__ */
Modified: trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -197,6 +197,7 @@
void Pawn::death()
{
+ this->setHealth(1);
if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
{
// Set bAlive_ to false and wait for PawnManager to do the destruction
@@ -213,8 +214,6 @@
if (GameMode::isMaster())
this->deatheffect();
}
- else
- this->setHealth(1);
}
void Pawn::deatheffect()
Copied: trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc (from rev 3032, branches/gametypes/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc)
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc (rev 0)
+++ trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -0,0 +1,88 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Val Mikos
+ * Co-authors:
+ * ...
+ *
+ */
+
+
+#include "TeamBaseMatchBase.h"
+#include "core/CoreIncludes.h"
+#include "objects/gametypes/TeamBaseMatch.h"
+#include "objects/Teamcolourable.h"
+
+namespace orxonox
+{
+ CreateFactory(TeamBaseMatchBase);
+
+ TeamBaseMatchBase::TeamBaseMatchBase(BaseObject* creator) : Pawn(creator)
+ {
+ RegisterObject(TeamBaseMatchBase);
+
+ this->state_ = BaseState::uncontrolled;
+
+ TeamBaseMatch* gametype = dynamic_cast<TeamBaseMatch*>(this->getGametype());
+ if (gametype)
+ {
+ gametype->addBase(this);
+ }
+ }
+
+ void TeamBaseMatchBase::changeTeamColour()
+ {
+ this->fireEvent();
+
+ TeamDeathmatch* gametype = dynamic_cast<TeamDeathmatch*>(this->getGametype());
+ if (!gametype)
+ return;
+
+ ColourValue colour;
+
+ switch (this->state_)
+ {
+ case BaseState::controlTeam1:
+ colour = gametype->getTeamColour(0);
+ break;
+ case BaseState::controlTeam2:
+ colour = gametype->getTeamColour(1);
+ break;
+ case BaseState::uncontrolled:
+ default:
+ colour = ColourValue(0.5, 0.5, 0.7, 1.0);
+ break;
+ }
+
+
+ std::set<WorldEntity*> attachments = this->getAttachedObjects();
+ for (std::set<WorldEntity*>::iterator it = attachments.begin(); it != attachments.end(); ++it)
+ {
+ if ((*it)->isA(Class(Teamcolourable)))
+ {
+ Teamcolourable* tc = dynamic_cast<Teamcolourable*>(*it);
+ tc->setTeamColour(colour);
+ }
+ }
+ }
+}
+
Copied: trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.h (from rev 3032, branches/gametypes/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.h)
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.h (rev 0)
+++ trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.h 2009-05-23 19:57:52 UTC (rev 3033)
@@ -0,0 +1,81 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Val Mikos
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _TeamBaseMatchBase_H__
+#define _TeamBaseMatchBase_H__
+
+#include "Pawn.h"
+
+namespace orxonox
+{
+
+
+ namespace BaseState
+ {
+ enum Enum
+ {
+ uncontrolled,
+ controlTeam1,
+ controlTeam2,
+ };
+ }
+
+
+ class _OrxonoxExport TeamBaseMatchBase : public Pawn
+ {
+ public:
+ TeamBaseMatchBase(BaseObject* creator);
+
+ // if class closes, close everything
+ virtual ~TeamBaseMatchBase() {}
+
+
+
+ // Set the state of a base to whatever the argument of the function is
+ void setState(BaseState::Enum state)
+ {
+ this->state_ = state;
+ this->changeTeamColour();
+ }
+
+
+ // Get the state of a base as a return value
+ BaseState::Enum getState() const
+ {
+ return this->state_;
+ }
+
+
+ protected:
+ void changeTeamColour();
+
+ BaseState::Enum state_;
+ };
+}
+
+#endif /* _TeamBaseMatchBase_H__ */
Modified: trunk/src/orxonox/objects/worldentities/triggers/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/CMakeLists.txt 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/worldentities/triggers/CMakeLists.txt 2009-05-23 19:57:52 UTC (rev 3033)
@@ -3,4 +3,5 @@
DistanceTrigger.cc
EventTrigger.cc
PlayerTrigger.cc
+ CheckPoint.cc
)
Copied: trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc (from rev 3032, branches/gametypes/src/orxonox/objects/worldentities/triggers/CheckPoint.cc)
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc (rev 0)
+++ trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -0,0 +1,95 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Aurelian Jaggi
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "CheckPoint.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+#include "objects/gametypes/Asteroids.h"
+#include "orxonox/objects/worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+ CreateFactory(CheckPoint);
+
+ CheckPoint::CheckPoint(BaseObject* creator) : DistanceTrigger(creator)
+ {
+ RegisterObject(CheckPoint);
+
+ this->setStayActive(true);
+ this->setDistance(50);
+ this->bIsFirst_ = false;
+ this->bIsDestination_ = false;
+ //this->setVisible(true);
+
+ this->notifyMaskUpdate();
+ }
+
+ CheckPoint::~CheckPoint()
+ {
+ }
+
+ void CheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(CheckPoint, XMLPort, xmlelement, mode);
+
+ XMLPortParam(CheckPoint, "isfirst", setFirst, getFirst, xmlelement, mode).defaultValues(false);
+ XMLPortParam(CheckPoint, "isdestination", setDestination, getDestination, xmlelement, mode).defaultValues(false);
+ XMLPortParam(CheckPoint, "addtime", setAddTime, getAddTime, xmlelement, mode).defaultValues(30);
+ }
+
+ void CheckPoint::triggered(bool bIsTriggered)
+ {
+ DistanceTrigger::triggered(bIsTriggered);
+
+ Asteroids* gametype = dynamic_cast<Asteroids*>(this->getGametype());
+ if (gametype)
+ {
+ gametype->addTime(addTime_);
+
+ if (bIsTriggered && bIsFirst_)
+ {
+ gametype->setTimeLimit(addTime_);
+ gametype->firstCheckpointReached(true);
+ }
+
+ if (bIsTriggered && bIsDestination_)
+ {
+ gametype->end();
+ }
+ }
+ }
+
+ void CheckPoint::notifyMaskUpdate()
+ {
+ this->targetMask_.exclude(Class(BaseObject));
+ this->targetMask_.include(Class(Pawn));
+ }
+}
Copied: trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.h (from rev 3032, branches/gametypes/src/orxonox/objects/worldentities/triggers/CheckPoint.h)
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.h (rev 0)
+++ trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.h 2009-05-23 19:57:52 UTC (rev 3033)
@@ -0,0 +1,77 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Aurelian Jaggi
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief
+*/
+
+#ifndef _CheckPoint_H__
+#define _CheckPoint_H__
+
+#include "DistanceTrigger.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport CheckPoint : public DistanceTrigger
+ {
+ public:
+ CheckPoint(BaseObject* creator);
+ virtual ~CheckPoint();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a CheckPoint object through XML.
+
+ private:
+ virtual void triggered(bool bIsTriggered);
+ virtual void notifyMaskUpdate();
+
+ inline void setDestination(bool isDestination)
+ { bIsDestination_ = isDestination; }
+
+ inline bool getDestination()
+ { return bIsDestination_; }
+
+ inline void setFirst(bool isFirst)
+ { this->bIsFirst_ = isFirst; }
+
+ inline bool getFirst()
+ { return this->bIsFirst_; }
+
+ inline void setAddTime(float time)
+ { this->addTime_ = time; }
+
+ inline bool getAddTime()
+ { return this->addTime_; }
+
+ bool bIsFirst_;
+ bool bIsDestination_;
+ float addTime_;
+ };
+}
+
+#endif /* _CheckPoint_H__ */
Modified: trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -34,7 +34,7 @@
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
-#include "orxonox/objects/worldentities/ControllableEntity.h"
+#include "orxonox/objects/worldentities/pawns/Pawn.h"
namespace orxonox
{
@@ -108,6 +108,8 @@
ClassTreeMask WEMask;
WEMask.include(Class(WorldEntity));
this->targetMask_ *= WEMask;
+
+ this->notifyMaskUpdate();
}
void DistanceTrigger::removeTargets(const std::string& targets)
@@ -132,7 +134,7 @@
//! If the target is a player (resp. is a, or is derived from a, ControllableEntity) the triggeringPlayer is set to the target entity.
if(this->isForPlayer())
{
- ControllableEntity* player = dynamic_cast<ControllableEntity*>(entity);
+ Pawn* player = dynamic_cast<Pawn*>(entity);
this->setTriggeringPlayer(player);
}
Modified: trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h 2009-05-23 19:57:52 UTC (rev 3033)
@@ -62,9 +62,11 @@
protected:
virtual bool isTriggered(TriggerMode mode);
+ virtual void notifyMaskUpdate() {}
+ ClassTreeMask targetMask_;
+
private:
- ClassTreeMask targetMask_;
std::set<Ogre::Node*> targetSet_;
float distance_;
Modified: trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h 2009-05-23 19:57:52 UTC (rev 3033)
@@ -59,7 +59,7 @@
@brief Returns the player that triggered the PlayerTrigger.
@return Returns a pointer to the ControllableEntity that triggered the PlayerTrigger.
*/
- inline ControllableEntity* getTriggeringPlayer(void) const
+ inline Pawn* getTriggeringPlayer(void) const
{ return this->player_; }
/**
@@ -76,7 +76,7 @@
@brief Set the player that triggered the PlayerTrigger. This is normally done by classes inheriting vom PlayerTrigger.
@param player A pointer to the ControllableEntity that triggered the PlayerTrigger.
*/
- inline void setTriggeringPlayer(ControllableEntity* player)
+ inline void setTriggeringPlayer(Pawn* player)
{ this->player_ = player; }
/**
@@ -87,7 +87,7 @@
{ this->isForPlayer_ = isForPlayer; }
private:
- ControllableEntity* player_; //!< The player that triggered the PlayerTrigger.
+ Pawn* player_; //!< The player that triggered the PlayerTrigger.
bool isForPlayer_; //!< Is true when the PlayerTrigger schould be set to normally be triggered by ControllableEntities.
};
Modified: trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -101,7 +101,7 @@
if (this->bFirstTick_)
{
this->bFirstTick_ = false;
- this->fireEvent(false);
+ this->triggered(false);
}
// Check if the object is active (this is NOT Trigger::isActive()!)
@@ -143,7 +143,7 @@
char newState = this->stateChanges_.front().second;
this->bTriggered_ = (newState & 0x1);
this->bActive_ = newState & 2;
- this->fireEvent(this->bActive_);
+ this->triggered(this->bActive_);
this->stateChanges_.pop();
if (this->stateChanges_.size() != 0)
this->remainingTime_ = this->stateChanges_.front().first;
@@ -161,6 +161,11 @@
this->setBillboardColour(ColourValue(1.0, 0.0, 0.0));
}
+ void Trigger::triggered(bool bIsTriggered)
+ {
+ this->fireEvent(bIsTriggered);
+ }
+
bool Trigger::isTriggered(TriggerMode mode)
{
// if (this->bUpdating_)
Modified: trunk/src/orxonox/objects/worldentities/triggers/Trigger.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/Trigger.h 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/objects/worldentities/triggers/Trigger.h 2009-05-23 19:57:52 UTC (rev 3033)
@@ -88,6 +88,9 @@
inline int getActivations() const
{ return this->remainingActivations_; }
+ inline void setVisible(bool visibility)
+ { this->debugBillboard_.setVisible(visibility); }
+
void setDelay(float delay);
inline float getDelay() const
{ return this->delay_; }
@@ -100,6 +103,7 @@
protected:
inline bool isTriggered() { return this->isTriggered(this->mode_); }
virtual bool isTriggered(TriggerMode mode);
+ virtual void triggered(bool bIsTriggered);
private:
bool checkAnd();
Modified: trunk/src/orxonox/overlays/hud/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/overlays/hud/CMakeLists.txt 2009-05-23 18:07:31 UTC (rev 3032)
+++ trunk/src/orxonox/overlays/hud/CMakeLists.txt 2009-05-23 19:57:52 UTC (rev 3033)
@@ -4,6 +4,7 @@
HUDRadar.cc
HUDSpeedBar.cc
HUDHealthBar.cc
+ HUDTimer.cc
ChatOverlay.cc
GametypeStatus.cc
PongScore.cc
Copied: trunk/src/orxonox/overlays/hud/HUDTimer.cc (from rev 3032, branches/gametypes/src/orxonox/overlays/hud/HUDTimer.cc)
===================================================================
--- trunk/src/orxonox/overlays/hud/HUDTimer.cc (rev 0)
+++ trunk/src/orxonox/overlays/hud/HUDTimer.cc 2009-05-23 19:57:52 UTC (rev 3033)
@@ -0,0 +1,70 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Aurelian Jaggi
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDTimer.h"
+
+#include "core/CoreIncludes.h"
+#include "util/Convert.h"
+#include "objects/worldentities/ControllableEntity.h"
+#include "objects/gametypes/Gametype.h"
+
+namespace orxonox
+{
+ CreateFactory(HUDTimer);
+
+ HUDTimer::HUDTimer(BaseObject* creator) : OverlayText(creator)
+ {
+ RegisterObject(HUDTimer);
+
+ this->owner_ = 0;
+ }
+
+ HUDTimer::~HUDTimer()
+ {
+ }
+
+ void HUDTimer::tick(float dt)
+ {
+ SUPER(HUDTimer, tick, dt);
+
+ Gametype* gametype = this->getGametype();
+
+ if (gametype->getTimerIsActive())
+ {
+ this->setCaption(convertToString((int)gametype->getTime() + 1));
+ }
+ }
+
+ void HUDTimer::changedOwner()
+ {
+ SUPER(HUDTimer, changedOwner);
+
+ this->owner_ = dynamic_cast<ControllableEntity*>(this->getOwner());
+ }
+}
Copied: trunk/src/orxonox/overlays/hud/HUDTimer.h (from rev 3032, branches/gametypes/src/orxonox/overlays/hud/HUDTimer.h)
===================================================================
--- trunk/src/orxonox/overlays/hud/HUDTimer.h (rev 0)
+++ trunk/src/orxonox/overlays/hud/HUDTimer.h 2009-05-23 19:57:52 UTC (rev 3033)
@@ -0,0 +1,53 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Aurelian Jaggi
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _HUDTimer_H__
+#define _HUDTimer_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "overlays/OverlayText.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport HUDTimer : public OverlayText, public Tickable
+ {
+ public:
+ HUDTimer(BaseObject* creator);
+ ~HUDTimer();
+
+ virtual void tick(float dt);
+
+ virtual void changedOwner();
+
+ private:
+ ControllableEntity* owner_;
+ };
+}
+#endif /* _HUDTimer_H__ */
More information about the Orxonox-commit
mailing list