[Orxonox-commit 5970] r10629 - in code/trunk: data/levels data/levels/includes data/levels/templates src/modules/towerdefense src/modules/weapons src/modules/weapons/munitions src/modules/weapons/projectiles src/modules/weapons/weaponmodes
fvultier at orxonox.net
fvultier at orxonox.net
Sat Oct 10 16:34:27 CEST 2015
Author: fvultier
Date: 2015-10-10 16:34:26 +0200 (Sat, 10 Oct 2015)
New Revision: 10629
Added:
code/trunk/src/modules/towerdefense/TowerDefenseField.cc
code/trunk/src/modules/towerdefense/TowerDefenseField.h
code/trunk/src/modules/weapons/IceGunFreezer.cc
code/trunk/src/modules/weapons/IceGunFreezer.h
code/trunk/src/modules/weapons/munitions/IceMunition.cc
code/trunk/src/modules/weapons/munitions/IceMunition.h
code/trunk/src/modules/weapons/munitions/SplitMunition.cc
code/trunk/src/modules/weapons/munitions/SplitMunition.h
code/trunk/src/modules/weapons/projectiles/IceGunProjectile.cc
code/trunk/src/modules/weapons/projectiles/IceGunProjectile.h
code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.cc
code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.h
code/trunk/src/modules/weapons/weaponmodes/IceGun.cc
code/trunk/src/modules/weapons/weaponmodes/IceGun.h
code/trunk/src/modules/weapons/weaponmodes/SplitGun.cc
code/trunk/src/modules/weapons/weaponmodes/SplitGun.h
Removed:
code/trunk/data/levels/templates/enemytowerdefense.oxt
code/trunk/src/modules/towerdefense/TDEnemy.h
code/trunk/src/modules/towerdefense/TowerDefenseController.cc
code/trunk/src/modules/towerdefense/TowerDefenseController.h
Modified:
code/trunk/data/levels/emptyLevel.oxw
code/trunk/data/levels/includes/weaponSettingsRing.oxi
code/trunk/data/levels/includes/weaponSettingsSwallow.oxi
code/trunk/data/levels/jump.oxw
code/trunk/data/levels/towerDefense.oxw
code/trunk/src/modules/towerdefense/CMakeLists.txt
code/trunk/src/modules/towerdefense/TDCoordinate.cc
code/trunk/src/modules/towerdefense/TDCoordinate.h
code/trunk/src/modules/towerdefense/TowerDefense.cc
code/trunk/src/modules/towerdefense/TowerDefense.h
code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.cc
code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.h
code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc
code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h
code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc
code/trunk/src/modules/towerdefense/TowerDefenseSelecter.cc
code/trunk/src/modules/towerdefense/TowerDefenseSelecter.h
code/trunk/src/modules/towerdefense/TowerDefenseTower.cc
code/trunk/src/modules/towerdefense/TowerDefenseTower.h
code/trunk/src/modules/weapons/CMakeLists.txt
code/trunk/src/modules/weapons/munitions/CMakeLists.txt
code/trunk/src/modules/weapons/projectiles/BillboardProjectile.cc
code/trunk/src/modules/weapons/projectiles/BillboardProjectile.h
code/trunk/src/modules/weapons/projectiles/CMakeLists.txt
code/trunk/src/modules/weapons/projectiles/Projectile.cc
code/trunk/src/modules/weapons/projectiles/Projectile.h
code/trunk/src/modules/weapons/weaponmodes/CMakeLists.txt
Log:
Merged towerdefenseFabien branch back to trunk. The towerdefense Minigame is now a plugin.
Modified: code/trunk/data/levels/emptyLevel.oxw
===================================================================
--- code/trunk/data/levels/emptyLevel.oxw 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/data/levels/emptyLevel.oxw 2015-10-10 14:34:26 UTC (rev 10629)
@@ -15,6 +15,8 @@
include("templates/spaceshipAssff2.oxt")
include("templates/spaceshipPirate.oxt")
include("templates/spaceshipEscort.oxt")
+ include("templates/spaceshipRing.oxt")
+ include("templates/spaceshipSwallow.oxt")
?>
<Level>
Modified: code/trunk/data/levels/includes/weaponSettingsRing.oxi
===================================================================
--- code/trunk/data/levels/includes/weaponSettingsRing.oxi 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/data/levels/includes/weaponSettingsRing.oxi 2015-10-10 14:34:26 UTC (rev 10629)
@@ -13,10 +13,10 @@
<DefaultWeaponmodeLink firemode=1 weaponmode=1 />
</links>
<Weapon>
- <HsW01 mode=0 munitionpershot=0 delay=0.125 damage=9.3 material="Flares/point_lensflare" muzzleoffset=" 0.1, 1.4,-3" projectileMesh="LaserBeam2.mesh" />
+ <IceGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0.1, 1.4,-3" freezefactor=0.5 freezetime=2.0 />
</Weapon>
<Weapon>
- <HsW01 mode=0 munitionpershot=0 delay=0 damage=9.3 material="Flares/point_lensflare" muzzleoffset="0.1, 1.4, -3" projectileMesh="LaserBeam2.mesh" />
+ <IceGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0.1, 1.4,-3" freezefactor=0.5 freezetime=2.0 />
</Weapon>
</WeaponPack>
</weapons>
Modified: code/trunk/data/levels/includes/weaponSettingsSwallow.oxi
===================================================================
--- code/trunk/data/levels/includes/weaponSettingsSwallow.oxi 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/data/levels/includes/weaponSettingsSwallow.oxi 2015-10-10 14:34:26 UTC (rev 10629)
@@ -13,15 +13,10 @@
<DefaultWeaponmodeLink firemode=1 weaponmode=1 />
</links>
<Weapon>
- <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" />
- <HsW01 mode=0 munitionpershot=0 delay=0.125 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 0.5,0.6,1.7" />
-
- <LightningGun mode=1 muzzleoffset="0,0,0" damage=3.14159 shielddamage=20/>
+ <SplitGun mode=0 munitionpershot=0 damage=6.0 muzzleoffset="0.5,0.6,1.7" splittime=0.2 numberofsplits=2 numberofchilds=3 spread=0.1 damagereduction=2.0 />
</Weapon>
<Weapon>
- <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" />
- <HsW01 mode=0 munitionpershot=0 delay=0.125 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-0.5,0.6,1.7" />
- <LightningGun mode=1 muzzleoffset="0,0,0" damage=3.14159 shielddamage=20/>
+ <SplitGun mode=0 munitionpershot=0 damage=6.0 muzzleoffset="-0.5,0.6,1.7" splittime=0.2 numberofsplits=2 numberofchilds=3 spread=0.1 damagereduction=2.0 />
</Weapon>
</WeaponPack>
</weapons>
Modified: code/trunk/data/levels/jump.oxw
===================================================================
--- code/trunk/data/levels/jump.oxw 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/data/levels/jump.oxw 2015-10-10 14:34:26 UTC (rev 10629)
@@ -259,38 +259,5 @@
</attached>
</MovableEntity>
- <EventDispatcher>
- <targets>
- <EventTarget target=scoreeffect_right />
- <EventTarget target=scoreeffect_center />
- </targets>
- <events>
- <spawn>
- <EventFilter>
- <names>
- <EventName name=right />
- </names>
- <EventListener event=jumpcenter />
- </EventFilter>
- </spawn>
- </events>
- </EventDispatcher>
- <EventDispatcher>
- <targets>
- <EventTarget target=scoreeffect_left />
- <EventTarget target=scoreeffect_center />
- </targets>
- <events>
- <spawn>
- <EventFilter>
- <names>
- <EventName name=left />
- </names>
- <EventListener event=jumpcenter />
- </EventFilter>
- </spawn>
- </events>
- </EventDispatcher>
-
</Scene>
</Level>
Deleted: code/trunk/data/levels/templates/enemytowerdefense.oxt
===================================================================
--- code/trunk/data/levels/templates/enemytowerdefense.oxt 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/data/levels/templates/enemytowerdefense.oxt 2015-10-10 14:34:26 UTC (rev 10629)
@@ -1,234 +0,0 @@
-<Template name=enemytowerdefense1>
- <TowerDefenseEnemy
- hudtemplate = spaceshiphud
- camerapositiontemplate = spaceshipassffcameras
- spawnparticlesource = "Orxonox/fairytwirl"
- spawnparticleduration = 3
- explosionchunks = 6
-
- health = 1
- maxhealth = 2
- initialhealth = 1
-
- shieldhealth = 30
- initialshieldhealth = 30
- maxshieldhealth = 50
- shieldabsorption = 0.8
- reloadrate = 1
- reloadwaittime = 1
-
- primaryThrust = 100
- auxilaryThrust = 30
- rotationThrust = 50
-
- lift = 1;
- stallSpeed = 220;
-
- boostPower = 15
- boostPowerRate = 1
- boostRate = 5
- boostCooldownDuration = 10
-
- shakeFrequency = 15
- shakeAmplitude = 9
-
- collisionType = "dynamic"
- mass = 100
- linearDamping = 0.7
- angularDamping = 0.9999999
-
- explosionSound = "sounds/Explosion2.ogg"
- >
-
- <engines>
- <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipassffengine />
- <MultiStateEngine position="-7.6, 0, 0" template=spaceshipassffengine />
- </engines>
- <attached>
- <Model position="0,0,0" yaw=90 pitch=90 roll=0 scale=4 mesh="assff.mesh" />
- <BlinkingBillboard position="17,-1.5,0" material="Examples/Flare" colour="1.0, 0.5, 0.3" amplitude=0.1 frequency=0.5 quadratic=1 />
- <BlinkingBillboard position="-17,-1.5,0" material="Examples/Flare" colour="0.5, 1.0, 0.3" amplitude=0.1 frequency=0.5 phase=180 quadratic=1 />
- </attached>
- <collisionShapes>
- <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" />
- <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" />
- <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" />
- <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" />
- <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" />
- <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
- </collisionShapes>
- <controller>
- <WaypointController accuracy=60>
- <waypoints>
- <!-- 1,3 10,3 10,11, 13,11 -->
-
- <Model position="-700,-500, 150" />
- <Model position=" 200,-500, 150" />
-
- <Model position=" 200, 300, 150" />
- <Model position=" 500, 300, 150" />
- <!-- <Model mesh="cube.mesh" scale=10 position=" 500, 700, 150" /> -->
- <Model position=" 500, 700, 150" />
-
- </waypoints>
- </WaypointController>
- </controller>
- </TowerDefenseEnemy>
-</Template>
-
-
-<Template name=enemytowerdefense2>
- <TowerDefenseEnemy
- hudtemplate = spaceshiphud
- camerapositiontemplate = spaceshipassffcameras
- spawnparticlesource = "Orxonox/fairytwirl"
- spawnparticleduration = 3
- explosionchunks = 6
-
- health = 100
- maxhealth = 200
- initialhealth = 100
-
- shieldhealth = 30
- initialshieldhealth = 30
- maxshieldhealth = 50
- shieldabsorption = 0.8
- reloadrate = 1
- reloadwaittime = 1
-
- primaryThrust = 100
- auxilaryThrust = 30
- rotationThrust = 50
-
- lift = 1;
- stallSpeed = 220;
-
- boostPower = 15
- boostPowerRate = 1
- boostRate = 5
- boostCooldownDuration = 10
-
- shakeFrequency = 15
- shakeAmplitude = 9
-
- collisionType = "dynamic"
- mass = 100
- linearDamping = 0.7
- angularDamping = 0.9999999
-
- explosionSound = "sounds/Explosion2.ogg"
- >
-
- <engines>
- <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipassffengine />
- <MultiStateEngine position="-7.6, 0, 0" template=spaceshipassffengine />
- </engines>
- <attached>
- <Model position="0,0,0" yaw=90 pitch=90 roll=0 scale=4 mesh="JumpEnemy3.mesh" />
- <BlinkingBillboard position="17,-1.5,0" material="Examples/Flare" colour="1.0, 0.5, 0.3" amplitude=0.1 frequency=0.5 quadratic=1 />
- <BlinkingBillboard position="-17,-1.5,0" material="Examples/Flare" colour="0.5, 1.0, 0.3" amplitude=0.1 frequency=0.5 phase=180 quadratic=1 />
- </attached>
- <collisionShapes>
- <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" />
- <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" />
- <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" />
- <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" />
- <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" />
- <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
- </collisionShapes>
- <controller>
- <WaypointController accuracy=60>
- <waypoints>
- <!-- 1,3 10,3 10,11, 13,11 -->
-
- <Model position="-700,-500, 150" />
- <Model position=" 200,-500, 150" />
-
- <Model position=" 200, 300, 150" />
- <Model position=" 500, 300, 150" />
- <!-- <Model mesh="cube.mesh" scale=10 position=" 500, 700, 150" /> -->
- <Model position=" 500, 700, 150" />
-
- </waypoints>
- </WaypointController>
- </controller>
- </TowerDefenseEnemy>
-</Template>
-
-<Template name=enemytowerdefense3>
- <TowerDefenseEnemy
- hudtemplate = spaceshiphud
- camerapositiontemplate = spaceshipassffcameras
- spawnparticlesource = "Orxonox/fairytwirl"
- spawnparticleduration = 3
- explosionchunks = 6
-
- health = 100
- maxhealth = 200
- initialhealth = 100
-
- shieldhealth = 30
- initialshieldhealth = 30
- maxshieldhealth = 50
- shieldabsorption = 0.8
- reloadrate = 1
- reloadwaittime = 1
-
- primaryThrust = 100
- auxilaryThrust = 30
- rotationThrust = 50
-
- lift = 1;
- stallSpeed = 220;
-
- boostPower = 15
- boostPowerRate = 1
- boostRate = 5
- boostCooldownDuration = 10
-
- shakeFrequency = 15
- shakeAmplitude = 9
-
- collisionType = "dynamic"
- mass = 100
- linearDamping = 0.7
- angularDamping = 0.9999999
-
- explosionSound = "sounds/Explosion2.ogg"
- >
-
- <engines>
- <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipassffengine />
- <MultiStateEngine position="-7.6, 0, 0" template=spaceshipassffengine />
- </engines>
- <attached>
- <Model position="0,0,0" yaw=90 pitch=90 roll=0 scale=4 mesh="JumpEnemy4.mesh" />
- <BlinkingBillboard position="17,-1.5,0" material="Examples/Flare" colour="1.0, 0.5, 0.3" amplitude=0.1 frequency=0.5 quadratic=1 />
- <BlinkingBillboard position="-17,-1.5,0" material="Examples/Flare" colour="0.5, 1.0, 0.3" amplitude=0.1 frequency=0.5 phase=180 quadratic=1 />
- </attached>
- <collisionShapes>
- <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" />
- <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" />
- <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" />
- <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" />
- <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" />
- <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
- </collisionShapes>
- <controller>
- <WaypointController accuracy=60>
- <waypoints>
- <!-- 1,3 10,3 10,11, 13,11 -->
-
- <Model position="-700,-500, 150" />
- <Model position=" 200,-500, 150" />
-
- <Model position=" 200, 300, 150" />
- <Model position=" 500, 300, 150" />
- <!-- <Model mesh="cube.mesh" scale=10 position=" 500, 700, 150" /> -->
- <Model position=" 500, 700, 150" />
-
- </waypoints>
- </WaypointController>
- </controller>
- </TowerDefenseEnemy>
-</Template>
\ No newline at end of file
Modified: code/trunk/data/levels/towerDefense.oxw
===================================================================
--- code/trunk/data/levels/towerDefense.oxw 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/data/levels/towerDefense.oxw 2015-10-10 14:34:26 UTC (rev 10629)
@@ -14,21 +14,15 @@
include("HUDTemplates3.oxo")
include("towerdefenseHUD.oxo")
include("templates/lodInformation.oxt")
-?>
-
-<?lua
+ include("includes/weaponSettingsTurret.oxi")
include("templates/spaceshipAssff.oxt")
- include("templates/spaceshipPirate.oxt")
- include("templates/towerdefensetower.oxt")
- include("templates/enemytowerdefense.oxt")
include("templates/standardTurret.oxt")
?>
-
<Template name=selectercameras defaults=0>
<TowerDefenseSelecter>
<camerapositions>
- <CameraPosition position="0,0,1400" lookat="0,0,0" absolute=true />
+ <CameraPosition position="0,0,1300" lookat="0,0,0" absolute=true drag=true mouselook=true/>
</camerapositions>
</TowerDefenseSelecter>
</Template>
@@ -36,18 +30,414 @@
<Template name=selectertemplate>
<TowerDefenseSelecter team=0 camerapositiontemplate=selectercameras>
<attached>
- <Model pitch=90 position="0,0,-30" mesh="TD_Selection.mesh" scale=30 />
+ <Model position="0,0,0" pitch=90 mesh="TD_Selection.mesh" scale=25/>
</attached>
</TowerDefenseSelecter>
</Template>
+<Template name=tower1template>
+ <TowerDefenseTower
+ explosionchunks=6
+ reloadrate=10
+ reloadwaittime=5
+ collisionType="none"
+ pitch="0"
+ yaw="0"
+ roll="0"
+ maxPitch=360
+ maxYaw=360
+ maxAttackRadius=1000
+ minAttackRadius=0
+ team=0
+ >
+ <controller>
+ <TurretController team = 0/>
+ </controller>
+ <weaponslots>
+ <WeaponSlot position="0,0,0" />
+ </weaponslots>
+ <weaponsets>
+ <WeaponSet firemode=0 />
+ </weaponsets>
+ <weapons>
+ <WeaponPack>
+ <links>
+ <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
+ </links>
+ <Weapon>
+ <HsW01 mode=0 munitionpershot=0 muzzleoffset="0,0,0" damage=2 shielddamage=1 material="Flares/point_lensflare" delay=0/>
+ </Weapon>
+ </WeaponPack>
+ </weapons>
+ </TowerDefenseTower>
+</Template>
+<Template name=tower2template>
+ <TowerDefenseTower
+ explosionchunks=6
+ reloadrate=10
+ reloadwaittime=5
+ collisionType="none"
+ pitch="0"
+ yaw="0"
+ roll="0"
+ maxPitch=360
+ maxYaw=360
+ maxAttackRadius=1000
+ minAttackRadius=0
+ team=0
+ >
+ <controller>
+ <TurretController team = 0/>
+ </controller>
+ <weaponslots>
+ <WeaponSlot position="0,0,0" />
+ </weaponslots>
+ <weaponsets>
+ <WeaponSet firemode=0 />
+ </weaponsets>
+ <weapons>
+ <WeaponPack>
+ <links>
+ <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
+ </links>
+ <Weapon>
+ <LightningGun mode=0 munitionpershot=0 muzzleoffset="0,0,0" damage=2 shielddamage=4 />
+ </Weapon>
+ </WeaponPack>
+ </weapons>
+ <attached>
+ <Backlight position="0,0,0" scale=2.0 colour="0.4, 0.0, 1.0" width=10 length=10 lifetime=0.3 elements=20 trailmaterial="Trail/backlighttrail" material="Examples/Flare" loop=1 />
+ </attached>
+ </TowerDefenseTower>
+</Template>
+<Template name=tower3template>
+ <TowerDefenseTower
+ explosionchunks=6
+ reloadrate=10
+ reloadwaittime=5
+ collisionType="none"
+ pitch="0"
+ yaw="0"
+ roll="0"
+ maxPitch=360
+ maxYaw=360
+ maxAttackRadius=1000
+ minAttackRadius=0
+ team=0
+ >
+ <controller>
+ <TurretController team = 0/>
+ </controller>
+ <weaponslots>
+ <WeaponSlot position="0,0,0" />
+ </weaponslots>
+ <weaponsets>
+ <WeaponSet firemode=0 />
+ </weaponsets>
+ <weapons>
+ <WeaponPack>
+ <links>
+ <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
+ </links>
+ <Weapon>
+ <SplitGun mode=0 munitionpershot=0 damage=9.3 muzzleoffset=" 1.6, 1.3, -2.0" splittime=0.2 numberofsplits=2 numberofchilds=5 spread=0.1 damagereduction=3.0 />
+ </Weapon>
+ </WeaponPack>
+ </weapons>
+ </TowerDefenseTower>
+</Template>
-<Level
- plugins = "towerdefense"
- gametype = "TowerDefense"
->
+<Template name=tower4template>
+ <TowerDefenseTower
+ explosionchunks=6
+ reloadrate=10
+ reloadwaittime=5
+ collisionType="none"
+ pitch="0"
+ yaw="0"
+ roll="0"
+ maxPitch=360
+ maxYaw=360
+ maxAttackRadius=1000
+ minAttackRadius=0
+ team=0
+ >
+ <controller>
+ <TurretController team = 0/>
+ </controller>
+ <weaponslots>
+ <WeaponSlot position="0,0,0" />
+ </weaponslots>
+ <weaponsets>
+ <WeaponSet firemode=0 />
+ </weaponsets>
+ <weapons>
+ <WeaponPack>
+ <links>
+ <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
+ </links>
+ <Weapon>
+ <RocketFire mode=0 munitionpershot=0 muzzleoffset="0,0,0" damage=2 shielddamage=4 />
+ </Weapon>
+ </WeaponPack>
+ </weapons>
+ <attached>
+ <ParticleSpawner position="0,0,0" source="Orxonox/sparks" lifetime=3.0 autostart=1 loop=1 />
+ </attached>
+ </TowerDefenseTower>
+</Template>
+
+<Template name=tower5template>
+ <TowerDefenseTower
+ explosionchunks=6
+ reloadrate=10
+ reloadwaittime=5
+ collisionType="none"
+ pitch="0"
+ yaw="0"
+ roll="0"
+ maxPitch=360
+ maxYaw=360
+ maxAttackRadius=1000
+ minAttackRadius=0
+ team=0
+ >
+ <controller>
+ <TurretController team = 0/>
+ </controller>
+ <weaponslots>
+ <WeaponSlot position="0,0,0" />
+ </weaponslots>
+ <weaponsets>
+ <WeaponSet firemode=0 />
+ </weaponsets>
+ <weapons>
+ <WeaponPack>
+ <links>
+ <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
+ </links>
+ <Weapon>
+ <IceGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0,0,0" freezefactor=0.5 freezetime=2.0 />
+ </Weapon>
+ </WeaponPack>
+ </weapons>
+ </TowerDefenseTower>
+</Template>
+
+<Template name=enemytowerdefense1>
+ <TowerDefenseEnemy
+ hudtemplate = spaceshiphud
+ camerapositiontemplate = spaceshipassffcameras
+ spawnparticlesource = "Orxonox/fairytwirl"
+ spawnparticleduration = 3
+ explosionchunks = 6
+
+ health = 15
+ maxhealth = 15
+ initialhealth = 15
+
+ shieldhealth = 15
+ initialshieldhealth = 15
+ maxshieldhealth = 15
+ shieldabsorption = 0.8
+ reloadrate = 1
+ reloadwaittime = 1
+
+ primaryThrust = 1000
+ auxilaryThrust = 30
+ rotationThrust = 80
+
+ lift = 1;
+ stallSpeed = 220;
+
+ boostPower = 15
+ boostPowerRate = 1
+ boostRate = 5
+ boostCooldownDuration = 10
+
+ shakeFrequency = 15
+ shakeAmplitude = 9
+
+ collisionType = "dynamic"
+ mass = 10
+ linearDamping = 0.7
+ angularDamping = 0.9999999
+
+ explosionSound = "sounds/Explosion2.ogg"
+ >
+
+ <engines>
+ <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipassffengine />
+ <MultiStateEngine position="-7.6, 0, 0" template=spaceshipassffengine />
+ </engines>
+ <attached>
+ <Model position="0,0,0" yaw=90 pitch=90 roll=0 scale=4 mesh="assff.mesh" />
+ <BlinkingBillboard position="17,-1.5,0" material="Examples/Flare" colour="1.0, 0.5, 0.3" amplitude=0.1 frequency=0.5 quadratic=1 />
+ <BlinkingBillboard position="-17,-1.5,0" material="Examples/Flare" colour="0.5, 1.0, 0.3" amplitude=0.1 frequency=0.5 phase=180 quadratic=1 />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" />
+ <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" />
+ <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" />
+ <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
+ </collisionShapes>
+ <controller>
+ <WaypointController accuracy = 50/>
+ </controller>
+ </TowerDefenseEnemy>
+</Template>
+
+<Template name=enemytowerdefense2>
+ <TowerDefenseEnemy
+ hudtemplate = spaceshiphud
+ camerapositiontemplate = spaceshipassffcameras
+ spawnparticlesource = "Orxonox/fairytwirl"
+ spawnparticleduration = 3
+ explosionchunks = 6
+
+ health = 30
+ maxhealth = 30
+ initialhealth = 30
+
+ shieldhealth = 0
+ initialshieldhealth = 0
+ maxshieldhealth = 0
+ shieldabsorption = 0.8
+ reloadrate = 1
+ reloadwaittime = 1
+
+ primaryThrust = 100
+ auxilaryThrust = 30
+ rotationThrust = 80
+
+ lift = 1;
+ stallSpeed = 220;
+
+ boostPower = 15
+ boostPowerRate = 1
+ boostRate = 5
+ boostCooldownDuration = 10
+
+ shakeFrequency = 15
+ shakeAmplitude = 9
+
+ collisionType = "dynamic"
+ mass = 100
+ linearDamping = 0.7
+ angularDamping = 0.9999999
+
+ explosionSound = "sounds/Explosion2.ogg"
+ >
+
+ <engines>
+ <Engine position=" 0, 0, 0"
+ boostfactor = 2
+ speedfront = 100
+ speedback = 50
+ speedleftright = 50
+ speedupdown = 50
+ accelerationfront = 500
+ accelerationbrake = 500
+ accelerationback = 125
+ accelerationleftright = 125
+ accelerationupdown = 125
+ />
+ </engines>
+ <attached>
+ <Model position="0,0,0" yaw=0 pitch=0 roll=0 scale=2.5 mesh="JumpEnemy3.mesh" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" />
+ <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" />
+ <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" />
+ <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
+ </collisionShapes>
+ <controller>
+ <WaypointController accuracy = 50/>
+ </controller>
+ </TowerDefenseEnemy>
+</Template>
+
+<Template name=enemytowerdefense3>
+ <TowerDefenseEnemy
+ hudtemplate = spaceshiphud
+ camerapositiontemplate = spaceshipassffcameras
+ spawnparticlesource = "Orxonox/fairytwirl"
+ spawnparticleduration = 3
+ explosionchunks = 6
+
+ health = 15
+ maxhealth = 15
+ initialhealth = 15
+
+ shieldhealth = 5
+ initialshieldhealth = 5
+ maxshieldhealth = 5
+ shieldabsorption = 0.8
+ reloadrate = 1
+ reloadwaittime = 1
+
+ primaryThrust = 100
+ auxilaryThrust = 30
+ rotationThrust = 80
+
+ lift = 1;
+ stallSpeed = 220;
+
+ boostPower = 15
+ boostPowerRate = 1
+ boostRate = 5
+ boostCooldownDuration = 10
+
+ shakeFrequency = 15
+ shakeAmplitude = 9
+
+ collisionType = "dynamic"
+ mass = 100
+ linearDamping = 0.7
+ angularDamping = 0.9999999
+
+ explosionSound = "sounds/Explosion2.ogg"
+ >
+
+ <engines>
+ <Engine position=" 0, 0, 0"
+ boostfactor = 2
+ speedfront = 300
+ speedback = 300
+ speedleftright = 300
+ speedupdown = 300
+ accelerationfront = 500
+ accelerationbrake = 500
+ accelerationback = 500
+ accelerationleftright = 500
+ accelerationupdown = 500
+ />
+ </engines>
+ <attached>
+ <Model position="0,0,0" yaw=0 pitch=0 roll=0 scale=2.5 mesh="JumpEnemy4.mesh" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" />
+ <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" />
+ <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" />
+ <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
+ </collisionShapes>
+ <controller>
+ <WaypointController accuracy = 50/>
+ </controller>
+ </TowerDefenseEnemy>
+</Template>
+
+<Level plugins = "towerdefense" gametype = "TowerDefense">
<templates>
<Template link=lodtemplate_default />
</templates>
@@ -61,15 +451,50 @@
<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"/>
- <!-- Spawns the camera, attached to a crate -->
<SpawnPoint team=0 position="0,0,0"/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_S1.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_S2.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_S3.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_S4.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_S5.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_T1.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_T2.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_T3.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_T4.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_T5.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_F1.mesh" scale=1/>
+
<!-- PlayField -->
<TowerDefenseCenterpoint
name=towerdefensecenter
-
selecterTemplate=selectertemplate
-
+ tower1Template=tower1template
+ tower2Template=tower2template
+ tower3Template=tower3template
+ tower4Template=tower4template
+ tower5Template=tower5template
+ tower1Cost=100
+ tower2Cost=100
+ tower3Cost=100
+ tower4Cost=100
+ tower5Cost=100
+ fields="F1F1F1R1I1I1I1I1O1F1F1F1F1F1F1F1
+ F1F1F1I2F1F1F1F1F1F1F1F1F1F1F1F1
+ F1F1F1I2F1F1F1F1F1F1F1F1F1F1F1F1
+ F1F1F1I2F1F1F1F1F1F1F1Y1Y1Y1F1F1
+ F1F1F1I2F1F1F1F1F1F1F1F1F1F1F1F1
+ F1F1F1I2F1F1F1F1F1F1F1Y1Y1Y1F1F1
+ F1F1F1R2I3I3I3I3L3F1F1F1F1F1F1F1
+ F1F1F1F1F1F1F1F1I2F1F1F1F1F1F1F1
+ F1F1F1F1F1F1F1F1I2F1F1F1F1F1F1F1
+ X1I1I1I1R0F1F1F1I2F1F1F1F1F1F1F1
+ F1F1F1F1I0F1F1F1I2F1F1F1F1F1F1F1
+ F1F1F1F1I0F1F1F1I2F1F1F1F1F1F1F1
+ F1F1F1F1L1I1I1I1L2F1F1F1F1F1F1F1
+ F1F1F1F1F1F1F1F1F1F1F1F1F1F1F1F1
+ F1F1F1F1F1F1F1F1F1F1F1F1F1F1F1F1
+ F1F1F1F1F1F1F1F1F1F1F1F1F1F1F1F1"
width=16
height=16
tileScale=100
@@ -78,13 +503,9 @@
collisionType=dynamic
mass=100000
>
- <attached>
- <Model position="-50,-50,0" mesh="Playfield_ME.mesh" scale=80 />
- <Model position="500,700,100" mesh="sphere.mesh" scale=80 />
- </attached>
- <camerapositions>
- <CameraPosition position="0,0,1500" lookat="0,0,0" absolute=true/>
- </camerapositions>
+ <camerapositions>
+ <CameraPosition position="0,0,1400" lookat="0,0,0" absolute=true />
+ </camerapositions>
</TowerDefenseCenterpoint>
</Scene>
Modified: code/trunk/src/modules/towerdefense/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/towerdefense/CMakeLists.txt 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/CMakeLists.txt 2015-10-10 14:34:26 UTC (rev 10629)
@@ -7,6 +7,8 @@
TDCoordinate.cc
TowerDefenseEnemy.cc
TowerDefenseSelecter.cc
+ TowerDefenseField.cc
+ TDCoordinate.cc
)
ORXONOX_ADD_LIBRARY(towerdefense
Modified: code/trunk/src/modules/towerdefense/TDCoordinate.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TDCoordinate.cc 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/TDCoordinate.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -7,17 +7,13 @@
namespace orxonox
{
- //RegisterClass(TDCoordinate);
-
/**
@brief
- Constructor. Registers and initializes the object.
+ Constructor. Sets the default coordinates: (0,0)
*/
TDCoordinate::TDCoordinate()
{
- //RegisterObject(TDCoordinate);
Set(0,0);
-
}
TDCoordinate::TDCoordinate(int x, int y)
@@ -72,7 +68,7 @@
Vector3 *coord = new Vector3();
coord->x= (_x-8) * tileScale;
coord->y= (_y-8) * tileScale;
- coord->z=100;
+ coord->z=0;
return *coord;
}
Modified: code/trunk/src/modules/towerdefense/TDCoordinate.h
===================================================================
--- code/trunk/src/modules/towerdefense/TDCoordinate.h 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/TDCoordinate.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -1,6 +1,7 @@
#ifndef _TDCoordinate_H__
#define _TDCoordinate_H__
+#include "core/CoreIncludes.h"
#include "TDCoordinate.h"
//#include "towerdefense/TowerDefense.h"
#include "gametypes/Deathmatch.h"
@@ -20,7 +21,7 @@
virtual void Set(int x, int y);
virtual int GetX();
virtual int GetY();
- virtual Vector3 get3dcoordinate();
+ virtual Vector3 get3dcoordinate();
private:
int _x;
Deleted: code/trunk/src/modules/towerdefense/TDEnemy.h
===================================================================
--- code/trunk/src/modules/towerdefense/TDEnemy.h 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/TDEnemy.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -1,26 +0,0 @@
-/*
- * TDEnemy.h
- *
- * Created on: Mar 30, 2012
- * Author: weigeltm
- */
-/*
-#ifndef TDENEMY_H_
-#define TDENEMY_H_
-
-class TDEnemy
-{
-
-private:
- float health;
- float speed;
- float armour;
-
-
-
-
-
-};
-
-
-#endif TDENEMY_H_ */
Modified: code/trunk/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefense.cc 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/TowerDefense.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -74,86 +74,48 @@
#include "TowerDefense.h"
#include "TowerDefenseTower.h"
#include "TowerDefenseCenterpoint.h"
-//#include "TDCoordinate.h"
#include "worldentities/SpawnPoint.h"
-#include "worldentities/pawns/Pawn.h"
-#include "worldentities/pawns/SpaceShip.h"
#include "controllers/WaypointController.h"
#include "graphics/Model.h"
#include "infos/PlayerInfo.h"
#include "chat/ChatManager.h"
#include "core/CoreIncludes.h"
-/* Part of a temporary hack to allow the player to add towers */
-#include "core/command/ConsoleCommandIncludes.h"
-#include <cmath>
-
namespace orxonox
{
- static const std::string __CC_addTower_name = "addTower";
- static const std::string __CC_upgradeTower_name = "upgradeTower";
- static const int upgradeCost = 20;
- static const int towerCost = 20;
- unsigned int maxspaceships = 30;
- int maxspaceshipsstandard = 30;
-
-
-
- SetConsoleCommand("TowerDefense", __CC_addTower_name, &TowerDefense::addTower ).addShortcut().defaultValues(1);
- SetConsoleCommand("TowerDefense", __CC_upgradeTower_name, &TowerDefense::upgradeTower).addShortcut().defaultValues(0);
-
RegisterUnloadableClass(TowerDefense);
TowerDefense::TowerDefense(Context* context) : TeamDeathmatch(context)
{
RegisterObject(TowerDefense);
-/*
- for (int i=0; i < 16 ; i++){
- for (int j = 0; j< 16 ; j++){
- towermatrix[i][j] = NULL;
- }
- }*/
- //Timer for the waves (10 seconds between the waves)
selecter = NULL;
this->player_ = NULL;
this->setHUDTemplate("TowerDefenseHUD");
- this->nextwaveTimer_.setTimer(10, false, createExecutor(createFunctor(&TowerDefense::nextwave, this)));
- this->nextwaveTimer_.stopTimer();
- this->waves_ = 0;
- this->time = 0;
+ this->waveNumber_ = 0;
+ this->timeSinceLastSpawn_ = 0.0;
+ this->timeUntilNextWave_ = 0.0;
this->credit_ = 0;
this->lifes_ = 0;
- this->timeSetTower_ = 0;
- spaceships =15;
- eggs=3;
- ufos=7;
- randomships=5;
-
-
- ModifyConsoleCommand(__CC_addTower_name).setObject(this);
- ModifyConsoleCommand(__CC_upgradeTower_name).setObject(this);
+ this->waveSize_ = 0;
+ offset_ = Vector3(0,0,10);
}
TowerDefense::~TowerDefense()
{
- /* Part of a temporary hack to allow the player to add towers */
if (this->isInitialized())
{
- ModifyConsoleCommand(__CC_addTower_name).setObject(NULL);
- ModifyConsoleCommand(__CC_upgradeTower_name).setObject(NULL);
+
}
}
void TowerDefense::setCenterpoint(TowerDefenseCenterpoint *centerpoint)
{
- orxout() << "Centerpoint now setting..." << endl;
this->center_ = centerpoint;
- orxout() << "Centerpoint now set..." << endl;
}
void TowerDefense::start()
- {
+ {
if (center_ != NULL) // There needs to be a TowerDefenseCenterpoint, i.e. the area the game takes place.
{
if (selecter == NULL)
@@ -169,63 +131,23 @@
return;
}
+ enemies_.clear();
+
+ createFields();
TeamDeathmatch::start();
- // Waypoints: [1,3] [10,3] [10,11] [13,11] -> add the points to a matrix so the player cant place towers on the path
- for (int i=0; i < 16 ; i++)
- {
- for (int j = 0; j< 16 ; j++)
- {
- towerModelMatrix[i][j] = NULL;
- towerTurretMatrix[i][j] = NULL;
- }
- }
-
-
-
- if (player_ != NULL)
- {
- //this->player_->startControl(selecter);
- }
- else
- {
- orxout() << "player=NULL" << endl;
- }
-
-
- Model* dummyModel = new Model(this->center_->getContext());
-
- //the path of the spacehips has to be blocked, so that no towers can be build there
- for (int k=0; k<3; k++)
- towerModelMatrix[1][k]=dummyModel;
- for (int l=1; l<11; l++)
- towerModelMatrix[l][3]=dummyModel;
- for (int m=3; m<12; m++)
- towerModelMatrix[10][m]=dummyModel;
- for (int n=10; n<14; n++)
- towerModelMatrix[n][11]=dummyModel;
- for (int o=13; o<16; o++)
- towerModelMatrix[13][o]=dummyModel;
-
-
//set initial credits, lifes and WaveNumber
- this->setCredit(100);
- this->setLifes(100);
+ this->setCredit(1000);
+ this->setLifes(100);
+ this->timeSinceLastSpawn_ = 0.0;
+ this->timeUntilNextWave_ = 5.0;
+ this->waveSize_ = 0;
this->setWaveNumber(0);
- time=0.0;
-
- /*
- //adds initial towers
- for (int i=0; i <7; i++){
- addTower(i+3,4);
- }
- */
}
// Generates a TowerDefenseEnemy. Uses Template "enemytowerdefense". Sets position at first waypoint of path.
- void TowerDefense::addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr){
-
-
+ void TowerDefense::addTowerDefenseEnemy(int templatenr)
+ {
TowerDefenseEnemy* en1 = new TowerDefenseEnemy(this->center_->getContext());
switch(templatenr)
@@ -233,37 +155,42 @@
case 1 :
en1->addTemplate("enemytowerdefense1");
en1->setScale(3);
- en1->lookAt(Vector3(0,0,100000));
- en1->setHealth(en1->getHealth() +50 + this->getWaveNumber()*4);
+ en1->setHealth(en1->getHealth() + this->getWaveNumber()*4);
break;
case 2 :
en1->addTemplate("enemytowerdefense2");
en1->setScale(2);
- en1->lookAt(Vector3(0,0,100000));
- en1->roll(Degree(120));
- en1->setHealth(en1->getHealth() -30 + this->getWaveNumber()*4);
- // en1->setShieldHealth(en1->getShield() = this->getWaveNumber()*2))
+ en1->setHealth(en1->getHealth() + this->getWaveNumber()*4);
break;
case 3 :
en1->addTemplate("enemytowerdefense3");
en1->setScale(1);
- en1->lookAt(Vector3(0,0,100000));
- en1->roll(Degree(120));
- en1->setHealth(en1->getHealth() -10 + this->getWaveNumber()*4);
+ en1->setHealth(en1->getHealth() + this->getWaveNumber()*4);
break;
- }
+ }
en1->setTeam(2);
- en1->getController();
- en1->setPosition(path.at(0)->get3dcoordinate());
- TowerDefenseEnemyvector.push_back(en1);
- for(unsigned int i = 0; i < path.size(); ++i)
+ WaypointController* controller = (WaypointController*)(en1->getXMLController());
+
+ if (controller != NULL && waypoints_.size() > 1)
{
- en1->addWaypoint((path.at(i)));
+ en1->setPosition(waypoints_.at(0)->getPosition() + offset_);
+ en1->setOrientation(Vector3(0,0,10), Degree(0));
+ en1->setDirection(Vector3(0,1,0));
+ en1->lookAt(waypoints_.at(1)->getPosition() + offset_);
+
+ for (unsigned int i = 0; i < waypoints_.size(); ++ i)
+ {
+ orxonox::WeakPtr<MovableEntity> waypoint = new MovableEntity(this->center_->getContext());
+ waypoint->setPosition(waypoints_.at(i)->getPosition() + offset_);
+ controller->addWaypoint(waypoint);
+ }
}
+
+ enemies_.push_back(en1);
}
@@ -278,12 +205,11 @@
void TowerDefense::spawnPlayer(PlayerInfo* player)
{
assert(player);
- this->player_ = player;
+ player_ = player;
if (selecter->getPlayer() == NULL)
{
- this->player_ = player;
- player->startControl(selecter);
+ player_->startControl(selecter);
players_[player].state_ = PlayerState::Alive;
}
}
@@ -300,394 +226,185 @@
}
//not working yet
- void TowerDefense::upgradeTower(int x,int y)
+ void TowerDefense::addTower(int x,int y)
{
TDCoordinate* coord = new TDCoordinate(x,y);
x = coord->GetX();
y = coord->GetY();
-
- if (!this->hasEnoughCreditForTower(upgradeCost))
- {
- orxout() << "not enough credit: " << (this->getCredit()) << " available, " << upgradeCost << " needed.";
- return;
- }
+ int cost = center_->getTowerCost(1);
-
- Model* dummyModel2 = new Model(this->center_->getContext());
-
- if (towerModelMatrix [x][y] == NULL || (towerModelMatrix [x][y])->getMeshSource() == dummyModel2->getMeshSource())
+ if (fields_[x][y]->isFree() == true && getCredit() >= cost)
{
- orxout() << "no tower on this position" << endl;
- return;
+ payCredit(cost);
+ fields_[x][y]->createTower(1);
}
-
- else
- {
- (towerTurretMatrix [x][y])->upgradeTower();
- switch(towerTurretMatrix[x][y]->upgrade)
- {
- case 1 :
- towerModelMatrix[x][y]->setMeshSource("TD_T2.mesh");
- break;
-
- case 2 :
- towerModelMatrix[x][y]->setMeshSource("TD_T3.mesh");
- break;
- case 3 :
- towerModelMatrix[x][y]->setMeshSource("TD_T4.mesh");
- break;
- case 4 :
- towerModelMatrix[x][y]->setMeshSource("TD_T5.mesh");
- break;
-
- }
-
- this->buyTower(upgradeCost);
- }
}
/*adds Tower at Position (x,y) and reduces credit and adds the point to the towermatrix. template ("towerturret")
so towers have ability if the turrets
*/
- void TowerDefense::addTower(int x, int y)
- {
+ void TowerDefense::upgradeTower(int x, int y)
+ {
TDCoordinate* coord = new TDCoordinate(x,y);
x = coord->GetX();
- y = coord->GetY();
+ y = coord->GetY();
+ int cost = center_->getTowerCost(fields_[x][y]->getUpgrade() + 1);
- if (!this->hasEnoughCreditForTower(towerCost))
+ if (fields_[x][y]->isFree() == false && fields_[x][y]->canUpgrade() == true && getCredit() >= cost)
{
- orxout() << "not enough credit: " << (this->getCredit()) << " available, " << towerCost << " needed.";
- return;
+ payCredit(cost);
+ fields_[x][y]->upgrade();
}
-
- if (towerModelMatrix [x][y]!=NULL)
- {
- orxout() << "not possible to put tower here!!" << endl;
- return;
- }
-
-/*
- unsigned int width = this->center_->getWidth();
- unsigned int height = this->center_->getHeight();
-*/
-
- int tileScale = (int) this->center_->getTileScale();
-
- /*if (x > 15 || y > 15 || x < 0 || y < 0)
- {
- //Hard coded: TODO: let this depend on the centerpoint's height, width and fieldsize (fieldsize doesn't exist yet)
- orxout() << "Can not add Tower: x and y should be between 0 and 15" << endl;
- return;
- }*/
-
- //orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl;
- orxout() << "Will add tower at (" << x << "," << y << ")" << endl;
-
-
- //Create Model
- Model* newTowerModel = new Model(this->center_->getContext());
- newTowerModel->setMeshSource("TD_T1.mesh");
- newTowerModel->setScale(30);
- newTowerModel->pitch(Degree(90));
- newTowerModel->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 80);
-
- //Creates tower
- TowerDefenseTower* towernew = new TowerDefenseTower(this->center_->getContext());
- towernew->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 275);
- towernew->setGame(this);
- towernew->setTeam(1);
-
- //Reduce credit
- this->buyTower(towerCost);
- towerModelMatrix [x][y]= newTowerModel;
- towerTurretMatrix [x][y]= towernew;
}
- bool TowerDefense::hasEnoughCreditForTower(int towerCost)
- {
- return ((this->getCredit()) >= towerCost);
- }
-
-
- bool TowerDefense::hasEnoughCreditForUpgrade()
- {
- return true;
- }
-
-
- void TowerDefense::nextwave()
- {
-
- orxout() << "newwave" << endl;
- TowerDefenseEnemyvector.clear();
- waves_++;
- //maxspaceships = round(maxspaceshipsstandard + 0.25*(waves_));
- time=0;
-
- int helpnumber = 40 -(waves_);
- if(helpnumber <= 0) {helpnumber =1;}
- float numSpaceships = std::abs((rand() % 100)*5.0f*(helpnumber));
- float numEggs = std::abs((rand() % 100)*1.0f*(waves_));
- float numUfos = std::abs((rand() % 100)*1.5f*(0.5f*(waves_))) ;
-
- float totalnumber = (numSpaceships + numEggs + numUfos)*1.3f;
-
- int newspaceships = (int)(maxspaceships* numSpaceships / totalnumber);
- int neweggs = (int)(maxspaceships*numEggs / totalnumber);
- int newufos = (int)(maxspaceships*numUfos / totalnumber);
- int newrandomships = maxspaceships -newspaceships - neweggs - newufos;
- spaceships =newspaceships;
- eggs=neweggs;
- ufos=newufos;
- randomships=newrandomships;
-
- orxout() << spaceships << endl;
- orxout() << eggs << endl;
- orxout() << ufos << endl;
- orxout() << randomships << endl;
-
-
-
-
-
- }
-
void TowerDefense::tick(float dt)
{
SUPER(TowerDefense, tick, dt);
- time +=dt;
- timeSetTower_ +=dt;
- //Check if tower has to be set (because TowerDefenseSelecter asks for it)
- if(timeSetTower_ >= 0.25)
+ if (hasStarted() == false || player_ == NULL)
{
- timeSetTower_ =0;
- if(selecter != NULL && selecter->firePressed_)
- {
-
- int x = selecter->selectedPos_->GetX();
- int y = selecter->selectedPos_->GetY();
- Model* dummyModel2 = new Model(this->center_->getContext());
-
-
-
- if(towerModelMatrix[x][y] == NULL)
- {
- addTower(x,y);
- }
- else
- {
- if(!((towerModelMatrix [x][y])->getMeshSource() == dummyModel2->getMeshSource()))
- {
- towerTurretMatrix[x][y]->upgradeTower();
- if(towerTurretMatrix[x][y]->upgrade < towerTurretMatrix[x][y]->upgradeMax)
- {
- int specificupgradecost = (int)(upgradeCost*(std::pow(1.5,towerTurretMatrix[x][y]->upgrade)));
- if(this->credit_ >= specificupgradecost)
- {
- this->buyTower(specificupgradecost);
- switch(towerTurretMatrix[x][y]->upgrade)
- {
- case 1 :
- towerModelMatrix[x][y]->setMeshSource("TD_T2.mesh");
- break;
-
- case 2 :
- towerModelMatrix[x][y]->setMeshSource("TD_T3.mesh");
- break;
- case 3 :
- towerModelMatrix[x][y]->setMeshSource("TD_T4.mesh");
- break;
- case 4 :
- towerModelMatrix[x][y]->setMeshSource("TD_T5.mesh");
- break;
-
- }
- }
-
-
- }
- }
- }
- selecter->firePressed_ = false;
- }
+ return;
}
+ timeUntilNextWave_ -= dt;
+ timeSinceLastSpawn_ += dt;
- TDCoordinate* coord1 = new TDCoordinate(1,1);
- std::vector<TDCoordinate*> path;
- path.push_back(coord1);
+ //build/upgrade tower at selecter position
+ if (selecter != NULL && selecter->buildTower_ == true)
+ {
+ selecter->buildTower_ = false;
-
-
-
-
- if(time>=TowerDefenseEnemyvector.size() && TowerDefenseEnemyvector.size() < maxspaceships)
- {
-
- //adds different types of enemys depending on the WaveNumber progressively making the combination of enemys more difficult
- if(spaceships>0)
- {
- addTowerDefenseEnemy(path, 1);
- spaceships--;
-
- }else if(ufos>0)
- {
- addTowerDefenseEnemy(path, 3);
- ufos--;
- }else if(eggs>0)
- {
- addTowerDefenseEnemy(path, 2);
- eggs--;
- }else if(randomships>0)
- {
- addTowerDefenseEnemy(path, rand() % 3 +1);
- randomships--;
-
- }
-
- }
-
-
- Vector3* endpoint = new Vector3(500, 700, 150);
- //if ships are at the end they get destroyed
- for(unsigned int i =0; i < TowerDefenseEnemyvector.size(); ++i)
+ if (getField(selecter->selectedPos_)->canUpgrade() == true)
+ {
+ upgradeTower(selecter->selectedPos_->GetX(), selecter->selectedPos_->GetY());
+ }
+ else
+ {
+ addTower(selecter->selectedPos_->GetX(), selecter->selectedPos_->GetY());
+ }
+ }
+
+ for (std::list<WeakPtr<TowerDefenseEnemy> >::iterator it = enemies_.begin(); it != enemies_.end(); )
{
- if(TowerDefenseEnemyvector.at(i) != NULL && TowerDefenseEnemyvector.at(i)->isAlive())
+ if (*it == NULL)
{
- //destroys enemys at the end of the path and reduces the life by 1. no credits gifted
-
- Vector3 ship = TowerDefenseEnemyvector.at(i)->getRVWorldPosition();
- float distance = ship.distance(*endpoint);
-
- if(distance <50){
- TowerDefenseEnemyvector.at(i)->destroy();
+ // the enemy was destroyed by a tower - remove it from the list
+ enemies_.erase(it++);
+ addCredit(1);
+ }
+ else
+ {
+ //if ships are at the end they get destroyed
+ Vector3 ship = (*it)->getRVWorldPosition();
+ float distance = ship.distance(endpoint_);
+ if(distance < 40)
+ {
+ (*it)->destroy();
+ enemies_.erase(it++);
this->reduceLifes(1);
- this->buyTower(1);
- if (this->getLifes()==0)
+ if (this->getLifes() == 0)
{
this->end();
}
}
+ else
+ {
+ ++ it;
+ }
}
- }
+ }
- //goes thorugh vector to see if an enemy is still alive. if not next wave is launched
- int count= 0;
- for(unsigned int i =0; i < TowerDefenseEnemyvector.size(); ++i)
+ // Add new enemy?
+ if (timeSinceLastSpawn_ >= 1.0 && waveSize_ > 0)
{
- if(TowerDefenseEnemyvector.at(i)!= NULL)
- {
- ++count;
- }
+ // Add new enemy
+ timeSinceLastSpawn_ -= 1.0;
+ -- waveSize_;
+ addTowerDefenseEnemy(this->getWaveNumber() % 3 + 1);
}
+ else if (timeUntilNextWave_ <= 0.0 && waveSize_ <= 0)
+ {
+ //New wave
+ ++ waveNumber_;
+ timeSinceLastSpawn_ = 0.0;
- if (count == 0 && !this->nextwaveTimer_.isActive())
- this->nextwaveTimer_.startTimer();
+ timeUntilNextWave_ = waveNumber_+20;
+ waveSize_ = waveNumber_+5;
+ }
-/* time2 +=dt;
- if(count== 0)
+ }
+
+ void TowerDefense::createFields()
+ {
+ assert(center_);
+ TDCoordinate coord(0,0);
+ TDCoordinate startCoord(0,0);
+ std::string fields = center_->getFields();
+ int pos = 0;
+ for (int j = 15; j >= 0; --j)
{
- if(time2 > 10)
+ for (int i = 0; i < 16; ++i)
{
- TowerDefenseEnemyvector.clear();
- this->nextwave();
- time=0;
- time2=0;
+ coord.Set(i,j);
+ fields_[i][j] = new TowerDefenseField(center_->getContext());
+ fields_[i][j]->setCenterpoint(center_);
+ center_->attach(fields_[i][j]);
+ fields_[i][j]->setPosition(coord.get3dcoordinate());
+ fields_[i][j]->create(fields.at(pos), fields.at(pos+1));
+ pos += 2;
+ if (fields_[i][j]->getType() == START)
+ {
+ startCoord.Set(i,j);
+ waypoints_.push_back(fields_[i][j]);
+ }
}
}
-*/
+ //Place waypoints along the street for the waypoint controllers of the enemies
+ TDCoordinate* thisCoord = &startCoord;
+ TDCoordinate* nextCoord;
+ while ((nextCoord = getNextStreetCoord(thisCoord)) != NULL)
+ {
+ waypoints_.push_back(fields_[nextCoord->GetX()][nextCoord->GetY()]);
+ thisCoord = nextCoord;
+ endpoint_ = nextCoord->get3dcoordinate();
+ }
}
+ TDCoordinate* TowerDefense::getNextStreetCoord(TDCoordinate* thisCoord)
+ {
+ TowerDefenseField* thisField = fields_[thisCoord->GetX()][thisCoord->GetY()];
+ TDCoordinate* nextCoord = new TDCoordinate(0,0);
- // Function to test if we can add waypoints using code only. Doesn't work yet
-
- // THE PROBLEM: WaypointController's getControllableEntity() returns null, so it won't track. How do we get the controlableEntity to NOT BE NULL???
- /*
- void TowerDefense::addWaypointsAndFirstEnemy()
- {
- SpaceShip *newShip = new SpaceShip(this->center_);
- newShip->addTemplate("spaceshipassff");
-
- WaypointController *newController = new WaypointController(newShip);
- newController->setAccuracy(3);
-
- Model *wayPoint1 = new Model(newController);
- wayPoint1->setMeshSource("crate.mesh");
- wayPoint1->setPosition(7,-7,5);
- wayPoint1->setScale(0.2);
-
- Model *wayPoint2 = new Model(newController);
- wayPoint2->setMeshSource("crate.mesh");
- wayPoint2->setPosition(7,7,5);
- wayPoint2->setScale(0.2);
-
- newController->addWaypoint(wayPoint1);
- newController->addWaypoint(wayPoint2);
-
- // The following line causes the game to crash
-
- newShip->setController(newController);
-// newController -> getPlayer() -> startControl(newShip);
- newShip->setPosition(-7,-7,5);
- newShip->setScale(0.1);
- //newShip->addSpeed(1);
-
-
-
-// this->center_->attach(newShip);
- }
- */
- /*
- void TowerDefense::playerEntered(PlayerInfo* player)
- {
- TeamDeathmatch::playerEntered(player);
-
- const std::string& message = player->getName() + " entered the game";
- ChatManager::message(message);
- }
-
- bool TowerDefense::playerLeft(PlayerInfo* player)
- {
- bool valid_player = TeamDeathmatch::playerLeft(player);
-
- if (valid_player)
+ if (thisField->getType() != STREET && thisField->getType() != START)
{
- const std::string& message = player->getName() + " left the game";
- ChatManager::message(message);
+ return NULL;
}
- return valid_player;
- }
-
-
- void TowerDefense::pawnKilled(Pawn* victim, Pawn* killer)
- {
- if (victim && victim->getPlayer())
+ if (thisField->getAngle() == 0)
{
- std::string message;
- if (killer)
- {
- if (killer->getPlayer())
- message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
- else
- message = victim->getPlayer()->getName() + " was killed";
- }
- else
- message = victim->getPlayer()->getName() + " died";
+ nextCoord->Set(thisCoord->GetX(), thisCoord->GetY() - 1);
+ }
+ else if (thisField->getAngle() == 1)
+ {
+ nextCoord->Set(thisCoord->GetX() + 1, thisCoord->GetY());
+ }
+ else if (thisField->getAngle() == 2)
+ {
+ nextCoord->Set(thisCoord->GetX(), thisCoord->GetY() + 1);
+ }
+ else if (thisField->getAngle() == 3)
+ {
+ nextCoord->Set(thisCoord->GetX() - 1, thisCoord->GetY());
+ }
- ChatManager::message(message);
+ if (thisCoord->GetX() != nextCoord->GetX() || thisCoord->GetY() != nextCoord->GetY())
+ {
+ return nextCoord;
}
- TeamDeathmatch::pawnKilled(victim, killer);
+ return NULL;
}
-
- void TowerDefense::playerScored(PlayerInfo* player, int score)
- {
- Gametype::playerScored(player, score);
- }*/
}
Modified: code/trunk/src/modules/towerdefense/TowerDefense.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefense.h 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/TowerDefense.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -42,77 +42,55 @@
#include "gametypes/TeamDeathmatch.h"
#include "TowerDefenseEnemy.h"
#include "util/Output.h"
-#include "core/object/WeakPtr.h"
-#include "TowerDefenseSelecter.h"
-#include "graphics/Camera.h"
+#include "TowerDefenseField.h"
-
namespace orxonox
{
class _TowerDefenseExport TowerDefense : public TeamDeathmatch
{
public:
TowerDefense(Context* context);
- virtual ~TowerDefense();
-
- std::vector<orxonox::WeakPtr<TowerDefenseEnemy> > TowerDefenseEnemyvector;
- Model* towerModelMatrix[16][16];
- TowerDefenseTower* towerTurretMatrix[16][16];
- void addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr);
+ virtual ~TowerDefense();
+ void addTowerDefenseEnemy(int templatenr);
virtual void start(); //<! The function is called when the gametype starts
virtual void end();
virtual void tick(float dt);
virtual void spawnPlayer(PlayerInfo* player);
PlayerInfo* getPlayer(void) const;
int getCredit(){ return this->credit_; }
+ void payCredit(int pay){ this->credit_ -= pay; }
int getLifes(){ return this->lifes_; }
- int getWaveNumber(){ return this->waves_; }
+ int getWaveNumber(){ return this->waveNumber_; }
+ void setWaveNumber(int wavenumber){ waveNumber_=wavenumber; }
void setCredit(int credit){ credit_ = credit; }
- void setLifes(int lifes){ lifes_ = lifes; }
- void setWaveNumber(int wavenumber){ waves_=wavenumber; }
- void buyTower(int cost){ credit_ -= cost;}
+ void setLifes(int lifes){ lifes_ = lifes; }
+ void buyTower(int cost){ cost -= cost;}
void addCredit(int credit) { credit_+=credit; }
- void nextwave();
int reduceLifes(int NumberofLifes){ return lifes_-=NumberofLifes; }
- TowerDefenseSelecter* selecter;
- int spaceships;
- int eggs;
- int ufos;
- int randomships;
-
-
- //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
- //virtual void playerScored(PlayerInfo* player, int score);
-
-
- /* Called by TowerDefenseCenterpoint upon game start
- The centerpoint is used to create towers
- */
- void setCenterpoint(TowerDefenseCenterpoint *centerpoint);
-
- /* Adds a tower at x, y in the playfield */
+ TowerDefenseField* getField(TDCoordinate* coord){ return fields_[coord->GetX()][coord->GetY()]; }
+ void setCenterpoint(TowerDefenseCenterpoint* centerpoint);
void addTower(int x, int y);
- void upgradeTower(int x, int y);
+ void upgradeTower(int x, int y);
+ virtual TDCoordinate* getNextStreetCoord(TDCoordinate*);
+
+ TowerDefenseSelecter* selecter;
- //TODO: void spawnNewWave()
- //TODO: create a timer which regularly calls the spawnNewWave function (time driven)
- // or spawn a new wave when the old wave has been killed (event driven)
-
-
private:
- TowerDefenseCenterpoint *center_;
+ void createFields();
+
+ orxonox::WeakPtr<TowerDefenseCenterpoint> center_;
PlayerInfo* player_;
- float time;
- float timeSetTower_;
-// float time2;
+ float timeSinceLastSpawn_;
+ float timeUntilNextWave_;
+ int waveSize_;
int credit_;
- int waves_;
+ int waveNumber_;
int lifes_;
- Timer nextwaveTimer_;
-
- /* handles stats */
- bool hasEnoughCreditForTower(int towerCost);
- bool hasEnoughCreditForUpgrade();
+ std::list<orxonox::WeakPtr<TowerDefenseEnemy> > enemies_;
+ TowerDefenseField* fields_[16][16];
+ std::vector<orxonox::WeakPtr<TowerDefenseField> > waypoints_;
+ Vector3 endpoint_;
+ Vector3 offset_;
};
}
Modified: code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.cc 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -35,6 +35,7 @@
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
+#include "core/class/Super.h"
#include "TowerDefense.h"
@@ -71,13 +72,17 @@
XMLPortParam(TowerDefenseCenterpoint, "height", setHeight, getHeight, xmlelement, mode);
XMLPortParam(TowerDefenseCenterpoint, "tileScale", setTileScale, getTileScale, xmlelement, mode);
XMLPortParam(TowerDefenseCenterpoint, "selecterTemplate", setSelecterTemplate, getSelecterTemplate, xmlelement, mode);
-
- //TODO: add XMLPortObject(TowerDefenseCenterpoint, WorldEntity, "waypoints", addWaypoint, getWaypoint, xmlelement, mode);
- // This was copied and shightly modified from WaypointController.cc ; there are no getters and setters and no membervariable yet
- // The centerpoint should have all waypoints for "attached" to it. By using this function you can seperately add waypoints
- // When you spawn a new enemy you should let it be controlled by a WaypointController. And that controller should get the waypoints.
-
- // Alternatively you can manage the waypoints directly in TowerDefense.cc
+ XMLPortParam(TowerDefenseCenterpoint, "tower1Template", setTower1Template, getTower1Template, xmlelement, mode);
+ XMLPortParam(TowerDefenseCenterpoint, "tower2Template", setTower2Template, getTower2Template, xmlelement, mode);
+ XMLPortParam(TowerDefenseCenterpoint, "tower3Template", setTower3Template, getTower3Template, xmlelement, mode);
+ XMLPortParam(TowerDefenseCenterpoint, "tower4Template", setTower4Template, getTower4Template, xmlelement, mode);
+ XMLPortParam(TowerDefenseCenterpoint, "tower5Template", setTower5Template, getTower5Template, xmlelement, mode);
+ XMLPortParam(TowerDefenseCenterpoint, "fields", setFields, getFields, xmlelement, mode);
+ XMLPortParam(TowerDefenseCenterpoint, "tower1Cost", setTower1Cost, getTower1Cost, xmlelement, mode);
+ XMLPortParam(TowerDefenseCenterpoint, "tower2Cost", setTower2Cost, getTower2Cost, xmlelement, mode);
+ XMLPortParam(TowerDefenseCenterpoint, "tower3Cost", setTower3Cost, getTower3Cost, xmlelement, mode);
+ XMLPortParam(TowerDefenseCenterpoint, "tower4Cost", setTower4Cost, getTower4Cost, xmlelement, mode);
+ XMLPortParam(TowerDefenseCenterpoint, "tower5Cost", setTower5Cost, getTower5Cost, xmlelement, mode);
}
/**
@@ -93,4 +98,30 @@
towerDefenseGametype->setCenterpoint(this);
}
}
+
+ /**
+ @brief
+ Removes all blanks, tabs and returns from the string passed.
+ */
+ void TowerDefenseCenterpoint::trimString(std::string* str)
+ {
+ std::string* trimmed = new std::string("");
+ int length = str->size();
+ char temp;
+ for (int i = 0; i < length; ++ i)
+ {
+ temp = str->at(i);
+ if (temp != ' ' && temp != '\t' && temp != '\n')
+ {
+ trimmed->push_back(temp);
+ }
+ }
+
+ *str = *trimmed;
+ }
+
+ const int TowerDefenseCenterpoint::getTowerCost(int upgrade) const
+ {
+ return towerCosts_[(upgrade%5)];
+ }
}
Modified: code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.h 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -40,7 +40,7 @@
#include <string>
#include <util/Math.h>
-
+#include "TowerDefenseTower.h"
#include "worldentities/MobileEntity.h"
namespace orxonox
@@ -64,10 +64,60 @@
{ this->height_ = height; }
unsigned int getHeight(void) const
{ return this->height_; }
+ void setFields(const std::string& newFields)
+ { this->fields_ = newFields; trimString(&fields_); }
+ const std::string& getFields() const
+ { return this->fields_; }
void setSelecterTemplate(const std::string& newTemplate)
{ this->selecterTemplate_ = newTemplate; }
const std::string& getSelecterTemplate() const
{ return this->selecterTemplate_; }
+
+ void setTower1Template(const std::string& newTemplate)
+ { this->towerTemplates_[0] = newTemplate;}
+ const std::string& getTower1Template() const
+ { return this->towerTemplates_[0]; }
+ void setTower2Template(const std::string& newTemplate)
+ { this->towerTemplates_[1] = newTemplate; }
+ const std::string& getTower2Template() const
+ { return this->towerTemplates_[1]; }
+ void setTower3Template(const std::string& newTemplate)
+ { this->towerTemplates_[2] = newTemplate; }
+ const std::string& getTower3Template() const
+ { return this->towerTemplates_[2]; }
+ void setTower4Template(const std::string& newTemplate)
+ { this->towerTemplates_[3] = newTemplate; }
+ const std::string& getTower4Template() const
+ { return this->towerTemplates_[3]; }
+ void setTower5Template(const std::string& newTemplate)
+ { this->towerTemplates_[4] = newTemplate; }
+ const std::string& getTower5Template() const
+ { return this->towerTemplates_[4]; }
+
+ void setTower1Cost(const int& newCost)
+ { this->towerCosts_[0] = newCost;}
+ const int& getTower1Cost() const
+ { return this->towerCosts_[0]; }
+ void setTower2Cost(const int& newCost)
+ { this->towerCosts_[1] = newCost; }
+ const int& getTower2Cost() const
+ { return this->towerCosts_[1]; }
+ void setTower3Cost(const int& newCost)
+ { this->towerCosts_[2] = newCost; }
+ const int& getTower3Cost() const
+ { return this->towerCosts_[2]; }
+ void setTower4Cost(const int& newCost)
+ { this->towerCosts_[3] = newCost; }
+ const int& getTower4Cost() const
+ { return this->towerCosts_[3]; }
+ void setTower5Cost(const int& newCost)
+ { this->towerCosts_[4] = newCost; }
+ const int& getTower5Cost() const
+ { return this->towerCosts_[4]; }
+
+ const int getTowerCost(int upgrade) const;
+
+
/**
@brief How to convert to world coordinates, e.g. that 0,15 is not at -8,-8 but at -80,-80 (if scale would be 10)
*/
@@ -79,8 +129,11 @@
private:
void checkGametype();
-
+ void trimString(std::string*);
std::string selecterTemplate_;
+ std::string towerTemplates_[5];
+ int towerCosts_[5];
+ std::string fields_;
unsigned int width_;
unsigned int height_;
unsigned int tileScale_;
Deleted: code/trunk/src/modules/towerdefense/TowerDefenseController.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseController.cc 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/TowerDefenseController.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -1,146 +0,0 @@
-/*
- * 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:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-#include "TowerDefenseController.h"
-
-#include "util/Math.h"
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "worldentities/pawns/Pawn.h"
-#include "controllers/WaypointController.h"
-
-namespace orxonox
-{
- RegisterClass(TowerDefenseController);
-
- TowerDefenseController::TowerDefenseController(Context* context) : WaypointController(context)
- {
- RegisterObject(TowerDefenseController);
-
- this->alertnessradius_ = 500;
-
- this->patrolTimer_.setTimer(rnd(), true, createExecutor(createFunctor(&TowerDefenseController::searchEnemy, this)));
- }
-
- void TowerDefenseController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(TowerDefenseController, XMLPort, xmlelement, mode);
-
- XMLPortParam(TowerDefenseController, "alertnessradius", setAlertnessRadius, getAlertnessRadius, xmlelement, mode).defaultValues(500.0f);
- }
-
-
- void TowerDefenseController::tick(float dt)
- {
- if (!this->isActive())
- return;
-
- if (this->target_)
- {
- this->aimAtTarget();
-
- if (this->bHasTargetPosition_)
- this->moveToTargetPosition();
-
- if (this->getControllableEntity() && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f))
- this->getControllableEntity()->fire(0);
- }
- else
- {
- SUPER(TowerDefenseController, tick, dt);
- }
- }
-
-
- bool sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
- {
- if (entity1 == entity2)
- return true;
-
- int team1 = -1;
- int team2 = -1;
-
- Controller* controller = 0;
- if (entity1->getController())
- controller = entity1->getController();
- else
- controller = entity1->getXMLController();
- if (controller)
- {
- FormationController* ac = orxonox_cast<FormationController*>(controller);
- if (ac)
- team1 = ac->getTeam();
- }
-
- if (entity2->getController())
- controller = entity2->getController();
- else
- controller = entity2->getXMLController();
- if (controller)
- {
- FormationController* ac = orxonox_cast<FormationController*>(controller);
- if (ac)
- team2 = ac->getTeam();
- }
-
-
-
- return (team1 == team2 && team1 != -1);
- }
-
-
-
-
-
- void TowerDefenseController::searchEnemy()
- {
- this->patrolTimer_.setInterval(rnd());
-
- if (!this->getControllableEntity())
- return;
-
- Vector3 myposition = this->getControllableEntity()->getPosition();
- float shortestsqdistance = (float)static_cast<unsigned int>(-1);
-
- for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
- {
- if (ArtificialController::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>(*it), this->getGametype()))
- continue;
-
- float sqdistance = it->getPosition().squaredDistance(myposition);
- if (sqdistance < shortestsqdistance)
- {
- shortestsqdistance = sqdistance;
- this->target_ = (*it);
- }
- }
-
- if (shortestsqdistance > (this->alertnessradius_ * this->alertnessradius_))
- this->target_ = 0;
- }
-}
Deleted: code/trunk/src/modules/towerdefense/TowerDefenseController.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseController.h 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/TowerDefenseController.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -1,61 +0,0 @@
-/*
- * 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:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _TowerDefenseController_H__
-#define _TowerDefenseController_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "tools/Timer.h"
-#include "WaypointController.h"
-
-namespace orxonox
-{
- class _TowerDefenseExport TowerDefenseController : public WaypointController
- {
- public:
- TowerDefenseController(Context* context);
- virtual ~TowerDefenseController() {}
-
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- virtual void tick(float dt);
-
- inline void setAlertnessRadius(float radius)
- { this->alertnessradius_ = radius; }
- inline float getAlertnessRadius() const
- { return this->alertnessradius_; }
-
- protected:
- void searchEnemy();
-
- float alertnessradius_;
- Timer patrolTimer_;
- };
-}
-
-#endif /* _TowerDefenseController_H__ */
Modified: code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -29,30 +29,22 @@
this->setCollisionType(WorldEntity::Dynamic);
//needed to keep track of the PlayerStats coded in TowerDefense.h
this->td = orxonox_cast<TowerDefense*>(this->getGametype());
- once_=false;
-
+ once_ = false;
}
- //add credit if enemy is destroyed
- TowerDefenseEnemy::~TowerDefenseEnemy(){
- if (this->isInitialized())
- {
- getGame()->addCredit(1);
- }
- }
-
- void TowerDefenseEnemy::addWaypoint(TDCoordinate* coord)
+ TowerDefenseEnemy::~TowerDefenseEnemy()
{
- this->Waypointsvector_.push_back(coord);
+
}
-
void TowerDefenseEnemy::tick(float dt)
- {
+ {
+ //orxout() << "TDE tick1" << endl;
SUPER(TowerDefenseEnemy, tick, dt);
+ //orxout() << "TDE tick2" << endl;
}
- TowerDefense* TowerDefenseEnemy::getGame()
+ WeakPtr<TowerDefense> TowerDefenseEnemy::getGame()
{
if (game == NULL)
{
@@ -62,38 +54,14 @@
return game;
}
- void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
+ void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
{
- Pawn::damage(damage, healthdamage, shielddamage, originator, cs);
+ Pawn::damage(damage, healthdamage, shielddamage, originator);
+
if (getGame() && once_ == false && getHealth() <= 0)
{
- orxout() << "damagefunctionIF" << endl;
getGame()->addCredit(1);
once_ = true;
}
- orxout() << "damagefunction" << endl;
-
}
-
-/*
- void TowerDefenseEnemy::popWaypoint()
- {
- if(Waypointsvector_.size()>0)
- Waypointsvector_.pop_back();
- }
-
- TDCoordinate TowerDefenseEnemy::peekWaypoint()
- {
- if(Waypointsvector_.size()<=0){
- TDCoordinate* coord = TDCoordinate(-1,-1);
- return coord;
- }else{
- return Waypointsvector_.at(Waypointsvector_.size()-1);
-
- }
-
-
- }
-*/
-
}
Modified: code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -21,7 +21,6 @@
#include "towerdefense/TowerDefensePrereqs.h"
#include "worldentities/pawns/SpaceShip.h"
#include "util/Output.h"
-#include "controllers/ArtificialController.h"
#include "TowerDefense.h"
namespace orxonox
@@ -38,20 +37,13 @@
//health gibt es unter: health_
virtual void tick(float dt);
- void addWaypoint(TDCoordinate* coord);
- void popWaypoint();
- TDCoordinate peekWaypoint();
+ virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator);
- virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs);
-
-
private:
- TowerDefense* getGame();
+ WeakPtr<TowerDefense> getGame();
WeakPtr<TowerDefense> game;
TowerDefense* td;
bool once_;
- std::vector<TDCoordinate*> Waypointsvector_;
-
};
Added: code/trunk/src/modules/towerdefense/TowerDefenseField.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseField.cc (rev 0)
+++ code/trunk/src/modules/towerdefense/TowerDefenseField.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -0,0 +1,327 @@
+/*
+ * 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:
+ * ...
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file TowerDefenseField.cc
+ @brief Implementation of the TowerDefenseField class.
+*/
+
+#include "TowerDefenseField.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "TowerDefense.h"
+
+namespace orxonox
+{
+ RegisterClass(TowerDefenseField);
+
+ /**
+ @brief
+ Constructor. Registers and initializes the object and checks whether the gametype is actually TowerDefense.
+ */
+ TowerDefenseField::TowerDefenseField(Context* context) : MovableEntity(context)
+ {
+ RegisterObject(TowerDefenseField);
+
+ tower_ = NULL;
+ type_ = FREE;
+ center_ = NULL;
+ upgrade_ = 0;
+ setPosition(0,0,0);
+ modelGround_ = new Model(getContext());
+ modelGround_->setScale(25);
+ modelGround_->pitch(Degree(90));
+ attach(modelGround_);
+ modelObject_ = new Model(getContext());
+ modelObject_->setScale(25);
+ modelObject_->pitch(Degree(90));
+ attach(modelObject_);
+ setAngle(0);
+ }
+
+ /**
+ @brief
+ Method to create a TowerDefenseField through XML.
+ */
+ void TowerDefenseField::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(TowerDefenseField, XMLPort, xmlelement, mode);
+
+ //XMLPortParam(TowerDefenseField, "width", setWidth, getWidth, xmlelement, mode);
+
+ }
+
+ void TowerDefenseField::setCenterpoint(TowerDefenseCenterpoint* center)
+ {
+ center_ = center;
+ }
+
+ void TowerDefenseField::upgrade()
+ {
+ if (canUpgrade() == true)
+ {
+ destroyTower();
+ createTower(getUpgrade() + 1);
+ }
+ }
+
+ int TowerDefenseField::getUpgrade()
+ {
+ return upgrade_;
+ }
+
+ TowerDefenseFieldType TowerDefenseField::getType()
+ {
+ return type_;
+ }
+
+ void TowerDefenseField::setUpgrade(int upgrade)
+ {
+ if (upgrade < 0)
+ {
+ upgrade_ = 0;
+ }
+ else if (upgrade > 5)
+ {
+ upgrade = 5;
+ }
+ else
+ {
+ upgrade_ = upgrade;
+ }
+ }
+
+ bool TowerDefenseField::canUpgrade()
+ {
+ if (tower_ != NULL && upgrade_ < 5)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ void TowerDefenseField::setAngle(int newAngle)
+ {
+ if (modelGround_ != NULL)
+ {
+ switch (newAngle)
+ {
+ case 0:
+ modelGround_->yaw(Degree(0));
+ angle_ = 0;
+ break;
+ case 1:
+ modelGround_->yaw(Degree(90));
+ angle_ = 1;
+ break;
+ case 2:
+ modelGround_->yaw(Degree(180));
+ angle_ = 2;
+ break;
+ case 3:
+ modelGround_->yaw(Degree(270));
+ angle_ = 3;
+ break;
+ }
+ }
+
+ if (modelObject_ != NULL)
+ {
+ switch (newAngle)
+ {
+ case 0:
+ modelObject_->yaw(Degree(0));
+ angle_ = 0;
+ break;
+ case 1:
+ modelObject_->yaw(Degree(90));
+ angle_ = 1;
+ break;
+ case 2:
+ modelObject_->yaw(Degree(180));
+ angle_ = 2;
+ break;
+ case 3:
+ modelObject_->yaw(Degree(270));
+ angle_ = 3;
+ break;
+ }
+ }
+
+ }
+
+ int TowerDefenseField::getAngle()
+ {
+ return angle_;
+ }
+
+ void TowerDefenseField::createFree(int orientation)
+ {
+ modelGround_->setMeshSource("TD_F1.mesh");
+ tower_ = NULL;
+ type_ = FREE;
+ setUpgrade(0);
+ setAngle(orientation);
+ }
+
+ void TowerDefenseField::createStart(int orientation)
+ {
+ modelGround_->setMeshSource("TD_S5.mesh");
+ tower_ = NULL;
+ type_ = START;
+ setUpgrade(0);
+ setAngle(orientation);
+ }
+
+
+ void TowerDefenseField::createEnd(int orientation)
+ {
+ modelGround_->setMeshSource("TD_S4.mesh");
+ tower_ = NULL;
+ type_ = END;
+ setUpgrade(0);
+ setAngle(orientation);
+ }
+
+ void TowerDefenseField::createStraight(int orientation)
+ {
+ modelGround_->setMeshSource("TD_S1.mesh");
+ tower_ = NULL;
+ type_ = STREET;
+ setUpgrade(0);
+ setAngle(orientation);
+ }
+
+ void TowerDefenseField::createRCurve(int orientation)
+ {
+ modelGround_->setMeshSource("TD_S2.mesh");
+ tower_ = NULL;
+ type_ = STREET;
+ setUpgrade(0);
+ setAngle(orientation);
+ }
+
+ void TowerDefenseField::createLCurve(int orientation)
+ {
+ modelGround_->setMeshSource("TD_S3.mesh");
+ tower_ = NULL;
+ type_ = STREET;
+ setUpgrade(0);
+ setAngle(orientation);
+ }
+
+ void TowerDefenseField::createObstacle(int orientation)
+ {
+ modelGround_->setMeshSource("TD_F1.mesh");
+ modelObject_->setMeshSource("TD_O1.mesh");
+ tower_ = NULL;
+ type_ = OBSTACLE;
+ setUpgrade(0);
+ setAngle(orientation);
+ }
+
+ void TowerDefenseField::createTower(int upgrade)
+ {
+ if (tower_ == NULL)
+ {
+ modelGround_->setMeshSource("TD_F1.mesh");
+ tower_ = new TowerDefenseTower(center_->getContext());
+ attach(tower_);
+ type_ = TOWER;
+ setUpgrade(upgrade);
+ if (upgrade_ > 0 && modelObject_ != NULL)
+ {
+ switch (upgrade_)
+ {
+ case 1:
+ modelObject_->setMeshSource("TD_T1.mesh");
+ tower_->addTemplate(center_->getTower1Template());
+ break;
+ case 2:
+ modelObject_->setMeshSource("TD_T2.mesh");
+ tower_->addTemplate(center_->getTower2Template());
+ break;
+ case 3:
+ modelObject_->setMeshSource("TD_T3.mesh");
+ tower_->addTemplate(center_->getTower3Template());
+ break;
+ case 4:
+ modelObject_->setMeshSource("TD_T4.mesh");
+ tower_->addTemplate(center_->getTower4Template());
+ break;
+ case 5:
+ modelObject_->setMeshSource("TD_T5.mesh");
+ tower_->addTemplate(center_->getTower5Template());
+ break;
+ }
+ }
+ }
+ }
+
+ void TowerDefenseField::destroyTower()
+ {
+ if (tower_ != NULL)
+ {
+ tower_->destroy();
+ tower_ = NULL;
+ }
+ }
+
+ void TowerDefenseField::create(char object, char param)
+ {
+ int paramInt = atoi(¶m);
+ switch (object)
+ {
+ case 'F':
+ createFree(paramInt);
+ break;
+ case 'I':
+ createStraight(paramInt);
+ break;
+ case 'R':
+ createRCurve(paramInt);
+ break;
+ case 'L':
+ createLCurve(paramInt);
+ break;
+ case 'X':
+ createStart(paramInt);
+ break;
+ case 'O':
+ createEnd(paramInt);
+ break;
+ case 'Y':
+ createObstacle(paramInt);
+ break;
+ case 'T':
+ createTower(paramInt);
+ break;
+ }
+ }
+}
Added: code/trunk/src/modules/towerdefense/TowerDefenseField.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseField.h (rev 0)
+++ code/trunk/src/modules/towerdefense/TowerDefenseField.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -0,0 +1,97 @@
+/*
+ * 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:
+ * ...
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @brief
+ See TowerDefenseReadme.txt for Information.
+ @ingroup TowerDefense
+ */
+
+
+#ifndef _TowerDefenseField_H__
+#define _TowerDefenseField_H__
+
+#include "towerdefense/TowerDefensePrereqs.h"
+#include "TowerDefenseTower.h"
+ #include "TowerDefenseCenterpoint.h"
+#include <string>
+#include "graphics/Model.h"
+#include "worldentities/MovableEntity.h"
+
+namespace orxonox
+{
+ enum TowerDefenseFieldType
+ {
+ FREE,
+ STREET,
+ START,
+ END,
+ OBSTACLE,
+ TOWER
+ };
+
+
+ class _TowerDefenseExport TowerDefenseField : public MovableEntity
+ {
+ public:
+ TowerDefenseField(Context* context);
+ virtual ~TowerDefenseField() {}
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ const bool isFree() const
+ { return type_==FREE; }
+ virtual void create(char object, char param);
+ virtual void setCenterpoint(TowerDefenseCenterpoint* center);
+ virtual void upgrade();
+ virtual int getUpgrade();
+ virtual TowerDefenseFieldType getType();
+ virtual void setUpgrade(int upgrade);
+ virtual bool canUpgrade();
+ virtual void createFree(int orientation);
+ virtual void createStart(int orientation);
+ virtual void createEnd(int orientation);
+ virtual void createStraight(int orientation);
+ virtual void createLCurve(int orientation);
+ virtual void createRCurve(int orientation);
+ virtual void createObstacle(int orientation);
+ virtual void createTower(int upgrade);
+ virtual int getAngle();
+ private:
+ virtual void setAngle(int newAngle);
+ virtual void destroyTower();
+ int angle_;
+ TowerDefenseFieldType type_;
+ Model* modelGround_;
+ Model* modelObject_;
+ TowerDefenseTower* tower_;
+ TowerDefenseCenterpoint* center_;
+ int upgrade_;
+
+ };
+}
+
+#endif /* _TowerDefenseField_H__ */
Modified: code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -49,18 +49,23 @@
void TowerDefenseHUDController::tick(float dt)
{
SUPER(TowerDefenseHUDController, tick, dt);
+
const std::string& lifes = multi_cast<std::string>(this->td->getLifes());
const std::string& credits = multi_cast<std::string>(this->td->getCredit());
const std::string& wave = multi_cast<std::string>(this->td->getWaveNumber());
if(showlives == true)
- this->setCaption(multi_cast<std::string>(lifes));
+ {
+ this->setCaption(multi_cast<std::string>(lifes));
+ }
else if(showcredits == true)
- this->setCaption(multi_cast<std::string>(credits));
+ {
+ this->setCaption(multi_cast<std::string>(credits));
+ }
else if(showwaves == true)
- this->setCaption(multi_cast<std::string>(wave));
-
-
+ {
+ this->setCaption(multi_cast<std::string>(wave));
+ }
}
void TowerDefenseHUDController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
Modified: code/trunk/src/modules/towerdefense/TowerDefenseSelecter.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseSelecter.cc 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/TowerDefenseSelecter.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -50,9 +50,9 @@
moveDownPressed_ = false;
moveLeftPressed_ = false;
moveRightPressed_ = false;
- firePressed_ = false;
- setSelectedPosition(6,6);
- timerSetFire_=0;
+ boostPressed_ = false;
+ buildTower_ = false;
+ setSelectedPosition(0,0);
}
TowerDefenseSelecter::~TowerDefenseSelecter()
@@ -69,53 +69,48 @@
{
SUPER(TowerDefenseSelecter, tick, dt);
+ time_ += dt;
- if (hasLocalController())
- {
- timerSetFire_ +=dt;
+ if (hasLocalController() && time_ >= 0.25)
+ {
+ time_ = 0;
- if(timerSetFire_ >= 0.25)
- {
- timerSetFire_ = 0;
+ int selecterPosX = selectedPos_->GetX();
+ int selecterPosY = selectedPos_->GetY();
- int selecterPosX = selectedPos_->GetX();
- int selecterPosY = selectedPos_->GetY();
+ if (moveUpPressed_ == true)
+ {
+ moveUpPressed_ = false;
+ selectedPos_->Set(selecterPosX, selecterPosY + 1);
+ updatePosition();
+ }
+ if (moveDownPressed_ == true)
+ {
+ moveDownPressed_ = false;
+ selectedPos_->Set(selecterPosX, selecterPosY - 1);
+ updatePosition();
+ }
+ if (moveLeftPressed_ == true)
+ {
+ moveLeftPressed_ = false;
+ selectedPos_->Set(selecterPosX - 1, selecterPosY);
+ updatePosition();
+ }
+ if (moveRightPressed_ == true)
+ {
+ moveRightPressed_ = false;
+ selectedPos_->Set(selecterPosX + 1, selecterPosY);
+ updatePosition();
+ }
+ if (boostPressed_ == true)
+ {
+ boostPressed_ = false;
+ buildTower_ = true;
+ }
+ }
+ }
- if (moveUpPressed_ == true)
- {
- moveUpPressed_ = false;
- selectedPos_->Set(selecterPosX, selecterPosY + 1);
- updatePosition();
- }
- if (moveDownPressed_ == true)
- {
- moveDownPressed_ = false;
- selectedPos_->Set(selecterPosX, selecterPosY - 1);
- updatePosition();
- }
- if (moveLeftPressed_ == true)
- {
- moveLeftPressed_ = false;
- selectedPos_->Set(selecterPosX - 1, selecterPosY);
- updatePosition();
- }
- if (moveRightPressed_ == true)
- {
- moveRightPressed_ = false;
- selectedPos_->Set(selecterPosX + 1, selecterPosY);
- updatePosition();
- }
-
-
- }
-
-
-
- }
- }
-
-
void TowerDefenseSelecter::moveFrontBack(const Vector2& value)
{
if (value.x > 0)
@@ -156,14 +151,23 @@
{
}
+ void TowerDefenseSelecter::fire(unsigned int firemode)
+ {
+ }
+ void TowerDefenseSelecter::fired(unsigned int firemode)
+ {
+
+ }
+
void TowerDefenseSelecter::boost(bool bBoost)
{
- firePressed_ = true;
- orxout() << "boost" << endl;
+ if (bBoost == true)
+ {
+ boostPressed_ = true;
+ }
}
-
void TowerDefenseSelecter::updatePosition()
{
setPosition(selectedPos_->get3dcoordinate());
@@ -179,6 +183,4 @@
{
setSelectedPosition(new TDCoordinate(x,y));
}
-
-
}
Modified: code/trunk/src/modules/towerdefense/TowerDefenseSelecter.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseSelecter.h 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/TowerDefenseSelecter.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -47,20 +47,22 @@
virtual void rotateYaw(const Vector2& value);
virtual void rotatePitch(const Vector2& value);
virtual void rotateRoll(const Vector2& value);
+ void fire(unsigned int firemode);
+ virtual void fired(unsigned int firemode);
virtual void boost(bool bBoost);
virtual void setSelectedPosition(TDCoordinate* newPos);
virtual void setSelectedPosition(int x, int y);
- bool firePressed_;
+
+ bool buildTower_;
TDCoordinate* selectedPos_;
-
-
private:
- virtual void updatePosition();
- float timerSetFire_;
+ virtual void updatePosition();
+ float time_;
bool moveUpPressed_;
bool moveDownPressed_;
bool moveLeftPressed_;
- bool moveRightPressed_;
+ bool moveRightPressed_;
+ bool boostPressed_;
};
}
Modified: code/trunk/src/modules/towerdefense/TowerDefenseTower.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseTower.cc 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/TowerDefenseTower.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -26,12 +26,8 @@
RegisterObject(TowerDefenseTower);
game_ =NULL;
this->setCollisionType(WorldEntity::None);
- upgrade = 0;
- this->addTemplate("towerdefensetower");
+ upgrade = 1;
- upgradeMax = 5;
-
-
//this->removeAllEngines();
/*
@@ -61,15 +57,15 @@
bool TowerDefenseTower::upgradeTower()
{
- if(upgrade < upgradeMax)
+ if(upgrade < 5)
{
upgrade++;
float reloadrate = getReloadRate();
float reloadwaittime = getReloadWaitTime();
- this->setDamageMultiplier((upgrade+1)*1.5f);
- this->setRotationThrust(2*this->getRotationThrust());
- reloadrate = 0.7f*reloadrate;
- reloadwaittime = 0.7f*reloadwaittime;
+ this->setDamageMultiplier((upgrade+1)*2);
+ //this->setRotationThrust(2*this->getRotationThrust());
+ reloadrate = 0.5f*reloadrate;
+ reloadwaittime = 0.5f*reloadwaittime;
setReloadRate(reloadrate);
setReloadWaitTime(reloadwaittime);
//this->addTemplate("towerturret1");
Modified: code/trunk/src/modules/towerdefense/TowerDefenseTower.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseTower.h 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/towerdefense/TowerDefenseTower.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -18,7 +18,6 @@
#define Orxonox_TowerDefenseTower_h
#include "towerdefense/TowerDefensePrereqs.h"
-#include "worldentities/pawns/SpaceShip.h"
#include "objects/Turret.h"
@@ -37,22 +36,18 @@
*/
// Overriding these to stop TowerDefenseTowers from spasing out
- /*
- void setOrientation(const Quaternion& orientation);
- virtual void rotateYaw(const Vector2& value);
- virtual void rotatePitch(const Vector2& value);
- virtual void rotateRoll(const Vector2& value);
- */
+ //void setOrientation(const Quaternion& orientation);
+ //virtual void rotateYaw(const Vector2& value);
+ //virtual void rotatePitch(const Vector2& value);
+ //virtual void rotateRoll(const Vector2& value);
virtual bool upgradeTower();
void setGame(TowerDefense* Towerdefense)
{ assert(Towerdefense); game_ = Towerdefense; }
- int upgrade;
- int upgradeMax;
private:
TowerDefense* game_;
-
+ int upgrade;
};
}
Modified: code/trunk/src/modules/weapons/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/weapons/CMakeLists.txt 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/weapons/CMakeLists.txt 2015-10-10 14:34:26 UTC (rev 10629)
@@ -1,6 +1,7 @@
SET_SOURCE_FILES(WEAPONS_SRC_FILES
MuzzleFlash.cc
RocketController.cc
+ IceGunFreezer.cc
)
ADD_SUBDIRECTORY(munitions)
Added: code/trunk/src/modules/weapons/IceGunFreezer.cc
===================================================================
--- code/trunk/src/modules/weapons/IceGunFreezer.cc (rev 0)
+++ code/trunk/src/modules/weapons/IceGunFreezer.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -0,0 +1,127 @@
+/*
+* 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 IceGunFreezer.h
+ @brief Implementation of the IceGunFreezer class.
+*/
+
+#include "core/CoreIncludes.h"
+#include "core/command/Executor.h"
+
+#include "IceGunFreezer.h"
+
+namespace orxonox
+{
+ RegisterClass(IceGunFreezer);
+
+ /**
+ @brief
+ Constructor.
+ */
+ IceGunFreezer::IceGunFreezer(Context* context) : StaticEntity(context)
+ {
+ RegisterObject(IceGunFreezer);
+
+ model = new Model(this->getContext());
+ model->setMeshSource("IceStar.mesh");
+ model->setScale(4.0);
+ this->attach(model);
+ model->setPosition(Vector3(0,0,0));
+ }
+
+ IceGunFreezer::~IceGunFreezer()
+ {
+
+ }
+
+ /**
+ @brief
+ The controlling happens here. This method defines what the controller has to do each tick.
+ @param dt
+ The duration of the tick.
+ */
+ void IceGunFreezer::tick(float dt)
+ {
+ SUPER(IceGunFreezer, tick, dt);
+
+
+ }
+
+ /**
+ @brief
+ Sets the freeze time variable to the passed value.
+ */
+ void IceGunFreezer::setFreezeTime(float freezeTime)
+ {
+ freezeTime_ = freezeTime;
+ }
+
+ /**
+ @brief
+ Sets the freeze factor variable to the passed value.
+ */
+ void IceGunFreezer::setFreezeFactor(float freezeFactor)
+ {
+ freezeFactor_ = freezeFactor;
+ }
+
+ /**
+ @brief
+ Try to slow down the WorldEntity where this is attached to. It is only possible to slow down a SpaceShip.
+ */
+ void IceGunFreezer::startFreezing()
+ {
+ WorldEntity* parent = this->getParent();
+
+ // Check if the freezer is attached to a parent and check if the parent is a SpaceShip
+ if (parent != NULL && parent->isA(Class(SpaceShip)))
+ {
+ freezedSpaceShip_ = orxonox_cast<SpaceShip*>(parent);
+ //Slow down the SpaceShip
+ freezedSpaceShip_->addSpeedFactor(freezeFactor_);
+ }
+
+ // Start timer even if the victim is not a SpaceShip to avoid that the IceGunFreezer gets never destroyed if it collided against a Pawn
+ this->freezeTimer_.setTimer(this->freezeTime_, false, createExecutor(createFunctor(&IceGunFreezer::stopFreezing, this)));
+ }
+
+ /**
+ @brief
+ This method is called by the timer. It gives back the original engine strength to the hit SpaceShip.
+ */
+ void IceGunFreezer::stopFreezing()
+ {
+ if (freezedSpaceShip_ != NULL && freezeFactor_ != 0.0)
+ {
+ freezedSpaceShip_->addSpeedFactor(1/freezeFactor_);
+ }
+
+ this->destroy();
+ }
+}
Added: code/trunk/src/modules/weapons/IceGunFreezer.h
===================================================================
--- code/trunk/src/modules/weapons/IceGunFreezer.h (rev 0)
+++ code/trunk/src/modules/weapons/IceGunFreezer.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -0,0 +1,71 @@
+/*
+ * 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 IceGunFreezer.h
+ @brief Definition of the IceGunFreezer class.
+*/
+
+#ifndef _IceGunFreezer_H__
+#define _IceGunFreezer_H__
+
+#include "weapons/WeaponsPrereqs.h"
+
+#include "tools/interfaces/Tickable.h"
+#include "worldentities/StaticEntity.h"
+#include "graphics/Model.h"
+#include "tools/Timer.h"
+#include "worldentities/pawns/SpaceShip.h"
+
+namespace orxonox
+{
+ /**
+ @brief
+ This is the WorldEntity that gets attached to a victim hit by a IceGunProjectile. It slows down the hit SpaceShip by a defined amount and time.
+ @ingroup Weapons
+ */
+ class _WeaponsExport IceGunFreezer : public StaticEntity, public Tickable
+ {
+ public:
+ IceGunFreezer(Context* context);
+ virtual ~IceGunFreezer();
+ virtual void tick(float dt);
+ virtual void startFreezing();
+ virtual void stopFreezing();
+ virtual void setFreezeTime(float freezeTime);
+ virtual void setFreezeFactor(float freezeFactor);
+ private:
+ float freezeTime_; //The duration of the freezing effect on a target
+ float freezeFactor_; //The strength of the freezing effect
+ Model* model;
+ Timer freezeTimer_;
+ WeakPtr<SpaceShip> freezedSpaceShip_;
+ };
+}
+
+#endif /* _IceGunFreezer_H__ */
Modified: code/trunk/src/modules/weapons/munitions/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/weapons/munitions/CMakeLists.txt 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/weapons/munitions/CMakeLists.txt 2015-10-10 14:34:26 UTC (rev 10629)
@@ -4,4 +4,6 @@
FusionMunition.cc
RocketMunition.cc
GravityBombMunition.cc
+ IceMunition.cc
+ SplitMunition.cc
)
Added: code/trunk/src/modules/weapons/munitions/IceMunition.cc
===================================================================
--- code/trunk/src/modules/weapons/munitions/IceMunition.cc (rev 0)
+++ code/trunk/src/modules/weapons/munitions/IceMunition.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -0,0 +1,55 @@
+/*
+ * 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 IceMunition.h
+ @brief Implementation of the IceMunition class.
+*/
+
+#include "IceMunition.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ RegisterClass(IceMunition);
+
+ IceMunition::IceMunition(Context* context) : Munition(context)
+ {
+ RegisterObject(IceMunition);
+
+ this->maxMunitionPerMagazine_ = 1;
+ this->maxMagazines_ = 50;
+ this->magazines_ = 25;
+
+ this->bUseSeparateMagazines_ = false;
+ this->bStackMunition_ = true;
+
+ this->bAllowMunitionRefilling_ = false;
+ this->bAllowMultiMunitionRemovementUnderflow_ = false;
+ }
+}
Added: code/trunk/src/modules/weapons/munitions/IceMunition.h
===================================================================
--- code/trunk/src/modules/weapons/munitions/IceMunition.h (rev 0)
+++ code/trunk/src/modules/weapons/munitions/IceMunition.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -0,0 +1,58 @@
+/*
+ * 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 IceMunition.h
+ @brief Definition of the IceMunition class.
+*/
+
+#ifndef _IceMunition_H__
+#define _IceMunition_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weaponsystem/Munition.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ IceMunition.
+ @author
+ Fabien Vultier
+ @ingroup WeaponsMunitions
+ */
+ class _WeaponsExport IceMunition : public Munition
+ {
+ public:
+ IceMunition(Context* context);
+ virtual ~IceMunition() {}
+ };
+}
+
+#endif /* _SplitMunition_H__ */
Added: code/trunk/src/modules/weapons/munitions/SplitMunition.cc
===================================================================
--- code/trunk/src/modules/weapons/munitions/SplitMunition.cc (rev 0)
+++ code/trunk/src/modules/weapons/munitions/SplitMunition.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -0,0 +1,55 @@
+/*
+ * 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 SplitMunition.h
+ @brief Implementation of the SplitMunition class.
+*/
+
+#include "SplitMunition.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ RegisterClass(SplitMunition);
+
+ SplitMunition::SplitMunition(Context* context) : Munition(context)
+ {
+ RegisterObject(SplitMunition);
+
+ this->maxMunitionPerMagazine_ = 1;
+ this->maxMagazines_ = 100;
+ this->magazines_ = 25;
+
+ this->bUseSeparateMagazines_ = false;
+ this->bStackMunition_ = true;
+
+ this->bAllowMunitionRefilling_ = true;
+ this->bAllowMultiMunitionRemovementUnderflow_ = false;
+ }
+}
Added: code/trunk/src/modules/weapons/munitions/SplitMunition.h
===================================================================
--- code/trunk/src/modules/weapons/munitions/SplitMunition.h (rev 0)
+++ code/trunk/src/modules/weapons/munitions/SplitMunition.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -0,0 +1,58 @@
+/*
+ * 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 SplitMunition.h
+ @brief Definition of the SplitMunition class.
+*/
+
+#ifndef _SplitMunition_H__
+#define _SplitMunition_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weaponsystem/Munition.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ SplitMunition.
+ @author
+ Fabien Vultier
+ @ingroup WeaponsMunitions
+ */
+ class _WeaponsExport SplitMunition : public Munition
+ {
+ public:
+ SplitMunition(Context* context);
+ virtual ~SplitMunition() {}
+ };
+}
+
+#endif /* _SplitMunition_H__ */
Modified: code/trunk/src/modules/weapons/projectiles/BillboardProjectile.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/BillboardProjectile.cc 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/weapons/projectiles/BillboardProjectile.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -87,6 +87,17 @@
/**
@brief
+ Get the material of the BillboardProjectile.
+ @return
+ The material name.
+ */
+ const std::string& BillboardProjectile::getMaterial()
+ {
+ return this->billboard_.getMaterial();
+ }
+
+ /**
+ @brief
Is called when the visibility of the BillboardProjectile has changed.
*/
void BillboardProjectile::changedVisibility()
Modified: code/trunk/src/modules/weapons/projectiles/BillboardProjectile.h
===================================================================
--- code/trunk/src/modules/weapons/projectiles/BillboardProjectile.h 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/weapons/projectiles/BillboardProjectile.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -59,6 +59,7 @@
virtual void setColour(const ColourValue& colour);
virtual void setMaterial(const std::string& material);
+ virtual const std::string& getMaterial();
virtual void changedVisibility();
private:
Modified: code/trunk/src/modules/weapons/projectiles/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/weapons/projectiles/CMakeLists.txt 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/weapons/projectiles/CMakeLists.txt 2015-10-10 14:34:26 UTC (rev 10629)
@@ -4,6 +4,8 @@
ParticleProjectile.cc
Projectile.cc
LightningGunProjectile.cc
+ SplitGunProjectile.cc
+ IceGunProjectile.cc
Rocket.cc
RocketOld.cc
SimpleRocket.cc
Added: code/trunk/src/modules/weapons/projectiles/IceGunProjectile.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/IceGunProjectile.cc (rev 0)
+++ code/trunk/src/modules/weapons/projectiles/IceGunProjectile.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -0,0 +1,98 @@
+/*
+ * 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 IceGunProjectile.cc
+ @brief Implementation of the IceGunProjectile class.
+*/
+
+#include "IceGunProjectile.h"
+
+#include "core/CoreIncludes.h"
+#include "graphics/Model.h"
+
+namespace orxonox
+{
+ RegisterClass(IceGunProjectile);
+
+ IceGunProjectile::IceGunProjectile(Context* context) : Projectile(context)
+ {
+ RegisterObject(IceGunProjectile);
+
+ this->setCollisionShapeRadius(8.0f);
+
+ this->setFreezeTime(3.0);
+ this->setFreezeFactor(0.5);
+
+ Model* model = new Model(this->getContext());
+ model->setMeshSource("IceBolt.mesh");
+ model->setScale(15.0);
+ this->attach(model);
+ model->setPosition(Vector3(0,0,0));
+ }
+
+ /**
+ @brief
+ Sets the freeze time variable to the passed value.
+ */
+ void IceGunProjectile::setFreezeTime(float freezeTime)
+ {
+ freezeTime_ = freezeTime;
+ }
+
+ /**
+ @brief
+ Sets the freeze factor variable to the passed value.
+ */
+ void IceGunProjectile::setFreezeFactor(float freezeFactor)
+ {
+ freezeFactor_ = freezeFactor;
+ }
+
+ bool IceGunProjectile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
+ {
+ bool bCollision = Projectile::collidesAgainst(otherObject, cs, contactPoint);
+
+ if (bCollision)
+ {
+ // If there was a collision, attach a IceGunFreezer to the hit object.
+ IceGunFreezer* freezer = new IceGunFreezer(this->getContext());
+ freezer->setFreezeTime(freezeTime_);
+ freezer->setFreezeFactor(freezeFactor_);
+ otherObject->attach(freezer);
+
+ Vector3 offset = this->getWorldPosition() - otherObject->getWorldPosition();
+ freezer->setPosition(Vector3(0,0,0));
+ freezer->translate(offset, WorldEntity::World);
+ // Start the freezing effect.
+ freezer->startFreezing();
+ }
+
+ return bCollision;
+ }
+}
Added: code/trunk/src/modules/weapons/projectiles/IceGunProjectile.h
===================================================================
--- code/trunk/src/modules/weapons/projectiles/IceGunProjectile.h (rev 0)
+++ code/trunk/src/modules/weapons/projectiles/IceGunProjectile.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -0,0 +1,71 @@
+/*
+ * 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 IceGunProjectile.h
+ @brief Definition of the IceGunProjectile class.
+*/
+
+#ifndef _IceGunProjectile_H__
+#define _IceGunProjectile_H__
+
+#include "weapons/WeaponsPrereqs.h"
+
+#include <string>
+#include "tools/Timer.h"
+#include "BillboardProjectile.h"
+#include "weapons/IceGunFreezer.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ The IceGunProjectile is a projectile that attaches a IceGunFreezer to the hit object. This object gets slowed down by the IceGunFreezer.
+ @author
+ Fabien Vultier
+ @ingroup WeaponsProjectiles
+ */
+ class _WeaponsExport IceGunProjectile : public Projectile
+ {
+ public:
+ IceGunProjectile(Context* context);
+ virtual ~IceGunProjectile() {}
+
+ virtual void setFreezeTime(float freezeTime);
+ virtual void setFreezeFactor(float freezeFactor);
+
+ protected:
+ virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
+ private:
+ float freezeTime_; //The duration of the freezing effect on a target
+ float freezeFactor_; //The strength of the freezing effect
+ };
+}
+
+#endif /* _IceGunProjectile_H__ */
Modified: code/trunk/src/modules/weapons/projectiles/Projectile.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/Projectile.cc 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/weapons/projectiles/Projectile.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -38,7 +38,6 @@
#include "core/GameMode.h"
#include "core/command/Executor.h"
-#include "objects/collisionshapes/SphereCollisionShape.h"
#include "worldentities/pawns/Pawn.h"
namespace orxonox
@@ -59,9 +58,10 @@
this->setCollisionResponse(false);
this->setCollisionType(Dynamic);
- SphereCollisionShape* shape = new SphereCollisionShape(this->getContext());
- shape->setRadius(20.0f);
- this->attachCollisionShape(shape);
+ // Create a sphere collision shape and attach it to the projectile.
+ collisionShape_ = new SphereCollisionShape(this->getContext());
+ setCollisionShapeRadius(20.0f);
+ this->attachCollisionShape(collisionShape_);
this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&BasicProjectile::destroyObject, this)));
}
@@ -76,7 +76,6 @@
SetConfigValue(lifetime_, 4.0f).description("The time in seconds a projectile stays alive");
}
-
void Projectile::tick(float dt)
{
SUPER(Projectile, tick, dt);
@@ -92,4 +91,11 @@
return this->processCollision(otherObject, contactPoint, cs);
}
+ void Projectile::setCollisionShapeRadius(float radius)
+ {
+ if (collisionShape_ != NULL && radius > 0)
+ {
+ collisionShape_->setRadius(radius);
+ }
+ }
}
Modified: code/trunk/src/modules/weapons/projectiles/Projectile.h
===================================================================
--- code/trunk/src/modules/weapons/projectiles/Projectile.h 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/weapons/projectiles/Projectile.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -38,6 +38,7 @@
#include "tools/Timer.h"
#include "worldentities/MovableEntity.h"
+#include "objects/collisionshapes/SphereCollisionShape.h"
#include "BasicProjectile.h"
@@ -65,9 +66,13 @@
virtual void tick(float dt);
virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
+ protected:
+ virtual void setCollisionShapeRadius(float radius);
+
private:
float lifetime_; //!< The time the projectile exists.
Timer destroyTimer_; //!< Timer to destroy the projectile after its lifetime has run out.
+ WeakPtr<SphereCollisionShape> collisionShape_; // The collision shape of the projectile.
};
}
Added: code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.cc (rev 0)
+++ code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -0,0 +1,161 @@
+/*
+ * 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 SplitGunProjectile.h
+ @brief Implementation of the SplitGunProjectile class.
+*/
+
+#include "SplitGunProjectile.h"
+
+#include "core/CoreIncludes.h"
+#include "core/command/Executor.h"
+#include "util/Convert.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+ RegisterClass(SplitGunProjectile);
+
+ SplitGunProjectile::SplitGunProjectile(Context* context) : BillboardProjectile(context)
+ {
+ RegisterObject(SplitGunProjectile);
+
+ this->numberOfSplits_ = 0;
+ this->numberOfChilds_ = 0;
+ this->splitTime_ = 1.0f;
+ this->spread_ = 0.2f;
+ this->damageReduction_ = 1.0f;
+ }
+
+ void SplitGunProjectile::setNumberOfSplits(int numberOfSplits)
+ {
+ if (numberOfSplits >= 0)
+ {
+ this->numberOfSplits_ = numberOfSplits;
+ }
+ else
+ {
+ this->numberOfSplits_ = 0;
+ }
+ }
+
+ void SplitGunProjectile::setNumberOfChilds(int numberOfChilds)
+ {
+ if (numberOfChilds >= 0)
+ {
+ this->numberOfChilds_ = numberOfChilds;
+ }
+ else
+ {
+ this->numberOfChilds_ = 0;
+ }
+ }
+
+ /**
+ @brief
+ This function starts a timer that will cause the projectile to split after a time defined by the argument @param splitTime.
+ */
+ void SplitGunProjectile::setSplitTime(float splitTime)
+ {
+ if (splitTime >= 0)
+ {
+ this->splitTime_ = splitTime;
+ this->splitTimer_.setTimer(this->splitTime_, false, createExecutor(createFunctor(&SplitGunProjectile::split, this)));
+ }
+ else
+ {
+ this->splitTime_ = 0;
+ }
+ }
+
+ void SplitGunProjectile::setSpread(float spread)
+ {
+ this->spread_ = spread;
+ }
+
+ /**
+ @brief
+ This is the setter function for the damageReduction_ variable. The value of the variable is bounded between 0 and 1.
+ */
+ void SplitGunProjectile::setDamageReduction(float damageReduction)
+ {
+ this->damageReduction_ = (damageReduction >= 0.0f ? damageReduction : 1.0f);
+ }
+
+ /**
+ @brief
+ If this function is called the projectile splits up into many child projectiles. The original projectiles does not get destroyed but it will never split up again.
+ */
+ void SplitGunProjectile::split()
+ {
+ if (numberOfSplits_ > 0)
+ {
+ -- numberOfSplits_;
+
+ // Reduce damage of this projectile
+ this->setDamage(this->getDamage() * this->damageReduction_ / (this->numberOfChilds_+1));
+
+ // Calculate a normalized vector (velocityOffset) that is perpendicluar to the velocity of this projectile. Since there are infinitly many perpendicular vectors a random one is chosen.
+ Vector3 velocityInitial = this->getVelocity();
+ Vector3 velocityOffset = velocityInitial.perpendicular();
+ velocityOffset.normalise();
+ Degree angle = Degree(rnd(0,360));
+ velocityOffset = Quaternion(angle, velocityInitial.normalisedCopy()) * velocityOffset;
+ velocityOffset.normalise();
+
+ // Create as many childs as defined by numberOfChilds_
+ for (int i = 0; i < numberOfChilds_; ++i)
+ {
+ // Every child projectile should fly uniform in different directions -> Rotate the velocityOffset in every iteration
+ velocityOffset = Quaternion(Degree(360/numberOfChilds_), velocityInitial.normalisedCopy()) * velocityOffset;
+ velocityOffset.normalise();
+
+ SplitGunProjectile* projectile = new SplitGunProjectile(this->getContext());
+
+ projectile->setMaterial(this->getMaterial());
+ projectile->setOrientation(this->getOrientation());
+ projectile->setPosition(this->getPosition());
+ projectile->setVelocity(velocityInitial + spread_*velocityOffset*velocityInitial.length());
+
+ projectile->setNumberOfSplits(this->numberOfSplits_);
+ projectile->setNumberOfChilds(this->numberOfChilds_);
+ projectile->setSplitTime(this->splitTime_);
+ projectile->setSpread(this->spread_);
+ projectile->setDamageReduction(this->damageReduction_);
+
+ projectile->setShooter(this->getShooter());
+ projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
+ }
+
+ numberOfSplits_ = 0;
+ }
+ }
+}
Added: code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.h
===================================================================
--- code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.h (rev 0)
+++ code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -0,0 +1,77 @@
+/*
+ * 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 IceGunProjectile.h
+ @brief Definition of the SplitGunProjectile class.
+*/
+
+#ifndef _SplitGunProjectile_H__
+#define _SplitGunProjectile_H__
+
+#include "weapons/WeaponsPrereqs.h"
+
+#include <string>
+#include "tools/Timer.h"
+#include "BillboardProjectile.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ The SplitGunProjectile is a projectile that may split up into many child projectiles.
+ @author
+ Fabien Vultier
+ @ingroup WeaponsProjectiles
+ */
+ class _WeaponsExport SplitGunProjectile : public BillboardProjectile
+ {
+ public:
+ SplitGunProjectile(Context* context);
+ virtual ~SplitGunProjectile() {}
+
+ virtual void setNumberOfSplits(int numberOfSplits);
+ virtual void setNumberOfChilds(int numberOfChilds);
+ virtual void setSplitTime(float splitTime);
+ virtual void setSpread(float spread);
+ virtual void setDamageReduction(float damageReduction);
+
+ private:
+ int numberOfSplits_;
+ int numberOfChilds_;
+ float splitTime_;
+ float spread_;
+ float damageReduction_; //The damage of a child projectile is reduced by this factor
+ Timer splitTimer_;
+
+ virtual void split();
+ };
+}
+
+#endif /* _SplitGunProjectile_H__ */
Modified: code/trunk/src/modules/weapons/weaponmodes/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/CMakeLists.txt 2015-10-10 09:40:59 UTC (rev 10628)
+++ code/trunk/src/modules/weapons/weaponmodes/CMakeLists.txt 2015-10-10 14:34:26 UTC (rev 10629)
@@ -4,6 +4,8 @@
LaserFire.cc
HsW01.cc
LightningGun.cc
+ SplitGun.cc
+ IceGun.cc
RocketFire.cc
RocketFireOld.cc
SimpleRocketFire.cc
Added: code/trunk/src/modules/weapons/weaponmodes/IceGun.cc
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/IceGun.cc (rev 0)
+++ code/trunk/src/modules/weapons/weaponmodes/IceGun.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -0,0 +1,103 @@
+/*
+ * 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 IceGun.cc
+ @brief Implementation of the IceGun class.
+*/
+
+#include "IceGun.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/pawns/Pawn.h"
+
+#include "weapons/projectiles/IceGunProjectile.h"
+
+namespace orxonox
+{
+ RegisterClass(IceGun);
+
+ IceGun::IceGun(Context* context) : WeaponMode(context)
+ {
+ RegisterObject(IceGun);
+
+ // Default values
+ this->reloadTime_ = 1.0f;
+ this->damage_ = 0.0f;
+ this->speed_ = 1200.0f;
+
+ this->setFreezeTime(3.0);
+ this->setFreezeFactor(0.5);
+
+ this->setMunitionName("LaserMunition");
+ this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
+ }
+
+ IceGun::~IceGun()
+ {
+ }
+
+ /**
+ @brief
+ XMLPort for the IceGun. You can define how often the projectiles split, how many childs should be created per split, the spread and the time between two splits.
+ */
+ void IceGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(IceGun, XMLPort, xmlelement, mode);
+
+ XMLPortParam(IceGun, "freezetime", setFreezeTime, getFreezeTime, xmlelement, mode);
+ XMLPortParam(IceGun, "freezefactor", setFreezeFactor, getFreezeFactor, xmlelement, mode);
+ }
+
+ /**
+ @brief
+ Fires the weapon. Creates a projectile and fires it.
+ */
+ void IceGun::fire()
+ {
+ IceGunProjectile* projectile = new IceGunProjectile(this->getContext());
+
+ this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
+ projectile->setOrientation(this->getMuzzleOrientation());
+ projectile->setPosition(this->getMuzzlePosition());
+ projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
+
+ // Pass important information to the projectile: Freeze time and freeze factor
+ projectile->setFreezeTime(getFreezeTime());
+ projectile->setFreezeFactor(getFreezeFactor());
+
+ projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
+ }
+}
Added: code/trunk/src/modules/weapons/weaponmodes/IceGun.h
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/IceGun.h (rev 0)
+++ code/trunk/src/modules/weapons/weaponmodes/IceGun.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -0,0 +1,75 @@
+/*
+ * 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 IceGun.h
+ @brief Definition of the IceGun class.
+*/
+
+#ifndef _IceGun_H__
+#define _IceGun_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weaponsystem/WeaponMode.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ A Gun that fires ice arrows that slow down any SpaceShip object that gets hit.
+ @author
+ Fabien Vultier
+ @ingroup WeaponsWeaponModes
+ */
+ class _WeaponsExport IceGun : public WeaponMode
+ {
+ public:
+ IceGun(Context* context);
+ virtual ~IceGun();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void fire();
+
+ inline void setFreezeTime(float freezeTime)
+ { this->freezeTime_ = freezeTime; }
+ inline float getFreezeTime() const
+ { return this->freezeTime_; }
+ inline void setFreezeFactor(float freezeFactor)
+ { this->freezeFactor_ = freezeFactor; }
+ inline float getFreezeFactor() const
+ { return this->freezeFactor_; }
+
+ private:
+ float speed_; //The speed of the fired projectile.
+ float freezeTime_; //The duration of the freezing effect on a target
+ float freezeFactor_; //The strength of the freezing effect
+ };
+}
+
+#endif /* _IceGun_H__ */
Added: code/trunk/src/modules/weapons/weaponmodes/SplitGun.cc
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/SplitGun.cc (rev 0)
+++ code/trunk/src/modules/weapons/weaponmodes/SplitGun.cc 2015-10-10 14:34:26 UTC (rev 10629)
@@ -0,0 +1,111 @@
+/*
+ * 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 SplitGun.cc
+ @brief Implementation of the SplitGun class.
+*/
+
+#include "SplitGun.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/pawns/Pawn.h"
+
+#include "weapons/projectiles/SplitGunProjectile.h"
+
+namespace orxonox
+{
+ RegisterClass(SplitGun);
+
+ SplitGun::SplitGun(Context* context) : WeaponMode(context)
+ {
+ RegisterObject(SplitGun);
+
+ this->reloadTime_ = 1.0f;
+ this->damage_ = 0.0f;
+ this->speed_ = 750.0f;
+ this->numberOfSplits_ = 2;
+ this->numberOfChilds_ = 3;
+ this->splitTime_ = 0.3f;
+ this->spread_ = 0.1f;
+ this->damageReduction_ = 1.0f;
+
+ this->setMunitionName("SplitMunition");
+ this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
+ }
+
+ SplitGun::~SplitGun()
+ {
+ }
+
+ /**
+ @brief
+ XMLPort for the SplitGun. You can define how often the projectiles split, how many childs should be created per split, the spread and the time between two splits.
+ */
+ void SplitGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(SplitGun, XMLPort, xmlelement, mode);
+
+ XMLPortParam(SplitGun, "numberofsplits", setNumberOfSplits, getNumberOfSplits, xmlelement, mode);
+ XMLPortParam(SplitGun, "numberofchilds", setNumberOfChilds, getNumberOfChilds, xmlelement, mode);
+ XMLPortParam(SplitGun, "splittime", setSplitTime, getSplitTime, xmlelement, mode);
+ XMLPortParam(SplitGun, "spread", setSpread, getSpread, xmlelement, mode);
+ XMLPortParam(SplitGun, "damagereduction", setDamageReduction, getDamageReduction, xmlelement, mode);
+ }
+
+ /**
+ @brief
+ Fires the weapon. Creates a projectile and fires it.
+ */
+ void SplitGun::fire()
+ {
+ SplitGunProjectile* projectile = new SplitGunProjectile(this->getContext());
+ projectile->setMaterial("Flares/energyflare");
+
+ this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
+ projectile->setOrientation(this->getMuzzleOrientation());
+ projectile->setPosition(this->getMuzzlePosition());
+ projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
+
+ // Pass important information to the projectile: Number of splits, Number of childs, split time, spread and the damage reduction
+ projectile->setNumberOfSplits(getNumberOfSplits());
+ projectile->setNumberOfChilds(getNumberOfChilds());
+ projectile->setSplitTime(getSplitTime());
+ projectile->setSpread(getSpread());
+ projectile->setDamageReduction(getDamageReduction());
+
+ projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
+ }
+}
Added: code/trunk/src/modules/weapons/weaponmodes/SplitGun.h
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/SplitGun.h (rev 0)
+++ code/trunk/src/modules/weapons/weaponmodes/SplitGun.h 2015-10-10 14:34:26 UTC (rev 10629)
@@ -0,0 +1,90 @@
+/*
+ * 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 SplitGun.h
+ @brief Definition of the SplitGun class.
+*/
+
+#ifndef _SplitGun_H__
+#define _SplitGun_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weaponsystem/WeaponMode.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ A WeaponMode that fires projectiles that may split up into many other projectiles, that may again split up ...
+ @author
+ Fabien Vultier
+ @ingroup WeaponsWeaponModes
+ */
+ class _WeaponsExport SplitGun : public WeaponMode
+ {
+ public:
+ SplitGun(Context* context);
+ virtual ~SplitGun();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void fire();
+
+ inline void setNumberOfSplits(int numberOfSplits)
+ { this->numberOfSplits_ = numberOfSplits; }
+ inline int getNumberOfSplits() const
+ { return this->numberOfSplits_; }
+ inline void setNumberOfChilds(int numberOfChilds)
+ { this->numberOfChilds_ = numberOfChilds; }
+ inline int getNumberOfChilds() const
+ { return this->numberOfChilds_; }
+ inline void setSplitTime(float splitTime)
+ { this->splitTime_ = splitTime; }
+ inline float getSplitTime() const
+ { return this->splitTime_; }
+ inline void setSpread(float spread)
+ { this->spread_ = spread; }
+ inline float getSpread() const
+ { return this->spread_; }
+ inline void setDamageReduction(float damageReduction)
+ { this->damageReduction_ = (damageReduction >= 0.0f ? damageReduction : 1.0f); }
+ inline float getDamageReduction() const
+ { return this->damageReduction_; }
+
+ private:
+ float speed_; //The speed of the fired projectile.
+ int numberOfSplits_; //The number of times the projectile will split into child projectiles
+ int numberOfChilds_; //The number of child projectiles that are created if the projectile splits
+ float splitTime_; //The time between creation of the projectile and the split of the projectile
+ float spread_; //Low spread means that the child projectiles are concentrated in a small area
+ float damageReduction_; //The damage of a child projectile is reduced by this factor
+ };
+}
+
+#endif /* _SplitGun_H__ */
More information about the Orxonox-commit
mailing list