[Orxonox-commit 6033] r10692 - in code/branches/fabienHS15: data/levels data/levels/includes data/levels/templates src/modules/pickup src/modules/pickup/items src/orxonox/worldentities/pawns
fvultier at orxonox.net
fvultier at orxonox.net
Sun Oct 25 19:09:12 CET 2015
Author: fvultier
Date: 2015-10-25 19:09:11 +0100 (Sun, 25 Oct 2015)
New Revision: 10692
Added:
code/branches/fabienHS15/src/modules/pickup/items/MunitionPickup.cc
code/branches/fabienHS15/src/modules/pickup/items/MunitionPickup.h
Modified:
code/branches/fabienHS15/data/levels/includes/pickups.oxi
code/branches/fabienHS15/data/levels/pickups.oxw
code/branches/fabienHS15/data/levels/templates/pickupRepresentationTemplates.oxt
code/branches/fabienHS15/src/modules/pickup/PickupRepresentation.cc
code/branches/fabienHS15/src/modules/pickup/items/CMakeLists.txt
code/branches/fabienHS15/src/modules/pickup/items/DronePickup.h
code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.cc
code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.h
Log:
Modified: code/branches/fabienHS15/data/levels/includes/pickups.oxi
===================================================================
--- code/branches/fabienHS15/data/levels/includes/pickups.oxi 2015-10-25 18:04:23 UTC (rev 10691)
+++ code/branches/fabienHS15/data/levels/includes/pickups.oxi 2015-10-25 18:09:11 UTC (rev 10692)
@@ -77,6 +77,22 @@
inventoryRepresentation = "dropPickup"
/>
+<PickupRepresentation
+ name = "destroy"
+ pickupName = "Destroy Pickup"
+ pickupDescription = "Destroy all pickups you have."
+ spawnerTemplate = "destroypickupRepresentation"
+ inventoryRepresentation = "detroyPickup"
+/>
+
+<PickupRepresentation
+ name = "destroycarrier"
+ pickupName = "Destroy Carrier Pickup"
+ pickupDescription = "destroys you."
+ spawnerTemplate = "destroycarrierpickupRepresentation"
+ inventoryRepresentation = "destroyCarrierPickup"
+/>
+
<!-- Speed pickups -->
<PickupRepresentation
@@ -137,6 +153,32 @@
inventoryRepresentation = "HugeInvisible"
/>
+<!-- Munition pickups -->
+
+<PickupRepresentation
+ name = "smallmunitionpickup"
+ pickupName = "Small munition"
+ pickupDescription = "Gives a small amount of munition."
+ spawnerTemplate = "smallmunitionpickupRepresentation"
+ inventoryRepresentation = "SmallMunition"
+/>
+
+<PickupRepresentation
+ name = "mediummunitionpickup"
+ pickupName = "Medium munition"
+ pickupDescription = "Gives a medium amount of munition."
+ spawnerTemplate = "mediummunitionpickupRepresentation"
+ inventoryRepresentation = "MediumMunition"
+/>
+
+<PickupRepresentation
+ name = "hugemunitionpickup"
+ pickupName = "Huge munition"
+ pickupDescription = "Gives a huge amount of munition."
+ spawnerTemplate = "hugemunitionpickupRepresentation"
+ inventoryRepresentation = "HugeMunition"
+/>
+
<!-- Pickup Collection pickups -->
<PickupRepresentation
@@ -174,11 +216,11 @@
/>
<PickupRepresentation
- name = "largedamageboostpickup"
- pickupName = "Large DamageBoost Pickup"
+ name = "hugedamageboostpickup"
+ pickupName = "Huge DamageBoost Pickup"
pickupDescription = "Multiplies the ship damage with 7."
- spawnerTemplate = "largedamageboostpickupRepresentation"
- inventoryRepresentation = "LargeDamageBoost"
+ spawnerTemplate = "hugedamageboostpickupRepresentation"
+ inventoryRepresentation = "HugeDamageBoost"
/>
<!-- Shrink Pickup -->
Modified: code/branches/fabienHS15/data/levels/pickups.oxw
===================================================================
--- code/branches/fabienHS15/data/levels/pickups.oxw 2015-10-25 18:04:23 UTC (rev 10691)
+++ code/branches/fabienHS15/data/levels/pickups.oxw 2015-10-25 18:09:11 UTC (rev 10692)
@@ -35,6 +35,24 @@
<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" />
<SpawnPoint position="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <!-- DamageBoost pickup -->
+
+ <PickupSpawner pickup=smalldamageboostpickup position="-25,-100,-125" triggerDistance="10" respawnTime="30" maxSpawnedItems="10" />
+ <PickupSpawner pickup=mediumdamageboostpickup position="0,-100,-125" triggerDistance="10" respawnTime="30" maxSpawnedItems="10" />
+ <PickupSpawner pickup=hugedamageboostpickup position="25,-100,-125" triggerDistance="10" respawnTime="30" maxSpawnedItems="10" />
+
+ <!-- Munition pickups -->
+
+ <PickupSpawner pickup=smallmunitionpickup position="-25,-75,-125" triggerDistance="10" respawnTime="5" maxSpawnedItems="10" />
+ <PickupSpawner pickup=mediummunitionpickup position="0,-75,-125" triggerDistance="10" respawnTime="5" maxSpawnedItems="10" />
+ <PickupSpawner pickup=hugemunitionpickup position="25,-75,-125" triggerDistance="10" respawnTime="5" maxSpawnedItems="10" />
+
+ <!-- Shrink pickup -->
+
+ <PickupSpawner pickup=smallshrinkpickup position="-25,-50,-125" triggerDistance="20" respawnTime="60" maxSpawnedItems="5" />
+ <PickupSpawner pickup=mediumshrinkpickup position="0,-50,-125" triggerDistance="20" respawnTime="60" maxSpawnedItems="5" />
+ <PickupSpawner pickup=hugeshrinkpickup position="25,-50,-125" triggerDistance="20" respawnTime="60" maxSpawnedItems="5" />
+
<!-- Shield pickups -->
<PickupSpawner pickup=smallshieldpickup position="-25,-25,-125" triggerDistance="10" respawnTime="5" maxSpawnedItems="10" />
@@ -72,11 +90,11 @@
</Template>
<Template name=destroymetapickup baseclass=MetaPickup>
- <MetaPickup metaType="destroy" />
+ <MetaPickup representation="destroy" metaType="destroy" />
</Template>
<Template name=destroycarriermetapickup baseclass=MetaPickup>
- <MetaPickup metaType="destroyCarrier" />
+ <MetaPickup representation="destroycarrier" metaType="destroyCarrier" />
</Template>
<PickupSpawner pickup=usemetapickup position="-25,75,-125" triggerDistance="10" respawnTime="5" maxSpawnedItems="10" />
@@ -92,32 +110,22 @@
<PickupSpawner pickup=dronepickup position="-50,50,-125" triggerDistance="10" respawnTime="30" maxSpawnedItems="10" />
- <!-- DamageBoost pickup -->
-
- <PickupSpawner pickup=smalldamageboostpickup position="-50,75,-125" triggerDistance="10" respawnTime="30" maxSpawnedItems="10" />
- <PickupSpawner pickup=mediumdamageboostpickup position="-50,100,-125" triggerDistance="10" respawnTime="30" maxSpawnedItems="10" />
- <PickupSpawner pickup=largedamageboostpickup position="-50,125,-125" triggerDistance="10" respawnTime="30" maxSpawnedItems="10" />
-
<!-- Other pickups -->
<!-- PickupRepresentation for the pickup below, since it is not a standard pickup provided by pickups.oxi -->
<PickupRepresentation
- name = "MediumHealth"
- pickupName = "Medium Health Pack"
- pickupDescription = "Once used adds a medium amout of health to the ship."
+ name = "ContinousHealth"
+ pickupName = "Continous Health Pack"
+ pickupDescription = "While useing adds a medium amout of health to the ship."
spawnerTemplate = "mediumhealthpickupRepresentation"
inventoryRepresentation = "MediumHealth"
/>
<Template name=continuoushealthpickup baseclass=HealthPickup>
- <HealthPickup representation="MediumHealth" health=500 activationType=immediate healthRate=10 durationType=continuous />
+ <HealthPickup representation="ContinousHealth" health=500 activationType=immediate healthRate=10 durationType=continuous />
</Template>
<PickupSpawner pickup=continuoushealthpickup position="-50,0,-125" respawnTime="60" triggerDistance="20" maxSpawnedItems="5" />
-
- <PickupSpawner pickup="smallshrinkpickup" position="-25,-50,-125" respawnTime="60" triggerDistance="20" maxSpawnedItems="5" />
- <PickupSpawner pickup="mediumshrinkpickup" position="0,-50,-125" respawnTime="60" triggerDistance="20" maxSpawnedItems="5" />
- <PickupSpawner pickup="hugeshrinkpickup" position="25,-50,-125" respawnTime="60" triggerDistance="20" maxSpawnedItems="5" />
<!-- @Objects: 4 boxes (uncontrolled pawns) -->
<Pawn team=1 health=30 position="0,100,0" direction="0,-1,0" collisionType=dynamic mass=100000 name=box RVName = "Box 4" >
@@ -176,14 +184,5 @@
</collisionShapes>
</Pawn>
- <!--StaticEntity position="0,-200,0" direction="0,-1,0" collisionType=static mass=500 friction=0.01 >
- <attached>
- <Model position="0,0,0" mesh="cube.mesh" scale3D="10,10,10" />
- </attached>
- <collisionShapes>
- <BoxCollisionShape position="0,0,0" halfExtents="10,10,10" />
- </collisionShapes>
- </StaticEntity-->
-
</Scene>
</Level>
Modified: code/branches/fabienHS15/data/levels/templates/pickupRepresentationTemplates.oxt
===================================================================
--- code/branches/fabienHS15/data/levels/templates/pickupRepresentationTemplates.oxt 2015-10-25 18:04:23 UTC (rev 10691)
+++ code/branches/fabienHS15/data/levels/templates/pickupRepresentationTemplates.oxt 2015-10-25 18:09:11 UTC (rev 10692)
@@ -188,6 +188,86 @@
/>
</Template>
+<!-- Munition pickups: -->
+
+<Template name=smallmunitionpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.59,0.30,0.16" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.47,0.24,0.13" material="Munition" scale=0.3 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=smallmunitionpickup baseclass=MunitionPickup>
+ <MunitionPickup
+ representation = "smallmunitionpickup"
+ activationType = "immediate"
+ durationType = "once"
+ amount = 10
+ munitiontype = "LightningMunition"
+ />
+</Template>
+
+<Template name=mediummunitionpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.59,0.30,0.16" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.47,0.24,0.13" material="Munition" scale=0.5 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=mediummunitionpickup baseclass=MunitionPickup>
+ <MunitionPickup
+ representation = "mediummunitionpickup"
+ activationType = "immediate"
+ durationType = "once"
+ amount = 20
+ munitiontype = "LightningMunition"
+ />
+</Template>
+
+<Template name=hugemunitionpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.59,0.30,0.16" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.47,0.24,0.13" material="Munition" scale=0.7 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=hugemunitionpickup baseclass=MunitionPickup>
+ <MunitionPickup
+ representation = "hugemunitionpickup"
+ activationType = "immediate"
+ durationType = "once"
+ amount = 30
+ munitiontype = "LightningMunition"
+ />
+</Template>
+
<!-- Meta pickups: -->
<Template name=usepickupRepresentation>
@@ -222,6 +302,38 @@
</PickupRepresentation>
</Template>
+<Template name=destroypickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.60,0.97,0.23" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.40,0.81,0.10" material="Splash" scale=0.65 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=destroycarrierpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.60,0.97,0.23" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.40,0.81,0.10" material="Asterisk" scale=0.65 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
<!-- DamageBoost pickups -->
<Template name=smalldamageboostpickupRepresentation>
@@ -231,7 +343,7 @@
<attached>
<Billboard position="0,0,0" colour="0.95,0.10,0.05" material="Sphere2" scale=0.1 >
<attached>
- <Billboard position="0,0,0" colour="0.30,0.30,0.30" material="damageSmall" scale=0.7 />
+ <Billboard position="0,0,0" colour="0.70,0.10,0.10" material="Damage" scale=0.3 />
</attached>
</Billboard>
</attached>
@@ -257,7 +369,7 @@
<attached>
<Billboard position="0,0,0" colour="0.95,0.10,0.05" material="Sphere2" scale=0.1 >
<attached>
- <Billboard position="0,0,0" colour="0.30,0.30,0.30" material="damageMedium" scale=0.7 />
+ <Billboard position="0,0,0" colour="0.70,0.10,0.10" material="Damage" scale=0.5 />
</attached>
</Billboard>
</attached>
@@ -276,14 +388,14 @@
/>
</Template>
-<Template name=largedamageboostpickupRepresentation>
+<Template name=hugedamageboostpickupRepresentation>
<PickupRepresentation>
<spawner-representation>
<StaticEntity>
<attached>
<Billboard position="0,0,0" colour="0.95,0.10,0.05" material="Sphere2" scale=0.1 >
<attached>
- <Billboard position="0,0,0" colour="0.30,0.30,0.30" material="damageLarge" scale=0.7 />
+ <Billboard position="0,0,0" colour="0.70,0.10,0.10" material="Damage" scale=0.7 />
</attached>
</Billboard>
</attached>
@@ -292,9 +404,9 @@
</PickupRepresentation>
</Template>
-<Template name=largedamageboostpickup baseclass=DamageBoostPickup>
+<Template name=hugedamageboostpickup baseclass=DamageBoostPickup>
<DamageBoostPickup
- representation = "largedamageboostpickup"
+ representation = "hugedamageboostpickup"
duration = 10.0
damageMultiplier = 7.0
activationType = "immediate"
@@ -497,7 +609,7 @@
<attached>
<Billboard position="0,0,0" colour="1.0,0.55,1.0" material="Sphere2" scale=0.1>
<attached>
- <Billboard position="0,0,0" colour="1.0,0.55,1.0" material="Shrink" scale=0.4 />
+ <Billboard position="0,0,0" colour="1.0,0.55,1.0" material="Shrink" scale=0.35 />
</attached>
</Billboard>
</attached>
@@ -523,7 +635,7 @@
<attached>
<Billboard position="0,0,0" colour="1.0,0.55,1.0" material="Sphere2" scale=0.1>
<attached>
- <Billboard position="0,0,0" colour="1.0,0.55,1.0" material="Shrink" scale=0.7 />
+ <Billboard position="0,0,0" colour="1.0,0.55,1.0" material="Shrink" scale=0.55 />
</attached>
</Billboard>
</attached>
@@ -549,7 +661,7 @@
<attached>
<Billboard position="0,0,0" colour="1.0,0.55,1.0" material="Sphere2" scale=0.1>
<attached>
- <Billboard position="0,0,0" colour="1.0,0.55,1.0" material="Shrink" scale=1.0 />
+ <Billboard position="0,0,0" colour="1.0,0.55,1.0" material="Shrink" scale=0.75 />
</attached>
</Billboard>
</attached>
@@ -608,10 +720,10 @@
<Model scale="1" mesh="drone.mesh"/>
</attached>
<collisionShapes>
- <BoxCollisionShape position="0,0,0" halfExtents="1, 1, 1" />
+ <SphereCollisionShape position="0,0,0" radius=5 />
</collisionShapes>
<weaponslots>
- <WeaponSlot position=" 0, 0,0" />
+ <WeaponSlot position="0,0,0" />
</weaponslots>
<weaponsets>
<WeaponSet firemode=0 />
Modified: code/branches/fabienHS15/src/modules/pickup/PickupRepresentation.cc
===================================================================
--- code/branches/fabienHS15/src/modules/pickup/PickupRepresentation.cc 2015-10-25 18:04:23 UTC (rev 10691)
+++ code/branches/fabienHS15/src/modules/pickup/PickupRepresentation.cc 2015-10-25 18:09:11 UTC (rev 10692)
@@ -186,7 +186,7 @@
sphere->setScale(0.1f);
Billboard* icon = new Billboard(spawner->getContext());
icon->setColour(ColourValue(0.89f, 0.79f, 0.08f));
- icon->setMaterial("asterisk");
+ icon->setMaterial("Unknown");
icon->setScale(0.5);
sphere->attach(icon);
representation->attach(sphere);
Modified: code/branches/fabienHS15/src/modules/pickup/items/CMakeLists.txt
===================================================================
--- code/branches/fabienHS15/src/modules/pickup/items/CMakeLists.txt 2015-10-25 18:04:23 UTC (rev 10691)
+++ code/branches/fabienHS15/src/modules/pickup/items/CMakeLists.txt 2015-10-25 18:09:11 UTC (rev 10692)
@@ -7,4 +7,5 @@
ShieldPickup.cc
ShrinkPickup.cc
DamageBoostPickup.cc
+ MunitionPickup.cc
)
Modified: code/branches/fabienHS15/src/modules/pickup/items/DronePickup.h
===================================================================
--- code/branches/fabienHS15/src/modules/pickup/items/DronePickup.h 2015-10-25 18:04:23 UTC (rev 10691)
+++ code/branches/fabienHS15/src/modules/pickup/items/DronePickup.h 2015-10-25 18:09:11 UTC (rev 10692)
@@ -42,7 +42,8 @@
#include "pickup/Pickup.h"
#include "tools/interfaces/Tickable.h"
-namespace orxonox {
+namespace orxonox
+{
/**
@brief
@@ -79,9 +80,6 @@
void initialize(void); //!< Initializes the member variables.
std::string droneTemplate_; //!< The name of the template, based upon which the Drone is created.
Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
-
-
-
};
}
Added: code/branches/fabienHS15/src/modules/pickup/items/MunitionPickup.cc
===================================================================
--- code/branches/fabienHS15/src/modules/pickup/items/MunitionPickup.cc (rev 0)
+++ code/branches/fabienHS15/src/modules/pickup/items/MunitionPickup.cc 2015-10-25 18:09:11 UTC (rev 10692)
@@ -0,0 +1,165 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file MunitionPickup.cc
+ @brief Implementation of the MunitionPickup class.
+*/
+
+#include "MunitionPickup.h"
+
+#include <sstream>
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+#include "worldentities/pawns/SpaceShip.h"
+
+namespace orxonox
+{
+ RegisterClass(MunitionPickup);
+
+ /**
+ @brief
+ Constructor. Registers the object and initializes the member variables.
+ */
+ MunitionPickup::MunitionPickup(Context* context) : Pickup(context)
+ {
+ RegisterObject(MunitionPickup);
+
+ this->initialize();
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ MunitionPickup::~MunitionPickup()
+ {
+ }
+
+ /**
+ @brief
+ Initializes the member variables.
+ */
+ void MunitionPickup::initialize(void)
+ {
+ //Defines who is allowed to pick up the pickup.
+ this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
+ munitionAmount_ = 1;
+ setMunitionName("LaserMunition");
+ }
+
+ /**
+ @brief
+ Method for creating a MunitionPickup object through XML.
+ */
+ void MunitionPickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode)
+ {
+ SUPER(MunitionPickup, XMLPort, xmlelement, mode);
+
+ XMLPortParam(MunitionPickup, "amount", setMunitionAmount, getMunitionAmount, xmlelement, mode);
+ XMLPortParam(MunitionPickup, "munitiontype", setMunitionName, getMunitionName, xmlelement, mode);
+ }
+
+ /**
+ @brief
+ Is called when the pickup has transisted from used to unused or the other way around.
+ */
+ void MunitionPickup::changedUsed(void)
+ {
+ SUPER(MunitionPickup, changedUsed);
+
+ Pawn* pawn = this->carrierToPawnHelper();
+
+ if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
+ this->Pickupable::destroy();
+
+
+ // If the pickup has transited to used.
+ if(this->isUsed())
+ {
+ //Get pointer to the appropriate munition
+ Munition* munition = pawn->getMunition(&munitionType_);
+ if (munition)
+ {
+ // Add munition
+ munition->addMunition(munitionAmount_);
+ // This will destroy the pickp
+ this->setUsed(false);
+ }
+ }
+ else
+ {
+ this->Pickupable::destroy();
+ }
+ }
+
+ /**
+ @brief
+ Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
+ @return
+ A pointer to the Pawn, or NULL if the conversion failed.
+ */
+ Pawn* MunitionPickup::carrierToPawnHelper(void)
+ {
+ PickupCarrier* carrier = this->getCarrier();
+ Pawn* pawn = orxonox_cast<Pawn*>(carrier);
+
+ if(pawn == NULL)
+ {
+ orxout(internal_error, context::pickups) << "Invalid PickupCarrier in MunitionPickup." << endl;
+ }
+ return pawn;
+ }
+
+ void MunitionPickup::setMunitionName(const std::string& munitionname)
+ {
+ Identifier* identifier = ClassByString(munitionname);
+ if (identifier)
+ {
+ this->munitionType_ = identifier;
+ }
+ else
+ {
+ orxout(internal_warning) << "No munition class defined in MunitionPickup." << endl;
+ }
+ }
+
+ void MunitionPickup::setMunitionAmount(int munitionAmount)
+ {
+ if (munitionAmount > 0)
+ {
+ munitionAmount_ = munitionAmount;
+ }
+ else
+ {
+ munitionAmount = 0;
+ }
+ }
+}
+
Added: code/branches/fabienHS15/src/modules/pickup/items/MunitionPickup.h
===================================================================
--- code/branches/fabienHS15/src/modules/pickup/items/MunitionPickup.h (rev 0)
+++ code/branches/fabienHS15/src/modules/pickup/items/MunitionPickup.h 2015-10-25 18:09:11 UTC (rev 10692)
@@ -0,0 +1,79 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file MunitionPickup.h
+ @brief Declaration of the MunitionPickup class.
+ @ingroup PickupItems
+*/
+
+#ifndef _MunitionPickup_H__
+#define _MunitionPickup_H__
+
+#include "pickup/PickupPrereqs.h"
+
+#include <string>
+
+#include "pickup/Pickup.h"
+#include "core/class/SubclassIdentifier.h"
+#include "weaponsystem/Munition.h"
+
+namespace orxonox
+{
+
+ class _PickupExport MunitionPickup : public Pickup
+ {
+ public:
+
+ MunitionPickup(Context* context); //!< Constructor.
+ virtual ~MunitionPickup(); //!< Destructor.
+
+ virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a MunitionPickup object through XML.
+
+ virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
+
+ protected:
+ void setMunitionName(const std::string& munitionname);
+ inline const std::string& getMunitionName() const
+ { return this->munitionname_; }
+ void setMunitionAmount(int munitionAmount);
+ inline int getMunitionAmount() const
+ { return this->munitionAmount_; }
+
+ private:
+ void initialize(void); //!< Initializes the member variables.
+ Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
+
+ SubclassIdentifier<Munition> munitionType_; //!< Indentifier of the munition type.
+ std::string munitionname_; //!< String containing the class name of the munition type (e.g. "LaserMunition")
+ int munitionAmount_; //!< The amount of munition added if the pickup is used
+
+ };
+}
+
+#endif // _MunitionPickup_H__
Modified: code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.cc 2015-10-25 18:04:23 UTC (rev 10691)
+++ code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.cc 2015-10-25 18:09:11 UTC (rev 10692)
@@ -559,8 +559,18 @@
return this->weaponSystem_->getAllWeaponPacks();
else
return 0;
- }
+ }
+ Munition* Pawn::getMunition(SubclassIdentifier<Munition> * identifier)
+ {
+ if (weaponSystem_)
+ {
+ return weaponSystem_->getMunition(identifier);
+ }
+
+ return NULL;
+ }
+
//Tell the Map (RadarViewable), if this is a playership
void Pawn::startLocalHumanControl()
{
Modified: code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.h 2015-10-25 18:04:23 UTC (rev 10691)
+++ code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.h 2015-10-25 18:09:11 UTC (rev 10692)
@@ -154,6 +154,8 @@
void addWeaponPackXML(WeaponPack * wPack);
WeaponPack * getWeaponPack(unsigned int index) const;
std::vector<WeaponPack *> * getAllWeaponPacks();
+
+ Munition * getMunition(SubclassIdentifier<Munition> * identifier);
virtual void addedWeaponPack(WeaponPack* wPack) {}
More information about the Orxonox-commit
mailing list