Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10181


Ignore:
Timestamp:
Dec 15, 2014, 3:58:14 PM (9 years ago)
Author:
maxima
Message:

towerdefenseHS14 merged.

Location:
code/branches/presentationHS14
Files:
23 edited
12 copied

Legend:

Unmodified
Added
Removed
  • code/branches/presentationHS14

  • code/branches/presentationHS14/data/levels/includes/weaponSettingsTurret.oxi

    r9664 r10181  
    1111        </links>
    1212        <Weapon>
    13           <attached>
    14             <Model mesh="sphere.mesh" position="3,3,-2.2" scale=0.6 />
    15           </attached>
    16           <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 3, 3,-2.2" />
    17           <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 3,-3,-2.2" />
    18           <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-3, 3,-2.2" />
    19           <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-3,-3,-2.2" />
     13          <!-- <attached>
     14            <Model mesh="sphere.mesh" position="1.7,1.7,-24.5" scale=0.6 />
     15          </attached> -->
     16          <HsW01 mode=0 munitionpershot=0 delay=0 damage=1 material="Flares/point_lensflare" muzzleoffset="1.7, 1.7,-30" />
     17          <HsW01 mode=0 munitionpershot=0 delay=0 damage=1 material="Flares/point_lensflare" muzzleoffset="1.7, -1.7,-30" />
     18          <HsW01 mode=0 munitionpershot=0 delay=0 damage=1 material="Flares/point_lensflare" muzzleoffset="-1.7, 1.7,-30" />
     19          <HsW01 mode=0 munitionpershot=0 delay=0 damage=1 material="Flares/point_lensflare" muzzleoffset="-1.7, -1.7,-30" />
    2020        </Weapon>
    2121      </WeaponPack>
  • code/branches/presentationHS14/data/levels/templates/tower.oxt

    r9348 r10181  
    11<Template name=tower>
    2   <Tower
     2  <TowerDefenseTower
    33
    44
     
    2020        </WaypointPatrolController>
    2121    </controller>
     22   
    2223
    2324
    2425    <attached>
    2526        <Model position="0,0,0" scale=45 mesh="Tower.mesh" />
     27       
     28       
    2629    </attached>
    2730
     
    3336  include("../includes/towerWeaponSettings.oxi")
    3437?>
    35   </Tower>
     38  </TowerDefenseTower>
    3639</Template>
    3740
     41
     42
     43<Template name=towerturret>
     44  <TowerDefenseTower
     45
     46
     47   explosionchunks        = 6
     48
     49   reloadrate          = 10
     50   reloadwaittime      = 5
     51
     52   collisionType     = "dynamic"
     53   team = 1
     54
     55
     56  >
     57  <attached>
     58
     59    <Model position="0,0,0" scale=45 mesh="Tower.mesh" />
     60
     61    <Turret reloadrate=10 reloadwaittime=5 collisionType="dynamic" position="0,0,10" direction="0,0,1" pitch="0" yaw="0" roll="0" angularDamping=0.999999 mass=100 maxPitch=90 maxYaw=90 maxAttackRadius=1000 minAttackRadius=30>
     62
     63      <controller>
     64        <TurretController/>
     65      </controller>
     66      <?lua
     67        include("../includes/weaponSettingsTurret.oxi")
     68      ?>
     69    </Turret>
     70   
     71  </attached>
     72   
     73
     74
     75
     76    <!--collisionShapes>
     77
     78    </collisionShapes-->
     79
     80<?lua
     81  include("../includes/towerWeaponSettings.oxi")
     82?>
     83  </TowerDefenseTower>
     84</Template>
     85
     86
     87
     88<Template name=towerturret1>
     89  <TowerDefenseTower
     90
     91
     92   explosionchunks        = 6
     93
     94   reloadrate          = 10
     95   reloadwaittime      = 5
     96
     97   collisionType     = "dynamic"
     98   team = 1
     99
     100
     101  >
     102  <attached>
     103
     104
     105    <Turret reloadrate=10 reloadwaittime=5 collisionType="dynamic" position="0,0,10" direction="0,0,1" pitch="0" yaw="0" roll="0" angularDamping=0.999999 mass=100 maxPitch=90 maxYaw=90 maxAttackRadius=1000 minAttackRadius=30>
     106
     107      <controller>
     108        <TurretController/>
     109      </controller>
     110      <?lua
     111        include("../includes/weaponSettingsTurret1.oxi")
     112      ?>
     113    </Turret>
     114   
     115  </attached>
     116   
     117
     118
     119
     120    <!--collisionShapes>
     121
     122    </collisionShapes-->
     123
     124<?lua
     125  include("../includes/towerWeaponSettings.oxi")
     126?>
     127  </TowerDefenseTower>
     128</Template>
  • code/branches/presentationHS14/data/levels/towerDefense.oxw

    r9348 r10181  
    2121  include("templates/spaceshipPirate.oxt")
    2222  include("templates/tower.oxt")
     23  include("templates/enemytowerdefense.oxt")
     24  include("templates/standardTurret.oxt")
    2325?>
    2426
    2527<!-- Specify the position of the camera -->
    2628<Template name=centerpointmarkcamera defaults=0>
    27   <Pawn>
     29  <Pawn team=1>
    2830    <camerapositions>
    2931      <CameraPosition position="0,0,1500"/>
     
    3436<!-- Loads a mesh to mark the center-->
    3537<Template name=centerpointmark>
    36   <Pawn camerapositiontemplate=centerpointmarkcamera>
     38  <Pawn team=1 camerapositiontemplate=centerpointmarkcamera>
    3739    <attached>
    3840      <Model position="0,0,0" mesh="cylinder.mesh" scale3D="1,1,1" /> <!-- the camera is attached to this -->
     
    7072
    7173    <!-- Spawns the camera, attached to a crate -->
    72     <SpawnPoint team=0 position="0,0,0" spawnclass=Pawn pawndesign=centerpointmark />
     74    <SpawnPoint team=1 position="0,0,0" spawnclass=Pawn pawndesign=centerpointmark />
    7375    <!--TeamSpawnPoint team=1 position="-7,7,4" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff /-->
    7476
     
    7678    <!--SpawnPoint team=0 position="0,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /-->
    7779
    78     <SpaceShip position="-700,-500, 100" lookat="0,0,0" scale=3 team=1 >
    79       <templates>
    80         <Template link=spaceshipassff />
    81       </templates>
    82       <controller>
    83         <WaypointController accuracy=60>
    84           <waypoints>
    85             <!-- 1,3 10,3 10,11, 13,11 -->
    86             <Model mesh="cube.mesh" scale=0 position="-700,-500, 150" />
    87             <Model mesh="cube.mesh" scale=0 position=" 200,-500, 150" />
    88             <Model mesh="cube.mesh" scale=0 position=" 200, 300, 150" />
    89             <Model mesh="cube.mesh" scale=0 position=" 500, 300, 150" />
    90             <Model mesh="cube.mesh" scale=0 position=" 500, 700, 150" />
    91           </waypoints>
    92         </WaypointController>
    93       </controller>
    94     </SpaceShip>
     80
    9581
    9682
    9783    <!--invisible entity to attach towers to, since playfield is static and towers are dynamic-->
    98     <StaticEntity position=0,0,0>
     84    <StaticEntity team =1 position=0,0,0>
    9985
    10086        <attached>
     
    132118    direction="0,0,0"
    133119    collisionType=dynamic
    134     mass=100000>
    135 
    136     </TowerDefenseCenterpoint>
     120    mass=100000
     121    team=1
     122    />
    137123
    138124  </Scene>
  • code/branches/presentationHS14/data/levels/turretTest.oxw

    r9939 r10181  
    33<LevelInfo
    44 name = "turret Test"
    5  description = "A level with a turret in it."
     5 description = "A level to test turrets with."
    66 tags = "test"
    77 screenshot = "emptylevel.png"
     
    1616<?lua
    1717  include("templates/spaceshipAssff.oxt")
    18   include("templates/spaceshipPirate.oxt")
    19   include("templates/spaceshipTurret.oxt")
     18  include("templates/standardTurret.oxt")
    2019?>
    2120
     
    3332    <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
    3433
     34<SpaceShip position = "0,0,800" collisionType="dynamic" team=10>
     35  <controller>
     36    <TeamTargetProxy team=10/>
     37  </controller>
     38  <attached>
     39    <Model position="0,0,0" mesh="plane.mesh" scale3D="20,20,20" pitch=-90/>
    3540
    36 <StaticEntity position="0,0,0" yaw=0 pitch=0>
    37     <attached>
    38         <Model position="0,0,0" mesh="turretSocketFront.mesh" scale3D="10,10,10" />
    39         <Model position="0,0,0" mesh="turretSocketIn.mesh" scale3D="10,10,10" />
    40         <Model position="0,0,0" mesh="turretSocketTop.mesh" scale3D="10,10,10" />
    41         <Model position="0,0,0" mesh="turretSocketLeft.mesh" scale3D="10,10,10" />
    42         <Model position="0,0,0" mesh="turretSocketRight.mesh" scale3D="10,10,10" />
    43     </attached>
    44 </StaticEntity>
     41    <?lua for i = 1, 10, 1 do ?>
     42      <Turret position="<?lua print(150-i*30) ?>,<?lua print(150-i*30) ?>,0" pitch="0" yaw="0" roll="0">
     43        <templates>
     44          <Template link=standardturret />
     45        </templates>
     46      </Turret>
     47    <?lua end ?>
    4548
    46 
    47 
    48 <Turret position="0,10,0" pitch="90" yaw="0" roll="0">
    49     <templates>
    50         <Template link=spaceshipturret />
    51     </templates>
    52     <controller>
    53         <WaypointPatrolController alertnessradius=100 team=10>
    54         </WaypointPatrolController>
    55      </controller>
    56 </Turret>
    57 
    58 
    59 
     49  </attached>
     50  <collisionShapes>
     51    <BoxCollisionShape radius="10"   position="0,0,0" halfExtents="200, 200, 0"/>
     52  </collisionShapes>
     53</SpaceShip>
    6054   
    6155  </Scene>
  • code/branches/presentationHS14/data/overlays/towerdefenseHUD.oxo

    r9348 r10181  
    11<Template name="TowerDefenseHUD">
     2
     3
    24  <OverlayGroup name="TowerDefenseHUD" scale = "1, 1">
     5 
     6 
    37    <OverlayText
    4      position  = "0.05, 0.05"
     8     position  = "0.83, 0.05"
    59     pickpoint = "0.0, 0.0"
    610     font      = "ShareTechMono"
     
    913     align     = "left"
    1014
    11      caption = "Hello World"
     15     caption = "Cash:"
    1216    />
     17   
     18   
     19     <TowerDefenseHUDController
     20     position  = "0.88, 0.10"
     21     pickpoint = "0.0, 0.0"
     22     font      = "ShareTechMono"
     23     textsize  = 0.05
     24     colour    = "1.0, 1.0, 1.0, 1.0"
     25     align     = "left"
     26                showlives = false
     27                showcredits = true
     28                showwaves = false
     29    />
     30   
     31        <OverlayText
     32     position  = "0.83, 0.22"
     33     pickpoint = "0.0, 0.0"
     34     font      = "ShareTechMono"
     35     textsize  = 0.05
     36     colour    = "1.0, 1.0, 1.0, 1.0"
     37     align     = "left"
     38
     39     caption = "Lifes:"
     40    />
     41   
     42         <TowerDefenseHUDController
     43     position  = "0.88, 0.27"
     44     pickpoint = "0.0, 0.0"
     45     font      = "ShareTechMono"
     46     textsize  = 0.05
     47     colour    = "1.0, 1.0, 1.0, 1.0"
     48     align     = "left"
     49                showlives = true
     50                showcredits = false
     51                showwaves = false
     52    />
     53   
     54            <OverlayText
     55     position  = "0.83, 0.39"
     56     pickpoint = "0.0, 0.0"
     57     font      = "ShareTechMono"
     58     textsize  = 0.05
     59     colour    = "1.0, 1.0, 1.0, 1.0"
     60     align     = "left"
     61
     62     caption = "Waves:"
     63    />
     64   
     65         <TowerDefenseHUDController
     66     position  = "0.88, 0.44"
     67     pickpoint = "0.0, 0.0"
     68     font      = "ShareTechMono"
     69     textsize  = 0.05
     70     colour    = "1.0, 1.0, 1.0, 1.0"
     71     align     = "left"
     72        showlives = false
     73                showcredits = false
     74                showwaves = true
     75
     76    />
     77   
     78   
    1379  </OverlayGroup>
    1480</Template>
     81
     82
  • code/branches/presentationHS14/src/libraries/core/input/InputManager.cc

    r9667 r10181  
    175175
    176176        if (exclusiveMouse_ || GraphicsManager::getInstance().isFullScreen())
    177         {
     177        {   // HACK MARTIN for debugging, changed values here to true
    178178            if (CommandLineParser::getValue("keyboard_no_grab").get<bool>())
    179179                paramList.insert(StringPair("x11_keyboard_grab", "false"));
    180180            else
    181                 paramList.insert(StringPair("x11_keyboard_grab", "true"));
    182             paramList.insert(StringPair("x11_mouse_grab",  "true"));
    183             paramList.insert(StringPair("x11_mouse_hide", "true"));
     181                paramList.insert(StringPair("x11_keyboard_grab", "false"));
     182            paramList.insert(StringPair("x11_mouse_grab",  "false"));
     183            paramList.insert(StringPair("x11_mouse_hide", "false"));
    184184        }
    185185        else
  • code/branches/presentationHS14/src/modules/objects/CMakeLists.txt

    r9526 r10181  
    1111ADD_SUBDIRECTORY(eventsystem)
    1212ADD_SUBDIRECTORY(triggers)
     13ADD_SUBDIRECTORY(controllers)
    1314
    1415ORXONOX_ADD_LIBRARY(objects
  • code/branches/presentationHS14/src/modules/objects/Turret.cc

    r9945 r10181  
    2121 *
    2222 *   Author:
    23  *      Marian Runo
     23 *      Marian Runo, Martin Mueller
    2424 *   Co-authors:
    2525 *      ...
     
    2929#include "Turret.h"
    3030#include "core/CoreIncludes.h"
    31 #include "OgreQuaternion.h"
    3231#include "core/XMLPort.h"
    33 #include "controllers/WaypointPatrolController.h"
     32#include "Scene.h"
     33#include <OgreSceneManager.h>
     34
    3435
    3536namespace orxonox
     
    3738    RegisterClass(Turret);
    3839
    39     /**
    40      * @brief Constructor
     40
     41
     42    /**
     43        @brief
     44        Sets default values for all variables. Also hides the turret from the radar.
     45
     46        @param context
     47        The context
    4148     */
    42     Turret::Turret(Context* context) : SpaceShip(context)
     49    Turret::Turret(Context* context) : Pawn(context)
    4350    {
    4451        RegisterObject(Turret);
    45         this->controller_ = new WaypointPatrolController(this->getContext());
    46     }
    47 
    48     /**
    49      * @brief Destructor
     52        this->rotationThrust_ = 50;
     53        this->startDir_ = Vector3::ZERO;
     54        this->localZ_ = Vector3::UNIT_Z;
     55        this->localY_ = Vector3::UNIT_Y;
     56        this->localX_ = Vector3::UNIT_X;
     57        this->maxAttackRadius_ = 200;
     58        this->minAttackRadius_ = 0;
     59        this->maxPitch_ = 90;
     60        this->maxYaw_ = 90;
     61        this->once_ = false;
     62        this->rotation_ = Quaternion::IDENTITY;
     63
     64        this->setRadarVisibility(false);
     65
     66        //this->rayTest_ = this->getScene()->getSceneManager()->createRayQuery(Ogre::Ray());
     67    }
     68
     69    /**
     70        @brief
     71        Destructor. Destroys the rayTest_ element (if it was used)  .
    5072     */
    5173    Turret::~Turret()
    5274    {
    53 
    54     }
    55 
    56 
     75        //this->getScene()->getSceneManager()->destroyQuery(this->rayTest_);
     76    }
     77
     78    /**
     79        @brief
     80        Checks, if a WorldEntity is inside the turret's range.
     81
     82        This function is safe to use on turrets that are attached, rotated, etc.
     83        The turret's range is determined with the maxPitch, maxYaw, and the two attackRadius.
     84
     85        @param target
     86        The WorldEntity to check
     87
     88        @return
     89        The squared distance to the position. -1, if it's ouside of range
     90    */
     91    float Turret::isInRange(const WorldEntity* target )
     92    {
     93        //Check distance
     94        Vector3 distance = target->getWorldPosition() - this->getWorldPosition();
     95        float distanceVal = distance.squaredLength();
     96        if(distanceVal > (this->maxAttackRadius_ * this->maxAttackRadius_) || distanceVal < (this->minAttackRadius_ * this->minAttackRadius_))
     97        {
     98            return -1.f;
     99        }
     100
     101        //Check pitch
     102        Vector3 dir = getTransformedVector(distance, this->localX_, this->localY_, this->localZ_);
     103        Vector3 dirProjected = dir;
     104        dirProjected.x = 0;
     105        Vector3 startDirProjected = this->startDir_;
     106        startDirProjected.x = 0;
     107        Ogre::Real angle = startDirProjected.angleBetween(dirProjected).valueDegrees();
     108        if(angle > this->maxPitch_)
     109        {
     110            return -1.f;
     111        }
     112
     113        //Check yaw
     114        dirProjected = dir;
     115        dirProjected.y = 0;
     116        startDirProjected = this->startDir_;
     117        startDirProjected.y = 0;
     118        angle = startDirProjected.angleBetween(dirProjected).valueDegrees();
     119        if(angle > this->maxYaw_)
     120        {
     121            return -1.f;
     122        }
     123
     124        //TODO: Finish this. Find a way to convert objects from Ogre to Orxonox
     125        /*Ogre::Ray ray = Ogre::Ray(this->getWorldPosition(), distance);
     126        this->rayTest_->setRay(ray);
     127        Ogre::RaySceneQueryResult result = this->rayTest_->execute();*/
     128
     129
     130        return distanceVal;
     131    }
     132
     133    /**
     134        @brief
     135        Rotates the turret to make it aim at a certain position.
     136
     137        @note
     138        There are no checks, if the position is valid (i.e. if the turret is allowed to aim there).
     139        This function must be called again for every tick, or the turret will stop rotating.
     140
     141        @param position
     142        The position to aim at
     143    */
     144    void Turret::aimAtPosition(const Vector3& position)
     145    {
     146        Vector3 currDir = this->getWorldOrientation() * WorldEntity::FRONT;
     147        Vector3 targetDir = position - this->getWorldPosition();
     148
     149        this->rotation_ = currDir.getRotationTo(targetDir);
     150    }
     151
     152    /**
     153        @brief
     154        Does currently nothing.
     155
     156        Should rotate the turret with the specified pitch. Contains a failed attempt at limiting said rotation.
     157    */
    57158    void Turret::rotatePitch(const Vector2& value)
    58     {
    59         orxout()<< "Turret rotate Pitch"<< endl;
    60 
    61         const Quaternion& orient = this->getOrientation();
    62         Radian pitch = orient.getPitch();
    63 
    64         if((value.x > 0 && pitch < Radian(180)) || (value.x < 0 && pitch > Radian(0)))
    65             SpaceShip::rotatePitch(value);
    66     }
    67 
    68 
    69     void Turret::setAlertnessRadius(float value)
    70     {
    71         this->controller_->setAlertnessRadius(value);
    72     }
    73     float Turret::getAlertnessRadius()
    74     {
    75         return this->controller_->getAlertnessRadius();
    76     }
    77 
     159    {   
     160        //This is a failed attempt at limiting the turret's rotation. It's handled in the controller (for now?)
     161        /*
     162        Vector3 currentDir = getTransformedVector(this->getOrientation() * WorldEntity::FRONT, this->localX_, this->localY_, this->localZ_);
     163        Vector3 currentDirProjected = currentDir;
     164        currentDirProjected.x = 0;
     165        Vector3 startDirProjected = this->startDir_;
     166        startDirProjected.x = 0;     
     167        Ogre::Real angle = startDirProjected.angleBetween(currentDirProjected).valueDegrees();
     168        //orxout() << "Pitch: " << angle << endl;   
     169        //if(angle < this->maxPitch_ || (currentDirProjected.y <= 0 && value.x > 0) || (currentDirProjected.y > 0 && value.x < 0) )
     170        {
     171            this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x*0.8f);
     172        }
     173        */
     174    }
     175
     176    /**
     177        @brief
     178        Does currently nothing.
     179
     180        Should rotate the turret with the specified yaw. Contains a failed attempt at limiting said rotation.
     181    */
     182    void Turret::rotateYaw(const Vector2& value)
     183    {
     184        //This is a failed attempt at limiting the turret's rotation. It's handled in the controller (for now?)
     185        /*
     186        Vector3 currentDir = getTransformedVector(this->getOrientation() * WorldEntity::FRONT, this->localX_, this->localY_, this->localZ_);
     187        Vector3 currentDirProjected = currentDir;
     188        currentDirProjected.y = 0;
     189        Vector3 startDirProjected = this->startDir_;
     190        startDirProjected.y = 0;
     191        Ogre::Real angle = startDirProjected.angleBetween(currentDirProjected).valueDegrees();
     192        orxout() << "Yaw: " << angle << endl;
     193        if(angle < this->maxYaw_ || (currentDirProjected.x <= 0 && value.x < 0) || (currentDirProjected.x > 0 && value.x > 0))
     194        {
     195            this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x*0.8f);
     196        }
     197        */
     198    }
     199
     200    /**
     201        @brief
     202        Does currently nothing.
     203
     204        May be used to limit turret's rotation in the future.
     205    */
     206    void Turret::rotateRoll(const Vector2& value)
     207    {
     208    }
     209
     210    /**
     211        @brief
     212        Loads parameters from xml
     213
     214        Parameters loaded are: rotationThrust, maxAttackRadius, minAttackRadius, maxYaw, maxPitch
     215    */
    78216    void Turret::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    79217    {
    80218        SUPER(Turret, XMLPort, xmlelement, mode);
    81         XMLPortParam(Turret, "alertnessRadius", setAlertnessRadius, getAlertnessRadius, xmlelement, mode).defaultValues("400");
    82     }
    83 
    84 
     219       
     220        XMLPortParamVariable(Turret, "rotationThrust", rotationThrust_, xmlelement, mode);
     221        XMLPortParam(Turret, "maxAttackRadius", setMaxAttackRadius, getMaxAttackRadius, xmlelement, mode);
     222        XMLPortParam(Turret, "minAttackRadius", setMinAttackRadius, getMinAttackRadius, xmlelement, mode);
     223        XMLPortParam(Turret, "maxYaw", setMaxYaw, getMaxYaw, xmlelement, mode);
     224        XMLPortParam(Turret, "maxPitch", setMaxPitch, getMaxPitch, xmlelement, mode);
     225    }
     226
     227    /**
     228        @brief
     229        The turret's actions are done here.
     230
     231        Every tick, the turret gets rotated if it should, and the local axes get updated with the parent's rotation.
     232   
     233        @param dt
     234        Duration of the tick
     235    */
     236    void Turret::tick(float dt)
     237    {
     238        SUPER(Turret, tick, dt);
     239
     240        //Stuff isn't properly initialized in the c'tor, so we have to do it like this
     241        if(!this->once_)
     242        {
     243            //Account for rotations done in xml
     244            Quaternion startOrient = this->getOrientation();
     245            this->localXStart_ = startOrient * this->localX_;
     246            this->localXStart_.normalise();
     247            this->localX_ = this->localXStart_;
     248            this->localYStart_ = startOrient * this->localY_;
     249            this->localYStart_.normalise();
     250            this->localY_ = this->localYStart_;
     251            this->localZStart_ = startOrient * this->localZ_;
     252            this->localZStart_.normalise();
     253            this->localZ_ = this->localZStart_;
     254
     255            //startDir should always be (0,0,-1)
     256            this->startDir_ = getTransformedVector(startOrient * WorldEntity::FRONT, this->localX_, this->localY_, this->localZ_);
     257
     258            this->once_ = true;
     259
     260        }
     261
     262        //Adjust local axes to parent's rotation
     263        WorldEntity* parent = this->getParent();
     264        if(parent)
     265        {
     266            Quaternion parentrot = parent->getWorldOrientation();
     267            this->localX_ = parentrot * this->localXStart_;
     268            this->localY_ = parentrot * this->localYStart_;
     269            this->localZ_ = parentrot * this->localZStart_;
     270        }
     271
     272        //rotate
     273        if(this->rotation_ != Quaternion::IDENTITY)
     274        {
     275            //Don't make the rotation instantaneous. Use an arbitrary interpolation, not that great...
     276            //TODO: make the rotation better (constant velocity etc.). At the moment, the turret rotates
     277            //slower the closer it is to the destination
     278            Quaternion drot = Quaternion::nlerp(dt*this->rotationThrust_/20.f, Quaternion::IDENTITY, this->rotation_);
     279            this->rotate(drot, WorldEntity::World);
     280            this->rotation_ = Quaternion::IDENTITY;
     281        }
     282
     283    }
    85284}
  • code/branches/presentationHS14/src/modules/objects/Turret.h

    r9667 r10181  
    2121 *
    2222 *   Author:
    23  *      Marian Runo
     23 *      Marian Runo, Martin Mueller
    2424 *   Co-authors:
    2525 *      ...
     
    2828
    2929/**
    30     @file Turret.h
    3130    @brief Definition of the Turret class.
    3231    @ingroup Objects
     
    3736
    3837#include "objects/ObjectsPrereqs.h"
    39 
    40 #include "worldentities/pawns/SpaceShip.h"
     38#include "worldentities/pawns/Pawn.h"
     39#include <OgreSceneQuery.h>
    4140
    4241namespace orxonox
    4342{
    44     class _ObjectsExport Turret : public SpaceShip
     43    /**
     44    @brief
     45        Creates a turret with limited rotation. The point of this class is to be able to attach
     46        a turret to a spaceship or a spacestation which is more or less completely autonomous in
     47        it's behaviour.
     48
     49        This class also contains a custom local coordinate system, which gets initially rotated through xml, and
     50        afterwards is updated with the parent's rotation (if there is one). This allows for almost trivialal calculation
     51        of pitch, yaw and roll through coordinate transformation. (TODO: Ogre should do something like this already, investigate...)
     52       
     53
     54    @note
     55        The rotation isn't limited "physically". You have to call isInRange to find out if the turret is allowed to shoot at a target.
     56    */
     57    class _ObjectsExport Turret : public Pawn
    4558    {
    4659        public:
     
    4861            virtual ~Turret();
    4962
    50             //virtual void tick(float dt);
    51 
    5263            virtual void rotatePitch(const Vector2& value);
    53 
    54             void setAlertnessRadius(float value);
    55             float getAlertnessRadius();
     64            virtual void rotateYaw(const Vector2& value);
     65            virtual void rotateRoll(const Vector2& value);
     66            virtual float isInRange(const WorldEntity* target);
     67            virtual void aimAtPosition(const Vector3 &position);
    5668
    5769            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     70            virtual void tick(float dt);
    5871
     72            /** @brief Sets the maximum distance the turret is allowed to shoot. @param radius The distance*/
     73            inline void setMaxAttackRadius(float radius)
     74                { this->maxAttackRadius_ = radius; }
     75
     76            /** @brief Sets the minimum distance the turret is allowed to shoot. @param radius The distance*/
     77            inline void setMinAttackRadius(float radius)
     78                { this->minAttackRadius_ = radius; }
     79
     80            /** @brief Sets the maximum pitch the turret can have (in both directions). @param pitch The pitch (in one direction)*/
     81            inline void setMaxPitch(float pitch)
     82                { this->maxPitch_ = pitch; }
     83
     84            /** @brief Sets the maximum yaw the turret can have (in both directions). @param yaw The yaw (in one direction)*/
     85            inline void setMaxYaw(float yaw)
     86                { this->maxYaw_ = yaw; }
     87
     88            /** @brief Returns the maximum distance the turret is allowed to shoot. @return The distance */
     89            inline float getMaxAttackRadius() const
     90                { return this->maxAttackRadius_; }               
     91
     92            /** @brief Returns the minimum distance the turret is allowed to shoot. @return The distance */
     93            inline float getMinAttackRadius() const
     94                { return this->minAttackRadius_; }   
     95
     96            /** @brief Returns the maximum pitch the turret can have. @return The pitch */
     97            inline float getMaxPitch() const
     98                { return this->maxPitch_; }
     99
     100            /** @brief Returns the maximum yaw the turret can have. @return The yaw */
     101            inline float getMaxYaw() const
     102                { return this->maxYaw_; }
    59103
    60104        protected:
    61             WaypointPatrolController* controller_;
     105            Vector3 startDir_; //!< The initial facing direction, in local coordinates.
     106            Vector3 localZ_; //!< The local z-axis, includes for the parent's rotation and rotations done in xml.
     107            Vector3 localY_; //!< The local y-axis, includes for the parent's rotation and rotations done in xml.
     108            Vector3 localX_; //!< The local x-axis, includes for the parent's rotation and rotations done in xml.     
     109            Quaternion rotation_; //!< The rotation to be done by the turret.
     110
    62111        private:
     112            bool once_; //!< Flag for executing code in the tick function only once.
     113
     114            Vector3 localZStart_; //!< The local z-axis, without the parent's rotation.
     115            Vector3 localYStart_; //!< The local y-axis, without the parent's rotation.
     116            Vector3 localXStart_; //!< The local x-axis, without the parent's rotation.
     117            float maxAttackRadius_; //!< The maximum distance the turret is allowed to shoot.
     118            float minAttackRadius_; //!< The minimum distance the turret is allowed to shoot.
     119            Ogre::Real maxPitch_; //!< The maxmium pitch the turret can have (on one side).
     120            Ogre::Real maxYaw_; //!< The maxmium yaw the turret can have (on one side).
     121            float rotationThrust_;  //!< The velocity the turret rotates with.
     122            Ogre::RaySceneQuery* rayTest_; //!< Used to perform a raytest, currently unused @see isInRange
    63123
    64124    };
     
    66126
    67127#endif
    68 
  • code/branches/presentationHS14/src/modules/towerdefense/CMakeLists.txt

    r9958 r10181  
    11SET_SOURCE_FILES(TOWERDEFENSE_SRC_FILES
    22  TowerDefense.cc
    3   Tower.cc
     3  TowerDefenseTower.cc
     4  TowerTurret.cc
    45  TowerDefenseCenterpoint.cc
    56  TowerDefenseHUDController.cc
    67  TowerDefensePlayerStats.cc
     8  TDCoordinate.cc
     9  TowerDefenseEnemy.cc
    710
    811)
  • code/branches/presentationHS14/src/modules/towerdefense/TDEnemy.h

    r9272 r10181  
    55 *      Author: weigeltm
    66 */
    7 
     7/*
    88#ifndef TDENEMY_H_
    99#define TDENEMY_H_
     
    2424
    2525
    26 #endif /* TDENEMY_H_ */
     26#endif TDENEMY_H_ */
  • code/branches/presentationHS14/src/modules/towerdefense/Tower.cc

    r9667 r10181  
    4040    {
    4141        static int ori;
    42         orxout() << "orientation " << ++ori << endl;
     42        //orxout() << "orientation " << ++ori << endl;
    4343    }
    4444
     
    4646    {
    4747        static int yaw;
    48         orxout() << "rotateYaw " << ++yaw << endl;
     48        //orxout() << "rotateYaw " << ++yaw << endl;
    4949    }
    5050
     
    5252    {
    5353        static int pitch;
    54         orxout() << "rotatePitch " << ++pitch << endl;
     54        //orxout() << "rotatePitch " << ++pitch << endl;
    5555    }
    5656
     
    5858    {
    5959        static int roll;
    60         orxout() << "rotateRoll" << ++roll << endl;
     60        //orxout() << "rotateRoll" << ++roll << endl;
    6161    }
    6262
  • code/branches/presentationHS14/src/modules/towerdefense/TowerDefense.cc

    r9667 r10181  
    2020 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    2121 *
    22  *   Author:
     22 *  Author:
    2323 *
    2424 *   Co-authors:
     
    7373 *
    7474 */
    75 
    7675#include "TowerDefense.h"
    77 #include "Tower.h"
     76#include "TowerDefenseTower.h"
    7877#include "TowerDefenseCenterpoint.h"
    79 
     78//#include "TDCoordinate.h"
     79#include "TowerTurret.h"
    8080#include "worldentities/SpawnPoint.h"
    8181#include "worldentities/pawns/Pawn.h"
    8282#include "worldentities/pawns/SpaceShip.h"
    8383#include "controllers/WaypointController.h"
    84 
    8584#include "graphics/Model.h"
    8685#include "infos/PlayerInfo.h"
    87 
    8886#include "chat/ChatManager.h"
    8987#include "core/CoreIncludes.h"
    90 
    9188/* Part of a temporary hack to allow the player to add towers */
    9289#include "core/command/ConsoleCommand.h"
     
    9996    {
    10097        RegisterObject(TowerDefense);
     98/*
     99        for (int i=0; i < 16 ; i++){
     100                for (int j = 0; j< 16 ; j++){
     101                        towermatrix[i][j] = NULL;
     102                }
     103        }*/
    101104
    102105        this->setHUDTemplate("TowerDefenseHUD");
    103106
    104         this->stats_ = new TowerDefensePlayerStats();
    105 
    106         /* Temporary hack to allow the player to add towers */
     107        //this->stats_ = new TowerDefensePlayerStats();
     108
     109        /* Temporary hack to allow the player to add towers and upgrade them */
    107110        this->dedicatedAddTower_ = createConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) );
     111        this->dedicatedUpgradeTower_ = createConsoleCommand( "upgradeTower", createExecutor( createFunctor(&TowerDefense::upgradeTower, this) ) );
    108112    }
    109113
     
    127131    void TowerDefense::start()
    128132    {
     133
    129134        Deathmatch::start();
    130135
    131         const int kInitialTowerCount = 3;
    132         Coordinate initialTowerCoordinates[kInitialTowerCount] = {{3,2}, {8,5}, {12,10}};
    133 
    134         for (int i = 0; i < kInitialTowerCount; i++)
    135         {
    136             Coordinate coordinate = initialTowerCoordinates[i];
    137             addTower(coordinate.x, coordinate.y);
    138         }
    139 
    140         ChatManager::message("Use the console command addTower x y to add towers");
    141 
    142         //TODO: let the player control his controllable entity && TODO: create a new ControllableEntity for the player
    143     }
     136// Waypoints: [1,3] [10,3] [10,11] [13,11] -> add the points to a matrix so the player cant place towers on the path
     137        for (int i=0; i < 16 ; i++){
     138                for (int j = 0; j< 16 ; j++){
     139                        towermatrix[i][j] = false;
     140                }
     141        }
     142
     143        for (int k=0; k<3; k++)
     144                towermatrix[1][k]=true;
     145        for (int l=1; l<11; l++)
     146                towermatrix[l][3]=true;
     147        for (int m=3; m<12; m++)
     148                towermatrix[10][m]=true;
     149        for (int n=10; n<14; n++)
     150                towermatrix[n][11]=true;
     151        for (int o=13; o<16; o++)
     152                towermatrix[13][o]=true;
     153
     154//set initial credits, lifes and WaveNumber
     155        this->setCredit(200);
     156        this->setLifes(50);
     157        this->setWaveNumber(0);
     158        time=0.0;
     159
     160//adds initial towers
     161for (int i=0; i <7; i++){
     162          addTower(i+3,4);
     163        }/*
     164for (int j=0; j < 7; j++){
     165          addTower(9,j+5);
     166        }*/
     167}
     168    // Generates a TowerDefenseEnemy. Uses Template "enemytowerdefense". Sets position at first waypoint of path.
     169     void TowerDefense::addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr){
     170
     171
     172        TowerDefenseEnemy* en1 = new TowerDefenseEnemy(this->center_->getContext());
     173       
     174        switch(templatenr)
     175        {
     176        case 1 :
     177                en1->addTemplate("enemytowerdefense1");
     178                en1->setScale(3);
     179            en1->setHealth(en1->getHealth() + this->getWaveNumber()*4);
     180
     181                break;
     182        case 2 :
     183                en1->addTemplate("enemytowerdefense2");
     184                en1->setScale(2);
     185            en1->setHealth(en1->getHealth() + this->getWaveNumber()*4);
     186          //  en1->setShieldHealth(en1->getShield() = this->getWaveNumber()*2))
     187
     188                break;
     189        case 3 :
     190            en1->addTemplate("enemytowerdefense3");
     191            en1->setScale(1);
     192            en1->setHealth(en1->getHealth() + this->getWaveNumber()*4);
     193            break;
     194        }
     195
     196        en1->getController();
     197        en1->setPosition(path.at(0)->get3dcoordinate());
     198        TowerDefenseEnemyvector.push_back(en1);
     199
     200        for(unsigned int i = 0; i < path.size(); ++i)
     201                {
     202                en1->addWaypoint((path.at(i)));
     203                }
     204    }
     205
    144206
    145207    void TowerDefense::end()
    146     {
     208
     209    {
     210
    147211        Deathmatch::end();
    148 
    149         ChatManager::message("Match is over");
    150     }
    151 
     212        ChatManager::message("Match is over! Gameover!");
     213
     214    }
     215
     216    //not working yet
     217    void TowerDefense::upgradeTower(int x,int y)
     218    {/*
     219        const int upgradeCost = 20;
     220
     221        if (!this->hasEnoughCreditForTower(upgradeCost))
     222        {
     223            orxout() << "not enough credit: " << (this->getCredit()) << " available, " << upgradeCost << " needed.";
     224            return;
     225        }
     226
     227        if (towermatrix [x][y] == NULL)
     228        {
     229            orxout() << "no tower on this position" << endl;
     230            return;
     231        }
     232
     233        else
     234        {
     235                (towermatrix [x][y])->upgradeTower();
     236        }*/
     237    }
     238
     239    /*adds Tower at Position (x,y) and reduces credit and adds the point to the towermatrix. template ("towerturret")
     240    so towers have ability if the turrets
     241
     242    */
    152243    void TowerDefense::addTower(int x, int y)
    153244    {
    154         const TowerCost towerCost = TDDefaultTowerCost;
     245        const int towerCost = 20;
    155246
    156247        if (!this->hasEnoughCreditForTower(towerCost))
    157248        {
    158             orxout() << "not enough credit: " << (this->stats_->getCredit()) << " available, " << TDDefaultTowerCost << " needed.";
     249            orxout() << "not enough credit: " << (this->getCredit()) << " available, " << towerCost << " needed.";
    159250            return;
    160251        }
    161252
    162         if (this->towerExists(x,y))
    163         {
    164             orxout() << "tower exists!!" << endl;
     253        if (towermatrix [x][y]==true)
     254        {
     255            orxout() << "not possible to put tower here!!" << endl;
    165256            return;
    166257        }
    167258
    168         /*
     259/*
    169260        unsigned int width = this->center_->getWidth();
    170261        unsigned int height = this->center_->getHeight();
    171         */
     262*/
    172263
    173264        int tileScale = (int) this->center_->getTileScale();
     
    182273        orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl;
    183274
    184         // Add tower to coordinatesStack
    185         Coordinate newTowerCoordinates = {x, y};
    186         addedTowersCoordinates_.push_back(newTowerCoordinates);
    187 
    188         // Reduce credit
    189         this->stats_->buyTower(towerCost);
    190 
    191         // Create tower
    192         Tower* newTower = new Tower(this->center_->getContext());
    193         newTower->addTemplate(this->center_->getTowerTemplate());
    194 
    195         newTower->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 75);
    196         newTower->setGame(this);
    197     }
    198 
    199     bool TowerDefense::hasEnoughCreditForTower(TowerCost towerCost)
    200     {
    201         return ((this->stats_->getCredit()) >= towerCost);
    202     }
    203 
    204     bool TowerDefense::towerExists(int x, int y)
    205     {
    206         for(std::vector<Coordinate>::iterator it = addedTowersCoordinates_.begin(); it != addedTowersCoordinates_.end(); ++it)
    207         {
    208             Coordinate currentCoordinates = (Coordinate) (*it);
    209             if (currentCoordinates.x == x && currentCoordinates.y == y)
    210                 return true;
    211         }
    212 
    213         return false;
    214     }
    215 
    216 
     275       //Reduce credit
     276        this->buyTower(towerCost);
     277        towermatrix [x][y]=true;
     278
     279        //Creates tower
     280        TowerDefenseTower* towernew = new TowerDefenseTower(this->center_->getContext());
     281        towernew->addTemplate("towerturret");
     282        towernew->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 75);
     283        towernew->setGame(this);
     284    }
     285
     286    bool TowerDefense::hasEnoughCreditForTower(int towerCost)
     287    {
     288        return ((this->getCredit()) >= towerCost);
     289    }
     290
     291
     292    bool TowerDefense::hasEnoughCreditForUpgrade()
     293    {
     294        return true;
     295    }
     296
     297 
    217298    void TowerDefense::tick(float dt)
    218299    {
    219300        SUPER(TowerDefense, tick, dt);
     301        time +=dt;
     302
     303        TDCoordinate* coord1 = new TDCoordinate(1,1);
     304        std::vector<TDCoordinate*> path;
     305        path.push_back(coord1);
     306        if(time>1 && TowerDefenseEnemyvector.size() < 30)
     307        {
     308                //adds different types of enemys depending on the WaveNumber
     309                addTowerDefenseEnemy(path, this->getWaveNumber() % 3 +1 );
     310                time = time-1;
     311        }
     312
     313                Vector3* endpoint = new Vector3(500, 700, 150);
     314                //if ships are at the end they get destroyed
     315                for(unsigned int i =0; i < TowerDefenseEnemyvector.size(); ++i)
     316                {
     317                        if(TowerDefenseEnemyvector.at(i) != NULL && TowerDefenseEnemyvector.at(i)->isAlive())
     318                                {
     319                                //destroys enemys at the end of teh path and reduces the life by 1. no credits gifted
     320
     321                                        Vector3 ship = TowerDefenseEnemyvector.at(i)->getRVWorldPosition();
     322                                        float distance = ship.distance(*endpoint);
     323
     324                                        if(distance <50){
     325                                                TowerDefenseEnemyvector.at(i)->destroy();
     326                                                this->reduceLifes(1);
     327                                                this->buyTower(1);
     328                                                if (this->getLifes()==0)
     329                                                                {
     330                                                                    this->end();
     331                                                                }
     332                                        }
     333                                }
     334                        }
     335                        //goes thorugh vector to see if an enemy is still alive. if not next wave is launched
     336                        int count= 0;
     337                        for(unsigned int i =0; i < TowerDefenseEnemyvector.size(); ++i)
     338                        {
     339                                if(TowerDefenseEnemyvector.at(i)!= NULL)
     340                                {
     341                                        ++count;
     342                                }
     343                        }
     344
     345                        if(count== 0)
     346                        {
     347                                time2 +=dt;
     348                                if(time2 > 10)
     349                                {
     350                                        TowerDefenseEnemyvector.clear();
     351                                        this->nextwave();
     352                                        time=0;
     353                                        time2=0;
     354                                }
     355                        }
     356
     357
    220358    }
    221359
  • code/branches/presentationHS14/src/modules/towerdefense/TowerDefense.h

    r9667 r10181  
    3737#ifndef _TowerDefense_H__
    3838#define _TowerDefense_H__
    39 
     39#include "TDCoordinate.h"
    4040#include "towerdefense/TowerDefensePrereqs.h"
    4141#include "gametypes/Deathmatch.h"
    42 
    43  #include "TowerDefensePlayerStats.h"
     42#include "TowerDefenseEnemy.h"
     43#include "util/Output.h"
     44#include "core/object/WeakPtr.h"
    4445
    4546namespace orxonox
     
    5152        virtual ~TowerDefense();
    5253
     54        std::vector<orxonox::WeakPtr<TowerDefenseEnemy> > TowerDefenseEnemyvector;
     55        bool towermatrix[16][16];
     56        void addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr);
    5357        virtual void start(); //<! The function is called when the gametype starts
    5458        virtual void end();
     
    5660        //virtual void playerEntered(PlayerInfo* player);
    5761        //virtual bool playerLeft(PlayerInfo* player);
     62        //Player Stats (set,get, reduce)
     63        int getCredit(){        return this->credit_;   }
     64        int getLifes(){         return this->lifes_;    }
     65        int getWaveNumber(){    return this->waves_;    }
     66        void setCredit(int credit){ credit_ = credit; }
     67        void setLifes(int lifes){ lifes_ = lifes; }
     68        void setWaveNumber(int wavenumber){waves_=wavenumber;   }
     69        void buyTower(int cost){ credit_ -= cost;}
     70        void addCredit(int credit) {    credit_+=credit;        }
     71        void nextwave(){ waves_++;}
     72        int reduceLifes(int NumberofLifes){     return lifes_-=NumberofLifes;   }
    5873
    5974        //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
     
    6984        void addTower(int x, int y);
    7085
     86        void upgradeTower(int x, int y);
    7187        /* Part of a temporary hack to allow the player to add towers */
    7288        ConsoleCommand* dedicatedAddTower_;
     89        ConsoleCommand* dedicatedUpgradeTower_;
    7390
    7491        //TODO: void spawnNewWave()
     
    7996    private:
    8097        TowerDefenseCenterpoint *center_;
     98        float time;
     99        float time2;
     100        int credit_;
     101        int waves_;
     102        int lifes_;
    81103
    82104        /* handles stats */
    83         TowerDefensePlayerStats *stats_;
    84         bool hasEnoughCreditForTower(TowerCost towerCost);
     105        bool hasEnoughCreditForTower(int towerCost);
     106        bool hasEnoughCreditForUpgrade();
    85107
    86         bool towerExists(int x, int y);
    87108
    88         typedef struct {
    89             int x;
    90             int y;
    91         } Coordinate;
    92109
    93         std::vector<Coordinate> addedTowersCoordinates_;
    94         std::vector<Tower*> towers_;
     110        std::vector<TowerTurret*> towers_;
    95111    };
    96112}
  • code/branches/presentationHS14/src/modules/towerdefense/TowerDefenseController.cc

    r9667 r10181  
    3333#include "core/XMLPort.h"
    3434#include "worldentities/pawns/Pawn.h"
     35#include "controllers/WaypointController.h"
    3536
    3637namespace orxonox
     
    5354        XMLPortParam(TowerDefenseController, "alertnessradius", setAlertnessRadius, getAlertnessRadius, xmlelement, mode).defaultValues(500.0f);
    5455    }
     56
    5557
    5658    void TowerDefenseController::tick(float dt)
  • code/branches/presentationHS14/src/modules/towerdefense/TowerDefenseEnemy.cc

    r10180 r10181  
    3030        //needed to keep track of the PlayerStats coded in TowerDefense.h
    3131        this->td = orxonox_cast<TowerDefense*>(this->getGametype().get());
     32        once_=false;
    3233
    3334    }
    3435    //add credit if enemy is destroyed
    3536    TowerDefenseEnemy::~TowerDefenseEnemy(){
    36                 this->td->addCredit(1);
     37                //this->td->addCredit(1);
    3738    }
    3839
     
    4849    }
    4950
     51    WeakPtr<TowerDefense> TowerDefenseEnemy::getGame()
     52    {
     53        if (game == NULL)
     54        {
     55            for (ObjectList<TowerDefense>::iterator it = ObjectList<TowerDefense>::begin(); it != ObjectList<TowerDefense>::end(); ++it)
     56                game = *it;
     57        }
     58        return game;
     59    }
     60
     61    void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
     62    {
     63        Pawn::damage(damage, healthdamage, shielddamage, originator);
     64        if (getGame() && once_ == false && getHealth() <= 0)
     65        {
     66            getGame()->addCredit(1);
     67            once_ = true;
     68        }
     69    }
    5070/*
    5171    void TowerDefenseEnemy::popWaypoint()
  • code/branches/presentationHS14/src/modules/towerdefense/TowerDefenseEnemy.h

    r10180 r10181  
    4343        TDCoordinate peekWaypoint();
    4444
     45        virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator);
    4546
    46         private:
     47
     48        protected:
     49       
     50        WeakPtr<TowerDefense> getGame();
     51        WeakPtr<TowerDefense> game;
    4752        TowerDefense* td;
    4853        bool once_;
  • code/branches/presentationHS14/src/modules/towerdefense/TowerDefenseHUDController.cc

    r9667 r10181  
    3232#include "util/Convert.h"
    3333
    34 
    3534namespace orxonox
    3635{
     
    4039    {
    4140        RegisterObject(TowerDefenseHUDController);
     41        this->td = 0;
    4242    }
    4343
     
    5050    {
    5151        SUPER(TowerDefenseHUDController, tick, dt);
     52        const std::string& lifes = multi_cast<std::string>(this->td->getLifes());
     53        const std::string& credits = multi_cast<std::string>(this->td->getCredit());
     54        const std::string& wave = multi_cast<std::string>(this->td->getWaveNumber());
     55
     56        if(showlives == true)
     57          this->setCaption(multi_cast<std::string>(lifes));
     58        else if(showcredits == true)
     59          this->setCaption(multi_cast<std::string>(credits));
     60        else if(showwaves == true)
     61          this->setCaption(multi_cast<std::string>(wave));
     62
     63
    5264    }
    5365
     
    5567    {
    5668        SUPER(TowerDefenseHUDController, XMLPort, xmlelement, mode);
     69
     70        XMLPortParam(TowerDefenseHUDController, "showlives", setShowlives, getShowlives, xmlelement, mode);
     71        XMLPortParam(TowerDefenseHUDController, "showcredits", setShowcredits, getShowcredits, xmlelement, mode);
     72        XMLPortParam(TowerDefenseHUDController, "showwaves", setShowwaves, getShowwaves, xmlelement, mode);
     73
    5774    }
    5875
    5976    void TowerDefenseHUDController::changedOwner()
    60     {
    61         SUPER(TowerDefenseHUDController, changedOwner);
    62         /*
    63         if (this->getOwner() != NULL && this->getOwner()->getGametype())
    64             this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype().get());
    65         else
    66             this->owner_ = 0;
    67         */
    68     }
     77        {
     78            SUPER(TowerDefenseHUDController, changedOwner);
    6979
    70 }
     80            if (this->getOwner() && this->getOwner()->getGametype())
     81                    {
     82                        this->td = orxonox_cast<TowerDefense*>(this->getOwner()->getGametype().get());
     83                    }
     84                    else
     85                    {
     86                        this->td = 0;
     87                    }
     88                }
     89        }
     90
  • code/branches/presentationHS14/src/modules/towerdefense/TowerDefenseHUDController.h

    r9667 r10181  
    3939
    4040#include "towerdefense/TowerDefensePrereqs.h"
    41 
     41#include "TowerDefensePlayerStats.h"
    4242#include "tools/interfaces/Tickable.h"
    4343#include "overlays/OverlayText.h"
    44 
     44#include "TowerDefense.h"
    4545
    4646namespace orxonox
     
    5252        virtual ~TowerDefenseHUDController();
    5353
     54
    5455        virtual void tick(float dt);
    5556        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5657        virtual void changedOwner();
     58        void setShowlives(bool temp)
     59            { this->showlives = temp; }
     60        unsigned int getShowlives(void) const
     61            { return this->showlives; }
     62
     63        void setShowcredits(bool temp)
     64            { this->showcredits = temp; }
     65        unsigned int getShowcredits(void) const
     66            { return this->showcredits; }
     67
     68        void setShowwaves(bool temp)
     69            { this->showwaves = temp; }
     70        unsigned int getShowwaves(void) const
     71            { return this->showwaves; }
     72
     73    private:
     74        TowerDefense* td;
     75        bool showcredits;
     76        bool showlives;
     77        bool showwaves;
    5778    };
    5879}
  • code/branches/presentationHS14/src/modules/towerdefense/TowerDefensePlayerStats.cc

    r9272 r10181  
    2525 *      ...
    2626 */
    27 
     27/*
    2828#include "TowerDefensePlayerStats.h"
    2929
     
    3131{
    3232    const int kDefaultCredit = 200;
    33 
     33    const int kDefaultLifes=20;
    3434    TowerDefensePlayerStats::TowerDefensePlayerStats()
    3535    {
    3636        this->credit_ = kDefaultCredit;
    3737        this->waveNumber_ = 0;
     38        this->lifes_=kDefaultLifes;
    3839    }
    39     /*
     40
    4041    TowerDefensePlayerStats::~TowerDefensePlayerStats()
    4142    {
    4243    }
    43     */
     44
    4445}
     46*/
  • code/branches/presentationHS14/src/modules/towerdefense/TowerDefensePlayerStats.h

    r9272 r10181  
    2727 */
    2828
    29  /**
     29 /*
    3030    @brief
    3131        This manages the stats of the player. It is used by 'TowerDefense', the gametype
    3232
    3333    @ingroup TowerDefense
    34  */
     34
    3535
    3636
     
    4444    typedef enum _TowerCosts {
    4545        // Set to 0 for debug...
    46         TDDefaultTowerCost = 0
     46        TDDefaultTowerCost = 20 ,
     47        TDDefaultUpgradeCost = 15
    4748    } TowerCost;
    4849
     
    6768            { waveNumber_++; }
    6869
     70        inline int getLifes()
     71                {return lifes_; }
     72
     73        inline void reduceLifes(int NumberofLifes)
     74        {lifes_-=NumberofLifes; }
     75
     76        inline void upgradeTower(int upgradecost)
     77                { credit_ -= upgradecost;}
     78
     79
     80
    6981    private:
    7082        int credit_;
    7183        int waveNumber_;
     84        int upgradecost;
     85        int lifes_;
    7286        //int baseHealth_;
    7387    };
    7488}
    7589
    76 #endif /* _TowerDefensePlayerStats_H__ */
     90#endif _TowerDefensePlayerStats_H__ */
  • code/branches/presentationHS14/src/modules/towerdefense/TowerDefensePrereqs.h

    r9272 r10181  
    6666{
    6767    class TowerDefense;
    68     class Tower;
     68
     69    class TowerDefenseTower;
     70
    6971    class TowerDefenseCenterpoint;
    7072    class TowerDefenseHUDController;
    7173    class TowerDefensePlayerStats;
     74    class TowerDefenseEnemy;
     75    class TDCoordinate;
     76    class TowerTurret;
     77    class TowerDefenseTower;
    7278}
    7379
  • code/branches/presentationHS14/src/orxonox/controllers/ArtificialController.cc

    r9667 r10181  
    9494        static const float hardcoded_projectile_speed = 1250;
    9595
    96         this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(), hardcoded_projectile_speed, this->target_->getPosition(), this->target_->getVelocity());
     96        this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getWorldPosition(), hardcoded_projectile_speed, this->target_->getWorldPosition(), this->target_->getVelocity());
    9797        this->bHasTargetPosition_ = (this->targetPosition_ != Vector3::ZERO);
    9898
  • code/branches/presentationHS14/src/orxonox/worldentities/WorldEntity.cc

    r9667 r10181  
    414414            else if (this->isDynamic())
    415415            {
    416                 orxout(internal_warning) << "Cannot attach a dynamic object to a WorldEntity." << endl;
    417                 return false;
     416                //***HACKY HACK (to allow turrets to be attached)***
     417                //orxout(internal_warning) << "Cannot attach a dynamic object to a WorldEntity." << endl;
     418                //return false;
    418419            }
    419420            else if (this->isKinematic() && newParent->isDynamic())
Note: See TracChangeset for help on using the changeset viewer.