Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 27, 2017, 5:00:59 PM (6 years ago)
Author:
vyang
Message:

Asteroids2D erfolgreich als Minigame eingebunden, Dimensionen des Spielfeldes werden im CenterPoint gesetzt.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc

    r11593 r11608  
    3535#include "Asteroids2DShip.h" // Necessary for getPlayer function. Do NOT include this in Header!
    3636#include "core/CoreIncludes.h"
    37 
     37#include "Highscore.h"
    3838
    3939namespace orxonox
     
    4444    {
    4545        RegisterObject(Asteroids2D);
    46         this->bEndGame = false;
    4746
     47        bEndGame = false;
     48        lives = 1;
     49        level = 1;
     50        point = 0;
     51        bShowLevel = false;
     52        multiplier = 1;
     53        b_combo = false;
     54        counter = 5000;
     55        pattern = 1;
     56        lastPosition = 0;
     57        // spawn enemy every 3.5 seconds
     58        //enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Asteroids2D::spawnEnemy, this)));
     59        this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
     60        this->center_ = nullptr;
     61        this->setHUDTemplate("Asteroids2DHUD");
     62    }
     63
     64    void Asteroids2D::levelUp()
     65    {
     66        level++;
     67        if (getPlayer() != nullptr)
     68        {
     69            for (int i = 0; i < 7; i++)
     70            {
     71                WeakPtr<ExplosionPart> chunk5 = new ExplosionPart(this->center_->getContext());
     72                chunk5->setPosition(Vector3(600, 0, 100.f * i - 300));
     73                chunk5->setVelocity(Vector3(1000, 0, 0));  //player->getVelocity()
     74                chunk5->setScale(10);
     75                chunk5->setEffect1("Orxonox/explosion2b");
     76                chunk5->setEffect2("Orxonox/smoke6");
     77                chunk5->Explode();
     78
     79            }
     80        }
     81        addPoints(multiplier * 42);
     82        multiplier *= 2;
     83        toggleShowLevel();
     84        showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Asteroids2D::toggleShowLevel, this)));
    4885    }
    4986
    5087    void Asteroids2D::tick(float dt)
    5188    {
    52 
     89       
    5390        SUPER(Asteroids2D, tick, dt);
    5491    }
     
    66103    }
    67104
     105    void Asteroids2D::costLife()
     106    {
     107        //endGameTimer.setTimer(8.0f, false, createExecutor(createFunctor(&Asteroids2D::end, this)));
     108        lives = 0;
     109    };
     110
    68111    void Asteroids2D::start()
    69112    {
    70113        orxout() << "start" << endl;
    71        
     114
    72115        // Set variable to temporarily force the player to spawn.
    73116        this->bForceSpawn_ = false;
     
    83126    }
    84127
     128    void Asteroids2D::playerPreSpawn(PlayerInfo* player)
     129    {
     130        if(lives <= 0)
     131        {
     132            this->end();
     133        }
     134    }
     135
     136    void Asteroids2D::addPoints(int numPoints)
     137    {
     138        if (!bEndGame)
     139        {
     140            point += numPoints * multiplier;
     141            b_combo = true;
     142        }
     143    }
     144
    85145    void Asteroids2D::end()
    86146    {
     
    89149        // It will misteriously crash the game!
    90150        // Instead startMainMenu, this won't crash.
    91         orxout() << "Asteroids2D Game has ended" << endl;
     151        if (Highscore::exists()){
     152                    int score = this->getPoints();
     153                    if(score > Highscore::getInstance().getHighestScoreOfGame("Dodge Race"))
     154                        Highscore::getInstance().storeHighscore("Dodge Race",score);
     155
     156          }
    92157        GSLevel::startMainMenu();
    93158    }
Note: See TracChangeset for help on using the changeset viewer.