Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11578


Ignore:
Timestamp:
Nov 20, 2017, 4:06:43 PM (7 years ago)
Author:
varxth
Message:

abgleich

Location:
code/branches/SOBv2_HS17/src/modules/superorxobros
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc

    r11577 r11578  
    6262
    6363        //Vars for movement of player
    64         moveUpPressed_ = false;
    65         moveDownPressed_ = false;
    66         moveLeftPressed_ = false;
    67         moveDownPressed_ = false;
    68         firePressed_ = false;
    69         collDisZ_ = 0;
     64        moveUpPressed_      = false;
     65        moveDownPressed_    = false;
     66        moveLeftPressed_    = false;
     67        moveDownPressed_    = false;
     68        firePressed_        = false;
     69        collDisZ_           = 0;
    7070
    7171        //Times and turning
    72         timeSinceLastFire_ = 0.0;
    73         lastSpeed_z = 0.0;
    74         pitch_ = 0.0;
    75         timeCounter_ = 0;
     72        timeSinceLastFire_  = 0.0;
     73        lastSpeed_z         = 0.0;
     74        pitch_              = 0.0;
     75        timeCounter_        = 0;
    7676
    7777        //Properties of player
    78         gotPowerUp_ = false;
    79         isColliding_ = true;
    80         particlespawner_ = NULL;
     78
     79        isColliding_        = true;
     80        particlespawner_    = NULL;
    8181
    8282        //Properties of players life
    83         predead_ = false;
    84         dead_ = false;
    85         lvlEnded_ = false;
     83        predead_            = false;
     84        dead_               = false;
     85        lvlEnded_           = false;
    8686        reachedLvlEndState_ = 0;
    8787
     88        // Properties concerning PowerUps and items
     89        PowerUpCounter_     = 0;
     90        maxPowerUp_         = 2;
     91        FireballPower       = 2;
    8892        //Properties of fireing Fireballs, NOTE! fireballs are fired with the moveUP Key, not with the fire key
    89         fireallowed_=true;
    90         firecooldown_=0;
     93        fireallowed_        = true;
     94        firecooldown_       = 0;
    9195
    9296       
     
    110114        SOBCastlestone* castlestone = orxonox_cast<SOBCastlestone*> (otherObject);
    111115        SOBFireball* fireball       = orxonox_cast<SOBFireball*>    (otherObject);
    112 
    113         //Check if otherObject is a powerup
     116        SOB* SOBGame                = orxonox_cast<SOB*>            (getGametype());
     117
     118
     119        //Check if otherObject is a powerup-mushroom
    114120        if (mush != nullptr && !(mush->hasCollided_)) {
    115121            otherObject->destroyLater();
    116             gotPowerUp_ = true;
    117             SOB* SOBGame = orxonox_cast<SOB*>(getGametype()); //Get the Gametype
     122
     123            PowerUpCounter_++;
     124            if(PowerUpCounter_ > maxPowerUp_)   PowerUpCounter_ = maxPowerUp_; // you had already the max
     125            else                                this->changeClothes();
     126
    118127            SOBGame->addMushroom(); // Tell the gametype to increase points
    119128            mush->hasCollided_ = true; // needed because of destroyLater takes some time and player should receive points only once
    120129
    121             // now, change the clothes of the Figure to red
    122             std::string name = "orxo_material_gross";
    123             this->changeClothes(name);
     130           
    124131           
    125132        }
     
    133140            if (getVelocity().z >= -20) {
    134141                // If player hasn't a power up, he dies. Else he shrinks and the gumba dies.
    135                 if(!gotPowerUp_){
     142                if(PowerUpCounter_ == 0){
    136143                    this->die();
    137                 } else{
    138                     gotPowerUp_ = false;
    139                    
    140                    
    141            // now, change the clothes of the Figure to old ones
    142             std::string name = "orxo_material";
    143             this->changeClothes(name);
     144                }
     145                else{
     146                    PowerUpCounter_--;
     147                    this->changeClothes();
     148
    144149                    gumba->destroyLater();
    145150                    gumba->hasCollided_ = true;
     
    149154            gumba->destroyLater();
    150155            gumba->hasCollided_ = true;
    151             SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
    152156            SOBGame->addGumba();
    153157
     
    164168        flagstone->hasCollided_ = true;
    165169        reachedLvlEndState_ = 1;
    166         SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
     170
    167171        SOBGame->setDone(true);
    168172        SOBGame->addPoints(flagstone->getPoints());
     
    237241    //if input blocked, then cancel every movement operation
    238242    if (!inputAllowed) {
    239         moveUpPressed_ = false;
    240         moveDownPressed_ = false;
    241         moveLeftPressed_ = false;
    242         moveRightPressed_ = false;
     243        moveUpPressed_      = false;
     244        moveDownPressed_    = false;
     245        moveLeftPressed_    = false;
     246        moveRightPressed_   = false;
    243247    }
    244248
     
    251255    if (hasLocalController())
    252256    {
     257        SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
    253258        Vector3 velocity = getVelocity();
    254259        Vector3 position = getPosition();
     
    259264        if (position.z < -100) {
    260265            dead_ = true;
    261             SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
    262266            SOBGame->setDone(true);
    263267        }
     
    268272            velocity.z = 0;
    269273            setVelocity(velocity);
    270             SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
     274           
    271275            if (firePressed_)
    272276                SOBGame->restart();
     
    322326
    323327        //If moveUp pressed, fire a fireball
    324         if(moveUpPressed_ && gotPowerUp_ && fireallowed_)
     328        if(moveUpPressed_ && (PowerUpCounter_ >= FireballPower) && fireallowed_)
    325329        {
    326330            spawnFireball();
    327             fireallowed_=false;
    328             firecooldown_=0;
     331            fireallowed_  = false;
     332            firecooldown_ = 0;
    329333        }
    330334
    331335        //Increase the firecooldown
    332         if(firecooldown_>0.5)
     336        if(firecooldown_> 0.5)
    333337        {
    334             fireallowed_=true;
     338            fireallowed_ = true;
    335339        }
    336340        if(!fireallowed_)
    337341        {
    338             firecooldown_+=dt;
     342            firecooldown_ += dt;
    339343        }
    340344
     
    371375        }
    372376
    373 
    374 
    375 
    376     }
    377 
    378 
     377    }
    379378
    380379    // Reset key variables
    381     moveUpPressed_ = false;
    382     moveDownPressed_ = false;
    383     moveLeftPressed_ = false;
    384     moveRightPressed_ = false;
     380    moveUpPressed_      = false;
     381    moveDownPressed_    = false;
     382    moveLeftPressed_    = false;
     383    moveRightPressed_   = false;
    385384
    386385    isColliding_ = false;
     
    430429
    431430// PRE: name is an existing name of a material. Example orxo_material for orxo_material.material in data_extern/materials
     431//      !!! PowerUpCounter_ has to be modified before changing the clothes!!!
    432432// POST: clothes of body of player are changed to name
    433 void SOBFigure::changeClothes(std::string& name){
     433void SOBFigure::changeClothes(){
     434            // clothes: white (basic), red (one PowerUp), orange (Fireball enabled)
     435            std::string clothes[] = {"orxo_material", "orxo_material_gross", "orxo_material_fire"};
     436
    434437            std::set<WorldEntity*> attachedObjects = this->getAttachedObjects();
    435438            std::set<WorldEntity*>::iterator it;
     
    439442                if (FiguresModel != nullptr)
    440443                {
    441 
    442                     FiguresModel->setSubMaterial(name, 4); // 4 is the body
    443 
     444                    FiguresModel->setSubMaterial(clothes[PowerUpCounter_] , 4); // 4 is the body
    444445                }
    445446            }   
    446447}
    447 
     448// PRE:
     449// POST: Player jumps out of the game, game is finished and can be restarted.
    448450void SOBFigure::die(){
    449451    Vector3 vel = getVelocity();
     
    451453    vel.z = 200;
    452454    setVelocity(vel);
    453     predead_=true;
     455    predead_= true;
    454456    SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
    455457    SOBGame->setDone(true);
  • code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h

    r11575 r11578  
    4646            virtual void boost(bool boost) override;
    4747            virtual  bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
    48             void changeClothes(std::string& name);
     48            void changeClothes();
    4949            void spawnFireball();
    5050            void die();
     
    5858            //Soooo many declarations
    5959            bool fireallowed_;
    60             bool gotPowerUp_;
     60
    6161            bool moveUpPressed_;
    6262            bool moveDownPressed_;
     
    7272            bool isColliding_;
    7373            WorldEntity* particlespawner_;
     74            int PowerUpCounter_;
     75            int maxPowerUp_;
     76            int FireballPower;
    7477            int sgn(float x);
    7578            int reachedLvlEndState_;
Note: See TracChangeset for help on using the changeset viewer.