Changeset 11520
- Timestamp:
- Oct 30, 2017, 4:12:04 PM (7 years ago)
- Location:
- code/branches/AsteroidMining_HS17
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AsteroidMining_HS17/data/levels/AsteroidFarming.oxw
r11508 r11520 76 76 <visibility> 77 77 <EventListener event="flying4" /> 78 78 79 </visibility> 79 80 </events> … … 84 85 <BoxCollisionShape position="0,0,0" halfExtents="15,15,15" /> 85 86 </collisionShapes> 87 </Pawn> 86 88 87 </Pawn> 89 90 <!-----AsteroidMinable ---> 91 92 <AsteroidMinable size=5 position="0,-500,0" /> 88 93 89 94 -
code/branches/AsteroidMining_HS17/src/orxonox/worldentities/pawns/AsteroidMinable.cc
r11508 r11520 66 66 67 67 #include "controllers/FormationController.h" 68 #include "pickup/items/HealthPickup.h" 69 #include "pickup/PickupSpawner.h" 70 #include "pickup/Pickup.h" 68 71 69 72 namespace orxonox … … 74 77 { 75 78 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)); 91 80 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 92 89 93 90 } … … 101 98 { 102 99 SUPER(AsteroidMinable, XMLPort, xmlelement, mode); 100 // XMLPortParam(PickupSpawner, "pickup", setPickupTemplateName, getPickupTemplateName, xmlelement, mode); 101 XMLPortParam(AsteroidMinable, "size", setSize,getSize, xmlelement, mode); 102 103 103 } 104 104 … … 107 107 SUPER(AsteroidMinable, XMLEventPort, xmlelement, mode); 108 108 109 XMLPortEventState(AsteroidMinable, BaseObject, "vulnerability", setVulnerable, xmlelement, mode);109 //XMLPortEventState(AsteroidMinable, BaseObject, "vulnerability", setVulnerable, xmlelement, mode); 110 110 } 111 111 … … 124 124 } 125 125 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 126 135 void AsteroidMinable::death() //ueberschreiben 127 136 { 128 137 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 129 155 if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_)) 130 156 { … … 138 164 } 139 165 166 167 void 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 } 140 190 } 191 192 193 194 195 } 196 197 141 198 142 199 -
code/branches/AsteroidMining_HS17/src/orxonox/worldentities/pawns/AsteroidMinable.h
r11508 r11520 53 53 virtual ~AsteroidMinable(); 54 54 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 55 61 56 62 protected: … … 58 64 float asteroidVersion; // Bodenstrich-Konvention?, 59 65 // Wert zwischen 1 und 6 (Spezialdinger?), die Mesh-Form 60 float asteroidSize;66 float size; 61 67 bool generateSmaller; 68 virtual void death(); 69 70 62 71 63 72 private: 73 void registerVariables(); 74 virtual void spawnChildren(); 75 76 Context* context; 64 77 65 78
Note: See TracChangeset
for help on using the changeset viewer.