Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 23, 2017, 3:19:08 PM (7 years ago)
Author:
pascscha
Message:

MoveUpDown

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc

    r11481 r11503  
    2929/**
    3030    @file FlappyOrx.cc
     31    @brief Implementation of the FlappyOrx class.
    3132*/
    3233
     34#include "FlappyOrx.h"
     35#include "Highscore.h"
     36#include "core/CoreIncludes.h"
     37#include "core/EventIncludes.h"
     38#include "core/command/Executor.h"
     39#include "core/config/ConfigValueIncludes.h"
     40
     41#include "gamestates/GSLevel.h"
     42#include "chat/ChatManager.h"
     43
     44// ! HACK
     45#include "infos/PlayerInfo.h"
     46
     47#include "FlappyOrxCenterPoint.h"
     48#include "FlappyOrxShip.h"
     49
     50#include "core/command/ConsoleCommand.h"
     51#include "worldentities/ExplosionPart.h"
    3352
    3453namespace orxonox
     
    3958    {
    4059        RegisterObject(FlappyOrx);
    41         this->setHUDTemplate("FlappyHUD");
     60        this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
     61        this->center_ = nullptr;
     62        bEndGame = false;
     63        lives = 3;
     64        level = 1;
     65        point = 0;
     66        bShowLevel = false;
     67        multiplier = 1;
     68        b_combo = false;
     69       
     70        this->setHUDTemplate("FlappyOrxHUD");
     71    }
     72
     73    void FlappyOrx::levelUp()
     74    {
     75        level++;
     76        if (getPlayer() != nullptr)
     77        {
     78            for (int i = 0; i < 7; i++)
     79            {
     80
     81                WeakPtr<ExplosionPart> chunk5 = new ExplosionPart(this->center_->getContext());
     82                chunk5->setPosition(this->center_->getPosition());
     83                chunk5->setVelocity(Vector3(1000, 0, 0));  //player->getVelocity()
     84                chunk5->setScale(10);
     85                chunk5->setEffect1("Orxonox/explosion2b");
     86                chunk5->setEffect2("Orxonox/smoke6");
     87                chunk5->setMinSpeed(0);
     88                chunk5->setMaxSpeed(0);
     89                chunk5->Explode();
     90
     91            }
     92        }
     93        addPoints(multiplier * 42);
     94        multiplier *= 2;
     95        toggleShowLevel();
     96        showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&FlappyOrx::toggleShowLevel, this)));
     97    }
     98
     99    FlappyOrxShip* FlappyOrx::getPlayer()
     100    {
     101        if (player == nullptr)
     102        {
     103            for (FlappyOrxShip* ship : ObjectList<FlappyOrxShip>())
     104                player = ship;
     105        }
     106        return player;
     107    }
     108
     109
     110    void FlappyOrx::setCenterpoint(FlappyOrxCenterPoint* center)
     111    {
     112        this->center_ = center;
     113    }
     114
     115    void FlappyOrx::costLife()
     116    {
     117        lives--;
     118        multiplier = 1;
     119        // end the game in 30 seconds.
     120        if (lives <= 0)
     121            enemySpawnTimer.setTimer(30.0f, false, createExecutor(createFunctor(&FlappyOrx::end, this)));
     122    };
     123
     124    void FlappyOrx::comboControll()
     125    {
     126        if (b_combo)
     127            multiplier++;
     128        // if no combo was performed before, reset multiplier
     129        else
     130            multiplier = 1;
     131        b_combo = false;
    42132    }
    43133
    44134    void FlappyOrx::start()
    45135    {
     136        // Set variable to temporarily force the player to spawn.
     137        this->bForceSpawn_ = true;
     138
     139        if (this->center_ == nullptr)  // abandon mission!
     140        {
     141            orxout(internal_error) << "FlappyOrx: No Centerpoint specified." << endl;
     142            GSLevel::startMainMenu();
     143            return;
     144        }
     145        // Call start for the parent class.
    46146        Deathmatch::start();
     147    }
     148    void FlappyOrx::addPoints(int numPoints)
     149    {
     150        if (!bEndGame)
     151        {
     152            point += numPoints * multiplier;
     153            b_combo = true;
     154        }
    47155    }
    48156
     
    53161        // It will misteriously crash the game!
    54162        // Instead startMainMenu, this won't crash.
     163        if (Highscore::exists()){
     164                    int score = this->getPoints();
     165                    if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade"))
     166                        Highscore::getInstance().storeHighscore("Orxonox Arcade",score);
     167
     168          }
    55169        GSLevel::startMainMenu();
    56170    }
Note: See TracChangeset for help on using the changeset viewer.