Changeset 10629
- Timestamp:
- Oct 10, 2015, 4:34:26 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 16 added
- 4 deleted
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/data/levels/emptyLevel.oxw
r9415 r10629 16 16 include("templates/spaceshipPirate.oxt") 17 17 include("templates/spaceshipEscort.oxt") 18 include("templates/spaceshipRing.oxt") 19 include("templates/spaceshipSwallow.oxt") 18 20 ?> 19 21 -
code/trunk/data/levels/includes/weaponSettingsRing.oxi
r10622 r10629 14 14 </links> 15 15 <Weapon> 16 < HsW01 mode=0 munitionpershot=0 delay=0.125 damage=9.3 material="Flares/point_lensflare" muzzleoffset=" 0.1, 1.4,-3" projectileMesh="LaserBeam2.mesh"/>16 <IceGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0.1, 1.4,-3" freezefactor=0.5 freezetime=2.0 /> 17 17 </Weapon> 18 18 <Weapon> 19 < HsW01 mode=0 munitionpershot=0 delay=0 damage=9.3 material="Flares/point_lensflare" muzzleoffset="0.1, 1.4, -3" projectileMesh="LaserBeam2.mesh"/>19 <IceGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0.1, 1.4,-3" freezefactor=0.5 freezetime=2.0 /> 20 20 </Weapon> 21 21 </WeaponPack> -
code/trunk/data/levels/includes/weaponSettingsSwallow.oxi
r8891 r10629 14 14 </links> 15 15 <Weapon> 16 <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" /> 17 <HsW01 mode=0 munitionpershot=0 delay=0.125 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 0.5,0.6,1.7" /> 18 19 <LightningGun mode=1 muzzleoffset="0,0,0" damage=3.14159 shielddamage=20/> 16 <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 /> 20 17 </Weapon> 21 18 <Weapon> 22 <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" /> 23 <HsW01 mode=0 munitionpershot=0 delay=0.125 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-0.5,0.6,1.7" /> 24 <LightningGun mode=1 muzzleoffset="0,0,0" damage=3.14159 shielddamage=20/> 19 <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 /> 25 20 </Weapon> 26 21 </WeaponPack> -
code/trunk/data/levels/jump.oxw
r10624 r10629 260 260 </MovableEntity> 261 261 262 <EventDispatcher>263 <targets>264 <EventTarget target=scoreeffect_right />265 <EventTarget target=scoreeffect_center />266 </targets>267 <events>268 <spawn>269 <EventFilter>270 <names>271 <EventName name=right />272 </names>273 <EventListener event=jumpcenter />274 </EventFilter>275 </spawn>276 </events>277 </EventDispatcher>278 <EventDispatcher>279 <targets>280 <EventTarget target=scoreeffect_left />281 <EventTarget target=scoreeffect_center />282 </targets>283 <events>284 <spawn>285 <EventFilter>286 <names>287 <EventName name=left />288 </names>289 <EventListener event=jumpcenter />290 </EventFilter>291 </spawn>292 </events>293 </EventDispatcher>294 295 262 </Scene> 296 263 </Level> -
code/trunk/data/levels/towerDefense.oxw
r10624 r10629 15 15 include("towerdefenseHUD.oxo") 16 16 include("templates/lodInformation.oxt") 17 ?> 18 19 <?lua 17 include("includes/weaponSettingsTurret.oxi") 20 18 include("templates/spaceshipAssff.oxt") 21 include("templates/spaceshipPirate.oxt")22 include("templates/towerdefensetower.oxt")23 include("templates/enemytowerdefense.oxt")24 19 include("templates/standardTurret.oxt") 25 20 ?> 26 27 21 28 22 <Template name=selectercameras defaults=0> 29 23 <TowerDefenseSelecter> 30 24 <camerapositions> 31 <CameraPosition position="0,0,1 400" lookat="0,0,0" absolute=true/>25 <CameraPosition position="0,0,1300" lookat="0,0,0" absolute=true drag=true mouselook=true/> 32 26 </camerapositions> 33 27 </TowerDefenseSelecter> … … 37 31 <TowerDefenseSelecter team=0 camerapositiontemplate=selectercameras> 38 32 <attached> 39 <Model p itch=90 position="0,0,-30" mesh="TD_Selection.mesh" scale=30/>33 <Model position="0,0,0" pitch=90 mesh="TD_Selection.mesh" scale=25/> 40 34 </attached> 41 35 </TowerDefenseSelecter> 42 36 </Template> 43 37 44 45 46 47 <Level 48 plugins = "towerdefense" 49 gametype = "TowerDefense" 50 > 38 <Template name=tower1template> 39 <TowerDefenseTower 40 explosionchunks=6 41 reloadrate=10 42 reloadwaittime=5 43 collisionType="none" 44 pitch="0" 45 yaw="0" 46 roll="0" 47 maxPitch=360 48 maxYaw=360 49 maxAttackRadius=1000 50 minAttackRadius=0 51 team=0 52 > 53 <controller> 54 <TurretController team = 0/> 55 </controller> 56 <weaponslots> 57 <WeaponSlot position="0,0,0" /> 58 </weaponslots> 59 <weaponsets> 60 <WeaponSet firemode=0 /> 61 </weaponsets> 62 <weapons> 63 <WeaponPack> 64 <links> 65 <DefaultWeaponmodeLink firemode=0 weaponmode=0 /> 66 </links> 67 <Weapon> 68 <HsW01 mode=0 munitionpershot=0 muzzleoffset="0,0,0" damage=2 shielddamage=1 material="Flares/point_lensflare" delay=0/> 69 </Weapon> 70 </WeaponPack> 71 </weapons> 72 </TowerDefenseTower> 73 </Template> 74 75 <Template name=tower2template> 76 <TowerDefenseTower 77 explosionchunks=6 78 reloadrate=10 79 reloadwaittime=5 80 collisionType="none" 81 pitch="0" 82 yaw="0" 83 roll="0" 84 maxPitch=360 85 maxYaw=360 86 maxAttackRadius=1000 87 minAttackRadius=0 88 team=0 89 > 90 <controller> 91 <TurretController team = 0/> 92 </controller> 93 <weaponslots> 94 <WeaponSlot position="0,0,0" /> 95 </weaponslots> 96 <weaponsets> 97 <WeaponSet firemode=0 /> 98 </weaponsets> 99 <weapons> 100 <WeaponPack> 101 <links> 102 <DefaultWeaponmodeLink firemode=0 weaponmode=0 /> 103 </links> 104 <Weapon> 105 <LightningGun mode=0 munitionpershot=0 muzzleoffset="0,0,0" damage=2 shielddamage=4 /> 106 </Weapon> 107 </WeaponPack> 108 </weapons> 109 <attached> 110 <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 /> 111 </attached> 112 </TowerDefenseTower> 113 </Template> 114 115 <Template name=tower3template> 116 <TowerDefenseTower 117 explosionchunks=6 118 reloadrate=10 119 reloadwaittime=5 120 collisionType="none" 121 pitch="0" 122 yaw="0" 123 roll="0" 124 maxPitch=360 125 maxYaw=360 126 maxAttackRadius=1000 127 minAttackRadius=0 128 team=0 129 > 130 <controller> 131 <TurretController team = 0/> 132 </controller> 133 <weaponslots> 134 <WeaponSlot position="0,0,0" /> 135 </weaponslots> 136 <weaponsets> 137 <WeaponSet firemode=0 /> 138 </weaponsets> 139 <weapons> 140 <WeaponPack> 141 <links> 142 <DefaultWeaponmodeLink firemode=0 weaponmode=0 /> 143 </links> 144 <Weapon> 145 <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 /> 146 </Weapon> 147 </WeaponPack> 148 </weapons> 149 </TowerDefenseTower> 150 </Template> 151 152 <Template name=tower4template> 153 <TowerDefenseTower 154 explosionchunks=6 155 reloadrate=10 156 reloadwaittime=5 157 collisionType="none" 158 pitch="0" 159 yaw="0" 160 roll="0" 161 maxPitch=360 162 maxYaw=360 163 maxAttackRadius=1000 164 minAttackRadius=0 165 team=0 166 > 167 <controller> 168 <TurretController team = 0/> 169 </controller> 170 <weaponslots> 171 <WeaponSlot position="0,0,0" /> 172 </weaponslots> 173 <weaponsets> 174 <WeaponSet firemode=0 /> 175 </weaponsets> 176 <weapons> 177 <WeaponPack> 178 <links> 179 <DefaultWeaponmodeLink firemode=0 weaponmode=0 /> 180 </links> 181 <Weapon> 182 <RocketFire mode=0 munitionpershot=0 muzzleoffset="0,0,0" damage=2 shielddamage=4 /> 183 </Weapon> 184 </WeaponPack> 185 </weapons> 186 <attached> 187 <ParticleSpawner position="0,0,0" source="Orxonox/sparks" lifetime=3.0 autostart=1 loop=1 /> 188 </attached> 189 </TowerDefenseTower> 190 </Template> 191 192 <Template name=tower5template> 193 <TowerDefenseTower 194 explosionchunks=6 195 reloadrate=10 196 reloadwaittime=5 197 collisionType="none" 198 pitch="0" 199 yaw="0" 200 roll="0" 201 maxPitch=360 202 maxYaw=360 203 maxAttackRadius=1000 204 minAttackRadius=0 205 team=0 206 > 207 <controller> 208 <TurretController team = 0/> 209 </controller> 210 <weaponslots> 211 <WeaponSlot position="0,0,0" /> 212 </weaponslots> 213 <weaponsets> 214 <WeaponSet firemode=0 /> 215 </weaponsets> 216 <weapons> 217 <WeaponPack> 218 <links> 219 <DefaultWeaponmodeLink firemode=0 weaponmode=0 /> 220 </links> 221 <Weapon> 222 <IceGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0,0,0" freezefactor=0.5 freezetime=2.0 /> 223 </Weapon> 224 </WeaponPack> 225 </weapons> 226 </TowerDefenseTower> 227 </Template> 228 229 <Template name=enemytowerdefense1> 230 <TowerDefenseEnemy 231 hudtemplate = spaceshiphud 232 camerapositiontemplate = spaceshipassffcameras 233 spawnparticlesource = "Orxonox/fairytwirl" 234 spawnparticleduration = 3 235 explosionchunks = 6 236 237 health = 15 238 maxhealth = 15 239 initialhealth = 15 240 241 shieldhealth = 15 242 initialshieldhealth = 15 243 maxshieldhealth = 15 244 shieldabsorption = 0.8 245 reloadrate = 1 246 reloadwaittime = 1 247 248 primaryThrust = 1000 249 auxilaryThrust = 30 250 rotationThrust = 80 251 252 lift = 1; 253 stallSpeed = 220; 254 255 boostPower = 15 256 boostPowerRate = 1 257 boostRate = 5 258 boostCooldownDuration = 10 259 260 shakeFrequency = 15 261 shakeAmplitude = 9 262 263 collisionType = "dynamic" 264 mass = 10 265 linearDamping = 0.7 266 angularDamping = 0.9999999 267 268 explosionSound = "sounds/Explosion2.ogg" 269 > 270 271 <engines> 272 <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipassffengine /> 273 <MultiStateEngine position="-7.6, 0, 0" template=spaceshipassffengine /> 274 </engines> 275 <attached> 276 <Model position="0,0,0" yaw=90 pitch=90 roll=0 scale=4 mesh="assff.mesh" /> 277 <BlinkingBillboard position="17,-1.5,0" material="Examples/Flare" colour="1.0, 0.5, 0.3" amplitude=0.1 frequency=0.5 quadratic=1 /> 278 <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 /> 279 </attached> 280 <collisionShapes> 281 <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" /> 282 <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" /> 283 <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" /> 284 <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" /> 285 <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" /> 286 <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" /> 287 </collisionShapes> 288 <controller> 289 <WaypointController accuracy = 50/> 290 </controller> 291 </TowerDefenseEnemy> 292 </Template> 293 294 <Template name=enemytowerdefense2> 295 <TowerDefenseEnemy 296 hudtemplate = spaceshiphud 297 camerapositiontemplate = spaceshipassffcameras 298 spawnparticlesource = "Orxonox/fairytwirl" 299 spawnparticleduration = 3 300 explosionchunks = 6 301 302 health = 30 303 maxhealth = 30 304 initialhealth = 30 305 306 shieldhealth = 0 307 initialshieldhealth = 0 308 maxshieldhealth = 0 309 shieldabsorption = 0.8 310 reloadrate = 1 311 reloadwaittime = 1 312 313 primaryThrust = 100 314 auxilaryThrust = 30 315 rotationThrust = 80 316 317 lift = 1; 318 stallSpeed = 220; 319 320 boostPower = 15 321 boostPowerRate = 1 322 boostRate = 5 323 boostCooldownDuration = 10 324 325 shakeFrequency = 15 326 shakeAmplitude = 9 327 328 collisionType = "dynamic" 329 mass = 100 330 linearDamping = 0.7 331 angularDamping = 0.9999999 332 333 explosionSound = "sounds/Explosion2.ogg" 334 > 335 336 <engines> 337 <Engine position=" 0, 0, 0" 338 boostfactor = 2 339 speedfront = 100 340 speedback = 50 341 speedleftright = 50 342 speedupdown = 50 343 accelerationfront = 500 344 accelerationbrake = 500 345 accelerationback = 125 346 accelerationleftright = 125 347 accelerationupdown = 125 348 /> 349 </engines> 350 <attached> 351 <Model position="0,0,0" yaw=0 pitch=0 roll=0 scale=2.5 mesh="JumpEnemy3.mesh" /> 352 </attached> 353 <collisionShapes> 354 <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" /> 355 <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" /> 356 <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" /> 357 <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" /> 358 <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" /> 359 <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" /> 360 </collisionShapes> 361 <controller> 362 <WaypointController accuracy = 50/> 363 </controller> 364 </TowerDefenseEnemy> 365 </Template> 366 367 <Template name=enemytowerdefense3> 368 <TowerDefenseEnemy 369 hudtemplate = spaceshiphud 370 camerapositiontemplate = spaceshipassffcameras 371 spawnparticlesource = "Orxonox/fairytwirl" 372 spawnparticleduration = 3 373 explosionchunks = 6 374 375 health = 15 376 maxhealth = 15 377 initialhealth = 15 378 379 shieldhealth = 5 380 initialshieldhealth = 5 381 maxshieldhealth = 5 382 shieldabsorption = 0.8 383 reloadrate = 1 384 reloadwaittime = 1 385 386 primaryThrust = 100 387 auxilaryThrust = 30 388 rotationThrust = 80 389 390 lift = 1; 391 stallSpeed = 220; 392 393 boostPower = 15 394 boostPowerRate = 1 395 boostRate = 5 396 boostCooldownDuration = 10 397 398 shakeFrequency = 15 399 shakeAmplitude = 9 400 401 collisionType = "dynamic" 402 mass = 100 403 linearDamping = 0.7 404 angularDamping = 0.9999999 405 406 explosionSound = "sounds/Explosion2.ogg" 407 > 408 409 <engines> 410 <Engine position=" 0, 0, 0" 411 boostfactor = 2 412 speedfront = 300 413 speedback = 300 414 speedleftright = 300 415 speedupdown = 300 416 accelerationfront = 500 417 accelerationbrake = 500 418 accelerationback = 500 419 accelerationleftright = 500 420 accelerationupdown = 500 421 /> 422 </engines> 423 <attached> 424 <Model position="0,0,0" yaw=0 pitch=0 roll=0 scale=2.5 mesh="JumpEnemy4.mesh" /> 425 </attached> 426 <collisionShapes> 427 <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" /> 428 <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" /> 429 <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" /> 430 <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" /> 431 <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" /> 432 <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" /> 433 </collisionShapes> 434 <controller> 435 <WaypointController accuracy = 50/> 436 </controller> 437 </TowerDefenseEnemy> 438 </Template> 439 440 <Level plugins = "towerdefense" gametype = "TowerDefense"> 51 441 <templates> 52 442 <Template link=lodtemplate_default /> … … 62 452 <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"/> 63 453 64 <!-- Spawns the camera, attached to a crate -->65 454 <SpawnPoint team=0 position="0,0,0"/> 455 456 <Model position="0,0,10000" lodLevel=1 mesh="TD_S1.mesh" scale=1/> 457 <Model position="0,0,10000" lodLevel=1 mesh="TD_S2.mesh" scale=1/> 458 <Model position="0,0,10000" lodLevel=1 mesh="TD_S3.mesh" scale=1/> 459 <Model position="0,0,10000" lodLevel=1 mesh="TD_S4.mesh" scale=1/> 460 <Model position="0,0,10000" lodLevel=1 mesh="TD_S5.mesh" scale=1/> 461 <Model position="0,0,10000" lodLevel=1 mesh="TD_T1.mesh" scale=1/> 462 <Model position="0,0,10000" lodLevel=1 mesh="TD_T2.mesh" scale=1/> 463 <Model position="0,0,10000" lodLevel=1 mesh="TD_T3.mesh" scale=1/> 464 <Model position="0,0,10000" lodLevel=1 mesh="TD_T4.mesh" scale=1/> 465 <Model position="0,0,10000" lodLevel=1 mesh="TD_T5.mesh" scale=1/> 466 <Model position="0,0,10000" lodLevel=1 mesh="TD_F1.mesh" scale=1/> 66 467 67 468 <!-- PlayField --> 68 469 <TowerDefenseCenterpoint 69 470 name=towerdefensecenter 70 71 471 selecterTemplate=selectertemplate 72 472 tower1Template=tower1template 473 tower2Template=tower2template 474 tower3Template=tower3template 475 tower4Template=tower4template 476 tower5Template=tower5template 477 tower1Cost=100 478 tower2Cost=100 479 tower3Cost=100 480 tower4Cost=100 481 tower5Cost=100 482 fields="F1F1F1R1I1I1I1I1O1F1F1F1F1F1F1F1 483 F1F1F1I2F1F1F1F1F1F1F1F1F1F1F1F1 484 F1F1F1I2F1F1F1F1F1F1F1F1F1F1F1F1 485 F1F1F1I2F1F1F1F1F1F1F1Y1Y1Y1F1F1 486 F1F1F1I2F1F1F1F1F1F1F1F1F1F1F1F1 487 F1F1F1I2F1F1F1F1F1F1F1Y1Y1Y1F1F1 488 F1F1F1R2I3I3I3I3L3F1F1F1F1F1F1F1 489 F1F1F1F1F1F1F1F1I2F1F1F1F1F1F1F1 490 F1F1F1F1F1F1F1F1I2F1F1F1F1F1F1F1 491 X1I1I1I1R0F1F1F1I2F1F1F1F1F1F1F1 492 F1F1F1F1I0F1F1F1I2F1F1F1F1F1F1F1 493 F1F1F1F1I0F1F1F1I2F1F1F1F1F1F1F1 494 F1F1F1F1L1I1I1I1L2F1F1F1F1F1F1F1 495 F1F1F1F1F1F1F1F1F1F1F1F1F1F1F1F1 496 F1F1F1F1F1F1F1F1F1F1F1F1F1F1F1F1 497 F1F1F1F1F1F1F1F1F1F1F1F1F1F1F1F1" 73 498 width=16 74 499 height=16 … … 79 504 mass=100000 80 505 > 81 <attached> 82 <Model position="-50,-50,0" mesh="Playfield_ME.mesh" scale=80 /> 83 <Model position="500,700,100" mesh="sphere.mesh" scale=80 /> 84 </attached> 85 <camerapositions> 86 <CameraPosition position="0,0,1500" lookat="0,0,0" absolute=true/> 87 </camerapositions> 506 <camerapositions> 507 <CameraPosition position="0,0,1400" lookat="0,0,0" absolute=true /> 508 </camerapositions> 88 509 </TowerDefenseCenterpoint> 89 510 -
code/trunk/src/modules/towerdefense/CMakeLists.txt
r10624 r10629 8 8 TowerDefenseEnemy.cc 9 9 TowerDefenseSelecter.cc 10 TowerDefenseField.cc 11 TDCoordinate.cc 10 12 ) 11 13 -
code/trunk/src/modules/towerdefense/TDCoordinate.cc
r10622 r10629 8 8 namespace orxonox 9 9 { 10 //RegisterClass(TDCoordinate);11 12 10 /** 13 11 @brief 14 Constructor. Registers and initializes the object.12 Constructor. Sets the default coordinates: (0,0) 15 13 */ 16 14 TDCoordinate::TDCoordinate() 17 15 { 18 //RegisterObject(TDCoordinate);19 16 Set(0,0); 20 21 17 } 22 18 … … 73 69 coord->x= (_x-8) * tileScale; 74 70 coord->y= (_y-8) * tileScale; 75 coord->z= 100;71 coord->z=0; 76 72 77 73 return *coord; -
code/trunk/src/modules/towerdefense/TDCoordinate.h
r10624 r10629 2 2 #define _TDCoordinate_H__ 3 3 4 #include "core/CoreIncludes.h" 4 5 #include "TDCoordinate.h" 5 6 //#include "towerdefense/TowerDefense.h" … … 21 22 virtual int GetX(); 22 23 virtual int GetY(); 23 virtual Vector3 get3dcoordinate(); 24 virtual Vector3 get3dcoordinate(); 24 25 25 26 private: -
code/trunk/src/modules/towerdefense/TowerDefense.cc
r10624 r10629 75 75 #include "TowerDefenseTower.h" 76 76 #include "TowerDefenseCenterpoint.h" 77 //#include "TDCoordinate.h"78 77 #include "worldentities/SpawnPoint.h" 79 #include "worldentities/pawns/Pawn.h"80 #include "worldentities/pawns/SpaceShip.h"81 78 #include "controllers/WaypointController.h" 82 79 #include "graphics/Model.h" … … 84 81 #include "chat/ChatManager.h" 85 82 #include "core/CoreIncludes.h" 86 /* Part of a temporary hack to allow the player to add towers */87 #include "core/command/ConsoleCommandIncludes.h"88 #include <cmath>89 90 83 91 84 namespace orxonox 92 85 { 93 static const std::string __CC_addTower_name = "addTower";94 static const std::string __CC_upgradeTower_name = "upgradeTower";95 static const int upgradeCost = 20;96 static const int towerCost = 20;97 unsigned int maxspaceships = 30;98 int maxspaceshipsstandard = 30;99 100 101 102 SetConsoleCommand("TowerDefense", __CC_addTower_name, &TowerDefense::addTower ).addShortcut().defaultValues(1);103 SetConsoleCommand("TowerDefense", __CC_upgradeTower_name, &TowerDefense::upgradeTower).addShortcut().defaultValues(0);104 105 86 RegisterUnloadableClass(TowerDefense); 106 87 … … 108 89 { 109 90 RegisterObject(TowerDefense); 110 /* 111 for (int i=0; i < 16 ; i++){ 112 for (int j = 0; j< 16 ; j++){ 113 towermatrix[i][j] = NULL; 114 } 115 }*/ 116 117 //Timer for the waves (10 seconds between the waves) 91 118 92 selecter = NULL; 119 93 this->player_ = NULL; 120 94 this->setHUDTemplate("TowerDefenseHUD"); 121 this->nextwaveTimer_.setTimer(10, false, createExecutor(createFunctor(&TowerDefense::nextwave, this))); 122 this->nextwaveTimer_.stopTimer(); 123 this->waves_ = 0; 124 this->time = 0; 95 this->waveNumber_ = 0; 96 this->timeSinceLastSpawn_ = 0.0; 97 this->timeUntilNextWave_ = 0.0; 125 98 this->credit_ = 0; 126 99 this->lifes_ = 0; 127 this->timeSetTower_ = 0; 128 spaceships =15; 129 eggs=3; 130 ufos=7; 131 randomships=5; 132 133 134 ModifyConsoleCommand(__CC_addTower_name).setObject(this); 135 ModifyConsoleCommand(__CC_upgradeTower_name).setObject(this); 100 this->waveSize_ = 0; 101 offset_ = Vector3(0,0,10); 136 102 } 137 103 138 104 TowerDefense::~TowerDefense() 139 105 { 140 /* Part of a temporary hack to allow the player to add towers */141 106 if (this->isInitialized()) 142 107 { 143 ModifyConsoleCommand(__CC_addTower_name).setObject(NULL); 144 ModifyConsoleCommand(__CC_upgradeTower_name).setObject(NULL); 108 145 109 } 146 110 } … … 148 112 void TowerDefense::setCenterpoint(TowerDefenseCenterpoint *centerpoint) 149 113 { 150 orxout() << "Centerpoint now setting..." << endl;151 114 this->center_ = centerpoint; 152 orxout() << "Centerpoint now set..." << endl;153 115 } 154 116 155 117 void TowerDefense::start() 156 { 118 { 157 119 if (center_ != NULL) // There needs to be a TowerDefenseCenterpoint, i.e. the area the game takes place. 158 120 { … … 170 132 } 171 133 134 enemies_.clear(); 135 136 createFields(); 172 137 TeamDeathmatch::start(); 173 138 174 // Waypoints: [1,3] [10,3] [10,11] [13,11] -> add the points to a matrix so the player cant place towers on the path175 for (int i=0; i < 16 ; i++)176 {177 for (int j = 0; j< 16 ; j++)178 {179 towerModelMatrix[i][j] = NULL;180 towerTurretMatrix[i][j] = NULL;181 }182 }183 184 185 186 if (player_ != NULL)187 {188 //this->player_->startControl(selecter);189 }190 else191 {192 orxout() << "player=NULL" << endl;193 }194 195 196 Model* dummyModel = new Model(this->center_->getContext());197 198 //the path of the spacehips has to be blocked, so that no towers can be build there199 for (int k=0; k<3; k++)200 towerModelMatrix[1][k]=dummyModel;201 for (int l=1; l<11; l++)202 towerModelMatrix[l][3]=dummyModel;203 for (int m=3; m<12; m++)204 towerModelMatrix[10][m]=dummyModel;205 for (int n=10; n<14; n++)206 towerModelMatrix[n][11]=dummyModel;207 for (int o=13; o<16; o++)208 towerModelMatrix[13][o]=dummyModel;209 210 211 139 //set initial credits, lifes and WaveNumber 212 this->setCredit(100); 213 this->setLifes(100); 140 this->setCredit(1000); 141 this->setLifes(100); 142 this->timeSinceLastSpawn_ = 0.0; 143 this->timeUntilNextWave_ = 5.0; 144 this->waveSize_ = 0; 214 145 this->setWaveNumber(0); 215 time=0.0;216 217 /*218 //adds initial towers219 for (int i=0; i <7; i++){220 addTower(i+3,4);221 }222 */223 146 } 224 147 225 148 // Generates a TowerDefenseEnemy. Uses Template "enemytowerdefense". Sets position at first waypoint of path. 226 void TowerDefense::addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr){ 227 228 149 void TowerDefense::addTowerDefenseEnemy(int templatenr) 150 { 229 151 TowerDefenseEnemy* en1 = new TowerDefenseEnemy(this->center_->getContext()); 230 152 … … 234 156 en1->addTemplate("enemytowerdefense1"); 235 157 en1->setScale(3); 236 en1->lookAt(Vector3(0,0,100000)); 237 en1->setHealth(en1->getHealth() +50 + this->getWaveNumber()*4); 158 en1->setHealth(en1->getHealth() + this->getWaveNumber()*4); 238 159 break; 239 160 … … 241 162 en1->addTemplate("enemytowerdefense2"); 242 163 en1->setScale(2); 243 en1->lookAt(Vector3(0,0,100000)); 244 en1->roll(Degree(120)); 245 en1->setHealth(en1->getHealth() -30 + this->getWaveNumber()*4); 246 // en1->setShieldHealth(en1->getShield() = this->getWaveNumber()*2)) 164 en1->setHealth(en1->getHealth() + this->getWaveNumber()*4); 247 165 break; 248 166 … … 250 168 en1->addTemplate("enemytowerdefense3"); 251 169 en1->setScale(1); 252 en1->lookAt(Vector3(0,0,100000)); 253 en1->roll(Degree(120)); 254 en1->setHealth(en1->getHealth() -10 + this->getWaveNumber()*4); 170 en1->setHealth(en1->getHealth() + this->getWaveNumber()*4); 255 171 break; 256 } 172 } 257 173 258 174 en1->setTeam(2); 259 en1->getController(); 260 en1->setPosition(path.at(0)->get3dcoordinate()); 261 TowerDefenseEnemyvector.push_back(en1); 262 263 for(unsigned int i = 0; i < path.size(); ++i) 264 { 265 en1->addWaypoint((path.at(i))); 266 } 175 176 WaypointController* controller = (WaypointController*)(en1->getXMLController()); 177 178 if (controller != NULL && waypoints_.size() > 1) 179 { 180 en1->setPosition(waypoints_.at(0)->getPosition() + offset_); 181 en1->setOrientation(Vector3(0,0,10), Degree(0)); 182 en1->setDirection(Vector3(0,1,0)); 183 en1->lookAt(waypoints_.at(1)->getPosition() + offset_); 184 185 for (unsigned int i = 0; i < waypoints_.size(); ++ i) 186 { 187 orxonox::WeakPtr<MovableEntity> waypoint = new MovableEntity(this->center_->getContext()); 188 waypoint->setPosition(waypoints_.at(i)->getPosition() + offset_); 189 controller->addWaypoint(waypoint); 190 } 191 } 192 193 enemies_.push_back(en1); 267 194 } 268 195 … … 279 206 { 280 207 assert(player); 281 this->player_ = player;208 player_ = player; 282 209 283 210 if (selecter->getPlayer() == NULL) 284 211 { 285 this->player_ = player; 286 player->startControl(selecter); 212 player_->startControl(selecter); 287 213 players_[player].state_ = PlayerState::Alive; 288 214 } … … 301 227 302 228 //not working yet 303 void TowerDefense:: upgradeTower(int x,int y)229 void TowerDefense::addTower(int x,int y) 304 230 { 305 231 TDCoordinate* coord = new TDCoordinate(x,y); 306 232 x = coord->GetX(); 307 233 y = coord->GetY(); 308 309 310 if (!this->hasEnoughCreditForTower(upgradeCost)) 311 { 312 orxout() << "not enough credit: " << (this->getCredit()) << " available, " << upgradeCost << " needed."; 313 return; 314 } 315 316 317 Model* dummyModel2 = new Model(this->center_->getContext()); 318 319 if (towerModelMatrix [x][y] == NULL || (towerModelMatrix [x][y])->getMeshSource() == dummyModel2->getMeshSource()) 320 { 321 orxout() << "no tower on this position" << endl; 322 return; 323 } 324 325 else 326 { 327 (towerTurretMatrix [x][y])->upgradeTower(); 328 switch(towerTurretMatrix[x][y]->upgrade) 329 { 330 case 1 : 331 towerModelMatrix[x][y]->setMeshSource("TD_T2.mesh"); 332 break; 333 334 case 2 : 335 towerModelMatrix[x][y]->setMeshSource("TD_T3.mesh"); 336 break; 337 case 3 : 338 towerModelMatrix[x][y]->setMeshSource("TD_T4.mesh"); 339 break; 340 case 4 : 341 towerModelMatrix[x][y]->setMeshSource("TD_T5.mesh"); 342 break; 343 344 } 345 346 this->buyTower(upgradeCost); 234 235 int cost = center_->getTowerCost(1); 236 237 if (fields_[x][y]->isFree() == true && getCredit() >= cost) 238 { 239 payCredit(cost); 240 fields_[x][y]->createTower(1); 347 241 } 348 242 } … … 352 246 */ 353 247 354 void TowerDefense:: addTower(int x, int y)355 { 248 void TowerDefense::upgradeTower(int x, int y) 249 { 356 250 TDCoordinate* coord = new TDCoordinate(x,y); 357 251 x = coord->GetX(); 358 y = coord->GetY(); 359 360 361 if (!this->hasEnoughCreditForTower(towerCost)) 362 { 363 orxout() << "not enough credit: " << (this->getCredit()) << " available, " << towerCost << " needed."; 252 y = coord->GetY(); 253 254 int cost = center_->getTowerCost(fields_[x][y]->getUpgrade() + 1); 255 256 if (fields_[x][y]->isFree() == false && fields_[x][y]->canUpgrade() == true && getCredit() >= cost) 257 { 258 payCredit(cost); 259 fields_[x][y]->upgrade(); 260 } 261 } 262 263 void TowerDefense::tick(float dt) 264 { 265 SUPER(TowerDefense, tick, dt); 266 267 if (hasStarted() == false || player_ == NULL) 268 { 364 269 return; 365 270 } 366 367 if (towerModelMatrix [x][y]!=NULL) 368 { 369 orxout() << "not possible to put tower here!!" << endl; 370 return; 371 } 372 373 /* 374 unsigned int width = this->center_->getWidth(); 375 unsigned int height = this->center_->getHeight(); 376 */ 377 378 int tileScale = (int) this->center_->getTileScale(); 379 380 /*if (x > 15 || y > 15 || x < 0 || y < 0) 381 { 382 //Hard coded: TODO: let this depend on the centerpoint's height, width and fieldsize (fieldsize doesn't exist yet) 383 orxout() << "Can not add Tower: x and y should be between 0 and 15" << endl; 384 return; 385 }*/ 386 387 //orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl; 388 orxout() << "Will add tower at (" << x << "," << y << ")" << endl; 389 390 391 //Create Model 392 Model* newTowerModel = new Model(this->center_->getContext()); 393 newTowerModel->setMeshSource("TD_T1.mesh"); 394 newTowerModel->setScale(30); 395 newTowerModel->pitch(Degree(90)); 396 newTowerModel->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 80); 397 398 //Creates tower 399 TowerDefenseTower* towernew = new TowerDefenseTower(this->center_->getContext()); 400 towernew->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 275); 401 towernew->setGame(this); 402 towernew->setTeam(1); 403 404 //Reduce credit 405 this->buyTower(towerCost); 406 towerModelMatrix [x][y]= newTowerModel; 407 towerTurretMatrix [x][y]= towernew; 408 } 409 410 bool TowerDefense::hasEnoughCreditForTower(int towerCost) 411 { 412 return ((this->getCredit()) >= towerCost); 413 } 414 415 416 bool TowerDefense::hasEnoughCreditForUpgrade() 417 { 418 return true; 419 } 420 421 422 void TowerDefense::nextwave() 423 { 424 425 orxout() << "newwave" << endl; 426 TowerDefenseEnemyvector.clear(); 427 waves_++; 428 //maxspaceships = round(maxspaceshipsstandard + 0.25*(waves_)); 429 time=0; 430 431 int helpnumber = 40 -(waves_); 432 if(helpnumber <= 0) {helpnumber =1;} 433 float numSpaceships = std::abs((rand() % 100)*5.0f*(helpnumber)); 434 float numEggs = std::abs((rand() % 100)*1.0f*(waves_)); 435 float numUfos = std::abs((rand() % 100)*1.5f*(0.5f*(waves_))) ; 436 437 float totalnumber = (numSpaceships + numEggs + numUfos)*1.3f; 438 439 int newspaceships = (int)(maxspaceships* numSpaceships / totalnumber); 440 int neweggs = (int)(maxspaceships*numEggs / totalnumber); 441 int newufos = (int)(maxspaceships*numUfos / totalnumber); 442 int newrandomships = maxspaceships -newspaceships - neweggs - newufos; 443 spaceships =newspaceships; 444 eggs=neweggs; 445 ufos=newufos; 446 randomships=newrandomships; 447 448 orxout() << spaceships << endl; 449 orxout() << eggs << endl; 450 orxout() << ufos << endl; 451 orxout() << randomships << endl; 452 453 454 455 456 457 } 458 459 void TowerDefense::tick(float dt) 460 { 461 SUPER(TowerDefense, tick, dt); 462 time +=dt; 463 timeSetTower_ +=dt; 464 465 //Check if tower has to be set (because TowerDefenseSelecter asks for it) 466 if(timeSetTower_ >= 0.25) 467 { 468 timeSetTower_ =0; 469 if(selecter != NULL && selecter->firePressed_) 470 { 471 472 int x = selecter->selectedPos_->GetX(); 473 int y = selecter->selectedPos_->GetY(); 474 Model* dummyModel2 = new Model(this->center_->getContext()); 475 476 477 478 if(towerModelMatrix[x][y] == NULL) 479 { 480 addTower(x,y); 481 } 482 else 483 { 484 if(!((towerModelMatrix [x][y])->getMeshSource() == dummyModel2->getMeshSource())) 485 { 486 towerTurretMatrix[x][y]->upgradeTower(); 487 if(towerTurretMatrix[x][y]->upgrade < towerTurretMatrix[x][y]->upgradeMax) 488 { 489 int specificupgradecost = (int)(upgradeCost*(std::pow(1.5,towerTurretMatrix[x][y]->upgrade))); 490 if(this->credit_ >= specificupgradecost) 491 { 492 this->buyTower(specificupgradecost); 493 switch(towerTurretMatrix[x][y]->upgrade) 494 { 495 case 1 : 496 towerModelMatrix[x][y]->setMeshSource("TD_T2.mesh"); 497 break; 498 499 case 2 : 500 towerModelMatrix[x][y]->setMeshSource("TD_T3.mesh"); 501 break; 502 case 3 : 503 towerModelMatrix[x][y]->setMeshSource("TD_T4.mesh"); 504 break; 505 case 4 : 506 towerModelMatrix[x][y]->setMeshSource("TD_T5.mesh"); 507 break; 508 509 } 510 } 511 512 513 } 514 } 515 } 516 selecter->firePressed_ = false; 517 } 518 } 519 520 TDCoordinate* coord1 = new TDCoordinate(1,1); 521 std::vector<TDCoordinate*> path; 522 path.push_back(coord1); 523 524 525 526 527 528 if(time>=TowerDefenseEnemyvector.size() && TowerDefenseEnemyvector.size() < maxspaceships) 529 { 530 531 //adds different types of enemys depending on the WaveNumber progressively making the combination of enemys more difficult 532 if(spaceships>0) 533 { 534 addTowerDefenseEnemy(path, 1); 535 spaceships--; 536 537 }else if(ufos>0) 538 { 539 addTowerDefenseEnemy(path, 3); 540 ufos--; 541 }else if(eggs>0) 542 { 543 addTowerDefenseEnemy(path, 2); 544 eggs--; 545 }else if(randomships>0) 546 { 547 addTowerDefenseEnemy(path, rand() % 3 +1); 548 randomships--; 549 550 } 551 552 } 553 554 555 Vector3* endpoint = new Vector3(500, 700, 150); 556 //if ships are at the end they get destroyed 557 for(unsigned int i =0; i < TowerDefenseEnemyvector.size(); ++i) 558 { 559 if(TowerDefenseEnemyvector.at(i) != NULL && TowerDefenseEnemyvector.at(i)->isAlive()) 560 { 561 //destroys enemys at the end of the path and reduces the life by 1. no credits gifted 562 563 Vector3 ship = TowerDefenseEnemyvector.at(i)->getRVWorldPosition(); 564 float distance = ship.distance(*endpoint); 565 566 if(distance <50){ 567 TowerDefenseEnemyvector.at(i)->destroy(); 271 timeUntilNextWave_ -= dt; 272 timeSinceLastSpawn_ += dt; 273 274 //build/upgrade tower at selecter position 275 if (selecter != NULL && selecter->buildTower_ == true) 276 { 277 selecter->buildTower_ = false; 278 279 if (getField(selecter->selectedPos_)->canUpgrade() == true) 280 { 281 upgradeTower(selecter->selectedPos_->GetX(), selecter->selectedPos_->GetY()); 282 } 283 else 284 { 285 addTower(selecter->selectedPos_->GetX(), selecter->selectedPos_->GetY()); 286 } 287 } 288 289 for (std::list<WeakPtr<TowerDefenseEnemy> >::iterator it = enemies_.begin(); it != enemies_.end(); ) 290 { 291 if (*it == NULL) 292 { 293 // the enemy was destroyed by a tower - remove it from the list 294 enemies_.erase(it++); 295 addCredit(1); 296 } 297 else 298 { 299 //if ships are at the end they get destroyed 300 Vector3 ship = (*it)->getRVWorldPosition(); 301 float distance = ship.distance(endpoint_); 302 if(distance < 40) 303 { 304 (*it)->destroy(); 305 enemies_.erase(it++); 568 306 this->reduceLifes(1); 569 this->buyTower(1); 570 if (this->getLifes()==0) 307 if (this->getLifes() == 0) 571 308 { 572 309 this->end(); 573 310 } 574 311 } 575 }576 }577 578 //goes thorugh vector to see if an enemy is still alive. if not next wave is launched579 int count= 0;580 for(unsigned int i =0; i < TowerDefenseEnemyvector.size(); ++i)581 {582 if(TowerDefenseEnemyvector.at(i)!= NULL)583 {584 ++count;585 }586 }587 588 if (count == 0 && !this->nextwaveTimer_.isActive())589 this->nextwaveTimer_.startTimer();590 591 /* time2 +=dt;592 if(count== 0)593 {594 if(time2 > 10)595 {596 TowerDefenseEnemyvector.clear();597 this->nextwave();598 time=0;599 time2=0;600 }601 }602 */603 604 }605 606 607 // Function to test if we can add waypoints using code only. Doesn't work yet608 609 // THE PROBLEM: WaypointController's getControllableEntity() returns null, so it won't track. How do we get the controlableEntity to NOT BE NULL???610 /*611 void TowerDefense::addWaypointsAndFirstEnemy()612 {613 SpaceShip *newShip = new SpaceShip(this->center_);614 newShip->addTemplate("spaceshipassff");615 616 WaypointController *newController = new WaypointController(newShip);617 newController->setAccuracy(3);618 619 Model *wayPoint1 = new Model(newController);620 wayPoint1->setMeshSource("crate.mesh");621 wayPoint1->setPosition(7,-7,5);622 wayPoint1->setScale(0.2);623 624 Model *wayPoint2 = new Model(newController);625 wayPoint2->setMeshSource("crate.mesh");626 wayPoint2->setPosition(7,7,5);627 wayPoint2->setScale(0.2);628 629 newController->addWaypoint(wayPoint1);630 newController->addWaypoint(wayPoint2);631 632 // The following line causes the game to crash633 634 newShip->setController(newController);635 // newController -> getPlayer() -> startControl(newShip);636 newShip->setPosition(-7,-7,5);637 newShip->setScale(0.1);638 //newShip->addSpeed(1);639 640 641 642 // this->center_->attach(newShip);643 }644 */645 /*646 void TowerDefense::playerEntered(PlayerInfo* player)647 {648 TeamDeathmatch::playerEntered(player);649 650 const std::string& message = player->getName() + " entered the game";651 ChatManager::message(message);652 }653 654 bool TowerDefense::playerLeft(PlayerInfo* player)655 {656 bool valid_player = TeamDeathmatch::playerLeft(player);657 658 if (valid_player)659 {660 const std::string& message = player->getName() + " left the game";661 ChatManager::message(message);662 }663 664 return valid_player;665 }666 667 668 void TowerDefense::pawnKilled(Pawn* victim, Pawn* killer)669 {670 if (victim && victim->getPlayer())671 {672 std::string message;673 if (killer)674 {675 if (killer->getPlayer())676 message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();677 312 else 678 message = victim->getPlayer()->getName() + " was killed"; 679 } 680 else 681 message = victim->getPlayer()->getName() + " died"; 682 683 ChatManager::message(message); 684 } 685 686 TeamDeathmatch::pawnKilled(victim, killer); 687 } 688 689 void TowerDefense::playerScored(PlayerInfo* player, int score) 690 { 691 Gametype::playerScored(player, score); 692 }*/ 313 { 314 ++ it; 315 } 316 } 317 } 318 319 // Add new enemy? 320 if (timeSinceLastSpawn_ >= 1.0 && waveSize_ > 0) 321 { 322 // Add new enemy 323 timeSinceLastSpawn_ -= 1.0; 324 -- waveSize_; 325 addTowerDefenseEnemy(this->getWaveNumber() % 3 + 1); 326 } 327 else if (timeUntilNextWave_ <= 0.0 && waveSize_ <= 0) 328 { 329 //New wave 330 ++ waveNumber_; 331 timeSinceLastSpawn_ = 0.0; 332 333 timeUntilNextWave_ = waveNumber_+20; 334 waveSize_ = waveNumber_+5; 335 } 336 337 } 338 339 void TowerDefense::createFields() 340 { 341 assert(center_); 342 TDCoordinate coord(0,0); 343 TDCoordinate startCoord(0,0); 344 std::string fields = center_->getFields(); 345 int pos = 0; 346 for (int j = 15; j >= 0; --j) 347 { 348 for (int i = 0; i < 16; ++i) 349 { 350 coord.Set(i,j); 351 fields_[i][j] = new TowerDefenseField(center_->getContext()); 352 fields_[i][j]->setCenterpoint(center_); 353 center_->attach(fields_[i][j]); 354 fields_[i][j]->setPosition(coord.get3dcoordinate()); 355 fields_[i][j]->create(fields.at(pos), fields.at(pos+1)); 356 pos += 2; 357 if (fields_[i][j]->getType() == START) 358 { 359 startCoord.Set(i,j); 360 waypoints_.push_back(fields_[i][j]); 361 } 362 } 363 } 364 //Place waypoints along the street for the waypoint controllers of the enemies 365 TDCoordinate* thisCoord = &startCoord; 366 TDCoordinate* nextCoord; 367 while ((nextCoord = getNextStreetCoord(thisCoord)) != NULL) 368 { 369 waypoints_.push_back(fields_[nextCoord->GetX()][nextCoord->GetY()]); 370 thisCoord = nextCoord; 371 endpoint_ = nextCoord->get3dcoordinate(); 372 } 373 374 } 375 376 TDCoordinate* TowerDefense::getNextStreetCoord(TDCoordinate* thisCoord) 377 { 378 TowerDefenseField* thisField = fields_[thisCoord->GetX()][thisCoord->GetY()]; 379 TDCoordinate* nextCoord = new TDCoordinate(0,0); 380 381 if (thisField->getType() != STREET && thisField->getType() != START) 382 { 383 return NULL; 384 } 385 386 if (thisField->getAngle() == 0) 387 { 388 nextCoord->Set(thisCoord->GetX(), thisCoord->GetY() - 1); 389 } 390 else if (thisField->getAngle() == 1) 391 { 392 nextCoord->Set(thisCoord->GetX() + 1, thisCoord->GetY()); 393 } 394 else if (thisField->getAngle() == 2) 395 { 396 nextCoord->Set(thisCoord->GetX(), thisCoord->GetY() + 1); 397 } 398 else if (thisField->getAngle() == 3) 399 { 400 nextCoord->Set(thisCoord->GetX() - 1, thisCoord->GetY()); 401 } 402 403 if (thisCoord->GetX() != nextCoord->GetX() || thisCoord->GetY() != nextCoord->GetY()) 404 { 405 return nextCoord; 406 } 407 408 return NULL; 409 } 693 410 } -
code/trunk/src/modules/towerdefense/TowerDefense.h
r10622 r10629 43 43 #include "TowerDefenseEnemy.h" 44 44 #include "util/Output.h" 45 #include "core/object/WeakPtr.h" 46 #include "TowerDefenseSelecter.h" 47 #include "graphics/Camera.h" 48 45 #include "TowerDefenseField.h" 49 46 50 47 namespace orxonox … … 54 51 public: 55 52 TowerDefense(Context* context); 56 virtual ~TowerDefense(); 57 58 std::vector<orxonox::WeakPtr<TowerDefenseEnemy> > TowerDefenseEnemyvector; 59 Model* towerModelMatrix[16][16]; 60 TowerDefenseTower* towerTurretMatrix[16][16]; 61 void addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr); 53 virtual ~TowerDefense(); 54 void addTowerDefenseEnemy(int templatenr); 62 55 virtual void start(); //<! The function is called when the gametype starts 63 56 virtual void end(); … … 66 59 PlayerInfo* getPlayer(void) const; 67 60 int getCredit(){ return this->credit_; } 61 void payCredit(int pay){ this->credit_ -= pay; } 68 62 int getLifes(){ return this->lifes_; } 69 int getWaveNumber(){ return this->waves_; } 63 int getWaveNumber(){ return this->waveNumber_; } 64 void setWaveNumber(int wavenumber){ waveNumber_=wavenumber; } 70 65 void setCredit(int credit){ credit_ = credit; } 71 void setLifes(int lifes){ lifes_ = lifes; } 72 void setWaveNumber(int wavenumber){ waves_=wavenumber; } 73 void buyTower(int cost){ credit_ -= cost;} 66 void setLifes(int lifes){ lifes_ = lifes; } 67 void buyTower(int cost){ cost -= cost;} 74 68 void addCredit(int credit) { credit_+=credit; } 75 void nextwave();76 69 int reduceLifes(int NumberofLifes){ return lifes_-=NumberofLifes; } 77 TowerDefenseSelecter* selecter; 78 int spaceships; 79 int eggs; 80 int ufos; 81 int randomships; 82 83 84 //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0); 85 //virtual void playerScored(PlayerInfo* player, int score); 86 87 88 /* Called by TowerDefenseCenterpoint upon game start 89 The centerpoint is used to create towers 90 */ 91 void setCenterpoint(TowerDefenseCenterpoint *centerpoint); 92 93 /* Adds a tower at x, y in the playfield */ 70 TowerDefenseField* getField(TDCoordinate* coord){ return fields_[coord->GetX()][coord->GetY()]; } 71 void setCenterpoint(TowerDefenseCenterpoint* centerpoint); 94 72 void addTower(int x, int y); 95 void upgradeTower(int x, int y); 96 97 //TODO: void spawnNewWave() 98 //TODO: create a timer which regularly calls the spawnNewWave function (time driven) 99 // or spawn a new wave when the old wave has been killed (event driven) 100 73 void upgradeTower(int x, int y); 74 virtual TDCoordinate* getNextStreetCoord(TDCoordinate*); 75 76 TowerDefenseSelecter* selecter; 101 77 102 78 private: 103 TowerDefenseCenterpoint *center_; 79 void createFields(); 80 81 orxonox::WeakPtr<TowerDefenseCenterpoint> center_; 104 82 PlayerInfo* player_; 105 float time ;106 float time SetTower_;107 // float time2;83 float timeSinceLastSpawn_; 84 float timeUntilNextWave_; 85 int waveSize_; 108 86 int credit_; 109 int wave s_;87 int waveNumber_; 110 88 int lifes_; 111 Timer nextwaveTimer_;112 113 /* handles stats */114 bool hasEnoughCreditForTower(int towerCost);115 bool hasEnoughCreditForUpgrade();89 std::list<orxonox::WeakPtr<TowerDefenseEnemy> > enemies_; 90 TowerDefenseField* fields_[16][16]; 91 std::vector<orxonox::WeakPtr<TowerDefenseField> > waypoints_; 92 Vector3 endpoint_; 93 Vector3 offset_; 116 94 }; 117 95 } -
code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.cc
r10624 r10629 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/XMLPort.h" 38 #include "core/class/Super.h" 38 39 39 40 #include "TowerDefense.h" … … 72 73 XMLPortParam(TowerDefenseCenterpoint, "tileScale", setTileScale, getTileScale, xmlelement, mode); 73 74 XMLPortParam(TowerDefenseCenterpoint, "selecterTemplate", setSelecterTemplate, getSelecterTemplate, xmlelement, mode); 74 75 //TODO: add XMLPortObject(TowerDefenseCenterpoint, WorldEntity, "waypoints", addWaypoint, getWaypoint, xmlelement, mode); 76 // This was copied and shightly modified from WaypointController.cc ; there are no getters and setters and no membervariable yet 77 // The centerpoint should have all waypoints for "attached" to it. By using this function you can seperately add waypoints 78 // When you spawn a new enemy you should let it be controlled by a WaypointController. And that controller should get the waypoints. 79 80 // Alternatively you can manage the waypoints directly in TowerDefense.cc 75 XMLPortParam(TowerDefenseCenterpoint, "tower1Template", setTower1Template, getTower1Template, xmlelement, mode); 76 XMLPortParam(TowerDefenseCenterpoint, "tower2Template", setTower2Template, getTower2Template, xmlelement, mode); 77 XMLPortParam(TowerDefenseCenterpoint, "tower3Template", setTower3Template, getTower3Template, xmlelement, mode); 78 XMLPortParam(TowerDefenseCenterpoint, "tower4Template", setTower4Template, getTower4Template, xmlelement, mode); 79 XMLPortParam(TowerDefenseCenterpoint, "tower5Template", setTower5Template, getTower5Template, xmlelement, mode); 80 XMLPortParam(TowerDefenseCenterpoint, "fields", setFields, getFields, xmlelement, mode); 81 XMLPortParam(TowerDefenseCenterpoint, "tower1Cost", setTower1Cost, getTower1Cost, xmlelement, mode); 82 XMLPortParam(TowerDefenseCenterpoint, "tower2Cost", setTower2Cost, getTower2Cost, xmlelement, mode); 83 XMLPortParam(TowerDefenseCenterpoint, "tower3Cost", setTower3Cost, getTower3Cost, xmlelement, mode); 84 XMLPortParam(TowerDefenseCenterpoint, "tower4Cost", setTower4Cost, getTower4Cost, xmlelement, mode); 85 XMLPortParam(TowerDefenseCenterpoint, "tower5Cost", setTower5Cost, getTower5Cost, xmlelement, mode); 81 86 } 82 87 … … 94 99 } 95 100 } 101 102 /** 103 @brief 104 Removes all blanks, tabs and returns from the string passed. 105 */ 106 void TowerDefenseCenterpoint::trimString(std::string* str) 107 { 108 std::string* trimmed = new std::string(""); 109 int length = str->size(); 110 char temp; 111 for (int i = 0; i < length; ++ i) 112 { 113 temp = str->at(i); 114 if (temp != ' ' && temp != '\t' && temp != '\n') 115 { 116 trimmed->push_back(temp); 117 } 118 } 119 120 *str = *trimmed; 121 } 122 123 const int TowerDefenseCenterpoint::getTowerCost(int upgrade) const 124 { 125 return towerCosts_[(upgrade%5)]; 126 } 96 127 } -
code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.h
r10624 r10629 41 41 #include <string> 42 42 #include <util/Math.h> 43 43 #include "TowerDefenseTower.h" 44 44 #include "worldentities/MobileEntity.h" 45 45 … … 65 65 unsigned int getHeight(void) const 66 66 { return this->height_; } 67 void setFields(const std::string& newFields) 68 { this->fields_ = newFields; trimString(&fields_); } 69 const std::string& getFields() const 70 { return this->fields_; } 67 71 void setSelecterTemplate(const std::string& newTemplate) 68 72 { this->selecterTemplate_ = newTemplate; } 69 73 const std::string& getSelecterTemplate() const 70 74 { return this->selecterTemplate_; } 75 76 void setTower1Template(const std::string& newTemplate) 77 { this->towerTemplates_[0] = newTemplate;} 78 const std::string& getTower1Template() const 79 { return this->towerTemplates_[0]; } 80 void setTower2Template(const std::string& newTemplate) 81 { this->towerTemplates_[1] = newTemplate; } 82 const std::string& getTower2Template() const 83 { return this->towerTemplates_[1]; } 84 void setTower3Template(const std::string& newTemplate) 85 { this->towerTemplates_[2] = newTemplate; } 86 const std::string& getTower3Template() const 87 { return this->towerTemplates_[2]; } 88 void setTower4Template(const std::string& newTemplate) 89 { this->towerTemplates_[3] = newTemplate; } 90 const std::string& getTower4Template() const 91 { return this->towerTemplates_[3]; } 92 void setTower5Template(const std::string& newTemplate) 93 { this->towerTemplates_[4] = newTemplate; } 94 const std::string& getTower5Template() const 95 { return this->towerTemplates_[4]; } 96 97 void setTower1Cost(const int& newCost) 98 { this->towerCosts_[0] = newCost;} 99 const int& getTower1Cost() const 100 { return this->towerCosts_[0]; } 101 void setTower2Cost(const int& newCost) 102 { this->towerCosts_[1] = newCost; } 103 const int& getTower2Cost() const 104 { return this->towerCosts_[1]; } 105 void setTower3Cost(const int& newCost) 106 { this->towerCosts_[2] = newCost; } 107 const int& getTower3Cost() const 108 { return this->towerCosts_[2]; } 109 void setTower4Cost(const int& newCost) 110 { this->towerCosts_[3] = newCost; } 111 const int& getTower4Cost() const 112 { return this->towerCosts_[3]; } 113 void setTower5Cost(const int& newCost) 114 { this->towerCosts_[4] = newCost; } 115 const int& getTower5Cost() const 116 { return this->towerCosts_[4]; } 117 118 const int getTowerCost(int upgrade) const; 119 120 71 121 /** 72 122 @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) … … 80 130 private: 81 131 void checkGametype(); 82 132 void trimString(std::string*); 83 133 std::string selecterTemplate_; 134 std::string towerTemplates_[5]; 135 int towerCosts_[5]; 136 std::string fields_; 84 137 unsigned int width_; 85 138 unsigned int height_; -
code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc
r10628 r10629 30 30 //needed to keep track of the PlayerStats coded in TowerDefense.h 31 31 this->td = orxonox_cast<TowerDefense*>(this->getGametype()); 32 once_=false; 32 once_ = false; 33 } 34 35 TowerDefenseEnemy::~TowerDefenseEnemy() 36 { 33 37 34 38 } 35 //add credit if enemy is destroyed36 TowerDefenseEnemy::~TowerDefenseEnemy(){37 39 38 if (this->isInitialized()) 39 { 40 getGame()->addCredit(1); 41 } 40 void TowerDefenseEnemy::tick(float dt) 41 { 42 //orxout() << "TDE tick1" << endl; 43 SUPER(TowerDefenseEnemy, tick, dt); 44 //orxout() << "TDE tick2" << endl; 42 45 } 43 46 44 void TowerDefenseEnemy::addWaypoint(TDCoordinate* coord) 45 { 46 this->Waypointsvector_.push_back(coord); 47 } 48 49 50 void TowerDefenseEnemy::tick(float dt) 51 { 52 SUPER(TowerDefenseEnemy, tick, dt); 53 } 54 55 TowerDefense* TowerDefenseEnemy::getGame() 47 WeakPtr<TowerDefense> TowerDefenseEnemy::getGame() 56 48 { 57 49 if (game == NULL) … … 63 55 } 64 56 65 void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator , const btCollisionShape* cs)57 void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator) 66 58 { 67 Pawn::damage(damage, healthdamage, shielddamage, originator, cs); 59 Pawn::damage(damage, healthdamage, shielddamage, originator); 60 68 61 if (getGame() && once_ == false && getHealth() <= 0) 69 62 { 70 orxout() << "damagefunctionIF" << endl;71 63 getGame()->addCredit(1); 72 64 once_ = true; 73 65 } 74 orxout() << "damagefunction" << endl;75 76 66 } 77 78 /*79 void TowerDefenseEnemy::popWaypoint()80 {81 if(Waypointsvector_.size()>0)82 Waypointsvector_.pop_back();83 }84 85 TDCoordinate TowerDefenseEnemy::peekWaypoint()86 {87 if(Waypointsvector_.size()<=0){88 TDCoordinate* coord = TDCoordinate(-1,-1);89 return coord;90 }else{91 return Waypointsvector_.at(Waypointsvector_.size()-1);92 93 }94 95 96 }97 */98 99 67 } -
code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h
r10626 r10629 22 22 #include "worldentities/pawns/SpaceShip.h" 23 23 #include "util/Output.h" 24 #include "controllers/ArtificialController.h"25 24 #include "TowerDefense.h" 26 25 … … 39 38 40 39 virtual void tick(float dt); 41 void addWaypoint(TDCoordinate* coord); 42 void popWaypoint(); 43 TDCoordinate peekWaypoint(); 44 45 virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs); 46 40 virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator); 47 41 48 42 private: 49 TowerDefense*getGame();43 WeakPtr<TowerDefense> getGame(); 50 44 WeakPtr<TowerDefense> game; 51 45 TowerDefense* td; 52 46 bool once_; 53 std::vector<TDCoordinate*> Waypointsvector_;54 55 47 }; 56 48 -
code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc
r10624 r10629 50 50 { 51 51 SUPER(TowerDefenseHUDController, tick, dt); 52 52 53 const std::string& lifes = multi_cast<std::string>(this->td->getLifes()); 53 54 const std::string& credits = multi_cast<std::string>(this->td->getCredit()); … … 55 56 56 57 if(showlives == true) 57 this->setCaption(multi_cast<std::string>(lifes)); 58 { 59 this->setCaption(multi_cast<std::string>(lifes)); 60 } 58 61 else if(showcredits == true) 59 this->setCaption(multi_cast<std::string>(credits)); 62 { 63 this->setCaption(multi_cast<std::string>(credits)); 64 } 60 65 else if(showwaves == true) 61 this->setCaption(multi_cast<std::string>(wave));62 63 66 { 67 this->setCaption(multi_cast<std::string>(wave)); 68 } 64 69 } 65 70 -
code/trunk/src/modules/towerdefense/TowerDefenseSelecter.cc
r10622 r10629 51 51 moveLeftPressed_ = false; 52 52 moveRightPressed_ = false; 53 firePressed_ = false;54 setSelectedPosition(6,6);55 timerSetFire_=0;53 boostPressed_ = false; 54 buildTower_ = false; 55 setSelectedPosition(0,0); 56 56 } 57 57 … … 70 70 SUPER(TowerDefenseSelecter, tick, dt); 71 71 72 time_ += dt; 72 73 73 if (hasLocalController() )74 { 75 timerSetFire_ +=dt;74 if (hasLocalController() && time_ >= 0.25) 75 { 76 time_ = 0; 76 77 77 if(timerSetFire_ >= 0.25) 78 { 79 timerSetFire_ = 0; 78 int selecterPosX = selectedPos_->GetX(); 79 int selecterPosY = selectedPos_->GetY(); 80 80 81 int selecterPosX = selectedPos_->GetX(); 82 int selecterPosY = selectedPos_->GetY(); 83 84 if (moveUpPressed_ == true) 85 { 86 moveUpPressed_ = false; 87 selectedPos_->Set(selecterPosX, selecterPosY + 1); 88 updatePosition(); 89 } 90 if (moveDownPressed_ == true) 91 { 92 moveDownPressed_ = false; 93 selectedPos_->Set(selecterPosX, selecterPosY - 1); 94 updatePosition(); 95 } 96 97 if (moveLeftPressed_ == true) 98 { 99 moveLeftPressed_ = false; 100 selectedPos_->Set(selecterPosX - 1, selecterPosY); 101 updatePosition(); 102 } 103 if (moveRightPressed_ == true) 104 { 105 moveRightPressed_ = false; 106 selectedPos_->Set(selecterPosX + 1, selecterPosY); 107 updatePosition(); 108 } 109 110 111 } 112 113 114 115 } 116 } 81 if (moveUpPressed_ == true) 82 { 83 moveUpPressed_ = false; 84 selectedPos_->Set(selecterPosX, selecterPosY + 1); 85 updatePosition(); 86 } 87 if (moveDownPressed_ == true) 88 { 89 moveDownPressed_ = false; 90 selectedPos_->Set(selecterPosX, selecterPosY - 1); 91 updatePosition(); 92 } 93 if (moveLeftPressed_ == true) 94 { 95 moveLeftPressed_ = false; 96 selectedPos_->Set(selecterPosX - 1, selecterPosY); 97 updatePosition(); 98 } 99 if (moveRightPressed_ == true) 100 { 101 moveRightPressed_ = false; 102 selectedPos_->Set(selecterPosX + 1, selecterPosY); 103 updatePosition(); 104 } 105 if (boostPressed_ == true) 106 { 107 boostPressed_ = false; 108 buildTower_ = true; 109 } 110 } 111 } 117 112 118 113 … … 157 152 } 158 153 154 void TowerDefenseSelecter::fire(unsigned int firemode) 155 { 156 } 157 158 void TowerDefenseSelecter::fired(unsigned int firemode) 159 { 160 161 } 159 162 160 163 void TowerDefenseSelecter::boost(bool bBoost) 161 164 { 162 firePressed_ = true; 163 orxout() << "boost" << endl; 165 if (bBoost == true) 166 { 167 boostPressed_ = true; 168 } 164 169 } 165 166 170 167 171 void TowerDefenseSelecter::updatePosition() … … 180 184 setSelectedPosition(new TDCoordinate(x,y)); 181 185 } 182 183 184 186 } -
code/trunk/src/modules/towerdefense/TowerDefenseSelecter.h
r10622 r10629 48 48 virtual void rotatePitch(const Vector2& value); 49 49 virtual void rotateRoll(const Vector2& value); 50 void fire(unsigned int firemode); 51 virtual void fired(unsigned int firemode); 50 52 virtual void boost(bool bBoost); 51 53 virtual void setSelectedPosition(TDCoordinate* newPos); 52 54 virtual void setSelectedPosition(int x, int y); 53 bool firePressed_; 55 56 bool buildTower_; 54 57 TDCoordinate* selectedPos_; 55 56 57 58 private: 58 virtual void updatePosition(); 59 float time rSetFire_;59 virtual void updatePosition(); 60 float time_; 60 61 bool moveUpPressed_; 61 62 bool moveDownPressed_; 62 63 bool moveLeftPressed_; 63 bool moveRightPressed_; 64 bool moveRightPressed_; 65 bool boostPressed_; 64 66 }; 65 67 } -
code/trunk/src/modules/towerdefense/TowerDefenseTower.cc
r10622 r10629 27 27 game_ =NULL; 28 28 this->setCollisionType(WorldEntity::None); 29 upgrade = 0; 30 this->addTemplate("towerdefensetower"); 31 32 upgradeMax = 5; 33 29 upgrade = 1; 34 30 35 31 //this->removeAllEngines(); … … 62 58 bool TowerDefenseTower::upgradeTower() 63 59 { 64 if(upgrade < upgradeMax)60 if(upgrade < 5) 65 61 { 66 62 upgrade++; 67 63 float reloadrate = getReloadRate(); 68 64 float reloadwaittime = getReloadWaitTime(); 69 this->setDamageMultiplier((upgrade+1)* 1.5f);70 this->setRotationThrust(2*this->getRotationThrust());71 reloadrate = 0. 7f*reloadrate;72 reloadwaittime = 0. 7f*reloadwaittime;65 this->setDamageMultiplier((upgrade+1)*2); 66 //this->setRotationThrust(2*this->getRotationThrust()); 67 reloadrate = 0.5f*reloadrate; 68 reloadwaittime = 0.5f*reloadwaittime; 73 69 setReloadRate(reloadrate); 74 70 setReloadWaitTime(reloadwaittime); -
code/trunk/src/modules/towerdefense/TowerDefenseTower.h
r10622 r10629 19 19 20 20 #include "towerdefense/TowerDefensePrereqs.h" 21 #include "worldentities/pawns/SpaceShip.h"22 21 #include "objects/Turret.h" 23 22 … … 38 37 39 38 // Overriding these to stop TowerDefenseTowers from spasing out 40 /* 41 void setOrientation(const Quaternion& orientation); 42 virtual void rotateYaw(const Vector2& value); 43 virtual void rotatePitch(const Vector2& value); 44 virtual void rotateRoll(const Vector2& value); 45 */ 39 //void setOrientation(const Quaternion& orientation); 40 //virtual void rotateYaw(const Vector2& value); 41 //virtual void rotatePitch(const Vector2& value); 42 //virtual void rotateRoll(const Vector2& value); 46 43 virtual bool upgradeTower(); 47 44 … … 49 46 void setGame(TowerDefense* Towerdefense) 50 47 { assert(Towerdefense); game_ = Towerdefense; } 51 int upgrade;52 int upgradeMax;53 48 private: 54 49 TowerDefense* game_; 55 50 int upgrade; 56 51 }; 57 52 } -
code/trunk/src/modules/weapons/CMakeLists.txt
r7163 r10629 2 2 MuzzleFlash.cc 3 3 RocketController.cc 4 IceGunFreezer.cc 4 5 ) 5 6 -
code/trunk/src/modules/weapons/munitions/CMakeLists.txt
r10622 r10629 5 5 RocketMunition.cc 6 6 GravityBombMunition.cc 7 IceMunition.cc 8 SplitMunition.cc 7 9 ) -
code/trunk/src/modules/weapons/projectiles/BillboardProjectile.cc
r9667 r10629 88 88 /** 89 89 @brief 90 Get the material of the BillboardProjectile. 91 @return 92 The material name. 93 */ 94 const std::string& BillboardProjectile::getMaterial() 95 { 96 return this->billboard_.getMaterial(); 97 } 98 99 /** 100 @brief 90 101 Is called when the visibility of the BillboardProjectile has changed. 91 102 */ -
code/trunk/src/modules/weapons/projectiles/BillboardProjectile.h
r9667 r10629 60 60 virtual void setColour(const ColourValue& colour); 61 61 virtual void setMaterial(const std::string& material); 62 virtual const std::string& getMaterial(); 62 63 virtual void changedVisibility(); 63 64 -
code/trunk/src/modules/weapons/projectiles/CMakeLists.txt
r10622 r10629 5 5 Projectile.cc 6 6 LightningGunProjectile.cc 7 SplitGunProjectile.cc 8 IceGunProjectile.cc 7 9 Rocket.cc 8 10 RocketOld.cc -
code/trunk/src/modules/weapons/projectiles/Projectile.cc
r10287 r10629 39 39 #include "core/command/Executor.h" 40 40 41 #include "objects/collisionshapes/SphereCollisionShape.h"42 41 #include "worldentities/pawns/Pawn.h" 43 42 … … 60 59 this->setCollisionType(Dynamic); 61 60 62 SphereCollisionShape* shape = new SphereCollisionShape(this->getContext()); 63 shape->setRadius(20.0f); 64 this->attachCollisionShape(shape); 61 // Create a sphere collision shape and attach it to the projectile. 62 collisionShape_ = new SphereCollisionShape(this->getContext()); 63 setCollisionShapeRadius(20.0f); 64 this->attachCollisionShape(collisionShape_); 65 65 66 66 this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&BasicProjectile::destroyObject, this))); … … 76 76 SetConfigValue(lifetime_, 4.0f).description("The time in seconds a projectile stays alive"); 77 77 } 78 79 78 80 79 void Projectile::tick(float dt) … … 93 92 } 94 93 94 void Projectile::setCollisionShapeRadius(float radius) 95 { 96 if (collisionShape_ != NULL && radius > 0) 97 { 98 collisionShape_->setRadius(radius); 99 } 100 } 95 101 } -
code/trunk/src/modules/weapons/projectiles/Projectile.h
r10216 r10629 39 39 #include "tools/Timer.h" 40 40 #include "worldentities/MovableEntity.h" 41 #include "objects/collisionshapes/SphereCollisionShape.h" 41 42 42 43 #include "BasicProjectile.h" … … 66 67 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 67 68 69 protected: 70 virtual void setCollisionShapeRadius(float radius); 71 68 72 private: 69 73 float lifetime_; //!< The time the projectile exists. 70 74 Timer destroyTimer_; //!< Timer to destroy the projectile after its lifetime has run out. 75 WeakPtr<SphereCollisionShape> collisionShape_; // The collision shape of the projectile. 71 76 }; 72 77 } -
code/trunk/src/modules/weapons/weaponmodes/CMakeLists.txt
r10622 r10629 5 5 HsW01.cc 6 6 LightningGun.cc 7 SplitGun.cc 8 IceGun.cc 7 9 RocketFire.cc 8 10 RocketFireOld.cc
Note: See TracChangeset
for help on using the changeset viewer.