Changeset 11561
- Timestamp:
- Nov 13, 2017, 4:34:53 PM (7 years ago)
- Location:
- code/branches/AsteroidMining_HS17
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AsteroidMining_HS17/data/levels/AsteroidFarming.oxw
r11551 r11561 3 3 description = "Testing the Asteroid Mining Project, PPS HS 17" 4 4 tags = "test" 5 screenshot = " mytestlevel.png"5 screenshot = "AsteroidFarming.png" 6 6 /> 7 7 … … 24 24 <?lua include("includes/notifications.oxi") ?> 25 25 26 26 27 <Scene 27 28 ambientlight = "0.8, 0.8, 0.8" 28 29 skybox = "Orxonox/Starbox" 29 30 > 31 32 <?lua 33 include("includes/pickups.oxi") 34 ?> 30 35 31 36 <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/> -
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc
r11553 r11561 41 41 /* 42 42 Veraenderungstagebuch 43 - Dynamische Definition von Argumenten funktioniert nicht (Immer auf default Values gesetzt) 44 ---> Was tut registerVariable? Wann werden die Argumente im XML-File angewendet? 45 (Fall Konstruktor -> Methoden: Beim ersten Tick initialisieren?) 46 ---> Mesh-Teil klappt, Hitbox noch nicht. 47 ---> Maximale Hitpunkte = 200? 48 ---> Meshgroesse passt, aber Hitbox wird iwieso nicht mehr generiert. 49 50 - Neue Asteroiden generieren -> Absturz 51 - Pickup spawning -> Absturz 52 53 o hat's mit den Context-Eingenschaften zu tun? Je einen Neuen/Aktuellen besorgen? 54 55 Nicht Pointer uebergeben? 56 - Manchmal: Absturz bei Zerstoerung eines Asteroiden 57 - Was tut 'Register Variables'? 58 59 o Error messages: change context::pickups to something else 43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 44 45 KNACKPUNKTE: 46 o Collision Shape-Problem (Funktioniert nur, wenn im Konstruktor) 47 o Maximale Hitpunkte = 200? 48 49 o Neue Asteroiden generieren -> Absturz 50 ---> Weil Elterndings zerstoert wird? 51 ---> Nicht moeglich, zur Laufzeit zu generieren? 52 53 o Pickups: setMaxSpawned funktioniert nicht 60 54 61 55 62 56 OFFEN: 63 o Add custom pickup 'resources' 64 65 66 67 Erlegt: 68 o Rand() geht bis zu riesigen Nummern! 57 o Add custom pickup 'resources'. Weird template stuff -> Problems setting 'size' and other properties? setNumber of Resources. 58 o Explosion parts 59 o custom HUD 60 61 HANDBUCH: 62 o im Level-File includes/pickups.oxi importieren. 63 64 Anpassungen Pickup-Zeug: 65 o Pickup.h: Zugriffsänderung createSpawner 66 o PickupSpawner.h: Zugriffsrechte setPickupTemplateName() und setMaxSpawnedItems() 67 68 ERLEGT: 69 o Rand() geht bis zu riesigen Nummern! 70 o Pickupgenerierung: vgl. Anpassungen. 71 o Dummes fisch-- statt fisch++ , Endlosschleife! 72 o Dynamische Definition -> putStuff-Methode, Werte noch nicht durchgesickert. 73 o Error-Nachricht: Einfach Argumente leer lassen. 69 74 */ 70 75 … … 120 125 this->bVulnerable_ = true; 121 126 122 123 124 127 // Default Values 125 128 this->generateSmaller = true; 126 //this->size = this->getSize(); // Value doesn-t get accepted. Weird. 127 this->size = 10; 129 this->size = 10; // customSize 128 130 this->context = context; 129 131 this->initialised = false; 130 132 //this->roll = rand()*5; //etwas Drehung. richtige Variable 131 132 133 134 135 136 133 137 134 … … 142 139 cs->setRadius((this->size)*2); //OFFEN: Feinabstimmung der Radien 143 140 this->attachCollisionShape(cs); 144 145 146 141 147 142 … … 165 160 // random one of the 6 shapes 166 161 char meshThingy[] = ""; 167 sprintf(meshThingy, "ast%.0f.mesh", (round((5*(double)rand()/(double)RAND_MAX))+1)); 168 // sprintf(str, "Value of Pi = %f", M_PI); 169 //char meshThingy[] = "ast5.mesh"; 162 sprintf(meshThingy, "ast%.0f.mesh", (round((5*(double)rand()/(double)RAND_MAX))+1)); // sprintf(str, "Value of Pi = %f", M_PI); 170 163 hull->setMeshSource(meshThingy); 171 164 hull->setScale(this->size); 172 165 this->attach(hull); 173 //hull->setPosition(this->getPosition());174 166 175 167 // Collision shape … … 240 232 { 241 233 242 243 //Spawn Pickup // Create at start already? ( Hidden in CollisionShape) 244 HealthPickup* hP = new HealthPickup(this->context); 245 if(hP == nullptr){ 246 orxout(internal_error, context::pickups) << "Weird, can't create new HealthPickup." << endl; 234 // Stuff that can be harvested. 235 PickupSpawner* thingy = new PickupSpawner(this->context); 236 237 // OFFEN: more precise size relation in custom resource pickup. 238 char tname[] = ""; // can-t overwrite strings easily in C (strcat etc.) 239 if(this->size <= 5){ 240 strcat(tname, "smallmunitionpickup"); 241 }else if(this->size <= 20){ 242 strcat(tname, "mediummunitionpickup"); 243 }else{ 244 strcat(tname, "hugemunitionpickup"); 247 245 } 248 // hP->setPosition(this->getPosition()); // Does not have a member named 'setPosition' (Inherits from Pickup//BAse Object) 249 250 // invoke spawnPickup on the pikcup itself? (returns bool, creates the hideous thing) 251 // HealthPickup inherits from Pickup. 252 // createSpawner is protected ->can be used as well in inheriting classes, but not here! 253 // bool unnecessary = hP->createSpawner(); 254 // hP->setPosition(this->getPosition()); 255 //OFFEN: Add custom pickup 'resources' 256 257 // createPickup is private, hP is of type Pickup! 258 // CreateDroppedPickup returns a PickupSpawner! 259 // PickupSpawner don't have public set methods, just that ugly 'factory method' which returns another PickupSpawner 260 // PickupSpawner* thingy = new PickupSpawner(this->context); 261 // What is Pickupable? says: Interface, no way to set type. Why do I even need the spawner? Trigger Distance? 246 //orxout() << "Zeugsname:" << tname << endl; 247 thingy->setPickupTemplateName(tname); 248 thingy->setPosition(this->getPosition()); 249 //thingy->setMaxSpawnedItems(1); // Somehow doesn-t work yet. 250 thingy->setRespawnTime(0.1f);// instantly 262 251 263 264 // Plan: Solve the Pickupable mystery, try to adapt the spawner somehow. Ask to modify it if that fails. (Change method types) 265 266 267 // PickupSpawner* thingy = (new PickupSpawner(this->context))->createDroppedPickup(this->context, hP, nullptr, 10); 268 // /*static*/ PickupSpawner* PickupSpawner::createDroppedPickup(Context* context, Pickupable* pickup, PickupCarrier* carrier, float triggerDistance) 269 270 271 272 // if(thingy == nullptr){ 273 // orxout(internal_error, context::pickups) << "Weird, can't create new PickupSpawner." << endl; 274 // } 275 // thingy->setPosition(this->getPosition()); 276 // thingy->setMaxSpawnedItems(1);//Default is 1 already, private anyways 277 278 279 280 // // Smaller Parts 281 // if(this->generateSmaller){ 282 // this->spawnChildren(); 283 // } 252 orxout() << "AsteroidMining::Death(): Passed Pickup stuff!" << endl; 253 254 255 256 257 258 // Smaller Parts = 'Children' 259 if(this->generateSmaller){ 260 this->spawnChildren(); 261 } 262 263 264 284 265 285 266 … … 290 271 this->destroyLater(); 291 272 this->setDestroyWhenPlayerLeft(false); 273 274 292 275 // pawn -> addExplosionPart 293 276 // this->goWithStyle(); 294 277 orxout() << "Wieder retour in death() geschafft. " << endl; 295 278 296 279 // if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_)) … … 310 293 // Spawn smaller Children 311 294 int massRem = this->size-1; //some mass is lost 312 int num = round((massRem-1)*(double)rand() / (double)RAND_MAX)+1; // random number of children, at least one 313 massRem = massRem-num; 295 int num = round((massRem-1)*(double)rand() / (double)RAND_MAX)+1; // random number of children, at least one // Tweak towards bigger junks? 296 num = 1; // zum Testen mal nur einen generieren. 297 298 massRem = massRem-num; 314 299 int extra = 0; 315 for(int fisch=num; fisch>=1; fisch++){ 300 301 302 orxout() << "Number of Children: " << num << endl; 303 304 305 for(int fisch=num; fisch>=1; fisch--){ 316 306 // to distribute remaining mass 317 307 if(fisch==1){ … … 320 310 extra = round(massRem*(double)rand() / (double)RAND_MAX); 321 311 massRem = massRem-extra; 312 322 313 } 323 314 324 315 orxout() << "Mass chosen: " << extra+1 << endl; 316 317 orxout() << "AsteroidMining::spawnChildren(): Inside for-loop." << endl; 325 318 326 319 //Spawn this child Game crashes! … … 328 321 // if(!(child == nullptr)){//Errorgebastel 329 322 330 323 // Position zu spaet gesetzt? Tick nicht atomar -> falsche Groesse evtl? 331 324 332 325 if(child == nullptr){ … … 342 335 child->setPosition(this->getPosition() + Vector3(num*5, 0, 0)); 343 336 337 338 orxout() << "Done: Creating new Asteroid" << endl; 339 344 340 // } 345 341 … … 355 351 356 352 } 353 orxout() << "Leaving spawnChildren() method. " << endl; 357 354 } 358 355 -
code/branches/AsteroidMining_HS17/src/modules/pickup/Pickup.h
r11071 r11561 145 145 virtual void changedPickedUp(void) override; //!< Should be called when the pickup has transited from picked up to dropped or the other way around. 146 146 147 148 virtual bool createSpawner(void) override; //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 149 150 147 151 protected: 148 virtual bool createSpawner(void) override; //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.149 152 150 153 /** -
code/branches/AsteroidMining_HS17/src/modules/pickup/PickupSpawner.h
r11071 r11561 114 114 {return this->pickupTemplate_; } 115 115 116 117 void setPickupTemplateName(const std::string& name); 118 void setMaxSpawnedItems(int items); //!< Sets the maximum number of spawned items. 119 120 inline void setRespawnTime(float time) 121 { this->respawnTime_ = time; } 122 123 116 124 private: 117 125 void initialize(void); … … 141 149 @param time New time after which this gets re-actived. 142 150 */ 143 inline void setRespawnTime(float time)144 { this->respawnTime_ = time; }145 151 146 void setMaxSpawnedItems(int items); //!< Sets the maximum number of spawned items.147 152 148 void setPickupTemplateName(const std::string& name); 153 149 154 void setPickupTemplate(Template* temp); 150 155
Note: See TracChangeset
for help on using the changeset viewer.