Index: /code/branches/Presentation_FS19/data/levels/Asteroids2D.oxw
===================================================================
--- /code/branches/Presentation_FS19/data/levels/Asteroids2D.oxw (revision 12410)
+++ /code/branches/Presentation_FS19/data/levels/Asteroids2D.oxw (revision 12411)
@@ -44,5 +44,5 @@
-
+
Index: /code/branches/Presentation_FS19/data/levels/emptyLevel.oxw
===================================================================
--- /code/branches/Presentation_FS19/data/levels/emptyLevel.oxw (revision 12410)
+++ /code/branches/Presentation_FS19/data/levels/emptyLevel.oxw (revision 12411)
@@ -1,5 +1,5 @@
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /code/branches/Presentation_FS19/data/levels/orxoblox.oxw
===================================================================
--- /code/branches/Presentation_FS19/data/levels/orxoblox.oxw (revision 12411)
+++ /code/branches/Presentation_FS19/data/levels/orxoblox.oxw (revision 12411)
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /code/branches/Presentation_FS19/data/levels/pong.oxw
===================================================================
--- /code/branches/Presentation_FS19/data/levels/pong.oxw (revision 12410)
+++ /code/branches/Presentation_FS19/data/levels/pong.oxw (revision 12411)
@@ -16,4 +16,5 @@
+
@@ -50,5 +51,4 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /code/branches/Presentation_FS19/data/levels/tetris.oxw
===================================================================
--- /code/branches/Presentation_FS19/data/levels/tetris.oxw (revision 12410)
+++ /code/branches/Presentation_FS19/data/levels/tetris.oxw (revision 12411)
@@ -125,64 +125,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
Index: /code/branches/Presentation_FS19/data/levels/towerDefense.oxw
===================================================================
--- /code/branches/Presentation_FS19/data/levels/towerDefense.oxw (revision 12410)
+++ /code/branches/Presentation_FS19/data/levels/towerDefense.oxw (revision 12411)
@@ -106,11 +106,11 @@
-
+
-
-
+
+ x
Index: /code/branches/Presentation_FS19/data/overlays/OrxoBloxHUD.oxo
===================================================================
--- /code/branches/Presentation_FS19/data/overlays/OrxoBloxHUD.oxo (revision 12411)
+++ /code/branches/Presentation_FS19/data/overlays/OrxoBloxHUD.oxo (revision 12411)
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /code/branches/Presentation_FS19/data/tcl/orxokart_highscores.txt
===================================================================
--- /code/branches/Presentation_FS19/data/tcl/orxokart_highscores.txt (revision 12410)
+++ /code/branches/Presentation_FS19/data/tcl/orxokart_highscores.txt (revision 12411)
@@ -19,2 +19,4 @@
Name: 0:25:40s
Name: 1:27:11s
+Name: 0:29:74s
+Name: 0:24:15s
Index: /code/branches/Presentation_FS19/src/modules/CMakeLists.txt
===================================================================
--- /code/branches/Presentation_FS19/src/modules/CMakeLists.txt (revision 12410)
+++ /code/branches/Presentation_FS19/src/modules/CMakeLists.txt (revision 12411)
@@ -55,2 +55,3 @@
ADD_SUBDIRECTORY(MouseAPI)
ADD_SUBDIRECTORY(MouseAPIExample)
+ADD_SUBDIRECTORY(OrxoBlox)
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/CMakeLists.txt
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/CMakeLists.txt (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/CMakeLists.txt (revision 12411)
@@ -0,0 +1,24 @@
+SET_SOURCE_FILES(OrxoBlox_SRC_FILES
+
+ OrxoBlox.cc
+ OrxoBloxWall.cc
+ OrxoBloxCenterpoint.cc
+ OrxoBloxStones.cc
+ OrxoBloxScore.cc
+ OrxoBloxShip.cc
+ ../weapons/weaponmodes/BallGun.cc
+ ../weapons/projectiles/BallProjectile.cc
+
+)
+
+ORXONOX_ADD_LIBRARY(OrxoBlox
+ PLUGIN
+ FIND_HEADER_FILES
+ LINK_LIBRARIES
+ orxonox
+ overlays
+ SOURCE_FILES ${OrxoBlox_SRC_FILES}
+)
+
+
+
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBlox.cc
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBlox.cc (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBlox.cc (revision 12411)
@@ -0,0 +1,207 @@
+#include "OrxoBlox.h"
+#include "Highscore.h"
+
+#include "core/CoreIncludes.h"
+#include "core/EventIncludes.h"
+#include "core/command/Executor.h"
+
+
+#include "core/config/ConfigValueIncludes.h"//Remove??
+
+#include "gamestates/GSLevel.h"
+
+
+#include "chat/ChatManager.h"//Remove?
+
+#include "OrxoBloxCenterpoint.h"
+#include "OrxoBloxStones.h"
+#include "OrxoBloxWall.h"
+#include "OrxoBloxShip.h"
+
+namespace orxonox
+{
+
+
+ RegisterUnloadableClass(OrxoBlox);
+
+ /**
+ @brief
+ Constructor. Registers and initializes the object.
+ */
+ OrxoBlox::OrxoBlox(Context* context) : Deathmatch(context)
+ {
+ RegisterObject(OrxoBlox);
+
+ this->center_ = nullptr;
+ //this->ball_ = nullptr;
+ this->futureWall_ = nullptr;
+ this->player_ = nullptr;
+ level_ = 0;
+ this->counter = 0;
+
+ this->setHUDTemplate("OrxoBloxHUD");
+ //Error when specified
+
+ // Pre-set the timer, but don't start it yet.
+ this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&OrxoBlox::LevelUp, this)));
+ this->starttimer_.stopTimer();
+
+
+
+ }
+
+ /**
+ @brief
+ Destructor. Cleans up, if initialized.
+ */
+ OrxoBlox::~OrxoBlox()
+ {
+ if (this->isInitialized())
+ this->cleanup();
+ }
+
+ /**
+ @brief
+ Cleans up the Gametype by destroying the ball and the bats.
+ */
+ void OrxoBlox::cleanup()
+ {
+
+ std::vector vyserion_targets;
+ std::vector casterly_rocks;
+
+ for (OrxoBloxWall* wall : ObjectList()) {
+ if(wall != nullptr) {
+ vyserion_targets.push_back(wall);
+ }
+ }
+ for (OrxoBloxStones* stone : ObjectList()) {
+ if(stone != nullptr) {
+ casterly_rocks.push_back(stone);
+ }
+ }
+ for(unsigned int i = 0; i < vyserion_targets.size(); i++) {
+ vyserion_targets.at(i)->destroy();
+ }
+ for(unsigned int i = 0; i < casterly_rocks.size(); i++) {
+ casterly_rocks.at(i)->destroy();
+ }
+
+ }
+
+ /**
+ @brieftt
+ Starts the OrxoBlox minigame.
+ */
+ void OrxoBlox::start()
+
+ {
+ orxout() << "Orxoblox started" << endl;
+ if (this->center_ != nullptr) // There needs to be a OrxoBloxCenterpoint, i.e. the area the game takes place.
+ {
+ level_= 1;
+ }
+ else // If no centerpoint was specified, an error is thrown and the level is exited.
+ {
+ orxout(internal_error) << "OrxoBlox: No Centerpoint specified." << endl;
+ GSLevel::startMainMenu();
+ return;
+ }
+ this->starttimer_.startTimer();
+
+ this->bForceSpawn_ = false;
+ Deathmatch::start();
+ }
+
+ /**
+ @brief
+ Ends the OrxoBlox minigame.
+ */
+ void OrxoBlox::end()
+ {
+ ChatManager::message("You suck!!");
+
+ if (Highscore::exists())
+ {
+ int score = this->getScore(this->getPlayer());
+ Highscore::getInstance().storeScore("OrxoBlox", score, this->getPlayer());
+ }
+
+ this->cleanup();
+
+ // Call end for the parent class.
+ Deathmatch::end();
+ //GSLevel::startMainMenu();
+ }
+
+ PlayerInfo* OrxoBlox::getPlayer()
+ {
+ return this->player_;
+ }
+
+
+ void OrxoBlox::LevelUp(){
+ level_++;
+ if((level_%10)==0){
+ --counter;
+ }
+ int z_ = 0;
+
+ orxout() << "level up called" << endl;
+ this->playerScored(this->player_);// add points
+
+ this->createWall();
+
+ for(OrxoBloxStones* stone : ObjectList()){
+ if (stone->isA(Class(OrxoBloxStones))) {
+ int x_=(stone->getPosition()).x;
+ int y_=(stone->getPosition()).y;
+ z_=(stone->getPosition()).z;
+ //if(z_==90)this->end();
+
+ stone->setPosition(x_,y_,z_+9.0f);
+ if( z_ >= 45){
+ orxout() << "calling end() function" << endl;
+ this->end();
+ return;
+ }
+ }
+ else {
+ orxout() << "WTF IS THIS SHIT?!?!?!" << endl;
+ }
+ }
+ }
+
+ void OrxoBlox::createWall(){
+ this->futureWall_ = new OrxoBloxWall(this->center_->getContext());
+ // Apply the stone template to the stone.
+ this->futureWall_->addTemplate(this->center_->getWallTemplate());
+
+ // Attach the brick to the Centerpoint and set the position of the brick to be at the left side.
+ this->center_->attach(this->futureWall_);
+
+ this->futureWall_->setPosition(0, 0, 0);
+ this->futureWall_->setGame(this);
+ }
+
+
+ void OrxoBlox::playerPreSpawn(PlayerInfo* player)
+ {
+ this->player_ = player;
+ }
+
+ void OrxoBlox::tick(float dt)
+ {
+ SUPER(OrxoBlox, tick, dt);
+ }
+
+ void OrxoBlox::count() {
+ if(++(this->counter) >= this->max_counter) {
+ this->LevelUp();
+ counter = 0;
+ return;
+ }
+ }
+
+
+}
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBlox.h
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBlox.h (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBlox.h (revision 12411)
@@ -0,0 +1,78 @@
+#ifndef _OrxoBlox_H__
+#define _OrxoBlox_H__
+
+#include "OrxoBlox/OrxoBloxPrereqs.h"
+
+#include "tools/Timer.h"
+
+#include "gametypes/Deathmatch.h"
+#include "OrxoBloxCenterpoint.h"
+#include "OrxoBloxWall.h"
+#include "OrxoBloxShip.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Implements a OrxoBlox minigame (Wikipedia::OrxoBlox).
+ It connects the different entities present in a game of OrxoBlox.
+
+ - The @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint" is the playing field for the OrxoBlox minigame, it allows for configuration of the minigame, e.g. by setting the size of the playing field, or the length of the @ref orxonox::OrxoBloxBat "OrxoBloxBats". The playing field is always in the x,y-plane, the x-axis being the horizontal and the z-axis being the vertical axis.
+ The OrxoBlox class redistributes the important parameters defined in @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint" to the other entities, that need to know them, e.g. the @ref orxonox::OrxoBloxBall "OrxoBloxBall" and the @ref orxonox::OrxoBloxBat "OrxoBloxBats".
+ The @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint" needs to exist in a level with the @ref orxonox::Gametype "Gametype" OrxoBlox.
+ - The @ref orxonox::OrxoBloxBall "OrxoBloxBall" is the ball both players play with. The @ref orxonox::OrxoBloxBall "OrxoBloxBall" both implements the movement of the ball, as well as the influence of the boundaries and consequently, also the bouncing (off the upper and lower delimiters, and as off the @ref orxonox::OrxoBloxBat "OrxoBloxBats") of the ball and the effects of the failure of a player to catch the ball (i.e. the scoring of the other player).
+ - The two @ref orxonox::OrxoBloxBat "OrxoBloxBats" are the entities through which the players can actively participate in the game, by controlling them. The @ref orxonox::OrxoBloxBat "OrxoBloxBat" class manages the movement (and restrictions thereof) and the influence of the players on the bats.
+
+ @author
+ Fabian 'x3n' Landau
+
+ @ingroup OrxoBlox
+ */
+ class _OrxoBloxExport OrxoBlox : public Deathmatch
+ {
+ public:
+ OrxoBlox(Context* context); //!< Constructor. Registers and initializes the object.
+ virtual ~OrxoBlox(); //!< Destructor. Cleans up, if initialized.
+
+ virtual void start() override; //!< Starts the OrxoBlox minigame.
+ virtual void end() override; ///!< Ends the OrxoBlox minigame.
+
+ PlayerInfo* getPlayer();
+ virtual void playerPreSpawn(PlayerInfo* player) override;
+ virtual void tick(float dt) override;
+
+ void LevelUp();
+
+ /**
+ @brief Set the OrxoBloxCenterpoint (the playing field).
+ @param center A pointer to the OrxoBloxCenterpoint to be set.
+ */
+ void setCenterpoint(OrxoBloxCenterpoint* center)
+ { this->center_ = center; }
+
+ OrxoBloxCenterpoint* getCenterpoint(void)
+ { return this->center_; }
+ virtual void addBots(unsigned int amount) override{} // center_; //!< The playing field.
+ unsigned int level_;
+
+ WeakPtr playership;
+ PlayerInfo* player_;
+ Timer starttimer_; //!< A timer to delay the start of the game.
+
+ WeakPtr futureWall_;
+ int counter;
+ const int max_counter = 5;
+
+ };
+}
+
+#endif /* _OrxoBlox_H__ */
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc (revision 12411)
@@ -0,0 +1,341 @@
+#include "OrxoBloxBall.h"
+#include "OrxoBloxStones.h"
+#include "OrxoBlox.h"
+#include
+
+#include "core/CoreIncludes.h"
+#include "core/GameMode.h"
+
+#include "gametypes/Gametype.h"
+
+
+#include "sound/WorldSound.h"
+#include "core/XMLPort.h"
+#include "core/input/InputManager.h"
+
+
+namespace orxonox
+{
+ RegisterClass(OrxoBloxBall);
+
+ const float OrxoBloxBall::MAX_REL_Z_VELOCITY = 1.5;
+
+ /**
+ @brief
+ Constructor. Registers and initializes the object.
+ */
+ OrxoBloxBall::OrxoBloxBall(Context* context)
+ : Pawn(context)
+ {
+ RegisterObject(OrxoBloxBall);
+
+ this->speed_ = 0;
+ this->accelerationFactor_ = 1.0f;
+
+ this->relMercyOffset_ = 0.05f;
+ this->orxoblox_ = this->getOrxoBlox();
+ this->radius_ = 3;
+
+ this->registerVariables();
+
+ //initialize sound
+ if (GameMode::isMaster())
+ {
+ this->defScoreSound_ = new WorldSound(this->getContext());
+ this->defScoreSound_->setVolume(1.0f);
+
+ this->defBoundarySound_ = new WorldSound(this->getContext());
+ this->defBoundarySound_->setVolume(0.5f);
+ }
+ else
+ {
+ this->defScoreSound_ = nullptr;
+
+ this->defBoundarySound_ = nullptr;
+ }
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ OrxoBloxBall::~OrxoBloxBall()
+ {
+
+ }
+
+ //xml port for loading sounds
+ void OrxoBloxBall::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(OrxoBloxBall, XMLPort, xmlelement, mode);
+ XMLPortParam(OrxoBloxBall, "defScoreSound", setDefScoreSound, getDefScoreSound, xmlelement, mode);
+
+ XMLPortParam(OrxoBloxBall, "defBoundarySound", setDefBoundarySound, getDefBoundarySound, xmlelement, mode);
+ }
+
+ /**
+ @brief
+ Register variables to synchronize over the network.
+ */
+ void OrxoBloxBall::registerVariables()
+ {
+ registerVariable( this->fieldWidth_ );
+ registerVariable( this->fieldHeight_ );
+
+ registerVariable( this->speed_ );
+ registerVariable( this->relMercyOffset_ );
+ }
+
+ /**
+ @brief
+ Is called every tick.
+ Handles the movement of the ball and its interaction with the boundaries and bats.
+ @param dt
+ The time since the last tick.
+ */
+ void OrxoBloxBall::tick(float dt)
+ {
+
+ SUPER(OrxoBloxBall, tick, dt);
+
+ // Get the current position, velocity and acceleration of the ball.
+ Vector3 position = this->getPosition();
+ Vector3 velocity = this->getVelocity();
+ Vector3 acceleration = this->getAcceleration();
+
+ // If the ball has gone over the top or bottom boundary of the playing field (i.e. the ball has hit the top or bottom delimiters).
+ if (position.z > this->fieldHeight_ / 2 || position.z - radius_ < -this->fieldHeight_ / 2)
+ {
+ defBoundarySound_->play(); //play boundary sound
+ // Its velocity in z-direction is inverted (i.e. it bounces off).
+ velocity.z = -velocity.z;
+ // And its position is set as to not overstep the boundary it has just crossed. Remember z axis is reverted!!!
+ if (position.z > this->fieldHeight_ / 2){
+ // Set the ball to be exactly at the boundary.
+ position.z = this-> fieldHeight_ / 2 - radius_;
+
+ orxoblox_->LevelUp();
+ orxoblox_->LevelUp();
+ //orxout() << "LevelUp 2 finished, trying to call end() function";
+ //this->end();
+
+
+
+ //this->setSpeed(0); // doesn't work here, why??;
+ //Stopping ball
+ orxout() << "Ball stopped" << endl;
+ velocity.x = 0;
+ velocity.y = 0;
+ velocity.z = 0;
+
+ //ChatManager::message("Waiting for your input");
+ //Input new speed here:
+ //ChatManager::message("Setting new speed");
+
+ //%%%%%%%%%%%%
+ //MAUSPOSITION
+ //%%%%%%%%%%%%
+ //Reads current mouse position
+ //TODO: read Mouse position on click!
+ //int mousex = InputManager::getInstance().getMousePosition().first;
+ //int mousey = InputManager::getInstance().getMousePosition().second;
+ //ChatManager::message("Read mouse position");
+ //orxout() << "Mouseposition" << endl;
+ //orxout() << mousex << endl;
+ //ChatManager::message(mousex);
+ //ChatManager::message("mousey");
+ //ChatManager::message(mousey);
+ //Set new speed here!!
+ velocity.x = rnd(-100,100);
+ velocity.z = rnd(-50,-100);
+
+
+ }
+ if (position.z - radius_ < -this->fieldHeight_ / 2){
+ position.z = -this->fieldHeight_ / 2 + radius_;
+
+ }
+
+ this->fireEvent();
+ }
+
+ //Ball hits the right or left wall and should bounce back.
+ // If the ball has crossed the left or right boundary of the playing field.
+ if (position.x + radius_ > this->fieldWidth_ / 2 || position.x - radius_ < -this->fieldWidth_ / 2)
+ {
+ //Ball hits the right Wall
+ if (position.x + radius_ > this->fieldWidth_ / 2)
+ {
+ // Set the ball to be exactly at the boundary.
+ position.x = this->fieldWidth_ / 2 - radius_;
+ // Invert its velocity in x-direction (i.e. it bounces off).
+ velocity.x = -velocity.x;
+ this->fireEvent();
+ }
+
+ //Ball hits the left wall
+ else if (position.x - radius_ < -this->fieldWidth_ / 2)
+ {
+ // Set the ball to be exactly at the boundary.
+ position.x = -this->fieldWidth_ / 2 + radius_;
+ // Invert its velocity in x-direction (i.e. it bounces off).
+ velocity.x = -velocity.x;
+ this->fireEvent();
+ }
+ }
+
+ // Set the position, velocity and acceleration of the ball, if they have changed.
+ if (acceleration != this->getAcceleration())
+ this->setAcceleration(acceleration);
+ if (velocity != this->getVelocity())
+ this->setVelocity(velocity);
+ if (position != this->getPosition())
+ this->setPosition(position);
+ //this->Collides((this->orxoblox_->CheckForCollision(this)));
+
+
+ }
+
+ /**
+ @brief
+ Set the speed of the ball (in x-direction).
+ @param speed
+ The speed to be set.
+ */
+ void OrxoBloxBall::setSpeed(float speed)
+ {
+
+ if (speed != this->speed_) // If the speed changes
+ {
+ this->speed_ = speed;
+ // Set the speed in the direction of the balls current velocity.
+ Vector3 velocity = this->getVelocity();
+ if (velocity.x != 0)
+ velocity.x = speed;
+ //velocity.x = sgn(velocity.x) * speed;
+ else // If the balls current velocity is zero, the speed is set in a random direction.
+ velocity.x = speed * sgn(rnd(-1,1));
+ //velocity.y = this->speed_;
+ velocity.z = speed;
+
+ this->setVelocity(velocity);
+ }
+ }
+
+
+ void OrxoBloxBall::setDefScoreSound(const std::string &OrxoBloxSound)
+ {
+ if( defScoreSound_ )
+ defScoreSound_->setSource(OrxoBloxSound);
+ else
+ assert(0); // This should never happen, because soundpointer is only available on master
+ }
+
+ const std::string& OrxoBloxBall::getDefScoreSound()
+ {
+ if( defScoreSound_ )
+ return defScoreSound_->getSource();
+ else
+ assert(0);
+ return BLANKSTRING;
+ }
+
+
+
+ void OrxoBloxBall::setDefBoundarySound(const std::string &OrxoBloxSound)
+ {
+ if( defBoundarySound_ )
+ defBoundarySound_->setSource(OrxoBloxSound);
+ else
+ assert(0); // This should never happen, because soundpointer is only available on master
+ }
+
+ const std::string& OrxoBloxBall::getDefBoundarySound()
+ {
+ if( defBoundarySound_ )
+ return defBoundarySound_->getSource();
+ else
+ assert(0);
+ return BLANKSTRING;
+ }
+
+
+ void OrxoBloxBall::Bounce(WorldEntity* Stone) {
+
+ Vector3 velocity = this->getVelocity();
+ Vector3 positionStone = Stone->getPosition();
+ Vector3 myPosition = this->getPosition();
+ //orxout() << "About to Bounce >D" << endl;
+
+ int distance_X = myPosition.x - positionStone.x;
+ int distance_Z = myPosition.z - positionStone.z;
+
+ if (distance_X < 0)
+ distance_X = -distance_X;
+
+
+ if (distance_Z < 0)
+ distance_Z = -distance_Z;
+
+ //orxout() << distance_X << endl;
+ //orxout() << distance_Z << endl;
+
+ if (distance_X < distance_Z) {
+ velocity.z = -velocity.z;
+ //orxout() << "z" << endl;
+ }
+ else if (distance_Z < distance_X) {
+ velocity.x = -velocity.x;
+ //orxout() << "x" << endl;
+ }
+ else {
+ velocity.x = -velocity.x;
+ velocity.z = -velocity.z;
+ //orxout() << "both" << endl;
+ }
+
+ this->setVelocity(velocity);
+ this->setPosition(myPosition);
+ }
+
+
+ void OrxoBloxBall::Collides(OrxoBloxStones* Stone)
+ {
+
+ if(Stone == nullptr)
+ return;
+
+ orxout() << "About to Bounce >D" << endl;
+ Bounce(Stone);
+ //if(otherObject->getHealth() <= 0) {
+ //Stone->destroy();
+
+ //}
+ //otherObject->reduceHealth();
+ }
+
+ bool OrxoBloxBall::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
+ {
+ orxout() << "detected collision" << endl;
+ Bounce(otherObject);
+
+ return true;
+ }
+
+ OrxoBlox* OrxoBloxBall::getOrxoBlox()
+ {
+ if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
+ {
+ OrxoBlox* orxobloxGametype = orxonox_cast(this->getGametype());
+ return orxobloxGametype;
+ }
+ else orxout()<<"There is no Gametype for OrxoBlox! ask Anna"<< endl;
+ return nullptr;
+ }
+
+ float OrxoBloxBall::getRadius() {
+ return this->radius_;
+ }
+
+
+}
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxBall.h
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxBall.h (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxBall.h (revision 12411)
@@ -0,0 +1,111 @@
+#ifndef _OrxoBloxBall_H__
+#define _OrxoBloxBall_H__
+
+#include "OrxoBlox/OrxoBloxPrereqs.h"
+
+#include "util/Math.h"
+
+#include "worldentities/pawns/Pawn.h"
+#include
+
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ This class manages the ball for @ref orxonox::OrxoBlox "OrxoBlox".
+
+ It is responsible for both the movement of the ball in the x,z-plane as well as its interaction with the boundaries of the playing field (defined by the @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint") and the @ref orxonox::OrxoBloxBat "OrxoBloxBats". Or more precisely, it makes the ball bounce off then upper and lower delimiters of the playing field, it makes the ball bounce off the bats and also detects when a player scores and takes appropriate measures.
+
+ @author
+ Fabian 'x3n' Landau
+
+ @ingroup OrxoBlox
+ */
+ class _OrxoBloxExport OrxoBloxBall : public Pawn
+ {
+ public:
+ OrxoBloxBall(Context* context);
+ virtual ~OrxoBloxBall();
+
+ virtual void tick(float dt) override;
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+
+ /**
+ @brief Set the dimensions of the playing field.
+ @param width The width of the playing field.
+ @param height The height of the playing field.
+ */
+ void setFieldDimension(float width, float height)
+ { this->fieldWidth_ = width; this->fieldHeight_ = height; }
+ /**
+ @brief Get the dimensions of the playing field.
+ @param dimension A vector with the width as the first and height as the second component.
+ */
+ void setFieldDimension(const Vector2& dimension)
+ { this->setFieldDimension(dimension.x, dimension.y); }
+ /**
+ @brief Get the dimensions of the playing field.
+ @return Returns a vector with the width as the first and height as the second component.
+ */
+ Vector2 getFieldDimension() const
+ { return Vector2(this->fieldWidth_, this->fieldHeight_); }
+
+ void setSpeed(float speed); //!< Set the speed of the ball (in x-direction).
+ /**
+ @brief Get the speed of the ball (in x-direction).
+ @return Returns the speed of the ball (in x-direction).
+ */
+ float getSpeed() const
+ { return this->speed_; }
+
+ /**
+ @brief Set the acceleration factor of the ball.
+ @param factor The factor the acceleration of the ball is set to.
+ */
+ void setAccelerationFactor(float factor)
+ { this->accelerationFactor_ = factor; }
+ /**
+ @brief Get the acceleration factor of the ball.
+ @return Returns the acceleration factor of the ball.
+ */
+ float getAccelerationFactor() const
+ { return this->accelerationFactor_; }
+
+
+
+ void Bounce(WorldEntity* Stone);
+ void Collides(OrxoBloxStones* otherObject);
+ bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
+
+ static const float MAX_REL_Z_VELOCITY;
+
+ void setDefScoreSound(const std::string& engineSound);
+ const std::string& getDefScoreSound();
+
+ void setDefBoundarySound(const std::string& engineSound);
+ const std::string& getDefBoundarySound();
+ float getRadius();
+
+
+ private:
+ void registerVariables();
+
+ OrxoBlox* getOrxoBlox();
+ float radius_;
+ float fieldWidth_; //!< The width of the playing field.
+ float fieldHeight_; //!< The height of the playing field.
+ float speed_; //!< The speed (in x-direction) of the ball.
+ float accelerationFactor_; //!< The acceleration factor of the ball.
+
+ unsigned int* batID_; //!< The object IDs of the bats, to be able to synchronize them over the network.
+ float relMercyOffset_; //!< Offset, that makes the player not loose, when, in all fairness, he would have.
+ WorldSound* defScoreSound_;
+ WorldSound* defBoundarySound_;
+ OrxoBlox* orxoblox_;
+ };
+}
+
+#endif /* _OrxoBloxBall_H__ */
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxBot.cc
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxBot.cc (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxBot.cc (revision 12411)
@@ -0,0 +1,19 @@
+#include "OrxoBloxBot.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ RegisterClass(OrxoBloxBot);
+
+ /**
+ @brief
+ Constructor. Registers the object and creates a OrxoBloxAI controller.
+ */
+ OrxoBloxBot::OrxoBloxBot(Context* context) : Bot(context)
+ {
+ RegisterObject(OrxoBloxBot);
+
+
+ }
+}
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxBot.h
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxBot.h (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxBot.h (revision 12411)
@@ -0,0 +1,29 @@
+#ifndef _OrxoBloxBot_H__
+#define _OrxoBloxBot_H__
+
+#include "OrxoBlox/OrxoBloxPrereqs.h"
+#include "infos/Bot.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ A bot especially for @ref orxonox::OrxoBlox "OrxoBlox".
+
+ Uses the @ref orxonox::OrxoBloxAI "OrxoBloxAI".
+
+ @author
+ Fabian 'x3n' Landau
+
+ @ingroup OrxoBlox
+ */
+ class _OrxoBloxExport OrxoBloxBot : public Bot
+ {
+ public:
+ OrxoBloxBot(Context* context);
+ virtual ~OrxoBloxBot() {}
+ };
+}
+
+#endif /* _OrxoBloxBot_H__ */
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxCanon.cc
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxCanon.cc (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxCanon.cc (revision 12411)
@@ -0,0 +1,61 @@
+#include "OrxoBloxCanon.h"
+
+#include "core/CoreIncludes.h"
+
+#include "graphics/Model.h"
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSystem.h"
+
+#include "weapons/projectiles/BallProjectile.h"
+#include "weapons/MuzzleFlash.h"
+
+namespace orxonox
+{
+ RegisterClass(OrxoBloxCanon);
+
+ OrxoBloxCanon::OrxoBloxCanon(Context* context) : HsW01(context)
+ {
+ RegisterObject(OrxoBloxCanon);
+
+
+ }
+
+ OrxoBloxCanon::~OrxoBloxCanon()
+ {
+
+ }
+
+ void OrxoBloxCanon::shot()
+ {
+ assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
+
+ // Create the projectile.
+ Projectile* projectile = new BallProjectile(this->getContext());
+ Model* model = new Model(projectile->getContext());
+ model->setMeshSource(mesh_);
+ model->setCastShadows(false);
+ projectile->attach(model);
+ model->setScale(5);
+
+ //get position and orientation of the ship to know in which direction the projectile needs to fire off
+ Pawn* player = this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn();
+
+ projectile->setOrientation(player->getOrientation());
+ projectile->setPosition(player->getPosition());
+
+ //Velocity & position of the projectile must be y = 0 since the game takes place in the x-z plane
+ Vector3 muzzle2D = player->getOrientation()* WorldEntity::FRONT ;
+ muzzle2D.y = 0;
+ projectile->setVelocity(muzzle2D * this->speed_);
+
+ projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
+
+ // Display the muzzle flash.
+ this->HsW01::muzzleflash();
+ }
+
+}
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxCanon.h
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxCanon.h (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxCanon.h (revision 12411)
@@ -0,0 +1,24 @@
+#ifndef _OrxoBloxCanon_H__
+#define _OrxoBloxCanon_H__
+
+#include "asteroids2D/Asteroids2DPrereqs.h"
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weapons/weaponmodes/HsW01.h"
+#include "weapons/projectiles/BallProjectile.h"
+
+namespace orxonox
+{
+ class _OrxoBloxExport OrxoBloxCanon : public HsW01
+ {
+ public:
+ OrxoBloxCanon(Context* context);
+ virtual ~OrxoBloxCanon();
+
+ protected:
+ virtual void shot() override; //2D movement
+ WeakPtr projectile;
+ };
+}
+
+#endif /* _OrxoBloxCanon_H__ */
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.cc
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.cc (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.cc (revision 12411)
@@ -0,0 +1,57 @@
+#include "OrxoBloxCenterpoint.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+#include "OrxoBlox.h"
+
+namespace orxonox
+{
+ RegisterClass(OrxoBloxCenterpoint);
+
+ /**
+ @brief
+ Constructor. Registers and initializes the object and checks whether the gametype is actually OrxoBlox.
+ */
+ OrxoBloxCenterpoint::OrxoBloxCenterpoint(Context* context) : StaticEntity(context)
+ {
+ RegisterObject(OrxoBloxCenterpoint);
+
+ this->width_ = 100;
+ this->height_ = 50;
+ this->ballspeed_ = 100;
+ this->ballaccfactor_ = 1.0;
+
+ this->checkGametype();
+ }
+
+ /**
+ @brief
+ Method to create a OrxoBloxCenterpoint through XML.
+ */
+ void OrxoBloxCenterpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(OrxoBloxCenterpoint, XMLPort, xmlelement, mode);
+
+ XMLPortParam(OrxoBloxCenterpoint, "dimension", setFieldDimension, getFieldDimension, xmlelement, mode);
+ XMLPortParam(OrxoBloxCenterpoint, "balltemplate", setBalltemplate, getBalltemplate, xmlelement, mode);
+ XMLPortParam(OrxoBloxCenterpoint, "ballspeed", setBallSpeed, getBallSpeed, xmlelement, mode);
+ XMLPortParam(OrxoBloxCenterpoint, "ballaccfactor", setBallAccelerationFactor, getBallAccelerationFactor, xmlelement, mode);
+
+ XMLPortParam(OrxoBloxCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode);
+ XMLPortParam(OrxoBloxCenterpoint, "WallTemplate", setWallTemplate, getWallTemplate, xmlelement, mode);
+ }
+
+ /**
+ @brief
+ Checks whether the gametype is OrxoBlox and if it is, sets its centerpoint.
+ */
+ void OrxoBloxCenterpoint::checkGametype()
+ {
+ if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
+ {
+ OrxoBlox* OrxoBloxGametype = orxonox_cast(this->getGametype());
+ OrxoBloxGametype->setCenterpoint(this);
+ }
+ }
+}
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.h
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.h (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.h (revision 12411)
@@ -0,0 +1,122 @@
+#ifndef _OrxoBloxCenterpoint_H__
+#define _OrxoBloxCenterpoint_H__
+
+#include "OrxoBlox/OrxoBloxPrereqs.h"
+
+#include
+
+#include
+
+#include "worldentities/StaticEntity.h"
+
+namespace orxonox
+{
+
+ class _OrxoBloxExport OrxoBloxCenterpoint : public StaticEntity
+ {
+ public:
+ OrxoBloxCenterpoint(Context* context); //!< Constructor. Registers and initializes the object and checks whether the gametype is actually OrxoBlox.
+ virtual ~OrxoBloxCenterpoint() {}
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; //!< Method to create a OrxoBloxCenterpoint through XML.
+
+ /**
+ @brief Set the template for the ball. (e.g. to attach the model of the ball, but also to attach an EventListener to it to detect, when it hits the boundaries, and e.g. display some ParticleEffets, when it does.)
+ @param balltemplate The name of the template to be set.
+ */
+ void setBalltemplate(const std::string& balltemplate)
+ { this->balltemplate_ = balltemplate; }
+ /**
+ @brief Get the template of the ball.
+ @return Returns the name of the template of the ball.
+ */
+ const std::string& getBalltemplate() const
+ { return this->balltemplate_; }
+
+
+ /**
+ @brief Set the dimensions of the playing field.
+ @param dimension A vector with the width of the playing field as first component and the height as second.
+ */
+ void setFieldDimension(const Vector2& dimension)
+ { this->width_ = dimension.x; this->height_ = dimension.y; }
+ /**
+ @brief Get the dimensions of the playing field.
+ @return Returns a vector with the width of the playing field as first component and the height as second.
+ */
+ Vector2 getFieldDimension() const
+ { return Vector2(this->width_, this->height_); }
+
+ /**
+ @brief Set the speed of the ball.
+ @param ballspeed The speed of the ball.
+ */
+ void setBallSpeed(float ballspeed)
+ { this->ballspeed_ = ballspeed; }
+ /**
+ @brief Get the speed of the ball.
+ @return Returns the speed of the ball.
+ */
+ float getBallSpeed() const
+ { return this->ballspeed_; }
+
+ /**
+ @brief Set the ball's acceleration factor.
+ @param ballaccfactor The ball's acceleration factor.
+ */
+ void setBallAccelerationFactor(float ballaccfactor)
+ { this->ballaccfactor_ = ballaccfactor; }
+ /**
+ @brief Get the ball's acceleration factor
+ @return Returns the ball's acceleration factor.
+ */
+ float getBallAccelerationFactor() const
+ { return this->ballaccfactor_; }
+
+
+ /**
+ @brief Set the template for the stones.
+ @param templateName The template name to be applied to each stone.
+ */
+ void setStoneTemplate(const std::string& templateName)
+ { this->stoneTemplate_ = templateName; }
+ /**
+ @brief Get the template for the stones.
+ @return Returns the template name to be applied to each stone.
+ */
+ const std::string& getStoneTemplate(void) const
+ { return this->stoneTemplate_; }
+
+
+ /**
+ @brief Set the template for the bricks.
+ @param templateName The template name to be applied to each brick.
+ */
+ void setWallTemplate(const std::string& templateName)
+ { this->WallTemplate_ = templateName; }
+
+ /**
+ @brief Get the template for the bricks.
+ @return Returns the template name to be applied to each brick.
+ */
+ const std::string& getWallTemplate(void) const
+ { return this->WallTemplate_; }
+
+
+ private:
+ void checkGametype(); //!< Checks whether the gametype is OrxoBlox and if it is, sets its centerpoint.
+
+ std::string balltemplate_; //!< The template for the ball.
+ std::string WallTemplate_;
+ std::string stoneTemplate_;
+
+ float ballspeed_; //!< The speed of then ball.
+ float ballaccfactor_; //!< The acceleration factor of the ball.
+ float width_; //!< The height of the playing field.
+ float height_; //!< The width of the playing field.
+
+
+ };
+}
+
+#endif /* _OrxoBloxCenterpoint_H__ */
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h (revision 12411)
@@ -0,0 +1,45 @@
+#ifndef _OrxoBloxPrereqs_H__
+#define _OrxoBloxPrereqs_H__
+
+#include "OrxonoxConfig.h"
+#include "OrxonoxPrereqs.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXOBLOX_STATIC_BUILD)
+# ifdef ORXOBLOX_SHARED_BUILD
+# define _OrxoBloxExport __declspec(dllexport)
+# else
+# if defined( __MINGW32__ )
+# define _OrxoBloxExport
+# else
+# define _OrxoBloxExport __declspec(dllimport)
+# endif
+# endif
+# define _OrxoBloxPrivate
+#elif defined (ORXONOX_GCC_VISIBILITY)
+# define _OrxoBloxExport __attribute__ ((visibility("default")))
+# define _OrxoBloxPrivate __attribute__ ((visibility("hidden")))
+#else
+# define _OrxoBloxExport
+# define _OrxoBloxPrivate
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+ class OrxoBlox;
+ //class OrxoBloxBall;
+ class OrxoBloxCenterpoint;
+ class OrxoBloxWall;
+ class OrxoBloxStones;
+ class OrxoBloxScore;
+ class OrxoBloxShip;
+}
+
+#endif /* _OrxoBloxPrereqs_H__ */
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxScore.cc
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxScore.cc (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxScore.cc (revision 12411)
@@ -0,0 +1,79 @@
+#include "OrxoBloxScore.h"
+
+#include "core/CoreIncludes.h"
+#include "util/Convert.h"
+
+#include "infos/PlayerInfo.h"
+
+#include "OrxoBlox.h"
+
+namespace orxonox
+{
+ RegisterClass(OrxoBloxScore);
+
+ /**
+ @brief
+ Constructor. Registers and initializes the object.
+ */
+ OrxoBloxScore::OrxoBloxScore(Context* context) : OverlayText(context)
+ {
+ RegisterObject(OrxoBloxScore);
+
+ this->owner_ = nullptr;
+ this->player_ = nullptr;
+ }
+ /**
+ @brief
+ Destructor.
+ */
+ OrxoBloxScore::~OrxoBloxScore()
+ {
+ }
+
+
+ /**
+ @brief
+ Is called each tick.
+ Creates and sets the caption to be displayed by the OrxoBloxScore.
+ @param dt
+ The time that has elapsed since the last tick.
+ */
+ void OrxoBloxScore::tick(float dt)
+ {
+ SUPER(OrxoBloxScore, tick, dt);
+
+ // If the owner is set. The owner being a OrxoBlox game.
+ if (this->owner_ != nullptr)
+ {
+ std::string score("0");
+ if(!this->owner_->hasEnded())
+ {
+ //get the player
+ player_ = this->owner_->getPlayer();
+ }
+
+ if(this->owner_->hasStarted())
+ {
+ // Save the name and score of each player as a string.
+ if (player_ != nullptr)
+ score = multi_cast(this->owner_->getScore(player_));
+ }
+ this->setCaption(score);
+ }
+ }
+
+ /**
+ @brief
+ Is called when the owner changes.
+ Sets the owner to nullptr, if it is not a pointer to a OrxoBlox game.
+ */
+ void OrxoBloxScore::changedOwner()
+ {
+ SUPER(OrxoBloxScore, changedOwner);
+
+ if (this->getOwner() != nullptr && this->getOwner()->getGametype())
+ this->owner_ = orxonox_cast(this->getOwner()->getGametype());
+ else
+ this->owner_ = nullptr;
+ }
+}
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxScore.h
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxScore.h (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxScore.h (revision 12411)
@@ -0,0 +1,37 @@
+#ifndef _OrxoBloxScore_H__
+#define _OrxoBloxScore_H__
+
+#include "OrxoBlox/OrxoBloxPrereqs.h"
+
+#include "tools/interfaces/Tickable.h"
+
+#include "overlays/OverlayText.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ The OrxoBloxScore class displays the score for a game of @ref orxonox::OrxoBlox "OrxoBlox".
+
+ @author
+ Fabian 'x3n' Landau
+
+ @ingroup OrxoBlox
+ */
+ class _OrxoBloxExport OrxoBloxScore : public OverlayText, public Tickable
+ {
+ public:
+ OrxoBloxScore(Context* context);
+ virtual ~OrxoBloxScore();
+
+ virtual void tick(float dt) override; //!< Creates and sets the caption to be displayed by the OrxoBloxScore.
+ virtual void changedOwner() override; //!< Is called when the owner changes.
+
+
+ private:
+ OrxoBlox* owner_; //!< The OrxoBlox game that owns this OrxoBloxScore.
+ PlayerInfo* player_; //!< Store information about the player permanently.
+ };
+}
+#endif /* _OrxoBloxScore_H__ */
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxShip.cc
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxShip.cc (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxShip.cc (revision 12411)
@@ -0,0 +1,62 @@
+#include "OrxoBloxShip.h"
+#include "OrxoBlox.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ RegisterClass(OrxoBloxShip);
+
+ OrxoBloxShip::OrxoBloxShip(Context* context) : SpaceShip(context)
+ {
+ RegisterObject(OrxoBloxShip);
+
+ this->bImmune = false;
+ this->width = 120;
+ this->height = 100;
+ orxout() << "SPACESHIP Spawned" << std::endl;
+
+ //timer.setTimer(3.5f, true, createExecutor(createFunctor(&OrxoBloxShip::showorientation, this)));
+ }
+
+ //Use this function to display your position on the field -> to determine field width and height
+ void OrxoBloxShip::showposition()
+ {
+ Vector3 pos = this->getPosition();
+ orxout() << "x = "<< pos.x << " y = " << pos.y << " z = "<< pos.z << endl;
+ }
+
+ //Same thing for orientation
+ void OrxoBloxShip::showorientation()
+ {
+ Quaternion ort = this->getOrientation();
+ orxout() << "w = " << ort.w << " x = " << ort.x << " y = " << ort.y << "z = " << ort.z << endl;
+ }
+
+ void OrxoBloxShip::tick(float dt)
+ {
+ Vector3 pos = this->getPosition();
+
+ //ensure that the ship stays in playing field
+ if(pos.x > width/2) pos.x = -width/2;
+ if(pos.x < -width/2) pos.x = width/2;
+ if(pos.z > height/2) pos.z = -height/2;
+ if(pos.z < -height/2) pos.z = height/2;
+
+ //2D movement, position should always = 0 on y-axis
+ if(pos.y!=0) pos.y = 0;
+ this->setPosition(pos);
+
+
+ //if you hit an asteroid, the ship will turn -> you need to reorientate the ship
+ Quaternion ort = this->getOrientation();
+ ort.x = 0;
+ ort.z = 0;
+ this->setOrientation(ort);
+ }
+
+ void OrxoBloxShip::boost(bool bBoost)
+ {
+ }
+
+}
+
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxShip.h
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxShip.h (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxShip.h (revision 12411)
@@ -0,0 +1,52 @@
+#ifndef _OrxoBloxShip_H__
+#define _OrxoBloxShip_H__
+
+
+#include "OrxoBloxPrereqs.h"
+
+#include "worldentities/pawns/SpaceShip.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+ class _OrxoBloxExport OrxoBloxShip : public SpaceShip
+ {
+ public:
+ OrxoBloxShip(Context* context);
+
+ virtual void tick(float dt) override;
+
+ //no rotation in x and z direction!
+ //virtual void rotatePitch(const Vector2& value) override{}; // Rotate in pitch direction.
+ //Yaw
+ virtual void rotatePitch(const Vector2& value) override{}; // Rotate in pitch direction.
+ virtual void rotateRoll(const Vector2& value) override{}; // Rotate in roll direction.
+ virtual void boost(bool boost) override; //Override, so that the ship does not shake
+
+
+ /*Functions that can be helpful while debugging.
+ - Set a timer so that the function is called for instance every 3s to display the coordinates
+ - Open console with "~`"-key in when you start the Asteroids2D - Minigame.
+ */
+ void showposition();
+ void showorientation();
+
+
+ void toggleImmune()
+ {
+ bImmune = !bImmune;
+ }
+
+ //protected:
+ private:
+ OrxoBlox* getGame();
+
+ float width, height;
+ WeakPtr game;
+ bool bImmune;
+ Timer timer;
+ Timer isimmune;
+ };
+}
+
+#endif /* _Asteroids2DShip_H__ */
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc (revision 12411)
@@ -0,0 +1,42 @@
+#include "OrxoBloxStones.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+#include "OrxoBlox.h"
+
+namespace orxonox
+{
+ RegisterClass(OrxoBloxStones);
+ /**
+ @brief
+ Constructor. Registers and initializes the object.
+ */
+ OrxoBloxStones::OrxoBloxStones(Context* context) : Pawn(context)
+ {
+ RegisterObject(OrxoBloxStones);
+
+ this->size_ = 9.0f;
+ this->setHealth(1);
+ this->delay_ = false;
+ }
+
+ unsigned int OrxoBloxStones::getHealth() {
+ return this->health_;
+ }
+
+ void OrxoBloxStones::reduceHealth() {
+ this->health_ -= 1;
+ }
+
+ float OrxoBloxStones::getSize() {
+ return this->size_;
+ }
+
+ bool OrxoBloxStones::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
+ {
+ orxout() << "a stone should die" << endl;
+ this->destroy();
+ return true;
+ }
+}
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxStones.h
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxStones.h (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxStones.h (revision 12411)
@@ -0,0 +1,74 @@
+#ifndef _OrxoBloxStones_H__
+#define _OrxoBloxStones_H__
+
+
+#include "OrxoBlox/OrxoBloxPrereqs.h"
+
+
+#include "worldentities/StaticEntity.h"
+#include "worldentities/pawns/Pawn.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+
+ @author
+
+ @ingroup OrxoBlox
+ */
+ class _OrxoBloxExport OrxoBloxStones : public Pawn
+ {
+ public:
+ OrxoBloxStones(Context* context); //!< Constructor. Registers and initializes the object.
+ virtual ~OrxoBloxStones() {}
+ // this.destroy();
+ //}
+
+ /**
+ @brief Set the size of the stone.
+ @param size The dimensions a stone has in the game world. (A stone is a cube)
+ */
+ void setSize(float size)
+ { this->size_ = size; }
+ /**
+ @brief Get the size of the stone.
+ @return Returns the dimensions a stone has in the game world. (A stone is a cube)
+ */
+ float getSize(void) const
+ { return this->size_; }
+
+ void gotHit(){
+ orxout()<<"GOT HIT"<getHealth();
+ if (health_> 0){
+ this->setHealth(++health_);
+ }
+ else {
+ this->kill();
+ }
+ }
+
+ void setGame(OrxoBlox* orxoblox)
+ { assert(orxoblox); orxoblox_ = orxoblox; }
+
+ unsigned int getHealth();
+
+ void reduceHealth();
+
+ float getSize();
+ virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
+
+ private:
+ float size_; //!< The dimensions a stone has in the game world.
+ bool delay_;
+
+ OrxoBlox* orxoblox_;
+
+
+ };
+}
+
+#endif /* _OrxoBloxStones_H__ */
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc (revision 12411)
@@ -0,0 +1,117 @@
+#include "OrxoBloxWall.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+#include "OrxoBlox.h"
+#include "OrxoBloxStones.h"
+#include "OrxoBloxCenterpoint.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+ RegisterClass(OrxoBloxWall);
+ /**
+ @brief
+ Constructor. Registers and initializes the object.
+ */
+ OrxoBloxWall::OrxoBloxWall(Context* context) : StaticEntity(context)
+ {
+ RegisterObject(OrxoBloxWall);
+
+ this->num_Stones_ = 10;
+ this->size_ = 9.0f;
+ this->delay_ = false;
+
+ this->orxoblox_ = this->getOrxoBlox();
+ this->center_ = this->orxoblox_->getCenterpoint();
+ this->createWall();
+ }
+
+
+ void OrxoBloxWall::createWall(){
+ for (unsigned int i=0; inum_Stones_;++i){
+ unsigned int j=1 + static_cast(rnd(2.0f)); //size_ = 9.0f;
+ OrxoBloxStones* stone = new OrxoBloxStones(this->center_->getContext());
+ stone->addTemplate(this->orxoblox_->getCenterpoint()->getStoneTemplate());
+ if (stone == nullptr) {
+ std::abort();
+ }
+ this->TotalStones_.push_back(stone);
+ this->attach(stone);
+ float x_=(this->center_->getFieldDimension()).x;
+ float y_=(this->center_->getFieldDimension()).y;
+ stone->setPosition(size_*i -x_/2 +4.5f, -3.5f, -y_/2 - 2.25f);
+
+
+
+ if(this->orxoblox_ != nullptr)
+ {
+ stone->setGame(this->orxoblox_);
+ if(this->orxoblox_->getCenterpoint() != nullptr)
+ stone->addTemplate(this->orxoblox_->getCenterpoint()->getStoneTemplate());
+ else
+ orxout()<< "tetris_->getCenterpoint == nullptr in TetrisBrick.cc"<< endl;
+ }
+ else
+ orxout()<< "tetris_ == nullptr in TetrisBrick.cc"<< endl;
+ }
+
+ }
+
+
+
+ // OrxoBloxStones* stone = new OrxoBloxStones(this->getContext());
+ // if(this->orxoblox_ != nullptr)
+ // {
+ // stone->setGame(this->orxoblox_);
+ // if(this->orxoblox_->getCenterpoint() != nullptr)
+ // stone->addTemplate(this->orxoblox_->getCenterpoint()->getStoneTemplate());
+ // else
+ // orxout()<< "orxoblox_->getCenterpoint == nullptr in TetrisBrick.cc"<< endl;
+ // }
+ // else
+ // orxout()<< "orxoblox_ == nullptr in TetrisBrick.cc"<< endl;
+ }
+
+ OrxoBloxStones* OrxoBloxWall::getStone(unsigned int i)
+ {
+ if(i < this->TotalStones_.size())
+ return this->TotalStones_[i];
+ else return nullptr;
+ }
+
+ OrxoBlox* OrxoBloxWall::getOrxoBlox()
+ {
+ if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
+ {
+ OrxoBlox* orxobloxGametype = orxonox_cast(this->getGametype());
+ return orxobloxGametype;
+ }
+ else orxout()<<"There is no Gametype for OrxoBlox! ask Anna"<< endl;
+ return nullptr;
+ }
+
+ int OrxoBloxWall::getNumberOfStones() {
+ return TotalStones_.size();
+ }
+
+ void OrxoBloxWall::setNumberOfStones(int number) {
+ this->num_Stones_ = number;
+ }
+
+ bool OrxoBloxWall::isEmpty() {
+ if (num_Stones_ == 0) {
+ return true;
+ }
+ return false;
+ }
+
+ void OrxoBloxWall::reduceNumberOfStones() {
+ if(num_Stones_ == 0) {
+ orxout() << "Wanted to reduce number of stones, but there were none" << endl;
+ }
+ this->num_Stones_ -= 1;
+ }
+}
Index: /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxWall.h
===================================================================
--- /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxWall.h (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxWall.h (revision 12411)
@@ -0,0 +1,62 @@
+#ifndef _OrxoBloxWall_H__
+#define _OrxoBloxWall_H__
+
+#include "OrxoBlox/OrxoBloxPrereqs.h"
+#include "worldentities/StaticEntity.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+
+ @author
+
+ @ingroup OrxoBlox
+ */
+ class _OrxoBloxExport OrxoBloxWall : public StaticEntity
+ {
+ public:
+ OrxoBloxWall(Context* context); //!< Constructor. Registers and initializes the object.
+ virtual ~OrxoBloxWall() {}
+ // this.destroy();
+ //}
+ OrxoBloxStones* getStone(unsigned int i);
+ /**
+ @brief Set the Health of the stone.
+ @param size The dimensions a stone has in the game world. (A stone is a cube)
+ */
+ void setHealth(unsigned int health)
+ {
+ this->totalhealth_ = health;
+ }
+
+ /**
+ @brief Get the size of the stone.
+ @return Returns the dimensions a stone has in the game world. (A stone is a cube)
+ */
+ unsigned int getHealth(void) const
+ { return this->totalhealth_; }
+
+ void setGame(OrxoBlox* orxoblox)
+ { assert(orxoblox); orxoblox_ = orxoblox; }
+ int getNumberOfStones();
+ bool isEmpty();
+ void reduceNumberOfStones();
+ void setNumberOfStones(int number);
+ std::vector TotalStones_;
+ private:
+ void createWall(void);
+ OrxoBlox* getOrxoBlox();
+ unsigned int totalhealth_;
+ unsigned int num_Stones_;
+ unsigned int size_; //!< A list of all stones in a Wall.
+ bool delay_;
+ OrxoBlox* orxoblox_;
+ WeakPtr center_; //!< The playing field.
+
+ };
+}
+
+#endif /* _OrxoBloxWall_H__ */
Index: /code/branches/Presentation_FS19/src/modules/asteroids2D/Asteroids2DShip.cc
===================================================================
--- /code/branches/Presentation_FS19/src/modules/asteroids2D/Asteroids2DShip.cc (revision 12410)
+++ /code/branches/Presentation_FS19/src/modules/asteroids2D/Asteroids2DShip.cc (revision 12411)
@@ -69,5 +69,5 @@
void Asteroids2DShip::tick(float dt)
{
- SUPER(Asteroids2DShip, tick, dt);
+ //SUPER(Asteroids2DShip, tick, dt);
Vector3 pos = this->getPosition();
Index: /code/branches/Presentation_FS19/src/modules/pong/Pong.cc
===================================================================
--- /code/branches/Presentation_FS19/src/modules/pong/Pong.cc (revision 12410)
+++ /code/branches/Presentation_FS19/src/modules/pong/Pong.cc (revision 12411)
@@ -127,4 +127,5 @@
void Pong::start()
{
+ orxout() << "Hello" << endl;
if (this->center_ != nullptr) // There needs to be a PongCenterpoint, i.e. the area the game takes place.
{
Index: /code/branches/Presentation_FS19/src/modules/weapons/munitions/BallMunition.cc
===================================================================
--- /code/branches/Presentation_FS19/src/modules/weapons/munitions/BallMunition.cc (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/weapons/munitions/BallMunition.cc (revision 12411)
@@ -0,0 +1,59 @@
+/*
+ * 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:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file IceMunition.cc
+ @brief Implementation of the IceMunition class.
+*/
+
+#include "BallMunition.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ RegisterClass(BallMunition);
+
+ BallMunition::BallMunition(Context* context) : ReplenishingMunition(context)
+ {
+ RegisterObject(BallMunition);
+
+ this->maxMunitionPerMagazine_ = 20;
+ this->maxMagazines_ = 10;
+ this->unassignedMagazines_ = 10;
+
+ this->deployment_ = MunitionDeployment::Separate;
+
+ this->bAllowMunitionRefilling_ = true;
+ this->bAllowMultiMunitionRemovementUnderflow_ = true;
+
+ this->replenishInterval_ = 7.0f;
+ this->replenishAmount_ = 1;
+
+ this->reloadTime_ = 0.6f;
+ }
+}
Index: /code/branches/Presentation_FS19/src/modules/weapons/munitions/BallMunition.h
===================================================================
--- /code/branches/Presentation_FS19/src/modules/weapons/munitions/BallMunition.h (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/weapons/munitions/BallMunition.h (revision 12411)
@@ -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:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file IceMunition.h
+ @brief Definition of the IceMunition class.
+*/
+
+#ifndef _BallMunition_H__
+#define _BallMunition_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weaponsystem/ReplenishingMunition.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ IceMunition.
+ @author
+ Fabien Vultier
+ @ingroup WeaponsMunitions
+ */
+ class _WeaponsExport BallMunition : public ReplenishingMunition
+ {
+ public:
+ BallMunition(Context* context);
+ virtual ~BallMunition() = default;
+ };
+}
+
+#endif /* _SplitMunition_H__ */
Index: /code/branches/Presentation_FS19/src/modules/weapons/munitions/CMakeLists.txt
===================================================================
--- /code/branches/Presentation_FS19/src/modules/weapons/munitions/CMakeLists.txt (revision 12410)
+++ /code/branches/Presentation_FS19/src/modules/weapons/munitions/CMakeLists.txt (revision 12411)
@@ -9,3 +9,4 @@
SplitMunition.cc
MineMunition.cc
+ BallMunition.cc
)
Index: /code/branches/Presentation_FS19/src/modules/weapons/projectiles/BallProjectile.cc
===================================================================
--- /code/branches/Presentation_FS19/src/modules/weapons/projectiles/BallProjectile.cc (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/weapons/projectiles/BallProjectile.cc (revision 12411)
@@ -0,0 +1,266 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file ParticleProjectile.h
+ @brief Implementation of the ParticleProjectile class.
+*/
+
+#include "BallProjectile.h"
+#include "gametypes/Gametype.h"
+#include
+
+
+#include
+#include "core/CoreIncludes.h"
+#include "tools/ParticleInterface.h"
+#include "Scene.h"
+#include "core/command/Executor.h"
+#include "util/Convert.h"
+#include
+#include
+
+namespace orxonox
+{
+ RegisterClass(BallProjectile);
+
+ BallProjectile::BallProjectile(Context* context) : BillboardProjectile(context)
+ {
+ RegisterObject(BallProjectile);
+ this->textureIndex_ = 1;
+ this->setMass(0.1f);
+ this->maxTextureIndex_ = 8;
+ this->setDestroyAfterCollision(false); //I want the ball to bounce, not to be destroyed
+ this->fieldWidth_ = 46;
+ this->fieldHeight_ = 49;
+ this->orxoblox_ = this->getOrxoBlox();
+ this->setCollisionShapeRadius(2.5);
+
+ //setEffect("Orxonox/sparks2");
+ }
+
+ void BallProjectile::registerVariables()
+ {
+ registerVariable(this->materialBase_);
+ registerVariable( this->speed_ );
+ }
+
+ /**
+ @brief
+ Set the material.
+ @param material
+ The name of the material. Material names with 1 to 8 appended must exist.
+ */
+ void BallProjectile::setMaterial(const std::string& material)
+ {
+ this->materialBase_ = material;
+
+ BillboardProjectile::setMaterial(material + multi_cast(this->textureIndex_));
+ }
+
+ /**
+ @brief
+ Change the texture.
+ */
+ void BallProjectile::changeTexture()
+ {
+ this->textureIndex_++;
+ if (this->textureIndex_ > this->maxTextureIndex_)
+ this->textureIndex_ = 1;
+
+ this->setMaterial(this->materialBase_);
+ }
+
+
+
+ void BallProjectile::Bounce(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs) {
+
+ Vector3 velocity = this->getVelocity();
+ Vector3 myPosition = otherObject->getPosition();
+ btVector3 positionOtherObject = contactPoint.getPositionWorldOnA();
+
+ int distance_X = positionOtherObject.getX() - myPosition.x;
+ int distance_Z = positionOtherObject.getZ() - myPosition.z;
+
+ if (distance_X < 0)
+ distance_X = -distance_X;
+
+
+ if (distance_Z < 0)
+ distance_Z = -distance_Z;
+
+ //orxout() << distance_X << endl;
+ //orxout() << distance_Z << endl;
+
+ if (distance_X < distance_Z) {
+ velocity.z = -velocity.z;
+ //orxout() << "z" << endl;
+ }
+ if (distance_Z < distance_X) {
+ velocity.x = -velocity.x;
+ //orxout() << "x" << endl;
+ }
+ else {
+ velocity.x = -velocity.x;
+ velocity.z = -velocity.z;
+ //orxout() << "both" << endl;
+ }
+ this->setVelocity(velocity);
+ //}
+ }
+
+
+ bool BallProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs)
+ {
+ bool result = BasicProjectile::processCollision(otherObject, contactPoint, cs);
+ if (result == true) {
+ if (otherObject->isA(Class(OrxoBloxStones))) {
+ Bounce(otherObject, contactPoint, cs);
+ (orxonox_cast(otherObject))->gotHit();
+
+ }
+ }
+ return result;
+ }
+
+
+
+ OrxoBlox* BallProjectile::getOrxoBlox()
+ {
+ if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
+ {
+ OrxoBlox* orxobloxGametype = orxonox_cast(this->getGametype());
+ return orxobloxGametype;
+ }
+ else orxout()<<"There is no Gametype for OrxoBlox! ask Anna"<< endl;
+ return nullptr;
+ }
+
+
+
+ void BallProjectile::tick(float dt)
+ {
+ SUPER(BallProjectile, tick, dt);
+
+ // Get the current position, velocity and acceleration of the ball.
+ bool suicidal = false;
+ Vector3 position = this->getPosition();
+ Vector3 velocity = this->getVelocity();
+ Vector3 acceleration = this->getAcceleration();
+
+ velocity.y = 0;
+ position.y = 0;
+
+ // If the ball has gone over the top or bottom boundary of the playing field (i.e. the ball has hit the top or bottom delimiters).
+ if (position.z > this->fieldHeight_ || position.z < -this->fieldHeight_)
+ {
+
+ velocity.z = -velocity.z;
+ // And its position is set as to not overstep the boundary it has just crossed. Remember z axis is reverted!!!
+ if (position.z > this->fieldHeight_){
+ // Set the ball to be exactly at the boundary.
+ position.z = this-> fieldHeight_;
+ orxoblox_->count();
+ suicidal = true;
+
+ }
+ if (position.z < -this->fieldHeight_){
+ position.z = -this->fieldHeight_;
+
+ }
+
+ this->fireEvent();
+ }
+
+ //Ball hits the right or left wall and should bounce back.
+ // If the ball has crossed the left or right boundary of the playing field.
+ if (position.x > this->fieldWidth_ || position.x < -this->fieldWidth_)
+ {
+ //Ball hits the right Wall
+ if (position.x > this->fieldWidth_)
+ {
+ // Set the ball to be exactly at the boundary.
+ position.x = this->fieldWidth_;
+ // Invert its velocity in x-direction (i.e. it bounces off).
+ velocity.x = -velocity.x;
+ this->fireEvent();
+ }
+
+ //Ball hits the left wall
+ else if (position.x < -this->fieldWidth_)
+ {
+ // Set the ball to be exactly at the boundary.
+ position.x = -this->fieldWidth_;
+ // Invert its velocity in x-direction (i.e. it bounces off).
+ velocity.x = -velocity.x;
+ this->fireEvent();
+ }
+ }
+
+ // Set the position, velocity and acceleration of the ball, if they have changed.
+ if (acceleration != this->getAcceleration())
+ this->setAcceleration(acceleration);
+ if (velocity != this->getVelocity())
+ this->setVelocity(velocity);
+ if (position != this->getPosition())
+ this->setPosition(position);
+ //this->Collides((this->orxoblox_->CheckForCollision(this)));
+ if (suicidal == true) {
+ this->destroy();
+ }
+
+ }
+
+
+
+ void BallProjectile::setSpeed(float speed)
+ {
+ if (speed != this->speed_) // If the speed changes
+ {
+ this->speed_ = speed;
+
+ // Set the speed in the direction of the balls current velocity.
+ Vector3 velocity = this->getVelocity();
+ if (velocity.x != 0)
+ velocity.x = sgn(velocity.x) * this->speed_;
+ else // If the balls current velocity is zero, the speed is set in a random direction.
+ velocity.x = this->speed_ * sgn(rnd(-1,1));
+
+ this->setVelocity(velocity);
+ }
+ }
+
+ void BallProjectile::destroyObject(void)
+ {
+ if(GameMode::isMaster()) {
+ }
+ }
+
+
+
+}
Index: /code/branches/Presentation_FS19/src/modules/weapons/projectiles/BallProjectile.h
===================================================================
--- /code/branches/Presentation_FS19/src/modules/weapons/projectiles/BallProjectile.h (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/weapons/projectiles/BallProjectile.h (revision 12411)
@@ -0,0 +1,44 @@
+#ifndef _BallProjectile_H__
+#define _BallProjectile_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weapons/projectiles/BillboardProjectile.h"
+#include "../../OrxoBlox/OrxoBlox.h"
+#include "../../OrxoBlox/OrxoBloxStones.h"
+
+#include "OrxoBlox/OrxoBloxPrereqs.h"
+
+namespace orxonox
+{
+
+ class _WeaponsExport BallProjectile : public BillboardProjectile
+ {
+ public:
+ BallProjectile(Context* context);
+ void Bounce(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
+ virtual void setMaterial(const std::string& material) override;
+ virtual void tick(float dt) override;
+ void setSpeed(float speed);
+
+
+ protected:
+ bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs) override;
+
+ private:
+ void destroyObject() override;
+ void registerVariables();
+ void changeTexture();
+ OrxoBlox* getOrxoBlox();
+
+ float speed_; //!< The speed (in x-direction) of the ball.
+ float fieldWidth_; //!< The width of the playing field.
+ float fieldHeight_; //!< The height of the playing field.
+ unsigned int textureIndex_; //!< The current index of the texture. (i.e. the index of the currently displayed texture)
+ unsigned int maxTextureIndex_; //!< The maximal index.
+ std::string materialBase_; //!< The base name of the material.
+ OrxoBlox* orxoblox_;
+ OrxoBloxStones* stone_;
+ };
+}
+
+#endif /* _ParticleProjectile_H__ */
Index: /code/branches/Presentation_FS19/src/modules/weapons/projectiles/BasicProjectile.cc
===================================================================
--- /code/branches/Presentation_FS19/src/modules/weapons/projectiles/BasicProjectile.cc (revision 12410)
+++ /code/branches/Presentation_FS19/src/modules/weapons/projectiles/BasicProjectile.cc (revision 12411)
@@ -172,6 +172,7 @@
void BasicProjectile::destroyCheck(void)
{
- if(GameMode::isMaster() && this->bDestroy_)
+ if(GameMode::isMaster() && this->bDestroy_) {
this->destroy();
+ }
}
@@ -182,6 +183,7 @@
void BasicProjectile::destroyObject(void)
{
- if(GameMode::isMaster())
+ if(GameMode::isMaster()) {
this->destroy();
+ }
}
}
Index: /code/branches/Presentation_FS19/src/modules/weapons/projectiles/BasicProjectile.h
===================================================================
--- /code/branches/Presentation_FS19/src/modules/weapons/projectiles/BasicProjectile.h (revision 12410)
+++ /code/branches/Presentation_FS19/src/modules/weapons/projectiles/BasicProjectile.h (revision 12411)
@@ -117,5 +117,5 @@
protected:
- bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
+ virtual bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
void destroyCheck(void);
inline void setDestroyAfterCollision(bool destroyAfterCollision)
Index: /code/branches/Presentation_FS19/src/modules/weapons/weaponmodes/BallGun.cc
===================================================================
--- /code/branches/Presentation_FS19/src/modules/weapons/weaponmodes/BallGun.cc (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/weapons/weaponmodes/BallGun.cc (revision 12411)
@@ -0,0 +1,149 @@
+/*
+ * 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:
+ * Hagen Seifert
+ * Co-authors:
+ * simonmie
+ *
+ */
+
+/**
+ @file HsW01.h
+ @brief Implementation of the HsW01 class.
+*/
+
+#include "BallGun.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"
+#include "weapons/projectiles/BallProjectile.h"
+
+namespace orxonox
+{
+ RegisterClass(BallGun);
+
+ BallGun::BallGun(Context* context) : WeaponMode(context)
+ {
+ RegisterObject(BallGun);
+
+ this->reloadTime_ = 0.25f;
+ this->damage_ = 10000; //default 15
+ this->speed_ = 100;
+ this->delay_ = 100;
+ this->setMunitionName("BallMunition");
+ this->mesh_ = "laserbeam.mesh";
+
+
+ this->delayTimer_.setTimer(this->delay_, false, createExecutor(createFunctor(&BallGun::shot, this)));
+ this->delayTimer_.stopTimer();
+
+ this->setFireSound("sounds/Weapon_HsW01.ogg");
+ this->setReloadSound("sounds/Reload_HsW01.ogg", 0.5);
+
+ hudImageString_ = "Orxonox/WSHUD_WM_HsW01";
+ }
+
+ BallGun::~BallGun()
+ {
+ }
+
+ void BallGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(BallGun, XMLPort, xmlelement, mode);
+
+ XMLPortParam(BallGun, "delay", setDelay, getDelay, xmlelement, mode);
+ XMLPortParam(BallGun, "material", setMaterial, getMaterial, xmlelement, mode);
+ XMLPortParam(BallGun, "projectileMesh", setMesh, getMesh, xmlelement, mode);
+ XMLPortParam(BallGun, "sound", setSound, getSound, xmlelement, mode);
+ }
+
+ /**
+ @brief
+ Set the firing delay.
+ @param delay
+ The firing delay in seconds.
+ */
+ void BallGun::setDelay(float delay)
+ {
+ orxout() << "delay" << endl;
+ this->delay_ = delay;
+ this->delayTimer_.setInterval(this->delay_);
+ }
+
+ void BallGun::fire()
+ {
+ this->delayTimer_.startTimer();
+ }
+
+ /**
+ @brief
+ Fires the weapon. Creates a projectile and fires it.
+ */
+ void BallGun::shot()
+ {
+ assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
+ // Create the projectile.
+ Projectile* projectile = new BallProjectile(this->getContext());
+ 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());
+ projectile->setOrientation(this->getMuzzleOrientation());
+ projectile->setPosition(this->getMuzzlePosition());
+ projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
+
+ projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
+
+ // Display the muzzle flash.
+ this->BallGun::muzzleflash();
+ }
+
+ /**
+ @brief
+ Displays the muzzle flash.
+ */
+ void BallGun::muzzleflash()
+ {
+ MuzzleFlash *muzzleFlash = new MuzzleFlash(this->getContext());
+ this->getWeapon()->attach(muzzleFlash);
+ muzzleFlash->setPosition(this->getMuzzleOffset());
+ muzzleFlash->setMaterial(this->material_);
+ }
+}
Index: /code/branches/Presentation_FS19/src/modules/weapons/weaponmodes/BallGun.h
===================================================================
--- /code/branches/Presentation_FS19/src/modules/weapons/weaponmodes/BallGun.h (revision 12411)
+++ /code/branches/Presentation_FS19/src/modules/weapons/weaponmodes/BallGun.h (revision 12411)
@@ -0,0 +1,126 @@
+/*
+ * 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:
+ * Hagen Seifert
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file HsW01.h
+ @brief Definition of the HsW01 class.
+*/
+
+#ifndef _BallGun_H__
+#define _BallGun_H__
+
+#include "weapons/WeaponsPrereqs.h"
+
+#include "tools/Timer.h"
+#include "weaponsystem/WeaponMode.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Shoots laser beams.
+ @author
+ Hagen Seifert
+ @ingroup WeaponsWeaponModes
+ */
+ class _WeaponsExport BallGun : public WeaponMode
+ {
+ public:
+ BallGun(Context* context);
+ virtual ~BallGun();
+
+ virtual void fire() override;
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+
+ protected:
+ /**
+ @brief Set the mesh.
+ @param mesh The mesh name.
+ */
+ void setMesh(const std::string& mesh)
+ { this->mesh_ = mesh; }
+
+ /**
+ @brief Get the mesh.
+ @return Returns the mesh name.
+ */
+ const std::string& getMesh() const
+ { return this->mesh_; }
+
+ /**
+ @brief Set the sound.
+ @param sound The Sound name.
+ */
+ void setSound(const std::string& sound)
+ { this->sound_ = sound; }
+
+ /**
+ @brief Get the sound.
+ @return Returns the sound name.
+ */
+ const std::string& getSound() const
+ { return this->sound_; }
+
+ /**
+ @brief Set the material.
+ @param material The material name.
+ */
+ void setMaterial(const std::string& material)
+ { this->material_ = material; }
+ /**
+ @brief Get the material.
+ @return Returns the material name.
+ */
+ const std::string& getMaterial() const
+ { return this->material_; }
+
+ void setDelay(float delay);
+ /**
+ @brief Get the firing delay.
+ @return Returns the firing delay in seconds.
+ */
+ float getDelay() const
+ { return this->delay_; }
+
+ virtual void shot();
+ void muzzleflash();
+
+ std::string material_; //!< The material.
+ std::string mesh_; //!< The mesh.
+ std::string sound_; //!< The sound.
+
+
+
+ float speed_; //!< The speed of the fired projectile.
+ float delay_; //!< The firing delay.
+ Timer delayTimer_; //!< A timer to delay the firing.
+ };
+}
+
+#endif /* _HsW01_H__ */