Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11520


Ignore:
Timestamp:
Oct 30, 2017, 4:12:04 PM (7 years ago)
Author:
remartin
Message:

Added spawning of pickup and smaller asteroids, doesn't work yet.

Location:
code/branches/AsteroidMining_HS17
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/AsteroidMining_HS17/data/levels/AsteroidFarming.oxw

    r11508 r11520  
    7676          <visibility>
    7777            <EventListener event="flying4" />
     78
    7879          </visibility>
    7980        </events>
     
    8485            <BoxCollisionShape position="0,0,0" halfExtents="15,15,15" />
    8586        </collisionShapes>
     87    </Pawn>
    8688
    87     </Pawn>
     89
     90    <!-----AsteroidMinable --->
     91
     92    <AsteroidMinable size=5 position="0,-500,0" />
    8893
    8994   
  • code/branches/AsteroidMining_HS17/src/orxonox/worldentities/pawns/AsteroidMinable.cc

    r11508 r11520  
    6666
    6767#include "controllers/FormationController.h"
     68#include "pickup/items/HealthPickup.h"
     69#include "pickup/PickupSpawner.h"
     70#include "pickup/Pickup.h"
    6871
    6972namespace orxonox
     
    7477    {
    7578        RegisterObject(AsteroidMinable);
    76 
    77         this->bAlive_ = true;
    78         this->bVulnerable_ = true;
    79 
    80         this->health_ = 0;
    81         this->maxHealth_ = 0;
    82         this->initialHealth_ = 0;
    83 
    84         this->damageMultiplier_ = 1;
    85 
    86         this->spawnparticleduration_ = 3.0f;
    87 
    88         this->aimPosition_ = Vector3::ZERO;
    89 
    90         this->setRadarObjectColour(ColourValue::Yellow);
     79        this->setRadarObjectColour(ColourValue(1.0f, 1.0f, 0.0f, 1.0f));
    9180        this->setRadarObjectShape(RadarViewable::Shape::Dot);
     81
     82        this->size = 5;
     83        this->context = context;
     84
     85
     86
     87        //      <Model position="0,-40,40" yaw="90" pitch="-90" roll="0" scale="4" mesh="ast6.mesh" />
     88
    9289 
    9390    }
     
    10198    {
    10299        SUPER(AsteroidMinable, XMLPort, xmlelement, mode);
     100        //        XMLPortParam(PickupSpawner, "pickup", setPickupTemplateName, getPickupTemplateName, xmlelement, mode);
     101        XMLPortParam(AsteroidMinable, "size", setSize,getSize, xmlelement, mode);
     102
    103103    }
    104104
     
    107107        SUPER(AsteroidMinable, XMLEventPort, xmlelement, mode);
    108108
    109         XMLPortEventState(AsteroidMinable, BaseObject, "vulnerability", setVulnerable, xmlelement, mode);
     109        //XMLPortEventState(AsteroidMinable, BaseObject, "vulnerability", setVulnerable, xmlelement, mode);
    110110    }
    111111
     
    124124    }
    125125
     126    void AsteroidMinable::setSize(float s){
     127        this->size = s;
     128        this->health_ = 200*s;
     129    }
     130
     131    float AsteroidMinable::getSize(){
     132        return this->size;
     133    }
     134
    126135    void AsteroidMinable::death() //ueberschreiben
    127136    {
    128137        this->setHealth(1);
     138
     139
     140
     141        // Spawn Pickup
     142        HealthPickup* hP = new HealthPickup(context);
     143        //OFFEN: Add custom pickup 'resources'
     144        PickupSpawner* thingy = new PickupSpawner(context);
     145        thingy->createDroppedPickup(context, hP, nullptr, 10);
     146//    /*static*/ PickupSpawner* PickupSpawner::createDroppedPickup(Context* context, Pickupable* pickup, PickupCarrier* carrier, float triggerDistance)
     147   
     148
     149
     150
     151        this->spawnChildren();
     152
     153
     154
    129155        if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
    130156        {
     
    138164    }
    139165
     166
     167void AsteroidMinable::spawnChildren(){
     168    // Spawn smaller Children
     169    int massRem = this->size-1; //some mass is lost
     170    int num = round(massRem*rand()); // random number of children
     171    massRem = massRem-num;
     172    int extra = 0;
     173    for(int fisch=num; fisch>=1; fisch++){
     174        // to distribute remaining mass
     175        if(fisch==1){
     176            extra = massRem;
     177        }else{
     178            extra = round(massRem*rand());
     179            massRem = massRem-extra;
     180        }
     181        //Spawn this child
     182        AsteroidMinable* child = new AsteroidMinable(context);
     183        child->setSize(extra + 1);
     184           
     185        //OFFEN:Kollision der Kinder verhindern
     186        //Relativ zu Elternteil automatisch?
     187        //Typ position:rand()*Vektoriwas?
     188        child->setPosition(this->getCarrierPosition());
     189    }
    140190}
     191
     192
     193
     194
     195}
     196
     197
    141198
    142199
  • code/branches/AsteroidMining_HS17/src/orxonox/worldentities/pawns/AsteroidMinable.h

    r11508 r11520  
    5353            virtual ~AsteroidMinable();
    5454            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     55            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override;
     56            virtual void tick(float dt) override;
     57
     58            virtual void setSize(float f);
     59            virtual float getSize();
     60
    5561
    5662        protected:
     
    5864            float asteroidVersion; // Bodenstrich-Konvention?,
    5965            // Wert zwischen 1 und 6 (Spezialdinger?), die Mesh-Form
    60             float asteroidSize;
     66            float size;
    6167            bool generateSmaller;
     68            virtual void death();
     69
     70
    6271
    6372        private:
     73            void registerVariables();
     74            virtual void spawnChildren();
     75
     76            Context* context;
    6477
    6578
Note: See TracChangeset for help on using the changeset viewer.