Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9829


Ignore:
Timestamp:
Nov 25, 2013, 6:51:39 PM (10 years ago)
Author:
zifloria
Message:

points, level up, hud

Location:
code/branches/invaders
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/invaders/data/overlays/InvaderHUD.oxo

    r9828 r9829  
    3030     colour    = "1.0, 1.0, 1.0, 1.0"
    3131     align     = "left"
    32      caption   = "Players: "
     32     caption   = "Level: "
    3333    />
    3434
  • code/branches/invaders/src/modules/invader/Invader.cc

    r9828 r9829  
    6464        this->setHUDTemplate("InvaderHUD");
    6565
     66        lives = 3;
     67        level = 1;
     68        point = 0;
     69        multiplier = 1;
     70        b_combo = false;
    6671        enemySpawnTimer.setTimer(2.0f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));
     72        comboTimer.setTimer(2.5f, true, createExecutor(createFunctor(&Invader::comboControll, this)));
    6773    }
    6874
     
    8591
    8692        newPawn->setPosition(player->getPosition() + Vector3(1000, 0, 0)); // BUG:
     93    }
     94
     95    void Invader::comboControll()
     96    {
     97        if (b_combo)
     98            multiplier++;
     99        else
     100            multiplier = 1;
     101        b_combo = false;
    87102    }
    88103
  • code/branches/invaders/src/modules/invader/Invader.h

    r9828 r9829  
    6666            int getLevel(){return this->level;}
    6767            int getPoints(){return this->point;}
     68
     69            void costLife(){lives--; if (lives == 0) orxout() << "end<<<<<<<<<<<<<<<<<" << endl;};
     70            void levelUp(){level++;}
     71            void addPoints(int numPoints){point += numPoints * multiplier; b_combo = true;}
     72            void comboControll();
    6873        private:
    6974            WeakPtr<InvaderCenterPoint> center_;
     
    7277            ConsoleCommand* console_addEnemy;
    7378            Timer enemySpawnTimer;
     79            Timer comboTimer;
    7480            //Context* context;
    7581            int lives;
    7682            int level;
    7783            int point;
     84            bool b_combo;
     85            int multiplier;
    7886    };
    7987}
  • code/branches/invaders/src/modules/invader/InvaderEnemy.cc

    r9828 r9829  
    5858        return false;
    5959    }
     60
     61    WeakPtr<Invader> InvaderEnemy::getGame()
     62    {
     63        if (game == NULL)
     64        {
     65            for (ObjectList<Invader>::iterator it = ObjectList<Invader>::begin(); it != ObjectList<Invader>::end(); ++it)
     66                game = *it;
     67        }
     68        return game;
     69    }
     70
     71    void InvaderEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
     72    {
     73        if (getGame())
     74            getGame()->addPoints(42);
     75        // SUPER(InvaderEnemy, damage, damage, healthdamage, shielddamage, originator);
     76    }
    6077}
  • code/branches/invaders/src/modules/invader/InvaderEnemy.h

    r9828 r9829  
    4949            virtual void tick(float dt);
    5050            virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
     51            virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator);
    5152
    5253        private:
     54            WeakPtr<Invader> getGame();
     55            WeakPtr<Invader> game;
    5356            Camera* camera;
    5457            bool isFireing;
  • code/branches/invaders/src/modules/invader/InvaderShip.cc

    r9828 r9829  
    3636#include "core/CoreIncludes.h"
    3737#include "core/XMLPort.h"
     38#include "Invader.h"
    3839
    3940namespace orxonox
     
    120121    {
    121122        lastTime = 0;
     123        if (getGame())
     124        {
     125            getGame()->levelUp();
     126            // SmartPtr<Invader> game = orxonox_cast<Invader>(getGametype());
     127           
     128        }
    122129        //level++
    123130    }
     
    151158            {
    152159                orxout() << "DIED!!!! " << endl;
     160                if (getGame())
     161                {
     162                    getGame()->costLife();
     163                    // SmartPtr<Invader> game = orxonox_cast<Invader>(getGametype());
     164                   
     165                }
    153166            }
    154167            return false;
     
    157170        // SUPER(InvaderShip, collidesAgainst, otherObject, contactPoint);
    158171    }
     172
     173    WeakPtr<Invader> InvaderShip::getGame()
     174    {
     175        if (game == NULL)
     176        {
     177            for (ObjectList<Invader>::iterator it = ObjectList<Invader>::begin(); it != ObjectList<Invader>::end(); ++it)
     178                game = *it;
     179        }
     180        return game;
     181    }
    159182}
  • code/branches/invaders/src/modules/invader/InvaderShip.h

    r9828 r9829  
    6565            virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
    6666        private:
     67
     68            WeakPtr<Invader> getGame();
     69            WeakPtr<Invader> game;
    6770            Camera* camera;
    6871            bool isFireing;
Note: See TracChangeset for help on using the changeset viewer.