Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 11, 2017, 2:14:15 PM (6 years ago)
Author:
varxth
Message:

better than evver

File:
1 edited

Legend:

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

    r11647 r11650  
    3131    @file SOBGumbaBoss.cc
    3232    @brief A Boss Gumba, which shoots small Gumbas
    33 */
     33**/
    3434
    3535#include "SOB.h"
     
    5454        RegisterObject(SOBGumbaBoss);
    5555
    56         gumbaMaxTime_ = 1;
    57         gumbaTime_ = 0;
    58         maxGumbas = 2; //Max Gumbas spawnable by a Boss
     56        gumbaMaxTime_   = 1;
     57        gumbaTime_      = 0;
     58        maxGumbas_      = 10; //Max Gumbas spawnable by a Boss
     59        jumpTime_       = 0;
     60        jumpTimeMax_    = 5;
    5961       
    6062    }
     
    6365    bool SOBGumbaBoss::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
    6466
     67        SOBGumba*       gumba       = orxonox_cast<SOBGumba*>(otherObject);
     68        SOBGumbaBoss*   gumbaBoss   = orxonox_cast<SOBGumbaBoss*>(otherObject);
     69
     70        if (gumba != nullptr && gumbaBoss == nullptr && !(gumba->hasCollided_)) {
     71            gumba->destroyLater();
     72            gumba->hasCollided_ = true;
     73        }
     74
     75
    6576        //Every object with mass -1 does not change the direction of the GumbaBoss. For example the ground floor! The other objects switch the direction of the GumbaBoss.
    66         if (changeAllowed_ && otherObject->getMass() != -1) {
     77        else if (changeAllowed_ && otherObject->getMass() != -1) {
    6778            goesRight_ = !goesRight_;
    6879            changeAllowed_ = false;
     
    7889    {
    7990        SUPER(SOBGumbaBoss, tick, dt);
     91        gumbaTime_ += dt;
     92        jumpTime_  += dt;
    8093
    8194        if (!changeAllowed_) {
     
    89102        }
    90103   
    91         gumbaTime_ += dt;
    92104
    93105        if(gumbaTime_ > gumbaMaxTime_){ //Spawn Gumba
     
    103115
    104116
    105             if(gumbaCounter<maxGumbas){    //only maxGumbas are allowed at one time per Gumbaboss
     117            if(gumbaCounter<maxGumbas_){    //only maxGumbas are allowed at one time per Gumbaboss
    106118                spawnGumba();
    107119                gumbaTime_ = 0;
     
    114126
    115127        Vector3 velocity = getVelocity();
    116         velocity.z -= gravityAcceleration_*dt;
     128        if(jumpTime_ > jumpTimeMax_){
     129            velocity.z = speed_*15;
     130            jumpTime_ = 0;
     131        }
     132        else{
     133            velocity.z -= gravityAcceleration_*dt;
     134        }
     135
    117136        velocity.x = dir*speed_;
    118137        setVelocity(velocity);
     
    132151        {
    133152            gumba->addTemplate("gumbaShootable");
    134             bool direction = ((this->getWorldOrientation().getRoll().valueRadians())>-1.6&&(this->getWorldOrientation().getRoll().valueRadians()<1.6));
    135             gumba->setDirection(direction);
    136             if(direction)
     153            gumba->setDirection(goesRight_);
     154            if(goesRight_)
    137155            {
    138156                spawnpos.x+=20;
     
    148166
    149167        Vector3 velocity = gumba->getVelocity();
    150         velocity.z -= 100;
     168        velocity.x += (2*goesRight_ -1) * 100;
     169        velocity.z += 200;
    151170        gumba->setVelocity(velocity);
    152171     }
Note: See TracChangeset for help on using the changeset viewer.