Changeset 6945 in orxonox.OLD for branches/powerups/src/world_entities/power_ups
- Timestamp:
- Feb 1, 2006, 3:48:03 PM (19 years ago)
- Location:
- branches/powerups/src/world_entities/power_ups
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/powerups/src/world_entities/power_ups/power_up.cc
r6815 r6945 21 21 #include "primitive_model.h" 22 22 23 #include " assert.h"23 #include "load_param.h" 24 24 25 25 using namespace std; … … 29 29 this->setClassID(CL_POWER_UP, "PowerUp"); 30 30 31 this->respawnType = RESPAWN_ NONE;31 this->respawnType = RESPAWN_TIME; 32 32 this->respawnStart = 10; 33 33 this->model = NULL; … … 39 39 this->buildObbTree( 4); 40 40 this->sphereMaterial = new Material; 41 this->sphereMaterial->setTransparency(. 1);41 this->sphereMaterial->setTransparency(.8); 42 42 this->sphereMaterial->setDiffuse(r, g, b); 43 43 this->toList(OM_COMMON); … … 53 53 { 54 54 WorldEntity::loadParams(root); 55 LoadParam(root, "respawnType", this, PowerUp, setRespawnType); 56 LoadParam(root, "respawnTime", this, PowerUp, setRespawnTime); 55 57 } 56 58 … … 62 64 if(dynamic_cast<Extendable*>(entity)->pickup(this)) 63 65 { 64 this->respawnTime = this->respawnStart; 65 this->toList(OM_DEAD_TICK); 66 switch(respawnType) { 67 case RESPAWN_NONE: 68 this->toList(OM_DEAD); 69 break; 70 case RESPAWN_TIME: 71 this->toList(OM_DEAD_TICK); 72 this->respawnTime = this->respawnStart; 73 break; 74 } 66 75 } 67 76 } … … 72 81 this->respawnTime -= dt; 73 82 if(this->respawnTime <= 0) { 74 this->respawn();75 83 this->toList(OM_COMMON); 76 84 } … … 110 118 } 111 119 120 void PowerUp::setRespawnTime(const float respawnTime) 121 { 122 this->respawnStart = respawnTime; 123 } 112 124 113 125 -
branches/powerups/src/world_entities/power_ups/power_up.h
r6589 r6945 26 26 virtual void tick(float dt); 27 27 void setRespawnType(const char* type); 28 void setRespawnTime(const float respawn); 28 29 29 30 int writeState(const byte* data, int length, int sender); … … 33 34 PowerUp(float r, float g, float b); 34 35 virtual ~PowerUp (); 35 virtual void respawn() {};36 36 Model* model; 37 37 -
branches/powerups/src/world_entities/power_ups/weapon_power_up.cc
r6815 r6945 53 53 this->setClassID(CL_WEAPON_POWER_UP, "WeaponPowerUp"); 54 54 this->weaponXML = NULL; 55 this->weaponID = CL_NULL;56 55 this->weapon = NULL; 57 56 } … … 65 64 { 66 65 this->weaponXML = elem; 67 respawn();66 newWeapon(); 68 67 } 69 68 else … … 78 77 } 79 78 80 void WeaponPowerUp::respawn() 79 bool WeaponPowerUp::process(WeaponManager* manager) 80 { 81 if(manager->addWeapon(this->weapon)) { 82 newWeapon(); 83 } 84 else { 85 manager->increaseAmmunition(this->weapon->getProjectileType(), this->weapon->getEnergy()); 86 } 87 return true; 88 } 89 90 void WeaponPowerUp::newWeapon() 81 91 { 82 92 this->weapon = dynamic_cast<Weapon*>((weaponXML == NULL) 83 ? Factory::fabricate(static_cast<ClassID>( weaponID))93 ? Factory::fabricate(static_cast<ClassID>(this->weapon->getLeafClassID())) 84 94 : Factory::fabricate((TiXmlElement*)this->getXmlElem()->FirstChildElement("weapon"))); 85 95 this->model = this->weapon->getModel(0); … … 89 99 { 90 100 this->weapon = dynamic_cast<Weapon*>(Factory::fabricate(name)); 91 this->weaponID = (ClassID)this->weapon->getLeafClassID();92 101 this->model = this->weapon->getModel(0); 93 102 } -
branches/powerups/src/world_entities/power_ups/weapon_power_up.h
r6710 r6945 9 9 #include "power_up.h" 10 10 #include "weapons/weapon.h" 11 #include "weapons/weapon_manager.h" 11 12 12 13 /* FORWARD DEFINITION */ … … 27 28 virtual int readBytes(byte* data, int maxLength, int * reciever ); 28 29 29 protected: 30 virtual void respawn(); 30 bool process(WeaponManager* manager); 31 31 32 32 private: 33 33 void init(); 34 void newWeapon(); 34 35 private: 35 36 Weapon* weapon; 36 ClassID weaponID;37 37 const TiXmlElement* weaponXML; 38 38
Note: See TracChangeset
for help on using the changeset viewer.