Changeset 7350 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Apr 19, 2006, 3:42:23 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/playable.cc
r7347 r7350 16 16 17 17 #include "playable.h" 18 19 #include "weapons/weapon_manager.h"20 18 #include "event_handler.h" 19 21 20 #include "player.h" 22 21 #include "state.h" … … 25 24 #include "util/loading/load_param.h" 26 25 27 #include "world_entities/projectiles/projectile.h"28 29 26 #include "power_ups/weapon_power_up.h" 30 27 #include "power_ups/param_power_up.h" … … 38 35 39 36 #include "effects/explosion.h" 37 38 #include "shell_command.h" 39 SHELL_COMMAND(orxoWeapon, Playable, addSomeWeapons_CHEAT); 40 40 41 41 … … 122 122 * @param slotID the slotID to add the Weapon to. 123 123 */ 124 void Playable::addWeapon(Weapon* weapon, int configID, int slotID) 125 { 126 this->weaponMan.addWeapon(weapon, configID, slotID); 127 128 this->weaponConfigChanged(); 124 bool Playable::addWeapon(Weapon* weapon, int configID, int slotID) 125 { 126 if(this->weaponMan.addWeapon(weapon, configID, slotID)) 127 { 128 this->weaponConfigChanged(); 129 return true; 130 } 131 else 132 { 133 if (weapon != NULL) 134 PRINTF(2)("Unable to add Weapon (%s::%s) to %s::%s\n", 135 weapon->getClassName(), weapon->getName(), this->getClassName(), this->getName()); 136 else 137 PRINTF(2)("No weapon defined\n"); 138 return false; 139 140 } 129 141 } 130 142 … … 170 182 } 171 183 184 /** 185 * @brief a Cheat that gives us some Weapons 186 */ 187 void Playable::addSomeWeapons_CHEAT() 188 { 189 PRINTF(2)("ADDING WEAPONS - you cheater\n"); 190 this->addWeapon(Weapon::createWeapon(CL_HYPERBLASTER)); 191 this->addWeapon(Weapon::createWeapon(CL_TURRET)); 192 this->addWeapon(Weapon::createWeapon(CL_AIMING_TURRET)); 193 this->addWeapon(Weapon::createWeapon(CL_CANNON)); 194 this->addWeapon(Weapon::createWeapon(CL_TARGETING_TURRET)); 195 PRINTF(2)("ADDING WEAPONS FINISHED\n"); 196 } 172 197 173 198 /** -
trunk/src/world_entities/playable.h
r7347 r7350 43 43 // Weapon and Pickups 44 44 virtual bool pickup(PowerUp* powerUp); 45 voidaddWeapon(Weapon* weapon, int configID = -1, int slotID = -1);45 bool addWeapon(Weapon* weapon, int configID = -1, int slotID = -1); 46 46 void removeWeapon(Weapon* weapon); 47 47 void nextWeaponConfig(); … … 49 49 inline WeaponManager& getWeaponManager() { return this->weaponMan; }; 50 50 void weaponConfigChanged(); 51 void addSomeWeapons_CHEAT(); 51 52 52 53 -
trunk/src/world_entities/weapons/aiming_turret.cc
r7221 r7350 48 48 { 49 49 this->init(); 50 this->loadParams(root); 50 if (root != NULL) 51 this->loadParams(root); 51 52 } 52 53 -
trunk/src/world_entities/weapons/weapon.cc
r7221 r7350 26 26 #include "util/loading/resource_manager.h" 27 27 #include "class_list.h" 28 #include "util/loading/factory.h" 28 29 #include "util/loading/load_param.h" 29 30 #include "state.h" … … 34 35 35 36 #include "glgui_bar.h" 37 38 using namespace std; 36 39 37 40 //////////////////// … … 66 69 67 70 /** 71 * @brief creates a new Weapon of type weaponID and returns it. 72 * @param weaponID the WeaponID type to create. 73 * @returns the newly created Weapon. 74 */ 75 Weapon* Weapon::createWeapon(ClassID weaponID) 76 { 77 BaseObject* createdObject = Factory::fabricate(weaponID); 78 if (createdObject != NULL) 79 { 80 if (createdObject->isA(CL_WEAPON)) 81 return dynamic_cast<Weapon*>(createdObject); 82 else 83 { 84 delete createdObject; 85 return NULL; 86 } 87 } 88 } 89 90 /** 68 91 * initializes the Weapon with ALL default values 69 92 * … … 72 95 void Weapon::init() 73 96 { 97 this->setClassID(CL_WEAPON, "Weapon"); 74 98 this->currentState = WS_INACTIVE; //< Normaly the Weapon is Inactive 75 99 this->requestedAction = WA_NONE; //< No action is requested by default … … 382 406 switch (action) 383 407 { 384 case WA_SHOOT:385 return this->fireW();386 break;387 case WA_CHARGE:388 return this->chargeW();389 break;390 case WA_RELOAD:391 return this->reloadW();392 break;393 case WA_DEACTIVATE:394 return this->deactivateW();395 break;396 case WA_ACTIVATE:397 return this->activateW();398 break;408 case WA_SHOOT: 409 return this->fireW(); 410 break; 411 case WA_CHARGE: 412 return this->chargeW(); 413 break; 414 case WA_RELOAD: 415 return this->reloadW(); 416 break; 417 case WA_DEACTIVATE: 418 return this->deactivateW(); 419 break; 420 case WA_ACTIVATE: 421 return this->activateW(); 422 break; 399 423 } 400 424 } … … 495 519 PRINTF(4)("Reloading Weapon %s\n", this->getName()); 496 520 if (this->ammoContainer.get() != NULL && 497 521 unlikely(this->energy + this->ammoContainer->getStoredEnergy() < this->minCharge)) 498 522 { 499 523 this->requestAction(WA_DEACTIVATE); … … 643 667 switch (action) 644 668 { 645 case WA_SHOOT:646 return "shoot";647 break;648 case WA_CHARGE:649 return "charge";650 break;651 case WA_RELOAD:652 return "reload";653 break;654 case WA_ACTIVATE:655 return "activate";656 break;657 case WA_DEACTIVATE:658 return "deactivate";659 break;660 case WA_SPECIAL1:661 return "special1";662 break;663 default:664 return "none";665 break;669 case WA_SHOOT: 670 return "shoot"; 671 break; 672 case WA_CHARGE: 673 return "charge"; 674 break; 675 case WA_RELOAD: 676 return "reload"; 677 break; 678 case WA_ACTIVATE: 679 return "activate"; 680 break; 681 case WA_DEACTIVATE: 682 return "deactivate"; 683 break; 684 case WA_SPECIAL1: 685 return "special1"; 686 break; 687 default: 688 return "none"; 689 break; 666 690 } 667 691 } … … 706 730 switch (state) 707 731 { 708 case WS_SHOOTING:709 return "shooting";710 break;711 case WS_CHARGING:712 return "charging";713 break;714 case WS_RELOADING:715 return "reloading";716 break;717 case WS_ACTIVATING:718 return "activating";719 break;720 case WS_DEACTIVATING:721 return "deactivating";722 break;723 case WS_IDLE:724 return "idle";725 break;726 case WS_INACTIVE:727 return "inactive";728 break;729 default:730 return "none";731 break;732 } 733 } 732 case WS_SHOOTING: 733 return "shooting"; 734 break; 735 case WS_CHARGING: 736 return "charging"; 737 break; 738 case WS_RELOADING: 739 return "reloading"; 740 break; 741 case WS_ACTIVATING: 742 return "activating"; 743 break; 744 case WS_DEACTIVATING: 745 return "deactivating"; 746 break; 747 case WS_IDLE: 748 return "idle"; 749 break; 750 case WS_INACTIVE: 751 return "inactive"; 752 break; 753 default: 754 return "none"; 755 break; 756 } 757 } -
trunk/src/world_entities/weapons/weapon.h
r7221 r7350 88 88 Weapon (); 89 89 virtual ~Weapon (); 90 static Weapon* createWeapon(ClassID weaponID); 90 91 91 92 void init(); -
trunk/src/world_entities/weapons/weapon_manager.cc
r7193 r7350 17 17 */ 18 18 19 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON19 #define DEBUG_SPECIAL_MODULE 4 //DEBUG_MODULE_WEAPON 20 20 21 21 #include "weapon_manager.h" … … 113 113 114 114 /** 115 * loads the settings of the WeaponManager115 * @brief loads the settings of the WeaponManager 116 116 * @param root the XML-element to load from 117 117 */ … … 133 133 134 134 /** 135 * loads a Weapon onto the WeaponManager135 * @brief loads a Weapon onto the WeaponManager 136 136 * @param root the XML-element to load the Weapons from 137 137 */ … … 148 148 149 149 /** 150 * sets the Parent of the WeaponManager.150 * @brief sets the Parent of the WeaponManager. 151 151 * @param parent the parent of the WeaponManager 152 152 * … … 168 168 169 169 /** 170 * sets the number of Slots the WeaponManager has170 * @brief sets the number of Slots the WeaponManager has 171 171 * @param slotCount the number of slots 172 172 */ … … 181 181 182 182 /** 183 * sets the position of the Slot relative to the parent183 * @brief sets the position of the Slot relative to the parent 184 184 * @param slot the slot to set-up 185 185 * @param position the position of the given slot … … 198 198 199 199 /** 200 * sets the relative rotation of the slot to its parent200 * @brief sets the relative rotation of the slot to its parent 201 201 * @param slot the slot to set-up 202 202 * @param rotation the relative rotation of the given slot … … 210 210 211 211 /** 212 * adds a weapon to the selected weaponconfiguration into the selected slot212 * @brief adds a weapon to the selected weaponconfiguration into the selected slot 213 213 * @param weapon the weapon to add 214 214 * @param configID an identifier for the slot: number between 0..7 if not specified: slotID=next free slot
Note: See TracChangeset
for help on using the changeset viewer.