Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 21, 2019, 2:19:16 PM (6 years ago)
Author:
ahuwyler
Message:

A new Game is born

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc

    r12210 r12212  
    2828
    2929/**
    30     @file Pong.cc
    31     @brief Implementation of the Pong class.
     30    @file OrxoBlox.cc
     31    @brief Implementation of the OrxoBlox class.
    3232*/
    3333
    34 #include "Pong.h"
     34#include "OrxoBlox.h"
    3535
    3636#include "core/CoreIncludes.h"
     
    4242#include "chat/ChatManager.h"
    4343
    44 #include "PongCenterpoint.h"
    45 #include "PongBall.h"
    46 #include "PongBat.h"
    47 #include "PongBot.h"
    48 #include "PongAI.h"
    49 
     44#include "OrxoBloxCenterpoint.h"
     45#include "OrxoBloxBall.h"
     46#include "OrxoBloxBat.h"
     47#include "OrxoBloxBot.h"
     48#include "OrxoBloxAI.h"
    5049namespace orxonox
    5150{
    5251    // Events to allow to react to scoring of a player, in the level-file.
    53     CreateEventName(PongCenterpoint, right);
    54     CreateEventName(PongCenterpoint, left);
    55 
    56     RegisterUnloadableClass(Pong);
     52    CreateEventName(OrxoBloxCenterpoint, right);
     53    CreateEventName(OrxoBloxCenterpoint, left);
     54
     55    RegisterUnloadableClass(OrxoBlox);
    5756
    5857    /**
     
    6059        Constructor. Registers and initializes the object.
    6160    */
    62     Pong::Pong(Context* context) : Deathmatch(context)
    63     {
    64         RegisterObject(Pong);
     61    OrxoBlox::OrxoBlox(Context* context) : Deathmatch(context)
     62    {
     63        RegisterObject(OrxoBlox);
    6564
    6665        this->center_ = nullptr;
     
    6968        this->bat_[1] = nullptr;
    7069
    71         this->setHUDTemplate("PongHUD");
     70        this->setHUDTemplate("OrxoBloxHUD");
    7271
    7372        // Pre-set the timer, but don't start it yet.
    74         this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&Pong::startBall, this)));
     73        this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&OrxoBlox::startBall, this)));
    7574        this->starttimer_.stopTimer();
    7675
    7776        // Set the type of Bots for this particular Gametype.
    78         this->botclass_ = Class(PongBot);
     77        this->botclass_ = Class(OrxoBloxBot);
    7978
    8079        this->scoreLimit_ = 10;
     
    8685        Destructor. Cleans up, if initialized.
    8786    */
    88     Pong::~Pong()
     87    OrxoBlox::~OrxoBlox()
    8988    {
    9089        if (this->isInitialized())
     
    9291    }
    9392
    94     void Pong::setConfigValues()
     93    void OrxoBlox::setConfigValues()
    9594    {
    9695        SetConfigValue(scoreLimit_, 10).description("The player first reaching those points wins.");
     
    101100        Cleans up the Gametype by destroying the ball and the bats.
    102101    */
    103     void Pong::cleanup()
     102    void OrxoBlox::cleanup()
    104103    {
    105104        if (this->ball_ != nullptr) // Destroy the ball, if present.
     
    123122    /**
    124123    @brief
    125         Starts the Pong minigame.
    126     */
    127     void Pong::start()
    128     {
    129         if (this->center_ != nullptr) // There needs to be a PongCenterpoint, i.e. the area the game takes place.
     124        Starts the OrxoBlox minigame.
     125    */
     126    void OrxoBlox::start()
     127    {
     128        if (this->center_ != nullptr) // There needs to be a OrxoBloxCenterpoint, i.e. the area the game takes place.
    130129        {
    131130            if (this->ball_ == nullptr) // If there is no ball, create a new ball.
    132131            {
    133                 this->ball_ = new PongBall(this->center_->getContext());
     132                this->ball_ = new OrxoBloxBall(this->center_->getContext());
    134133                // Apply the template for the ball specified by the centerpoint.
    135134                this->ball_->addTemplate(this->center_->getBalltemplate());
     
    145144
    146145            // If one of the bats is missing, create it. Apply the template for the bats as specified in the centerpoint.
    147             for (WeakPtr<orxonox::PongBat>& bat : this->bat_)
     146            for (WeakPtr<orxonox::OrxoBloxBat>& bat : this->bat_)
    148147            {
    149148                if (bat == nullptr)
    150149                {
    151                     bat = new PongBat(this->center_->getContext());
     150                    bat = new OrxoBloxBat(this->center_->getContext());
    152151                    bat->addTemplate(this->center_->getBattemplate());
    153152                }
     
    173172        else // If no centerpoint was specified, an error is thrown and the level is exited.
    174173        {
    175             orxout(internal_error) << "Pong: No Centerpoint specified." << endl;
     174            orxout(internal_error) << "OrxoBlox: No Centerpoint specified." << endl;
    176175            GSLevel::startMainMenu();
    177176            return;
     
    194193    /**
    195194    @brief
    196         Ends the Pong minigame.
    197     */
    198     void Pong::end()
     195        Ends the OrxoBlox minigame.
     196    */
     197    void OrxoBlox::end()
    199198    {
    200199        this->cleanup();
     
    208207        Spawns players, and fills the rest up with bots.
    209208    */
    210     void Pong::spawnPlayersIfRequested()
     209    void OrxoBlox::spawnPlayersIfRequested()
    211210    {
    212211        // first spawn human players to assign always the left bat to the player in singleplayer
     
    226225        The player to be spawned.
    227226    */
    228     void Pong::spawnPlayer(PlayerInfo* player)
     227    void OrxoBlox::spawnPlayer(PlayerInfo* player)
    229228    {
    230229        assert(player);
     
    247246
    248247        // If the player is an AI, it receives a pointer to the ball.
    249         if (player->getController() != nullptr && player->getController()->isA(Class(PongAI)))
    250         {
    251             PongAI* ai = orxonox_cast<PongAI*>(player->getController());
    252             ai->setPongBall(this->ball_);
     248        if (player->getController() != nullptr && player->getController()->isA(Class(OrxoBloxAI)))
     249        {
     250            OrxoBloxAI* ai = orxonox_cast<OrxoBloxAI*>(player->getController());
     251            ai->setOrxoBloxBall(this->ball_);
    253252        }
    254253    }
     
    258257        Is called when the player scored.
    259258    */
    260     void Pong::playerScored(PlayerInfo* player, int score)
     259    void OrxoBlox::playerScored(PlayerInfo* player, int score)
    261260    {
    262261        Deathmatch::playerScored(player, score);
     
    266265            // Fire an event for the player that has scored, to be able to react to it in the level, e.g. by displaying fireworks.
    267266            if (player == this->getRightPlayer())
    268                 this->center_->fireEvent(FireEventName(PongCenterpoint, right));
     267                this->center_->fireEvent(FireEventName(OrxoBloxCenterpoint, right));
    269268            else if (player == this->getLeftPlayer())
    270                 this->center_->fireEvent(FireEventName(PongCenterpoint, left));
     269                this->center_->fireEvent(FireEventName(OrxoBloxCenterpoint, left));
    271270
    272271            // Also announce, that the player has scored.
     
    312311        Starts the ball with some default speed.
    313312    */
    314     void Pong::startBall()
     313    void OrxoBlox::startBall()
    315314    {
    316315        if (this->ball_ != nullptr && this->center_ != nullptr)
     
    324323        Returns a pointer to the player playing on the left. If there is no left player, nullptr is returned.
    325324    */
    326     PlayerInfo* Pong::getLeftPlayer() const
     325    PlayerInfo* OrxoBlox::getLeftPlayer() const
    327326    {
    328327        if (this->bat_[0] != nullptr)
     
    338337        Returns a pointer to the player playing on the right. If there is no right player, nullptr is returned.
    339338    */
    340     PlayerInfo* Pong::getRightPlayer() const
     339    PlayerInfo* OrxoBlox::getRightPlayer() const
    341340    {
    342341        if (this->bat_[1] != nullptr)
Note: See TracChangeset for help on using the changeset viewer.