[Orxonox-commit 5451] r10114 - in code/branches/surfaceraceHS14: . src/modules src/modules/dodgerace2 src/modules/invader
sriedel at orxonox.net
sriedel at orxonox.net
Wed Nov 5 16:33:51 CET 2014
Author: sriedel
Date: 2014-11-05 16:33:51 +0100 (Wed, 05 Nov 2014)
New Revision: 10114
Added:
code/branches/surfaceraceHS14/src/modules/dodgerace2/
code/branches/surfaceraceHS14/src/modules/dodgerace2/CMakeLists.txt
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.cc
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.h
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceCenterPoint.cc
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceCenterPoint.h
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.cc
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.h
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRacePrereqs.h
code/branches/surfaceraceHS14/src/modules/invader/Invader.cc
code/branches/surfaceraceHS14/src/modules/invader/Invader.h
code/branches/surfaceraceHS14/src/modules/invader/InvaderCenterPoint.cc
code/branches/surfaceraceHS14/src/modules/invader/InvaderCenterPoint.h
code/branches/surfaceraceHS14/src/modules/invader/InvaderEnemy.cc
code/branches/surfaceraceHS14/src/modules/invader/InvaderEnemy.h
code/branches/surfaceraceHS14/src/modules/invader/InvaderEnemyShooter.cc
code/branches/surfaceraceHS14/src/modules/invader/InvaderEnemyShooter.h
code/branches/surfaceraceHS14/src/modules/invader/InvaderHUDinfo.cc
code/branches/surfaceraceHS14/src/modules/invader/InvaderHUDinfo.h
code/branches/surfaceraceHS14/src/modules/invader/InvaderPrereqs.h
code/branches/surfaceraceHS14/src/modules/invader/InvaderShip.cc
code/branches/surfaceraceHS14/src/modules/invader/InvaderShip.h
code/branches/surfaceraceHS14/src/modules/invader/InvaderWeapon.cc
code/branches/surfaceraceHS14/src/modules/invader/InvaderWeapon.h
code/branches/surfaceraceHS14/src/modules/invader/InvaderWeaponEnemy.cc
code/branches/surfaceraceHS14/src/modules/invader/InvaderWeaponEnemy.h
code/branches/surfaceraceHS14/svn-commit.tmp
Removed:
code/branches/surfaceraceHS14/src/modules/dodgerace/
code/branches/surfaceraceHS14/src/modules/invader/DodgePlayer.cc
code/branches/surfaceraceHS14/src/modules/invader/DodgePlayer.h
code/branches/surfaceraceHS14/src/modules/invader/DodgeRace.cc
code/branches/surfaceraceHS14/src/modules/invader/DodgeRace.h
Modified:
code/branches/surfaceraceHS14/src/modules/CMakeLists.txt
code/branches/surfaceraceHS14/src/modules/invader/CMakeLists.txt
Log:
Started copying all over again, HUD doesnt work
Modified: code/branches/surfaceraceHS14/src/modules/CMakeLists.txt
===================================================================
--- code/branches/surfaceraceHS14/src/modules/CMakeLists.txt 2014-11-05 15:13:41 UTC (rev 10113)
+++ code/branches/surfaceraceHS14/src/modules/CMakeLists.txt 2014-11-05 15:33:51 UTC (rev 10114)
@@ -39,4 +39,4 @@
ADD_SUBDIRECTORY(docking)
ADD_SUBDIRECTORY(towerdefense)
ADD_SUBDIRECTORY(invader)
-ADD_SUBDIRECTORY(dodgerace)
+ADD_SUBDIRECTORY(dodgerace2)
Added: code/branches/surfaceraceHS14/src/modules/dodgerace2/CMakeLists.txt
===================================================================
--- code/branches/surfaceraceHS14/src/modules/dodgerace2/CMakeLists.txt (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/dodgerace2/CMakeLists.txt 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,15 @@
+SET_SOURCE_FILES(Dodgerace2_SRC_FILES
+DodgeRace.cc
+DodgeRaceCenterPoint.cc
+DodgeRaceHUDinfo.cc
+)
+
+ORXONOX_ADD_LIBRARY(dodgerace2
+ MODULE
+ FIND_HEADER_FILES
+ LINK_LIBRARIES
+ orxonox
+ overlays
+ weapons
+ SOURCE_FILES ${Dodgerace2_SRC_FILES}
+)
Added: code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.cc
===================================================================
--- code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.cc (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.cc 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,187 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file DodgeRace.cc
+ @brief Implementation of the DodgeRace class.
+*/
+
+#include "DodgeRace.h"
+
+#include "core/CoreIncludes.h"
+#include "core/EventIncludes.h"
+#include "core/command/Executor.h"
+#include "core/config/ConfigValueIncludes.h"
+
+#include "gamestates/GSLevel.h"
+#include "chat/ChatManager.h"
+
+// ! HACK
+#include "infos/PlayerInfo.h"
+
+#include "DodgeRaceCenterPoint.h"
+/*#include "DodgeRaceShip.h"
+#include "DodgeRaceEnemy.h"
+#include "DodgeRaceEnemyShooter.h"
+*/
+#include "core/command/ConsoleCommand.h"
+#include "worldentities/BigExplosion.h"
+
+namespace orxonox
+{
+ RegisterClass(DodgeRace);
+
+ DodgeRace::DodgeRace(Context* context) : Deathmatch(context)
+ {
+ RegisterObject(DodgeRace);
+ this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
+ this->center_ = 0;
+ init();
+ this->setHUDTemplate("InvaderHUD"); // !!!!!!!!!!!!!!!INVADERHUD change later
+ }
+
+ void DodgeRace::init()
+ {
+ bEndGame = false;
+ lives = 3;
+ level = 1;
+ point = 0;
+ bShowLevel = false;
+ multiplier = 1;
+ b_combo = false;
+ // spawn enemy every 3.5 seconds
+ //enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&DodgeRace::spawnEnemy, this)));
+ //comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&DodgeRace::comboControll, this)));
+ }
+
+ void DodgeRace::levelUp()
+ {
+ level++;/*
+ if (getPlayer() != NULL)
+ {
+ for (int i = 0; i < 7; i++)
+ {
+ WeakPtr<BigExplosion> chunk = new BigExplosion(this->center_->getContext());
+ chunk->setPosition(Vector3(600, 0, 100.f * i - 300));
+ chunk->setVelocity(Vector3(1000, 0, 0)); //player->getVelocity()
+ chunk->setScale(20);
+ }
+ }
+ addPoints(multiplier * 42);
+ multiplier *= 2;
+ toggleShowLevel();
+ showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&DodgeRace::toggleShowLevel, this)));*/
+ }
+
+ /*WeakPtr<DodgeRaceShip> DodgeRace::getPlayer()
+ {
+ if (player == NULL)
+ {
+ //for (ObjectList<DodgeRaceShip>::iterator it = ObjectList<DodgeRaceShip>::begin(); it != ObjectList<DodgeRaceShip>::end(); ++it)
+ // player = *it;
+ }
+ return player;
+ }
+
+ void DodgeRace::spawnEnemy()
+ {
+ if (getPlayer() == NULL)
+ return;
+
+ for (int i = 0; i < (3*log10(static_cast<double>(level)) + 1); i++)
+ {
+ WeakPtr<DodgeRaceEnemy> newPawn;
+ if (rand() % 42/(1 + level*level) == 0)
+ {
+ newPawn = new DodgeRaceEnemyShooter(this->center_->getContext());
+ newPawn->addTemplate("enemyinvadershooter");
+ }
+ else
+ {
+ newPawn = new DodgeRaceEnemy(this->center_->getContext());
+ newPawn->addTemplate("enemyinvader");
+ }
+ newPawn->setPlayer(player);
+ newPawn->level = level;
+ // spawn enemy at random points in front of player.
+ newPawn->setPosition(player->getPosition() + Vector3(500.f + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200));
+ }
+ }*/
+
+ void DodgeRace::costLife()
+ {
+ lives--;
+ multiplier = 1;
+ // end the game in 30 seconds.
+ // if (lives <= 0)
+ // enemySpawnTimer.setTimer(30.0f, false, createExecutor(createFunctor(&DodgeRace::end, this)));
+ };
+
+ void DodgeRace::comboControll()
+ {
+ if (b_combo)
+ multiplier++;
+ // if no combo was performed before, reset multiplier
+ else
+ multiplier = 1;
+ b_combo = false;
+ }
+
+ void DodgeRace::start()
+ {
+ init();
+ // Set variable to temporarily force the player to spawn.
+ this->bForceSpawn_ = true;
+
+ if (this->center_ == NULL) // abandon mission!
+ {
+ orxout(internal_error) << "DodgeRace: No Centerpoint specified." << endl;
+ GSLevel::startMainMenu();
+ return;
+ }
+ // Call start for the parent class.
+ Deathmatch::start();
+ }
+ void DodgeRace::addPoints(int numPoints)
+ {
+ if (!bEndGame)
+ {
+ point += numPoints * multiplier;
+ b_combo = true;
+ }
+ }
+
+ void DodgeRace::end()
+ {
+ // DON'T CALL THIS!
+ // Deathmatch::end();
+ // It will misteriously crash the game!
+ // Instead startMainMenu, this won't crash.
+ GSLevel::startMainMenu();
+ }
+}
Added: code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.h (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.h 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,98 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file DodgeRace.h
+ @brief Gametype.
+ @ingroup DodgeRace
+*/
+
+#ifndef _DodgeRace_H__
+#define _DodgeRace_H__
+
+//#include "dodgerace2/DodgeRacePrereqs.h"
+
+#include "DodgeRaceCenterPoint.h"
+#include "DodgeRaceHUDinfo.h"
+
+#include "gametypes/Deathmatch.h"
+
+#include "DodgeRaceCenterPoint.h"
+
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+
+ class DodgeRace : public Deathmatch
+ {
+ public:
+ DodgeRace(Context* context);
+
+ virtual void start();
+ virtual void end();
+ virtual void addBots(unsigned int amount){} //<! overwrite function in order to bypass the addbots command
+
+ //void spawnEnemy();
+
+ void setCenterpoint(DodgeRaceCenterPoint* center)
+ { this->center_ = center; }
+
+ int getLives(){return this->lives;}
+ int getLevel(){return this->level;}
+ int getPoints(){return this->point;}
+ int getMultiplier(){return this->multiplier;}
+
+ void costLife();
+ void levelUp();
+ void addPoints(int numPoints);
+
+ // checks if multiplier should be reset.
+ void comboControll();
+ void init();
+ int lives;
+ int multiplier;
+ bool bEndGame;
+ bool bShowLevel;
+ private:
+ void toggleShowLevel(){bShowLevel = !bShowLevel;}
+ //WeakPtr<DodgeRaceShip> getPlayer();
+ WeakPtr<DodgeRaceCenterPoint> center_;
+ //WeakPtr<DodgeRaceShip> player;
+
+ Timer enemySpawnTimer;
+ Timer comboTimer;
+ Timer showLevelTimer;
+ //Context* context;
+ int level;
+ int point;
+ bool b_combo;
+ };
+}
+
+#endif /* _DodgeRace_H__ */
Added: code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceCenterPoint.cc
===================================================================
--- code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceCenterPoint.cc (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceCenterPoint.cc 2014-11-05 15:33:51 UTC (rev 10114)
@@ -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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file DodgeRaceCenterPoint.cc
+ @brief Implementation of the DodgeRaceCenterPoint class.
+*/
+
+#include "DodgeRaceCenterPoint.h"
+
+#include "core/CoreIncludes.h"
+
+//#include "DodgeRace.h"
+
+namespace orxonox
+{
+ RegisterClass(DodgeRaceCenterPoint);
+
+ DodgeRaceCenterPoint::DodgeRaceCenterPoint(Context* context) : StaticEntity(context)
+ {
+ RegisterObject(DodgeRaceCenterPoint);
+
+ this->checkGametype();
+ }
+
+ void DodgeRaceCenterPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(DodgeRaceCenterPoint, XMLPort, xmlelement, mode);
+ }
+
+ void DodgeRaceCenterPoint::changedGametype()
+ {
+ SUPER(DodgeRaceCenterPoint, changedGametype);
+
+ // Check, whether it's still DodgeRace.
+ this->checkGametype();
+ }
+
+ void DodgeRaceCenterPoint::checkGametype()
+ {
+ if (this->getGametype() != NULL && this->getGametype()->isA(Class(DodgeRace)))
+ {
+ DodgeRace* DodgeRaceGametype = orxonox_cast<DodgeRace*>(this->getGametype().get());
+ DodgeRaceGametype->setCenterpoint(this);
+ }
+ }
+}
Added: code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceCenterPoint.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceCenterPoint.h (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceCenterPoint.h 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,60 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file DodgeRaceCenterPoint.h
+ @brief Declaration of the DodgeRaceCenterPoint class.
+ @ingroup DodgeRace
+*/
+
+#ifndef _DodgeRaceCenterPoint_H__
+#define _DodgeRaceCenterPoint_H__
+
+//#include "dodgerace2/DodgeRacePrereqs.h"
+#include "DodgeRace.h"
+#include "DodgeRaceHUDinfo.h"
+
+#include "worldentities/StaticEntity.h"
+
+namespace orxonox
+{
+ class DodgeRaceCenterPoint : public StaticEntity
+ {
+ public:
+ DodgeRaceCenterPoint(Context* context); //checks whether the gametype is actually DodgeRace.
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+ virtual void changedGametype(); //!< Is called when the gametype has changed.
+ private:
+ void checkGametype();
+
+ };
+}
+
+#endif /* _DodgeRaceCenterPoint_H__ */
Added: code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.cc
===================================================================
--- code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.cc (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.cc 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,137 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ *
+ */
+
+#include "DodgeRaceHUDinfo.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Convert.h"
+#include "DodgeRace.h"
+
+namespace orxonox
+{
+ RegisterClass(DodgeRaceHUDinfo);
+
+ DodgeRaceHUDinfo::DodgeRaceHUDinfo(Context* context) : OverlayText(context)
+ {
+ RegisterObject(DodgeRaceHUDinfo);
+
+ this->DodgeRaceGame = 0;
+ this->bShowLives_ = false;
+ this->bShowLevel_ = false;
+ this->bShowPoints_ = false;
+ this->bShowMultiplier_ = false;
+ }
+
+ void DodgeRaceHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(DodgeRaceHUDinfo, XMLPort, xmlelement, mode);
+
+ XMLPortParam(DodgeRaceHUDinfo, "showlives", setShowLives, getShowLives, xmlelement, mode).defaultValues(false);
+ XMLPortParam(DodgeRaceHUDinfo, "showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false);
+ XMLPortParam(DodgeRaceHUDinfo, "showLevel", setShowLevel, getShowLevel, xmlelement, mode).defaultValues(false);
+ XMLPortParam(DodgeRaceHUDinfo, "showMultiplier", setShowMultiplier, getShowMultiplier, xmlelement, mode).defaultValues(false);
+ }
+
+ void DodgeRaceHUDinfo::tick(float dt)
+ {
+ SUPER(DodgeRaceHUDinfo, tick, dt);
+
+ if (this->DodgeRaceGame)
+ {
+ if (this->bShowLives_)
+ {
+ const std::string& lives = multi_cast<std::string>(this->DodgeRaceGame->getLives());
+ this->setCaption(lives);
+ }
+ else if(this->bShowLevel_)
+ {
+ const std::string& Level = multi_cast<std::string>(this->DodgeRaceGame->getLevel());
+ if (this->DodgeRaceGame->lives <= 0)
+ {
+ setPosition(Vector2(0.1, 0.65));
+ this->setCaption("Game ends in 30 seconds.\nPress (e)xit / (q)uit to go to the main menu.\nTo restart fly out of the screen!");
+ setTextSize(0.05);
+ this->DodgeRaceGame->bEndGame = true;
+ }
+ else if (this->DodgeRaceGame->bShowLevel)
+ {
+ setTextSize(0.1);
+ setPosition(Vector2(0.3, 0.55));
+ std::stringstream sstm;
+ sstm << "Level " << Level;
+ this->setCaption(sstm.str()); // + level
+ }
+ else
+ {
+ setTextSize(0.04);
+ setPosition(Vector2(0.14, 0.055));
+ this->setCaption(Level);
+ }
+ }
+ else if(this->bShowPoints_)
+ {
+ const std::string& points = multi_cast<std::string>(this->DodgeRaceGame->getPoints());
+ if (this->DodgeRaceGame->lives <= 0)
+ {
+ setTextSize(0.2);
+ setPosition(Vector2(0.1, 0.25));
+ this->setCaption("Final score:\n" + points);
+ this->setColour(ColourValue(1, 0, 0, 1));
+ }
+ else
+ {
+ setTextSize(0.04);
+ setPosition(Vector2(0.14, 0.1));
+ this->setColour(ColourValue(1, 1, 1, 1));
+ this->setCaption(points);
+ }
+ }
+ else if(this->bShowMultiplier_)
+ {
+ int mult = this->DodgeRaceGame->getMultiplier();
+ const std::string& Multiplier = "X " + multi_cast<std::string>(mult);
+ this->setCaption(Multiplier);
+ this->setColour(ColourValue(1, 0, 0, clamp(float(mult * 0.1), 0.0f, 1.0f)));
+ this->setTextSize(clamp(float(mult * 0.1), 0.0f, 1.0f) * 0.01f + 0.04f);
+ }
+ }
+ }
+
+ void DodgeRaceHUDinfo::changedOwner()
+ {
+ SUPER(DodgeRaceHUDinfo, changedOwner);
+
+ if (this->getOwner() && this->getOwner()->getGametype())
+ {
+ this->DodgeRaceGame = orxonox_cast<DodgeRace*>(this->getOwner()->getGametype().get());
+ }
+ else
+ {
+ this->DodgeRaceGame = 0;
+ }
+ }
+}
Added: code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.h (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.h 2014-11-05 15:33:51 UTC (rev 10114)
@@ -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:
+ * Florian Zinggeler
+ *
+ */
+
+#ifndef _DodgeRaceHUDinfo_H__
+#define _DodgeRaceHUDinfo_H__
+
+//#include "DodgeRacePrereqs.h"
+#include "DodgeRace.h"
+#include "DodgeRaceCenterPoint.h"
+
+#include "tools/interfaces/Tickable.h"
+#include "overlays/OverlayText.h"
+
+namespace orxonox
+{
+ class DodgeRaceHUDinfo : public OverlayText, public Tickable
+ {
+ public:
+ DodgeRaceHUDinfo(Context* context);
+
+ virtual void tick(float dt);
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void changedOwner();
+
+ inline void setShowLives(bool value)
+ { this->bShowLives_ = value; }
+ inline bool getShowLives() const
+ { return this->bShowLives_; }
+
+ inline void setShowLevel(bool value)
+ { this->bShowLevel_ = value; }
+ inline bool getShowLevel() const
+ { return this->bShowLevel_; }
+
+ inline void setShowPoints(bool value)
+ { this->bShowPoints_ = value; }
+ inline bool getShowPoints() const
+ { return this->bShowPoints_; }
+
+ inline void setShowMultiplier(bool value)
+ { this->bShowMultiplier_ = value; }
+ inline bool getShowMultiplier() const
+ { return this->bShowMultiplier_; }
+
+
+ private:
+ DodgeRace* DodgeRaceGame;
+ bool bShowLives_;
+ bool bShowLevel_;
+ bool bShowPoints_;
+ bool bShowMultiplier_;
+ };
+}
+#endif /* _DodgeRaceHUDinfo_H__ */
Added: code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRacePrereqs.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRacePrereqs.h (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRacePrereqs.h 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,80 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ at file
+ at brief
+ Shared library macros, enums, constants and forward declarations for the DodgeRace module
+*/
+
+#ifndef _DodgeRacePrereqs_H__
+#define _DodgeRacePrereqs_H__
+
+#include "OrxonoxConfig.h"
+#include "OrxonoxPrereqs.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(INVADER_STATIC_BUILD)
+# ifdef INVADER_SHARED_BUILD
+# define _DodgeRaceExport __declspec(dllexport)
+# else
+# if defined( __MINGW32__ )
+# define _DodgeRaceExport
+# else
+# define _DodgeRaceExport __declspec(dllimport)
+# endif
+# endif
+# define _DodgeRacePrivate
+#elif defined (ORXONOX_GCC_VISIBILITY)
+# define _DodgeRaceExport __attribute__ ((visibility("default")))
+# define _DodgeRacePrivate __attribute__ ((visibility("hidden")))
+#else
+# define _DodgeRaceExport
+# define _DodgeRacePrivate
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+ //class DodgeRace;
+ class DodgeRaceCenterPoint;/*
+ class DodgeRaceShip;
+ class DodgeRaceEnemy;
+ class DodgeRaceEnemyShooter;
+ class DodgeRaceWeapon;
+ class DodgeRaceWeaponEnemy;*/
+ class DodgeRaceHUDinfo;
+}
+
+#endif /* _DodgeRacePrereqs_H__ */
Modified: code/branches/surfaceraceHS14/src/modules/invader/CMakeLists.txt
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/CMakeLists.txt 2014-11-05 15:13:41 UTC (rev 10113)
+++ code/branches/surfaceraceHS14/src/modules/invader/CMakeLists.txt 2014-11-05 15:33:51 UTC (rev 10114)
@@ -1,15 +1,22 @@
-SET_SOURCE_FILES(DODGERACE_SRC_FILES
-BUILD_UNIT DodgeRaceBuildUnit.cc
- DodgePlayer.cc
- DodgeRace.cc
+SET_SOURCE_FILES(Invader_SRC_FILES
+BUILD_UNIT InvaderBuildUnit.cc
+ Invader.cc
+ InvaderCenterPoint.cc
+ InvaderShip.cc
+ InvaderEnemy.cc
+ InvaderEnemyShooter.cc
+ InvaderWeapon.cc
+ InvaderWeaponEnemy.cc
+ InvaderHUDinfo.cc
END_BUILD_UNIT
)
-ORXONOX_ADD_LIBRARY(dodgerace
+ORXONOX_ADD_LIBRARY(invader
MODULE
FIND_HEADER_FILES
LINK_LIBRARIES
orxonox
overlays
- SOURCE_FILES ${DODGERACE_SRC_FILES}
+ weapons
+ SOURCE_FILES ${Invader_SRC_FILES}
)
Deleted: code/branches/surfaceraceHS14/src/modules/invader/DodgePlayer.cc
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/DodgePlayer.cc 2014-11-05 15:13:41 UTC (rev 10113)
+++ code/branches/surfaceraceHS14/src/modules/invader/DodgePlayer.cc 2014-11-05 15:33:51 UTC (rev 10114)
@@ -1,33 +0,0 @@
-/*
- * DodgePlayer.cc
- *
- * Created on: Oct 15, 2014
- * Author: sriedel
- */
-
-#include "DodgePlayer.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
-namespace orxonox
-{
- RegisterClass(DodgePlayer);
-
- DodgePlayer::DodgePlayer()
- {
-
- }
-
- DodgePlayer::~DodgePlayer()
- {
-
- }
-
- void DodgePlayer::tick(float dt)
- {
-
-
- }
-
-} /* namespace orxonox */
Deleted: code/branches/surfaceraceHS14/src/modules/invader/DodgePlayer.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/DodgePlayer.h 2014-11-05 15:13:41 UTC (rev 10113)
+++ code/branches/surfaceraceHS14/src/modules/invader/DodgePlayer.h 2014-11-05 15:33:51 UTC (rev 10114)
@@ -1,27 +0,0 @@
-/*
- * DodgePlayer.h
- *
- * Created on: Oct 15, 2014
- * Author: sriedel
- */
-
-#ifndef DODGEPLAYER_H_
-#define DODGEPLAYER_H_
-
-#include "worldentities/pawns/SpaceShip.h"
-#include "graphics/Camera.h"
-
-namespace orxonox
-{
-
- class DodgePlayer
- {
- public:
- DodgePlayer();
- virtual ~DodgePlayer();
- virtual void tick(float dt);
- };
-
-} /* namespace orxonox */
-
-#endif /* DODGEPLAYER_H_ */
Deleted: code/branches/surfaceraceHS14/src/modules/invader/DodgeRace.cc
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/DodgeRace.cc 2014-11-05 15:13:41 UTC (rev 10113)
+++ code/branches/surfaceraceHS14/src/modules/invader/DodgeRace.cc 2014-11-05 15:33:51 UTC (rev 10114)
@@ -1,40 +0,0 @@
-/*
- * DodgeRace.cc
- *
- * Created on: Oct 15, 2014
- * Author: sriedel
- */
-
-#include "DodgeRace.h"
-
-#include "core/CoreIncludes.h"
-#include "core/EventIncludes.h"
-#include "core/command/Executor.h"
-#include "core/config/ConfigValueIncludes.h"
-
-#include "gamestates/GSLevel.h"
-#include "chat/ChatManager.h"
-
-namespace orxonox
-{
- RegisterUnloadableClass(DodgeRace);
-
- DodgeRace::DodgeRace()
- {
- init();
-
- }
-
- void DodgeRace::init()
- {
- level = 0;
- point = 0;
- lives = 1;
-
- }
-
- DodgeRace::~DodgeRace() {
- // TODO Auto-generated destructor stub
- }
-
-} /* namespace orxonox */
Deleted: code/branches/surfaceraceHS14/src/modules/invader/DodgeRace.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/DodgeRace.h 2014-11-05 15:13:41 UTC (rev 10113)
+++ code/branches/surfaceraceHS14/src/modules/invader/DodgeRace.h 2014-11-05 15:33:51 UTC (rev 10114)
@@ -1,30 +0,0 @@
-/*
- * DodgeRace.h
- *
- * Created on: Oct 15, 2014
- * Author: sriedel
- */
-
-#ifndef DODGERACE_H_
-#define DODGERACE_H_
-
-namespace orxonox
-{
-
- class DodgeRace
- {
- public:
- DodgeRace();
- virtual ~DodgeRace();
-
- void init();
-
- private:
- int point;
- int level;
- int lives
-
- };
-
-} /* namespace orxonox */
-#endif /* DODGERACE_H_ */
Added: code/branches/surfaceraceHS14/src/modules/invader/Invader.cc
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/Invader.cc (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/Invader.cc 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,187 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file Invader.cc
+ @brief Implementation of the Invader class.
+*/
+
+#include "Invader.h"
+
+#include "core/CoreIncludes.h"
+#include "core/EventIncludes.h"
+#include "core/command/Executor.h"
+#include "core/config/ConfigValueIncludes.h"
+
+#include "gamestates/GSLevel.h"
+#include "chat/ChatManager.h"
+
+// ! HACK
+#include "infos/PlayerInfo.h"
+
+#include "InvaderCenterPoint.h"
+#include "InvaderShip.h"
+#include "InvaderEnemy.h"
+#include "InvaderEnemyShooter.h"
+
+#include "core/command/ConsoleCommand.h"
+#include "worldentities/BigExplosion.h"
+
+namespace orxonox
+{
+ RegisterUnloadableClass(Invader);
+
+ Invader::Invader(Context* context) : Deathmatch(context)
+ {
+ RegisterObject(Invader);
+ this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
+ this->center_ = 0;
+ init();
+ this->setHUDTemplate("InvaderHUD");
+ }
+
+ void Invader::init()
+ {
+ bEndGame = false;
+ lives = 3;
+ level = 1;
+ point = 0;
+ bShowLevel = false;
+ multiplier = 1;
+ b_combo = false;
+ // spawn enemy every 3.5 seconds
+ enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));
+ comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&Invader::comboControll, this)));
+ }
+
+ void Invader::levelUp()
+ {
+ level++;
+ if (getPlayer() != NULL)
+ {
+ for (int i = 0; i < 7; i++)
+ {
+ WeakPtr<BigExplosion> chunk = new BigExplosion(this->center_->getContext());
+ chunk->setPosition(Vector3(600, 0, 100.f * i - 300));
+ chunk->setVelocity(Vector3(1000, 0, 0)); //player->getVelocity()
+ chunk->setScale(20);
+ }
+ }
+ addPoints(multiplier * 42);
+ multiplier *= 2;
+ toggleShowLevel();
+ showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Invader::toggleShowLevel, this)));
+ }
+
+ WeakPtr<InvaderShip> Invader::getPlayer()
+ {
+ if (player == NULL)
+ {
+ for (ObjectList<InvaderShip>::iterator it = ObjectList<InvaderShip>::begin(); it != ObjectList<InvaderShip>::end(); ++it)
+ player = *it;
+ }
+ return player;
+ }
+
+ void Invader::spawnEnemy()
+ {
+ if (getPlayer() == NULL)
+ return;
+
+ for (int i = 0; i < (3*log10(static_cast<double>(level)) + 1); i++)
+ {
+ WeakPtr<InvaderEnemy> newPawn;
+ if (rand() % 42/(1 + level*level) == 0)
+ {
+ newPawn = new InvaderEnemyShooter(this->center_->getContext());
+ newPawn->addTemplate("enemyinvadershooter");
+ }
+ else
+ {
+ newPawn = new InvaderEnemy(this->center_->getContext());
+ newPawn->addTemplate("enemyinvader");
+ }
+ newPawn->setPlayer(player);
+ newPawn->level = level;
+ // spawn enemy at random points in front of player.
+ newPawn->setPosition(player->getPosition() + Vector3(500.f + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200));
+ }
+ }
+
+ void Invader::costLife()
+ {
+ lives--;
+ multiplier = 1;
+ // end the game in 30 seconds.
+ if (lives <= 0)
+ enemySpawnTimer.setTimer(30.0f, false, createExecutor(createFunctor(&Invader::end, this)));
+ };
+
+ void Invader::comboControll()
+ {
+ if (b_combo)
+ multiplier++;
+ // if no combo was performed before, reset multiplier
+ else
+ multiplier = 1;
+ b_combo = false;
+ }
+
+ void Invader::start()
+ {
+ init();
+ // Set variable to temporarily force the player to spawn.
+ this->bForceSpawn_ = true;
+
+ if (this->center_ == NULL) // abandon mission!
+ {
+ orxout(internal_error) << "Invader: No Centerpoint specified." << endl;
+ GSLevel::startMainMenu();
+ return;
+ }
+ // Call start for the parent class.
+ Deathmatch::start();
+ }
+ void Invader::addPoints(int numPoints)
+ {
+ if (!bEndGame)
+ {
+ point += numPoints * multiplier;
+ b_combo = true;
+ }
+ }
+
+ void Invader::end()
+ {
+ // DON'T CALL THIS!
+ // Deathmatch::end();
+ // It will misteriously crash the game!
+ // Instead startMainMenu, this won't crash.
+ GSLevel::startMainMenu();
+ }
+}
Added: code/branches/surfaceraceHS14/src/modules/invader/Invader.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/Invader.h (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/Invader.h 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,94 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file Invader.h
+ @brief Gametype.
+ @ingroup Invader
+*/
+
+#ifndef _Invader_H__
+#define _Invader_H__
+
+#include "invader/InvaderPrereqs.h"
+
+#include "gametypes/Deathmatch.h"
+
+#include "InvaderCenterPoint.h"
+
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+
+ class _InvaderExport Invader : public Deathmatch
+ {
+ public:
+ Invader(Context* context);
+
+ virtual void start();
+ virtual void end();
+ virtual void addBots(unsigned int amount){} //<! overwrite function in order to bypass the addbots command
+
+ void spawnEnemy();
+
+ void setCenterpoint(InvaderCenterPoint* center)
+ { this->center_ = center; }
+
+ int getLives(){return this->lives;}
+ int getLevel(){return this->level;}
+ int getPoints(){return this->point;}
+ int getMultiplier(){return this->multiplier;}
+
+ void costLife();
+ void levelUp();
+ void addPoints(int numPoints);
+ // checks if multiplier should be reset.
+ void comboControll();
+ void init();
+ int lives;
+ int multiplier;
+ bool bEndGame;
+ bool bShowLevel;
+ private:
+ void toggleShowLevel(){bShowLevel = !bShowLevel;}
+ WeakPtr<InvaderShip> getPlayer();
+ WeakPtr<InvaderCenterPoint> center_;
+ WeakPtr<InvaderShip> player;
+
+ Timer enemySpawnTimer;
+ Timer comboTimer;
+ Timer showLevelTimer;
+ //Context* context;
+ int level;
+ int point;
+ bool b_combo;
+ };
+}
+
+#endif /* _Invader_H__ */
Added: code/branches/surfaceraceHS14/src/modules/invader/InvaderCenterPoint.cc
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/InvaderCenterPoint.cc (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/InvaderCenterPoint.cc 2014-11-05 15:33:51 UTC (rev 10114)
@@ -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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file InvaderCenterPoint.cc
+ @brief Implementation of the InvaderCenterPoint class.
+*/
+
+#include "InvaderCenterPoint.h"
+
+#include "core/CoreIncludes.h"
+
+#include "Invader.h"
+
+namespace orxonox
+{
+ RegisterClass(InvaderCenterPoint);
+
+ InvaderCenterPoint::InvaderCenterPoint(Context* context) : StaticEntity(context)
+ {
+ RegisterObject(InvaderCenterPoint);
+
+ this->checkGametype();
+ }
+
+ void InvaderCenterPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(InvaderCenterPoint, XMLPort, xmlelement, mode);
+ }
+
+ void InvaderCenterPoint::changedGametype()
+ {
+ SUPER(InvaderCenterPoint, changedGametype);
+
+ // Check, whether it's still Invader.
+ this->checkGametype();
+ }
+
+ void InvaderCenterPoint::checkGametype()
+ {
+ if (this->getGametype() != NULL && this->getGametype()->isA(Class(Invader)))
+ {
+ Invader* InvaderGametype = orxonox_cast<Invader*>(this->getGametype().get());
+ InvaderGametype->setCenterpoint(this);
+ }
+ }
+}
Added: code/branches/surfaceraceHS14/src/modules/invader/InvaderCenterPoint.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/InvaderCenterPoint.h (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/InvaderCenterPoint.h 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,58 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file InvaderCenterPoint.h
+ @brief Declaration of the InvaderCenterPoint class.
+ @ingroup Invader
+*/
+
+#ifndef _InvaderCenterPoint_H__
+#define _InvaderCenterPoint_H__
+
+#include "invader/InvaderPrereqs.h"
+
+#include "worldentities/StaticEntity.h"
+
+namespace orxonox
+{
+ class _InvaderExport InvaderCenterPoint : public StaticEntity
+ {
+ public:
+ InvaderCenterPoint(Context* context); //checks whether the gametype is actually Invader.
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+ virtual void changedGametype(); //!< Is called when the gametype has changed.
+ private:
+ void checkGametype();
+
+ };
+}
+
+#endif /* _InvaderCenterPoint_H__ */
Added: code/branches/surfaceraceHS14/src/modules/invader/InvaderEnemy.cc
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/InvaderEnemy.cc (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/InvaderEnemy.cc 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,87 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file InvaderEnemy.h
+ @brief Declaration of the InvaderEnemy class.
+*/
+
+#include "invader/InvaderPrereqs.h"
+#include "InvaderEnemy.h"
+#include "InvaderShip.h"
+
+namespace orxonox
+{
+ RegisterClass(InvaderEnemy);
+
+ InvaderEnemy::InvaderEnemy(Context* context) : Pawn(context)
+ {
+ RegisterObject(InvaderEnemy);
+ enableCollisionCallback();
+ lifetime = 0;
+ }
+
+ void InvaderEnemy::tick(float dt)
+ {
+ lifetime += dt;
+ // die after 5 seconds.
+ if (lifetime > 5000)
+ removeHealth(2000);
+
+ if (player != NULL)
+ {
+ float newZ = 2/(pow(abs(getPosition().x - player->getPosition().x) * 0.01f, 2) + 1) * (player->getPosition().z - getPosition().z);
+ setVelocity(Vector3(1000.f - level * 100 , 0, newZ));
+ }
+ SUPER(InvaderEnemy, tick, dt);
+ }
+
+ inline bool InvaderEnemy::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
+ {
+ if(orxonox_cast<InvaderShip*>(otherObject))
+ removeHealth(2000);
+ 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)
+ {
+ Pawn::damage(damage, healthdamage, shielddamage, originator);
+ if (getGame() && orxonox_cast<InvaderShip*>(originator) != NULL && getHealth() <= 0)
+ getGame()->addPoints(42);
+ }
+}
\ No newline at end of file
Added: code/branches/surfaceraceHS14/src/modules/invader/InvaderEnemy.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/InvaderEnemy.h (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/InvaderEnemy.h 2014-11-05 15:33:51 UTC (rev 10114)
@@ -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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file InvaderEnemy.h
+ @brief Declaration of the InvaderEnemy class.
+*/
+
+#ifndef _InvaderEnemy_H__
+#define _InvaderEnemy_H__
+
+#include "invader/InvaderPrereqs.h"
+
+#include "worldentities/pawns/SpaceShip.h"
+
+namespace orxonox
+{
+ class _InvaderExport InvaderEnemy : public Pawn
+ {
+ public:
+ InvaderEnemy(Context* context);
+
+ virtual void tick(float dt);
+ virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
+ virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator);
+ virtual void setPlayer(WeakPtr<InvaderShip> player){this->player = player;}
+
+ int level;
+ protected:
+ WeakPtr<Invader> getGame();
+ WeakPtr<Invader> game;
+ WeakPtr<InvaderShip> player;
+ Camera* camera;
+ bool isFireing;
+ float speed, damping;
+ float lastTimeFront, lastTimeLeft;
+ float lifetime;
+ struct Velocity
+ {
+ float x;
+ float y;
+ } velocity, desiredVelocity;
+
+ };
+}
+
+#endif /* _InvaderEnemy_H__ */
Added: code/branches/surfaceraceHS14/src/modules/invader/InvaderEnemyShooter.cc
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/InvaderEnemyShooter.cc (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/InvaderEnemyShooter.cc 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,79 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file InvaderEnemyShooter.h
+ @brief Declaration of the InvaderEnemyShooter class.
+*/
+
+#include "invader/InvaderPrereqs.h"
+#include "InvaderEnemyShooter.h"
+// #include "worldentities/pawns/SpaceShip.h"
+
+namespace orxonox
+{
+ RegisterClass(InvaderEnemyShooter);
+
+ InvaderEnemyShooter::InvaderEnemyShooter(Context* context) : InvaderEnemy(context)
+ {
+ RegisterObject(InvaderEnemyShooter);
+ enableCollisionCallback();
+ lifetime = 0;
+ // shoot every second
+ shootTimer.setTimer(1.0f, true, createExecutor(createFunctor(&InvaderEnemyShooter::shoot, this)));
+ }
+
+ void InvaderEnemyShooter::tick(float dt)
+ {
+ lifetime += dt;
+ // die after 20 seconds.
+ if (lifetime > 20000)
+ removeHealth(2000);
+
+ if (player != NULL)
+ {
+ float distPlayer = player->getPosition().z - getPosition().z;
+ // orxout() << "i'm different!" << endl;
+ float newZ = 2/(pow(abs(getPosition().x - player->getPosition().x) * 0.01f, 2) + 1) * distPlayer;
+ setVelocity(Vector3(950 - abs(distPlayer), 0, newZ));
+ }
+ Pawn::tick(dt);
+ }
+
+ void InvaderEnemyShooter::shoot()
+ {
+ ControllableEntity::fire(0);
+ }
+
+ void InvaderEnemyShooter::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
+ {
+ Pawn::damage(damage, healthdamage, shielddamage, originator);
+ if (getGame() && orxonox_cast<InvaderShip*>(originator) != NULL && getHealth() <= 0)
+ getGame()->addPoints(3*42);
+ }
+}
\ No newline at end of file
Added: code/branches/surfaceraceHS14/src/modules/invader/InvaderEnemyShooter.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/InvaderEnemyShooter.h (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/InvaderEnemyShooter.h 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,58 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file InvaderEnemyShooter.h
+ @brief Declaration of the InvaderEnemyShooter class.
+*/
+
+#ifndef _InvaderEnemyShooter_H__
+#define _InvaderEnemyShooter_H__
+
+#include "invader/InvaderPrereqs.h"
+
+#include "invader/InvaderEnemy.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+ class _InvaderExport InvaderEnemyShooter : public InvaderEnemy
+ {
+ public:
+ InvaderEnemyShooter(Context* context);
+
+ virtual void tick(float dt);
+ virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator);
+ protected:
+ void shoot();
+ Timer shootTimer;
+
+ };
+}
+
+#endif /* _InvaderEnemyShooter_H__ */
Added: code/branches/surfaceraceHS14/src/modules/invader/InvaderHUDinfo.cc
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/InvaderHUDinfo.cc (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/InvaderHUDinfo.cc 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,137 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ *
+ */
+
+#include "InvaderHUDinfo.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Convert.h"
+// #include "Invader.h"
+
+namespace orxonox
+{
+ RegisterClass(InvaderHUDinfo);
+
+ InvaderHUDinfo::InvaderHUDinfo(Context* context) : OverlayText(context)
+ {
+ RegisterObject(InvaderHUDinfo);
+
+ this->InvaderGame = 0;
+ this->bShowLives_ = false;
+ this->bShowLevel_ = false;
+ this->bShowPoints_ = false;
+ this->bShowMultiplier_ = false;
+ }
+
+ void InvaderHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(InvaderHUDinfo, XMLPort, xmlelement, mode);
+
+ XMLPortParam(InvaderHUDinfo, "showlives", setShowLives, getShowLives, xmlelement, mode).defaultValues(false);
+ XMLPortParam(InvaderHUDinfo, "showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false);
+ XMLPortParam(InvaderHUDinfo, "showLevel", setShowLevel, getShowLevel, xmlelement, mode).defaultValues(false);
+ XMLPortParam(InvaderHUDinfo, "showMultiplier", setShowMultiplier, getShowMultiplier, xmlelement, mode).defaultValues(false);
+ }
+
+ void InvaderHUDinfo::tick(float dt)
+ {
+ SUPER(InvaderHUDinfo, tick, dt);
+
+ if (this->InvaderGame)
+ {
+ if (this->bShowLives_)
+ {
+ const std::string& lives = multi_cast<std::string>(this->InvaderGame->getLives());
+ this->setCaption(lives);
+ }
+ else if(this->bShowLevel_)
+ {
+ const std::string& Level = multi_cast<std::string>(this->InvaderGame->getLevel());
+ if (this->InvaderGame->lives <= 0)
+ {
+ setPosition(Vector2(0.1, 0.65));
+ this->setCaption("Game ends in 30 seconds.\nPress (e)xit / (q)uit to go to the main menu.\nTo restart fly out of the screen!");
+ setTextSize(0.05);
+ this->InvaderGame->bEndGame = true;
+ }
+ else if (this->InvaderGame->bShowLevel)
+ {
+ setTextSize(0.1);
+ setPosition(Vector2(0.3, 0.55));
+ std::stringstream sstm;
+ sstm << "Level " << Level;
+ this->setCaption(sstm.str()); // + level
+ }
+ else
+ {
+ setTextSize(0.04);
+ setPosition(Vector2(0.14, 0.055));
+ this->setCaption(Level);
+ }
+ }
+ else if(this->bShowPoints_)
+ {
+ const std::string& points = multi_cast<std::string>(this->InvaderGame->getPoints());
+ if (this->InvaderGame->lives <= 0)
+ {
+ setTextSize(0.2);
+ setPosition(Vector2(0.1, 0.25));
+ this->setCaption("Final score:\n" + points);
+ this->setColour(ColourValue(1, 0, 0, 1));
+ }
+ else
+ {
+ setTextSize(0.04);
+ setPosition(Vector2(0.14, 0.1));
+ this->setColour(ColourValue(1, 1, 1, 1));
+ this->setCaption(points);
+ }
+ }
+ else if(this->bShowMultiplier_)
+ {
+ int mult = this->InvaderGame->getMultiplier();
+ const std::string& Multiplier = "X " + multi_cast<std::string>(mult);
+ this->setCaption(Multiplier);
+ this->setColour(ColourValue(1, 0, 0, clamp(float(mult * 0.1), 0.0f, 1.0f)));
+ this->setTextSize(clamp(float(mult * 0.1), 0.0f, 1.0f) * 0.01f + 0.04f);
+ }
+ }
+ }
+
+ void InvaderHUDinfo::changedOwner()
+ {
+ SUPER(InvaderHUDinfo, changedOwner);
+
+ if (this->getOwner() && this->getOwner()->getGametype())
+ {
+ this->InvaderGame = orxonox_cast<Invader*>(this->getOwner()->getGametype().get());
+ }
+ else
+ {
+ this->InvaderGame = 0;
+ }
+ }
+}
Added: code/branches/surfaceraceHS14/src/modules/invader/InvaderHUDinfo.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/InvaderHUDinfo.h (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/InvaderHUDinfo.h 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,75 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ *
+ */
+
+#ifndef _InvaderHUDinfo_H__
+#define _InvaderHUDinfo_H__
+
+#include "invader/InvaderPrereqs.h"
+
+#include "tools/interfaces/Tickable.h"
+#include "overlays/OverlayText.h"
+
+namespace orxonox
+{
+ class _InvaderExport InvaderHUDinfo : public OverlayText, public Tickable
+ {
+ public:
+ InvaderHUDinfo(Context* context);
+
+ virtual void tick(float dt);
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void changedOwner();
+
+ inline void setShowLives(bool value)
+ { this->bShowLives_ = value; }
+ inline bool getShowLives() const
+ { return this->bShowLives_; }
+
+ inline void setShowLevel(bool value)
+ { this->bShowLevel_ = value; }
+ inline bool getShowLevel() const
+ { return this->bShowLevel_; }
+
+ inline void setShowPoints(bool value)
+ { this->bShowPoints_ = value; }
+ inline bool getShowPoints() const
+ { return this->bShowPoints_; }
+
+ inline void setShowMultiplier(bool value)
+ { this->bShowMultiplier_ = value; }
+ inline bool getShowMultiplier() const
+ { return this->bShowMultiplier_; }
+
+
+ private:
+ Invader* InvaderGame;
+ bool bShowLives_;
+ bool bShowLevel_;
+ bool bShowPoints_;
+ bool bShowMultiplier_;
+ };
+}
+#endif /* _InvaderHUDinfo_H__ */
Added: code/branches/surfaceraceHS14/src/modules/invader/InvaderPrereqs.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/InvaderPrereqs.h (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/InvaderPrereqs.h 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,80 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ at file
+ at brief
+ Shared library macros, enums, constants and forward declarations for the Invader module
+*/
+
+#ifndef _InvaderPrereqs_H__
+#define _InvaderPrereqs_H__
+
+#include "OrxonoxConfig.h"
+#include "OrxonoxPrereqs.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(INVADER_STATIC_BUILD)
+# ifdef INVADER_SHARED_BUILD
+# define _InvaderExport __declspec(dllexport)
+# else
+# if defined( __MINGW32__ )
+# define _InvaderExport
+# else
+# define _InvaderExport __declspec(dllimport)
+# endif
+# endif
+# define _InvaderPrivate
+#elif defined (ORXONOX_GCC_VISIBILITY)
+# define _InvaderExport __attribute__ ((visibility("default")))
+# define _InvaderPrivate __attribute__ ((visibility("hidden")))
+#else
+# define _InvaderExport
+# define _InvaderPrivate
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+ class Invader;
+ class InvaderCenterPoint;
+ class InvaderShip;
+ class InvaderEnemy;
+ class InvaderEnemyShooter;
+ class InvaderWeapon;
+ class InvaderWeaponEnemy;
+ class InvaderHUDinfo;
+}
+
+#endif /* _InvaderPrereqs_H__ */
Added: code/branches/surfaceraceHS14/src/modules/invader/InvaderShip.cc
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/InvaderShip.cc (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/InvaderShip.cc 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,188 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file InvaderShip.cc
+ @brief Implementation of the InvaderShip class.
+*/
+
+#include "InvaderShip.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "Invader.h"
+
+namespace orxonox
+{
+ RegisterClass(InvaderShip);
+
+ InvaderShip::InvaderShip(Context* context) : SpaceShip(context)
+ {
+ RegisterObject(InvaderShip);
+
+ speed = 500;
+ isFireing = false;
+ damping = 10;
+ }
+
+ void InvaderShip::tick(float dt)
+ {
+ Vector3 pos = getPosition();
+
+ //Movement calculation
+ lastTimeFront += dt * damping;
+ lastTimeLeft += dt * damping;
+ lastTime += dt;
+
+ velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f);
+ velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f);
+
+ //Execute movement
+ if (this->hasLocalController())
+ {
+ float dist_y = velocity.y * dt;
+ float dist_x = velocity.x * dt;
+ if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6)
+ posforeward += dist_y;
+ else
+ {
+ velocity.y = 0;
+ // restart if game ended
+ if (getGame())
+ if (getGame()->bEndGame)
+ {
+ getGame()->start();
+ return;
+ }
+ }
+ if (pos.z + dist_x > 42*2.5 || pos.z + dist_x < -42*3)
+ velocity.x = 0;
+ pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt;
+ }
+
+ // shoot!
+ if (isFireing)
+ ControllableEntity::fire(0);
+
+ // Camera
+ WeakPtr<Camera> camera = this->getCamera();
+ if (camera != NULL)
+ {
+ camera->setPosition(Vector3(-pos.z, -posforeward, 0));
+ camera->setOrientation(Vector3::UNIT_Z, Degree(90));
+ }
+
+
+
+ // bring back on track!
+ if(pos.y != 0)
+ pos.y = 0;
+
+ setPosition(pos);
+ setOrientation(Vector3::UNIT_Y, Degree(270));
+
+ // Level up!
+ if (pos.x > 42000)
+ {
+ updateLevel();
+ setPosition(Vector3(0, 0, pos.z)); // pos - Vector3(30000, 0, 0)
+ }
+
+ SUPER(InvaderShip, tick, dt);
+ }
+
+ void InvaderShip::updateLevel()
+ {
+ lastTime = 0;
+ if (getGame())
+ getGame()->levelUp();
+ }
+
+ void InvaderShip::moveFrontBack(const Vector2& value)
+ {
+ lastTimeLeft = 0;
+ desiredVelocity.x = -value.x * speed;
+ }
+
+ void InvaderShip::moveRightLeft(const Vector2& value)
+ {
+ lastTimeFront = 0;
+ desiredVelocity.y = value.y * speed * 42;
+ }
+ void InvaderShip::boost(bool bBoost)
+ {
+ isFireing = bBoost;
+ }
+ inline bool InvaderShip::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
+ {
+ // orxout() << "touch!!! " << endl; //<< otherObject << " at " << contactPoint;
+ WeakPtr<InvaderEnemy> enemy = orxonox_cast<InvaderEnemy*>(otherObject);
+ WeakPtr<Projectile> shot = orxonox_cast<Projectile*>(otherObject);
+ // ensure that this gets only called once per enemy.
+ if (enemy != NULL && lastEnemy != enemy)
+ {
+ lastEnemy = enemy;
+
+ removeHealth(20);
+ if (getGame())
+ {
+ getGame()->multiplier = 1;
+ }
+ }
+ // was shot, decrease multiplier
+ else if (shot != NULL && lastShot != shot)
+ {
+ if (getGame() && orxonox_cast<InvaderEnemy*>(shot->getShooter()) != NULL)
+ {
+ if (getGame()->multiplier > 1)
+ {
+ lastShot = shot;
+ getGame()->multiplier -= 1;
+ }
+ }
+ }
+ 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;
+ }
+
+ void InvaderShip::death()
+ {
+ getGame()->costLife();
+ SpaceShip::death();
+ }
+}
Added: code/branches/surfaceraceHS14/src/modules/invader/InvaderShip.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/InvaderShip.h (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/InvaderShip.h 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,90 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file InvaderShip.h
+ @brief Declaration of the InvaderShip class.
+*/
+
+#ifndef _InvaderShip_H__
+#define _InvaderShip_H__
+
+#include "invader/InvaderPrereqs.h"
+
+#include "worldentities/pawns/SpaceShip.h"
+#include "graphics/Camera.h"
+#include "weapons/projectiles/Projectile.h"
+
+namespace orxonox
+{
+ class _InvaderExport InvaderShip : public SpaceShip
+ {
+ public:
+ InvaderShip(Context* context);
+
+ virtual void tick(float dt);
+
+ // overwrite for 2d movement
+ virtual void moveFrontBack(const Vector2& value);
+ virtual void moveRightLeft(const Vector2& value);
+
+ // Starts or stops fireing
+ virtual void boost(bool bBoost);
+
+ //no rotation!
+ virtual void rotateYaw(const Vector2& value){};
+ virtual void rotatePitch(const Vector2& value){};
+ //return to main menu if game has ended.
+ virtual void rotateRoll(const Vector2& value){if (getGame()) if (getGame()->bEndGame) getGame()->end();};
+
+ virtual void updateLevel();
+
+ virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
+
+ protected:
+ virtual void death();
+ private:
+ WeakPtr<Invader> getGame();
+ WeakPtr<Invader> game;
+ Camera* camera;
+ bool isFireing;
+ float speed, damping, posforeward;
+ float lastTimeFront, lastTimeLeft, lastTime;
+ struct Velocity
+ {
+ float x;
+ float y;
+ } velocity, desiredVelocity;
+
+ WeakPtr<InvaderEnemy> lastEnemy;
+ WeakPtr<Projectile> lastShot;
+
+ };
+}
+
+#endif /* _InvaderShip_H__ */
Added: code/branches/surfaceraceHS14/src/modules/invader/InvaderWeapon.cc
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/InvaderWeapon.cc (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/InvaderWeapon.cc 2014-11-05 15:33:51 UTC (rev 10114)
@@ -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:
+ * Florian Zinggeler
+ * Co-authors:
+ * --
+ *
+ */
+
+/**
+ @file InvaderWeapon.h
+ @brief Implementation of the InvaderWeapon class.
+*/
+
+#include "InvaderWeapon.h"
+
+#include "core/CoreIncludes.h"
+// #include "core/XMLPort.h"
+// #include "core/command/Executor.h"
+
+#include "graphics/Model.h"
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/WorldEntity.h"
+#include "worldentities/pawns/Pawn.h"
+
+#include "weapons/projectiles/Projectile.h"
+#include "weapons/MuzzleFlash.h"
+
+namespace orxonox
+{
+ RegisterClass(InvaderWeapon);
+
+ InvaderWeapon::InvaderWeapon(Context* context) : HsW01(context)
+ {
+ RegisterObject(InvaderWeapon);
+ }
+
+ InvaderWeapon::~InvaderWeapon(){}
+
+ void InvaderWeapon::shot()
+ {
+ assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
+
+ // Create the projectile.projectile
+ projectile = new Projectile(this->getContext());
+ WeakPtr<Model> model = new Model(projectile->getContext());
+ model->setMeshSource(mesh_);
+ model->setCastShadows(false);
+ projectile->attach(model);
+ model->setScale(5);
+
+ this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
+ // only shoot in foreward direction
+ projectile->setOrientation(Quaternion(sqrt(0.5f),0,sqrt(0.5f),0));
+ projectile->setPosition(this->getMuzzlePosition());
+ // only shoot in foreward direction
+ projectile->setVelocity(Vector3(1, 0, 0) * 2000);
+
+ projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
+
+ // Display the muzzle flash.
+ this->InvaderWeapon::muzzleflash();
+ }
+}
Added: code/branches/surfaceraceHS14/src/modules/invader/InvaderWeapon.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/InvaderWeapon.h (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/InvaderWeapon.h 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,55 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file InvaderWeapon.h
+ @brief Definition of the InvaderWeapon class.
+*/
+
+#ifndef _InvaderWeapon_H__
+#define _InvaderWeapon_H__
+
+#include "weapons/weaponmodes/HsW01.h"
+#include "weapons/WeaponsPrereqs.h"
+
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+ class _InvaderExport InvaderWeapon : public HsW01
+ {
+ public:
+ InvaderWeapon(Context* context);
+ virtual ~InvaderWeapon();
+ protected:
+ virtual void shot();
+ WeakPtr<Projectile> projectile;
+ };
+}
+
+#endif /* _InvaderWeapon_H__ */
Added: code/branches/surfaceraceHS14/src/modules/invader/InvaderWeaponEnemy.cc
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/InvaderWeaponEnemy.cc (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/InvaderWeaponEnemy.cc 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,55 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * --
+ *
+ */
+
+/**
+ @file InvaderWeaponEnemy.h
+ @brief Implementation of the InvaderWeaponEnemy class.
+*/
+
+#include "InvaderWeaponEnemy.h"
+
+namespace orxonox
+{
+ RegisterClass(InvaderWeaponEnemy);
+
+ InvaderWeaponEnemy::InvaderWeaponEnemy(Context* context) : InvaderWeapon(context)
+ {
+ RegisterObject(InvaderWeaponEnemy);
+ }
+
+ void InvaderWeaponEnemy::shot()
+ {
+ InvaderWeapon::shot();
+ // SUPER(InvaderWeaponEnemy, shot);
+ // only shoot in foreward direction
+ projectile->setVelocity(Vector3(1, 0, 0) * 300);
+ // projectile->setOrientation(Quaternion(sqrt(0.5),0,sqrt(0.5),0));
+ }
+}
+
+
Added: code/branches/surfaceraceHS14/src/modules/invader/InvaderWeaponEnemy.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/invader/InvaderWeaponEnemy.h (rev 0)
+++ code/branches/surfaceraceHS14/src/modules/invader/InvaderWeaponEnemy.h 2014-11-05 15:33:51 UTC (rev 10114)
@@ -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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file InvaderWeaponEnemy.h
+ @brief Definition of the InvaderWeaponEnemy class.
+*/
+
+#ifndef _InvaderWeaponEnemy_H__
+#define _InvaderWeaponEnemy_H__
+
+// #include "weapons/weaponmodes/HsW01.h"
+// #include "weapons/WeaponsPrereqs.h"
+#include "invader/InvaderWeapon.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+ class _InvaderExport InvaderWeaponEnemy : public InvaderWeapon
+ {
+ public:
+ InvaderWeaponEnemy(Context* context);
+ protected:
+ virtual void shot();
+ };
+}
+
+#endif /* _InvaderWeaponEnemy_H__ */
Added: code/branches/surfaceraceHS14/svn-commit.tmp
===================================================================
--- code/branches/surfaceraceHS14/svn-commit.tmp (rev 0)
+++ code/branches/surfaceraceHS14/svn-commit.tmp 2014-11-05 15:33:51 UTC (rev 10114)
@@ -0,0 +1,9 @@
+
+--This line, and those below, will be ignored--
+
+M data/levels/DodgeRace.oxw
+A data/levels/DodgeRaceold.oxw
+M data/levels/templates/spaceshipInvader.oxt
+M data/levels/templates/spaceshipDodgeRace.oxt
+A data/levels/DodgeRacePlus.oxw
+D data/levels/DodgeRace
More information about the Orxonox-commit
mailing list