Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 23, 2017, 3:53:52 PM (7 years ago)
Author:
jkindle
Message:

added some structire. Next to do, fix Centerpoint and error when compiling

Location:
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt

    r11370 r11378  
    1 SET_SOURCE_FILES(Superorxobros_SRC_FILES
    2   Orxo.cc
     1SET_SOURCE_FILES(SOB_SRC_FILES
    32
     3  SOBCenterpoint.cc
     4  SOB.cc
     5  SOBFigure.cc
     6 
    47
    58)
     
    1114    orxonox
    1215    overlays
    13     weapons
    14   SOURCE_FILES ${Superorxobros_SRC_FILES}
     16  SOURCE_FILES ${SOB_SRC_FILES}
    1517)
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc

    r11370 r11378  
    2121 *
    2222 *   Author:
    23  *      Florian Zinggeler
     23 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    2525 *      ...
     
    2828
    2929/**
    30     @file Invader.cc
    31     @brief Implementation of the Invader class.
     30    @file Pong.cc
     31    @brief Implementation of the Pong class.
    3232*/
    3333
    34 #include "Invader.h"
    35 #include "Highscore.h"
     34#include "SOB.h"
     35
    3636#include "core/CoreIncludes.h"
    3737#include "core/EventIncludes.h"
     
    4242#include "chat/ChatManager.h"
    4343
    44 // ! HACK
    45 #include "infos/PlayerInfo.h"
     44#include "SOBCenterpoint.h"
    4645
    47 #include "InvaderCenterPoint.h"
    48 #include "InvaderShip.h"
    49 #include "InvaderEnemy.h"
    50 #include "InvaderEnemyShooter.h"
    51 
    52 #include "core/command/ConsoleCommand.h"
    53 #include "worldentities/ExplosionPart.h"
     46//#include "PongBat.h"
     47//#include "PongBot.h"
     48//#include "PongAI.h"
    5449
    5550namespace orxonox
    5651{
    57     RegisterUnloadableClass(Invader);
     52 
     53    RegisterUnloadableClass(SOB);
    5854
    59     Invader::Invader(Context* context) : Deathmatch(context)
     55    /**
     56    @brief
     57        Constructor. Registers and initializes the object.
     58    */
     59    SOB::SOB(Context* context) : Deathmatch(context)
    6060    {
    61         RegisterObject(Invader);
    62         this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
     61        RegisterObject(SOB);
     62
    6363        this->center_ = nullptr;
    64         bEndGame = false;
    65         lives = 3;
    66         level = 1;
    67         point = 0;
    68         bShowLevel = false;
    69         multiplier = 1;
    70         b_combo = false;
    71         // spawn enemy every 3.5 seconds
    72         enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));
    73         comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&Invader::comboControll, this)));
    74         this->setHUDTemplate("InvaderHUD");
     64           figure_ = nullptr;
     65
    7566    }
    7667
    77     void Invader::levelUp()
     68    /**
     69    @brief
     70        Destructor. Cleans up, if initialized.
     71    */
     72    SOB::~SOB()
    7873    {
    79         level++;
    80         if (getPlayer() != nullptr)
    81         {
    82             for (int i = 0; i < 7; i++)
    83             {
    84 
    85                 WeakPtr<ExplosionPart> chunk5 = new ExplosionPart(this->center_->getContext());
    86                 chunk5->setPosition(this->center_->getPosition());
    87                 chunk5->setVelocity(Vector3(1000, 0, 0));  //player->getVelocity()
    88                 chunk5->setScale(10);
    89                 chunk5->setEffect1("Orxonox/explosion2b");
    90                 chunk5->setEffect2("Orxonox/smoke6");
    91                 chunk5->setMinSpeed(0);
    92                 chunk5->setMaxSpeed(0);
    93                 chunk5->Explode();
    94 
    95             }
    96         }
    97         addPoints(multiplier * 42);
    98         multiplier *= 2;
    99         toggleShowLevel();
    100         showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Invader::toggleShowLevel, this)));
     74        if (this->isInitialized())
     75            this->cleanup();
    10176    }
    10277
    103     InvaderShip* Invader::getPlayer()
     78
     79
     80        void SOB::start()
    10481    {
    105         if (player == nullptr)
     82        if (center_ != nullptr) // There needs to be a SOBCenterpoint, i.e. the area the game takes place.
    10683        {
    107             for (InvaderShip* ship : ObjectList<InvaderShip>())
    108                 player = ship;
     84            if (figure_ == nullptr)
     85            {
     86                figure_ = new SOBFigure(center_->getContext());
     87                figure_->addTemplate(center_->getFigureTemplate()); /
     88                figure_->InitializeAnimation(center_->getContext()); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
     89            }
     90
     91            center_->attach(figure_);   //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
     92            figure_->setPosition(0, 0, 0);
    10993        }
    110         return player;
     94        else // If no centerpoint was specified, an error is thrown and the level is exited.
     95        {
     96            orxout(internal_error) << "SOB: No Centerpoint specified." << endl;
     97            GSLevel::startMainMenu();
     98            return;
     99        }
     100
     101        // Call start for the parent class.
     102        Deathmatch::start();
     103
     104        if (figure_ != nullptr)
     105        {
     106            camera = figure_->getCamera();
     107        }
     108
     109        totalScreenShift_ = 0.0;
     110        screenShiftSinceLastUpdate_ = 0.0;
     111        sectionNumber_ = 0;
     112        adventureNumber_ = 0;
     113
     114        addStartSection();
     115        addSection();
     116        addSection();
    111117    }
    112118
    113     void Invader::spawnEnemy()
     119    void SOB::end()
    114120    {
    115         if (getPlayer() == nullptr)
    116             return;
     121        cleanup();
     122        GSLevel::startMainMenu();
     123 
     124        Deathmatch::end();
     125    }
    117126
    118         for (int i = 0; i < (3*log10(static_cast<double>(level)) + 1); i++)
     127    void SOB::spawnPlayer(PlayerInfo* player)
     128    {
     129        assert(player);
     130
     131        if (figure_->getPlayer() == nullptr)
    119132        {
    120             InvaderEnemy* newPawn;
    121             if (rand() % 42/(1 + level*level) == 0)
    122             {
    123                 newPawn = new InvaderEnemyShooter(this->center_->getContext());
    124                 newPawn->addTemplate("enemyinvadershooter");
    125             }
    126             else
    127             {
    128                 newPawn = new InvaderEnemy(this->center_->getContext());
    129                 newPawn->addTemplate("enemyinvader");
    130             }
    131             newPawn->setInvaderPlayer(player);
    132             newPawn->level = level;
    133             // spawn enemy at random points in front of player.
    134             newPawn->setPosition(player->getPosition() + Vector3(500.f + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200));
     133            player->startControl(figure_);
     134            players_[player].state_ = PlayerState::Alive;
    135135        }
    136136    }
    137137
    138     void Invader::setCenterpoint(InvaderCenterPoint* center)
     138    PlayerInfo* SOB::getPlayer() const
    139139    {
    140         this->center_ = center;
    141     }
    142 
    143     void Invader::costLife()
    144     {
    145         lives--;
    146         multiplier = 1;
    147         // end the game in 30 seconds.
    148         if (lives <= 0)
    149             enemySpawnTimer.setTimer(30.0f, false, createExecutor(createFunctor(&Invader::end, this)));
    150     };
    151 
    152     void Invader::comboControll()
    153     {
    154         if (b_combo)
    155             multiplier++;
    156         // if no combo was performed before, reset multiplier
     140        if (this->figure_ != nullptr)
     141        {
     142            return this->figure_->getPlayer();
     143        }
    157144        else
    158             multiplier = 1;
    159         b_combo = false;
    160     }
    161 
    162     void Invader::start()
    163     {
    164         // Set variable to temporarily force the player to spawn.
    165         this->bForceSpawn_ = true;
    166 
    167         if (this->center_ == nullptr)  // abandon mission!
    168145        {
    169             orxout(internal_error) << "Invader: No Centerpoint specified." << endl;
    170             GSLevel::startMainMenu();
    171             return;
    172         }
    173         // Call start for the parent class.
    174         Deathmatch::start();
    175     }
    176     void Invader::addPoints(int numPoints)
    177     {
    178         if (!bEndGame)
    179         {
    180             point += numPoints * multiplier;
    181             b_combo = true;
     146            return nullptr;
    182147        }
    183148    }
    184149
    185     void Invader::end()
    186     {
    187         // DON'T CALL THIS!
    188         //      Deathmatch::end();
    189         // It will misteriously crash the game!
    190         // Instead startMainMenu, this won't crash.
    191         if (Highscore::exists()){
    192                     int score = this->getPoints();
    193                     if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade"))
    194                         Highscore::getInstance().storeHighscore("Orxonox Arcade",score);
    195150
    196           }
    197         GSLevel::startMainMenu();
    198     }
     151   
     152 
    199153}
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h

    r11370 r11378  
    2121 *
    2222 *   Author:
    23  *      Florian Zinggeler
     23 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    2525 *      ...
     
    2828
    2929/**
    30     @file Invader.h
    31     @brief Gametype.
    32     @ingroup Invader
     30    @file Pong.h
     31    @brief Declaration of the Pong class.
     32    @ingroup Pong
    3333*/
    3434
    35 #ifndef _Invader_H__
    36 #define _Invader_H__
     35#ifndef _SOB_H__
     36#define _SOB_H__
    3737
    38 #include "invader/InvaderPrereqs.h"
     38#include "superorxobros/SOBPrereqs.h"
     39
     40#include "tools/Timer.h"
    3941
    4042#include "gametypes/Deathmatch.h"
    41 #include "tools/Timer.h"
     43#include "SOBCenterpoint.h"
    4244
    4345namespace orxonox
    4446{
    4547
    46     class _InvaderExport Invader : public Deathmatch
     48 
     49    class _SOBExport SOB : public Deathmatch
    4750    {
    4851        public:
    49             Invader(Context* context);
     52            SOB(Context* context); //!< Constructor. Registers and initializes the object.
     53            virtual ~SOB(); //!< Destructor. Cleans up, if initialized.
    5054
    51             virtual void start() override;
    52             virtual void end() override;
    53             virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
     55       
     56            void setCenterpoint(SOBCenterpoint* center)
     57                { this->center_ = center; }
     58            void setFigureTemplate(const std::string& newTemplate)
     59                { this->figureTemplate_ = newTemplate; }
     60           
     61            const std::string& getFigureTemplate() const
     62                { return this->figureTemplate_; }
     63       
     64         
     65        protected:
     66       
    5467
    55             void spawnEnemy();
    56 
    57             void setCenterpoint(InvaderCenterPoint* center);
    58 
    59             int getLives(){return this->lives;}
    60             int getLevel(){return this->level;}
    61             int getPoints(){return this->point;}
    62             int getMultiplier(){return this->multiplier;}
    63 
    64             void costLife();
    65             void levelUp();
    66             void addPoints(int numPoints);
    67             // checks if multiplier should be reset.
    68             void comboControll();
    69             int lives;
    70             int multiplier;
    71             bool bEndGame;
    72             bool bShowLevel;
    73         private:
    74             void toggleShowLevel(){bShowLevel = !bShowLevel;}
    75             InvaderShip* getPlayer();
    76             WeakPtr<InvaderCenterPoint> center_;
    77             WeakPtr<InvaderShip> player;
    78 
    79             Timer enemySpawnTimer;
    80             Timer comboTimer;
    81             Timer showLevelTimer;
    82             //Context* context;
    83             int level;
    84             int point;
    85             bool b_combo;
     68            void cleanup(); //!< Cleans up the Gametype by destroying the ball and the bats.
     69             WeakPtr<SOBCenterpoint> center_;
     70            WeakPtr<SOBFigure> figure_;
     71            WeakPtr<Camera> camera;
     72         
    8673    };
    8774}
    8875
    89 #endif /* _Invader_H__ */
     76#endif /* _Pong_H__ */
Note: See TracChangeset for help on using the changeset viewer.