Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 3, 2012, 6:05:24 PM (12 years ago)
Author:
landauf
Message:

replaced tabs with spaces (no code changed)

Location:
code/branches/presentation2012merge/src
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2012merge/src/modules/gametypes/SpaceRaceManager.cc

    r9271 r9272  
    149149            }
    150150            else
    151                         {
     151            {
    152152                // adjust the radarvisibility
    153153                gametype->newCheckpointReached(newCheckpoint, player);
  • code/branches/presentation2012merge/src/modules/pickup/items/DamageBoostPickup.cc

    r9271 r9272  
    7070    void DamageBoostPickup::initialize(void)
    7171    {
    72         this->duration_ = 0.0f;
    73         this->damageMultiplier_ = 1.0f; //The default damage multiplier.
     72        this->duration_ = 0.0f;
     73        this->damageMultiplier_ = 1.0f; //The default damage multiplier.
    7474        //Defines who is allowed to pick up the pickup.
    7575        this->addTarget(ClassIdentifier<SpaceShip>::getIdentifier());
     
    130130        SpaceShip* ship = this->carrierToSpaceShipHelper();
    131131        if(ship == NULL) // If the PickupCarrier is no SpaceShip, then this pickup is useless and therefore is destroyed.
    132                 this->Pickupable::destroy();
     132            this->Pickupable::destroy();
    133133
    134134
  • code/branches/presentation2012merge/src/modules/pickup/items/DamageBoostPickup.h

    r9271 r9272  
    5757            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
    5858
    59             /**
     59            /**
    6060            @brief Get the time the DamagePickup lasts.
    6161            @return Returns the time in seconds the DamagePickup lasts.
     
    9595
    9696            Timer durationTimer_; //!< Timer.
    97             float duration_; //! Duration of damage boost.
     97            float duration_; //! Duration of damage boost.
    9898
    9999    };
  • code/branches/presentation2012merge/src/modules/towerdefense/CMakeLists.txt

    r9271 r9272  
    55  TowerDefenseHUDController.cc
    66  TowerDefensePlayerStats.cc
    7  
     7
    88)
    99
     
    1313  LINK_LIBRARIES
    1414    orxonox
    15         overlays
     15    overlays
    1616  SOURCE_FILES ${TOWERDEFENSE_SRC_FILES}
    1717)
  • code/branches/presentation2012merge/src/modules/towerdefense/TDEnemy.h

    r9271 r9272  
    1313
    1414private:
    15         float health;
    16         float speed;
    17         float armour;
     15    float health;
     16    float speed;
     17    float armour;
    1818
    1919
  • code/branches/presentation2012merge/src/modules/towerdefense/Tower.cc

    r9271 r9272  
    1717{
    1818    CreateFactory(Tower);
    19        
     19
    2020    /**
    21         @brief
    22         Constructor. Registers and initializes the object.
    23         */
     21    @brief
     22        Constructor. Registers and initializes the object.
     23    */
    2424    Tower::Tower(BaseObject* creator) : Pawn(creator)
    2525    {
     
    3434        this->delay_ = false;
    3535        this->delayTimer_.setTimer(0.2f, false, createExecutor(createFunctor(&TetrisStone::enableMovement, this)));
    36                 */
     36        */
    3737    }
    38        
    39         void Tower::setOrientation(const Quaternion& orientation)
    40         {
    41                 static int ori;
    42                 orxout() << "orientation " << ++ori << endl;
    43         }
    44        
    45         void Tower::rotateYaw(const Vector2& value)
    46         {
    47                 static int yaw;
    48                 orxout() << "rotateYaw " << ++yaw << endl;
    49         }
    50        
    51         void Tower::rotatePitch(const Vector2& value)
    52         {
    53                 static int pitch;
    54                 orxout() << "rotatePitch " << ++pitch << endl;
    55         }
    56        
    57         void Tower::rotateRoll(const Vector2& value)
    58         {
    59                 static int roll;
    60                 orxout() << "rotateRoll" << ++roll << endl;
    61         }
    62                
    63         // This function is called whenever a player presses the up or the down key.
     38
     39    void Tower::setOrientation(const Quaternion& orientation)
     40    {
     41        static int ori;
     42        orxout() << "orientation " << ++ori << endl;
     43    }
     44
     45    void Tower::rotateYaw(const Vector2& value)
     46    {
     47        static int yaw;
     48        orxout() << "rotateYaw " << ++yaw << endl;
     49    }
     50
     51    void Tower::rotatePitch(const Vector2& value)
     52    {
     53        static int pitch;
     54        orxout() << "rotatePitch " << ++pitch << endl;
     55    }
     56
     57    void Tower::rotateRoll(const Vector2& value)
     58    {
     59        static int roll;
     60        orxout() << "rotateRoll" << ++roll << endl;
     61    }
     62
     63    // This function is called whenever a player presses the up or the down key.
    6464    // You have to implement what happens when the up or the down key is pressed.
    6565    // value.x < 0 means: down key is pressed.
     
    7575
    7676    /**
    77         @brief
    78         Overloaded the function to rotate the stone.
    79         @param value
    80         A vector whose first component is the angle by which to rotate.
    81         */
    82                 /*
     77    @brief
     78        Overloaded the function to rotate the stone.
     79    @param value
     80        A vector whose first component is the angle by which to rotate.
     81    */
     82    /*
    8383    void Tower::moveFrontBack(const Vector2& value)
    8484    {
    8585        //orxout() << "frontBack.x: " << value.x << endl;
    8686    }
    87         */
    88        
     87    */
     88
    8989    /**
    90         @brief
    91         Overloaded the function to steer the stone right and left
    92         @param value
    93         A vector whose first component is the direction in which we want to steer the stone.
    94         */
    95                 /*
     90    @brief
     91        Overloaded the function to steer the stone right and left
     92    @param value
     93        A vector whose first component is the direction in which we want to steer the stone.
     94    */
     95    /*
    9696    void Tower::moveRightLeft(const Vector2& value)
    9797    {
    98                 //orxout() << "rightLeft.x: " << value.x << endl;
    99                
     98        //orxout() << "rightLeft.x: " << value.x << endl;
     99
    100100        if(!this->delay_)
    101101        {
     
    104104            if(!this->tetris_->isValidMove(this, newPos))
    105105                return;
    106                        
     106
    107107            this->setPosition(newPos);
    108108            this->delay_ = true;
    109109            this->delayTimer_.startTimer();
    110                 }
     110        }
    111111    }
    112         */
     112    */
    113113}
  • code/branches/presentation2012merge/src/modules/towerdefense/Tower.h

    r9271 r9272  
    1010@brief
    1111See TowerDefenseReadme.txt for Information.
    12    
     12
    1313@ingroup TowerDefense
    1414*/
     
    2020#include "towerdefense/TowerDefensePrereqs.h"
    2121#include "worldentities/pawns/SpaceShip.h"
    22        
     22
    2323
    2424namespace orxonox
     
    2626    class _TowerDefenseExport Tower : public Pawn
    2727    {
    28         public:
    29                 Tower(BaseObject* creator);
    30                 virtual ~Tower() {};
    31                
    32                 // Maybe later override these to move towers with cursor keys
    33                 /*
    34                 virtual void moveFrontBack(const Vector2& value);
    35                 virtual void moveRightLeft(const Vector2& value);
    36                 */
    37                
    38                 // Overriding these to stop towers from spasing out
    39                 void setOrientation(const Quaternion& orientation);
     28    public:
     29        Tower(BaseObject* creator);
     30        virtual ~Tower() {};
     31
     32        // Maybe later override these to move towers with cursor keys
     33        /*
     34        virtual void moveFrontBack(const Vector2& value);
     35        virtual void moveRightLeft(const Vector2& value);
     36        */
     37
     38        // Overriding these to stop towers from spasing out
     39        void setOrientation(const Quaternion& orientation);
    4040        virtual void rotateYaw(const Vector2& value);
    4141        virtual void rotatePitch(const Vector2& value);
    4242        virtual void rotateRoll(const Vector2& value);
    43                
    44                 void setGame(TowerDefense* towerdefense)
    45                 { assert(towerdefense); game_ = towerdefense; }
    46         private:
    47                 TowerDefense* game_;
     43
     44        void setGame(TowerDefense* towerdefense)
     45        { assert(towerdefense); game_ = towerdefense; }
     46    private:
     47        TowerDefense* game_;
    4848    };
    4949}
  • code/branches/presentation2012merge/src/modules/towerdefense/TowerDefense.cc

    r9271 r9272  
    8282#include "worldentities/pawns/SpaceShip.h"
    8383#include "controllers/WaypointController.h"
    84          
     84
    8585#include "graphics/Model.h"
    8686#include "infos/PlayerInfo.h"
    87          
     87
    8888#include "chat/ChatManager.h"
    8989
     
    9494{
    9595    CreateUnloadableFactory(TowerDefense);
    96        
    97         TowerDefense::TowerDefense(BaseObject* creator) : Deathmatch(creator)
     96
     97    TowerDefense::TowerDefense(BaseObject* creator) : Deathmatch(creator)
    9898    {
    9999        RegisterObject(TowerDefense);
    100                
     100
    101101        this->setHUDTemplate("TowerDefenseHUD");
    102102
    103                 this->stats_ = new TowerDefensePlayerStats();
    104 
    105                 /* Temporary hack to allow the player to add towers */
    106                 this->dedicatedAddTower_ = createConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) );
    107     }
    108        
     103        this->stats_ = new TowerDefensePlayerStats();
     104
     105        /* Temporary hack to allow the player to add towers */
     106        this->dedicatedAddTower_ = createConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) );
     107    }
     108
    109109    TowerDefense::~TowerDefense()
    110110    {
    111                 /* Part of a temporary hack to allow the player to add towers */
     111        /* Part of a temporary hack to allow the player to add towers */
    112112        if (this->isInitialized())
    113113        {
     
    116116        }
    117117    }
    118        
    119         void TowerDefense::setCenterpoint(TowerDefenseCenterpoint *centerpoint)
    120         {
    121                 orxout() << "Centerpoint now setting..." << endl;
    122                 this->center_ = centerpoint;
    123                 orxout() << "Centerpoint now set..." << endl;
    124         }
    125        
     118
     119    void TowerDefense::setCenterpoint(TowerDefenseCenterpoint *centerpoint)
     120    {
     121        orxout() << "Centerpoint now setting..." << endl;
     122        this->center_ = centerpoint;
     123        orxout() << "Centerpoint now set..." << endl;
     124    }
     125
    126126    void TowerDefense::start()
    127127    {
    128128        Deathmatch::start();
    129                
    130                 const int kInitialTowerCount = 3;
    131                 Coordinate initialTowerCoordinates[kInitialTowerCount] = {{3,2}, {8,5}, {12,10}};
    132                
    133                 for (int i = 0; i < kInitialTowerCount; i++)
    134                 {
    135                         Coordinate coordinate = initialTowerCoordinates[i];
    136                         addTower(coordinate.x, coordinate.y);
    137                 }
    138                
    139                 ChatManager::message("Use the console command addTower x y to add towers");
    140 
    141                 //TODO: let the player control his controllable entity && TODO: create a new ControllableEntity for the player
    142         }
    143        
    144         void TowerDefense::end()
    145         {
    146                 Deathmatch::end();
    147          
    148                 ChatManager::message("Match is over");
    149         }
    150        
    151         void TowerDefense::addTower(int x, int y)
    152         {
    153                 const TowerCost towerCost = TDDefaultTowerCost;
    154                
    155                 if (!this->hasEnoughCreditForTower(towerCost))
    156                 {
    157                         orxout() << "not enough credit: " << (this->stats_->getCredit()) << " available, " << TDDefaultTowerCost << " needed.";
    158                         return;
    159                 }
    160                
    161                 if (this->towerExists(x,y))
    162                 {
    163                         orxout() << "tower exists!!" << endl;
    164                         return;
    165                 }               
    166                
    167                 /*
    168                 unsigned int width = this->center_->getWidth();
    169                 unsigned int height = this->center_->getHeight();
    170                 */
    171                
    172                 int tileScale = (int) this->center_->getTileScale();
    173                        
    174                 if (x > 15 || y > 15 || x < 0 || y < 0)
    175                 {
    176                         //Hard coded: TODO: let this depend on the centerpoint's height, width and fieldsize (fieldsize doesn't exist yet)
    177                         orxout() << "Can not add Tower: x and y should be between 0 and 15" << endl;
    178                         return;
    179                 }
    180                
    181                 orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl;
    182                
    183                 // Add tower to coordinatesStack
    184                 Coordinate newTowerCoordinates = {x, y};
    185                 addedTowersCoordinates_.push_back(newTowerCoordinates);
    186                
    187                 // Reduce credit
    188                 this->stats_->buyTower(towerCost);
    189                
    190                 // Create tower
    191                 Tower* newTower = new Tower(this->center_);
    192                 newTower->addTemplate(this->center_->getTowerTemplate());
    193 
    194                 newTower->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 75);
    195                 newTower->setGame(this);
    196         }
    197        
    198         bool TowerDefense::hasEnoughCreditForTower(TowerCost towerCost)
    199         {
    200                 return ((this->stats_->getCredit()) >= towerCost);
    201         }
    202        
    203         bool TowerDefense::towerExists(int x, int y)
    204         {
    205                 for(std::vector<Coordinate>::iterator it = addedTowersCoordinates_.begin(); it != addedTowersCoordinates_.end(); ++it)
    206                 {
    207                         Coordinate currentCoordinates = (Coordinate) (*it);
    208                         if (currentCoordinates.x == x && currentCoordinates.y == y)
    209                                 return true;
    210                 }
    211                
    212                 return false;
    213         }
    214        
    215        
    216         void TowerDefense::tick(float dt)
     129
     130        const int kInitialTowerCount = 3;
     131        Coordinate initialTowerCoordinates[kInitialTowerCount] = {{3,2}, {8,5}, {12,10}};
     132
     133        for (int i = 0; i < kInitialTowerCount; i++)
     134        {
     135            Coordinate coordinate = initialTowerCoordinates[i];
     136            addTower(coordinate.x, coordinate.y);
     137        }
     138
     139        ChatManager::message("Use the console command addTower x y to add towers");
     140
     141        //TODO: let the player control his controllable entity && TODO: create a new ControllableEntity for the player
     142    }
     143
     144    void TowerDefense::end()
     145    {
     146        Deathmatch::end();
     147
     148        ChatManager::message("Match is over");
     149    }
     150
     151    void TowerDefense::addTower(int x, int y)
     152    {
     153        const TowerCost towerCost = TDDefaultTowerCost;
     154
     155        if (!this->hasEnoughCreditForTower(towerCost))
     156        {
     157            orxout() << "not enough credit: " << (this->stats_->getCredit()) << " available, " << TDDefaultTowerCost << " needed.";
     158            return;
     159        }
     160
     161        if (this->towerExists(x,y))
     162        {
     163            orxout() << "tower exists!!" << endl;
     164            return;
     165        }
     166
     167        /*
     168        unsigned int width = this->center_->getWidth();
     169        unsigned int height = this->center_->getHeight();
     170        */
     171
     172        int tileScale = (int) this->center_->getTileScale();
     173
     174        if (x > 15 || y > 15 || x < 0 || y < 0)
     175        {
     176            //Hard coded: TODO: let this depend on the centerpoint's height, width and fieldsize (fieldsize doesn't exist yet)
     177            orxout() << "Can not add Tower: x and y should be between 0 and 15" << endl;
     178            return;
     179        }
     180
     181        orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl;
     182
     183        // Add tower to coordinatesStack
     184        Coordinate newTowerCoordinates = {x, y};
     185        addedTowersCoordinates_.push_back(newTowerCoordinates);
     186
     187        // Reduce credit
     188        this->stats_->buyTower(towerCost);
     189
     190        // Create tower
     191        Tower* newTower = new Tower(this->center_);
     192        newTower->addTemplate(this->center_->getTowerTemplate());
     193
     194        newTower->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 75);
     195        newTower->setGame(this);
     196    }
     197
     198    bool TowerDefense::hasEnoughCreditForTower(TowerCost towerCost)
     199    {
     200        return ((this->stats_->getCredit()) >= towerCost);
     201    }
     202
     203    bool TowerDefense::towerExists(int x, int y)
     204    {
     205        for(std::vector<Coordinate>::iterator it = addedTowersCoordinates_.begin(); it != addedTowersCoordinates_.end(); ++it)
     206        {
     207            Coordinate currentCoordinates = (Coordinate) (*it);
     208            if (currentCoordinates.x == x && currentCoordinates.y == y)
     209                return true;
     210        }
     211
     212        return false;
     213    }
     214
     215
     216    void TowerDefense::tick(float dt)
    217217    {
    218218        SUPER(TowerDefense, tick, dt);
    219219    }
    220        
    221         // Function to test if we can add waypoints using code only. Doesn't work yet
    222        
    223         // THE PROBLEM: WaypointController's getControllableEntity() returns null, so it won't track. How do we get the controlableEntity to NOT BE NULL???
    224         /*
    225         void TowerDefense::addWaypointsAndFirstEnemy()
    226         {
    227                 SpaceShip *newShip = new SpaceShip(this->center_);
    228                 newShip->addTemplate("spaceshipassff");
    229                
    230                 WaypointController *newController = new WaypointController(newShip);
    231                 newController->setAccuracy(3);
    232                
    233                 Model *wayPoint1 = new Model(newController);
    234                 wayPoint1->setMeshSource("crate.mesh");
    235                 wayPoint1->setPosition(7,-7,5);
    236                 wayPoint1->setScale(0.2);
    237                        
    238                 Model *wayPoint2 = new Model(newController);
    239                 wayPoint2->setMeshSource("crate.mesh");
    240                 wayPoint2->setPosition(7,7,5);
    241                 wayPoint2->setScale(0.2);
    242                        
    243                 newController->addWaypoint(wayPoint1);
    244                 newController->addWaypoint(wayPoint2);
    245                        
    246                 // The following line causes the game to crash
    247 
    248                 newShip->setController(newController);
    249 //              newController -> getPlayer() -> startControl(newShip);
    250                 newShip->setPosition(-7,-7,5);
    251                 newShip->setScale(0.1);
    252                 //newShip->addSpeed(1);
    253                
    254                
    255                
    256 //              this->center_->attach(newShip);
    257         }
    258         */
    259         /*
    260          void TowerDefense::playerEntered(PlayerInfo* player)
    261          {
    262          Deathmatch::playerEntered(player);
    263          
    264          const std::string& message = player->getName() + " entered the game";
    265          ChatManager::message(message);
    266          }
    267          
    268          bool TowerDefense::playerLeft(PlayerInfo* player)
    269          {
    270          bool valid_player = Deathmatch::playerLeft(player);
    271          
    272          if (valid_player)
    273          {
    274          const std::string& message = player->getName() + " left the game";
    275          ChatManager::message(message);
    276          }
    277          
    278          return valid_player;
    279          }
    280          
    281          
    282          void TowerDefense::pawnKilled(Pawn* victim, Pawn* killer)
    283          {
    284          if (victim && victim->getPlayer())
    285          {
    286          std::string message;
    287          if (killer)
    288          {
    289          if (killer->getPlayer())
    290          message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
    291          else
    292          message = victim->getPlayer()->getName() + " was killed";
    293          }
    294          else
    295          message = victim->getPlayer()->getName() + " died";
    296          
    297          ChatManager::message(message);
    298          }
    299          
    300          Deathmatch::pawnKilled(victim, killer);
    301          }
    302          
    303          void TowerDefense::playerScored(PlayerInfo* player)
    304          {
    305          Gametype::playerScored(player);
    306          
    307          }*/
     220
     221    // Function to test if we can add waypoints using code only. Doesn't work yet
     222
     223    // THE PROBLEM: WaypointController's getControllableEntity() returns null, so it won't track. How do we get the controlableEntity to NOT BE NULL???
     224    /*
     225    void TowerDefense::addWaypointsAndFirstEnemy()
     226    {
     227        SpaceShip *newShip = new SpaceShip(this->center_);
     228        newShip->addTemplate("spaceshipassff");
     229
     230        WaypointController *newController = new WaypointController(newShip);
     231        newController->setAccuracy(3);
     232
     233        Model *wayPoint1 = new Model(newController);
     234        wayPoint1->setMeshSource("crate.mesh");
     235        wayPoint1->setPosition(7,-7,5);
     236        wayPoint1->setScale(0.2);
     237
     238        Model *wayPoint2 = new Model(newController);
     239        wayPoint2->setMeshSource("crate.mesh");
     240        wayPoint2->setPosition(7,7,5);
     241        wayPoint2->setScale(0.2);
     242
     243        newController->addWaypoint(wayPoint1);
     244        newController->addWaypoint(wayPoint2);
     245
     246        // The following line causes the game to crash
     247
     248        newShip->setController(newController);
     249//        newController -> getPlayer() -> startControl(newShip);
     250        newShip->setPosition(-7,-7,5);
     251        newShip->setScale(0.1);
     252        //newShip->addSpeed(1);
     253
     254
     255
     256//      this->center_->attach(newShip);
     257    }
     258    */
     259    /*
     260    void TowerDefense::playerEntered(PlayerInfo* player)
     261    {
     262        Deathmatch::playerEntered(player);
     263
     264        const std::string& message = player->getName() + " entered the game";
     265        ChatManager::message(message);
     266    }
     267
     268    bool TowerDefense::playerLeft(PlayerInfo* player)
     269    {
     270        bool valid_player = Deathmatch::playerLeft(player);
     271
     272        if (valid_player)
     273        {
     274            const std::string& message = player->getName() + " left the game";
     275            ChatManager::message(message);
     276        }
     277
     278        return valid_player;
     279    }
     280
     281
     282    void TowerDefense::pawnKilled(Pawn* victim, Pawn* killer)
     283    {
     284        if (victim && victim->getPlayer())
     285        {
     286            std::string message;
     287            if (killer)
     288            {
     289                if (killer->getPlayer())
     290                    message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
     291                else
     292                    message = victim->getPlayer()->getName() + " was killed";
     293            }
     294            else
     295                message = victim->getPlayer()->getName() + " died";
     296
     297            ChatManager::message(message);
     298        }
     299
     300        Deathmatch::pawnKilled(victim, killer);
     301    }
     302
     303    void TowerDefense::playerScored(PlayerInfo* player)
     304    {
     305        Gametype::playerScored(player);
     306    }*/
    308307}
  • code/branches/presentation2012merge/src/modules/towerdefense/TowerDefense.h

    r9271 r9272  
    2626 *
    2727 */
    28          
     28
    2929 /**
    30         @brief
    31         GameType class for TowerDefense. See TowerDefenseReadme.txt for Information.
    32          
    33         @ingroup TowerDefense
     30    @brief
     31        GameType class for TowerDefense. See TowerDefenseReadme.txt for Information.
     32
     33    @ingroup TowerDefense
    3434 */
    35          
     35
    3636
    3737#ifndef _TowerDefense_H__
     
    4040#include "towerdefense/TowerDefensePrereqs.h"
    4141#include "gametypes/Deathmatch.h"
    42                  
     42
    4343 #include "TowerDefensePlayerStats.h"
    44                  
     44
    4545namespace orxonox
    4646{
    47         class _TowerDefenseExport TowerDefense : public Deathmatch
     47    class _TowerDefenseExport TowerDefense : public Deathmatch
    4848    {
    49         public:
    50                 TowerDefense(BaseObject* creator);
    51                 virtual ~TowerDefense();
    52                
    53                 virtual void start(); //<! The function is called when the gametype starts
    54                 virtual void end();
    55                 virtual void tick(float dt);
    56                 //virtual void playerEntered(PlayerInfo* player);
    57                 //virtual bool playerLeft(PlayerInfo* player);
    58                
    59                 //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
    60                 //virtual void playerScored(PlayerInfo* player);
    61                
    62                
    63                 /*      Called by TowerDefenseCenterpoint upon game start
    64                         The centerpoint is used to create towers
    65                 */
    66                 void setCenterpoint(TowerDefenseCenterpoint *centerpoint);
    67                
    68                 /* Adds a tower at x, y in the playfield */
    69                 void addTower(int x, int y);
    70                
    71                 /* Part of a temporary hack to allow the player to add towers */
    72                 ConsoleCommand* dedicatedAddTower_;
    73                
    74                 //TODO: void spawnNewWave()
    75             //TODO: create a timer which regularly calls the spawnNewWave function  (time driven)
    76                 //      or spawn a new wave when the old wave has been killed           (event driven)
     49    public:
     50        TowerDefense(BaseObject* creator);
     51        virtual ~TowerDefense();
     52
     53        virtual void start(); //<! The function is called when the gametype starts
     54        virtual void end();
     55        virtual void tick(float dt);
     56        //virtual void playerEntered(PlayerInfo* player);
     57        //virtual bool playerLeft(PlayerInfo* player);
     58
     59        //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
     60        //virtual void playerScored(PlayerInfo* player);
    7761
    7862
    79         private:
    80                 TowerDefenseCenterpoint *center_;
    81                
    82                 /* handles stats */
    83                 TowerDefensePlayerStats *stats_;
    84                 bool hasEnoughCreditForTower(TowerCost towerCost);
    85        
    86                 bool towerExists(int x, int y);
    87                
    88                 typedef struct {
    89                         int x;
    90                         int y;
    91                 } Coordinate;
    92                
    93                 std::vector<Coordinate> addedTowersCoordinates_;
    94                 std::vector<Tower*> towers_;
     63        /*  Called by TowerDefenseCenterpoint upon game start
     64            The centerpoint is used to create towers
     65        */
     66        void setCenterpoint(TowerDefenseCenterpoint *centerpoint);
     67
     68        /* Adds a tower at x, y in the playfield */
     69        void addTower(int x, int y);
     70
     71        /* Part of a temporary hack to allow the player to add towers */
     72        ConsoleCommand* dedicatedAddTower_;
     73
     74        //TODO: void spawnNewWave()
     75        //TODO: create a timer which regularly calls the spawnNewWave function  (time driven)
     76        //      or spawn a new wave when the old wave has been killed           (event driven)
     77
     78
     79    private:
     80        TowerDefenseCenterpoint *center_;
     81
     82        /* handles stats */
     83        TowerDefensePlayerStats *stats_;
     84        bool hasEnoughCreditForTower(TowerCost towerCost);
     85
     86        bool towerExists(int x, int y);
     87
     88        typedef struct {
     89            int x;
     90            int y;
     91        } Coordinate;
     92
     93        std::vector<Coordinate> addedTowersCoordinates_;
     94        std::vector<Tower*> towers_;
    9595    };
    9696}
  • code/branches/presentation2012merge/src/modules/towerdefense/TowerDefenseCenterpoint.cc

    r9271 r9272  
    5050    {
    5151        RegisterObject(TowerDefenseCenterpoint);
    52  
    53                 this->width_ = 15;
     52
     53        this->width_ = 15;
    5454        this->height_ = 15;
    5555        this->towerTemplate_ = "";
    56        
     56
    5757        //this->setCollisionType(Static);
    5858
    59                 this->checkGametype();
     59        this->checkGametype();
    6060
    6161    }
     
    7171        XMLPortParam(TowerDefenseCenterpoint, "width", setWidth, getWidth, xmlelement, mode);
    7272        XMLPortParam(TowerDefenseCenterpoint, "height", setHeight, getHeight, xmlelement, mode);
    73                 XMLPortParam(TowerDefenseCenterpoint, "tileScale", setTileScale, getTileScale, xmlelement, mode);
     73        XMLPortParam(TowerDefenseCenterpoint, "tileScale", setTileScale, getTileScale, xmlelement, mode);
    7474        XMLPortParam(TowerDefenseCenterpoint, "towerTemplate", setTowerTemplate, getTowerTemplate, xmlelement, mode);
    75                
     75
    7676        //TODO: add XMLPortObject(TowerDefenseCenterpoint, WorldEntity, "waypoints", addWaypoint, getWaypoint,  xmlelement, mode);
    7777        // This was copied and shightly modified from WaypointController.cc ; there are no getters and setters and no membervariable yet
     
    100100    void TowerDefenseCenterpoint::checkGametype()
    101101    {
    102                 if (this->getGametype() != NULL && this->getGametype()->isA(Class(TowerDefense)))
     102        if (this->getGametype() != NULL && this->getGametype()->isA(Class(TowerDefense)))
    103103        {
    104                         // Sets the centerpoint of the gametype. The gametype uses this to later spawn in towers, he needs the tower template stored in the center point
     104            // Sets the centerpoint of the gametype. The gametype uses this to later spawn in towers, he needs the tower template stored in the center point
    105105            TowerDefense* towerDefenseGametype = orxonox_cast<TowerDefense*>(this->getGametype().get());
    106106            towerDefenseGametype->setCenterpoint(this);
  • code/branches/presentation2012merge/src/modules/towerdefense/TowerDefenseCenterpoint.h

    r9271 r9272  
    5454            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5555            virtual void changedGametype();
    56            
     56
    5757            /**
    5858            @brief The width and hight in number of tiles. Default is 15 for both.
     
    6060            void setWidth(unsigned int width)
    6161                { this->width_ = width; }
    62            
    63                         unsigned int getWidth(void) const
     62
     63            unsigned int getWidth(void) const
    6464                { return this->width_; }
    65                
     65
    6666            void setHeight(unsigned int height)
    6767                { this->height_ = height; }
    68            
    69                         unsigned int getHeight(void) const
     68
     69            unsigned int getHeight(void) const
    7070                { return this->height_; }
    71                        
    72                         /**
    73                         @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)
    74                         */
    75                         void setTileScale(unsigned int tileScale)
    76                                 { this->tileScale_ = tileScale; }
    77                        
    78                         unsigned int getTileScale(void) const
    79                                 { return this->tileScale_; }
    80                
     71
     72            /**
     73                @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)
     74            */
     75            void setTileScale(unsigned int tileScale)
     76                { this->tileScale_ = tileScale; }
     77
     78            unsigned int getTileScale(void) const
     79                { return this->tileScale_; }
     80
    8181            /**
    8282            @brief Set the template for the towers.
     
    8585            void setTowerTemplate(const std::string& templateName)
    8686                { this->towerTemplate_ = templateName; }
    87            
    88                         const std::string& getTowerTemplate(void) const
     87
     88            const std::string& getTowerTemplate(void) const
    8989                { return this->towerTemplate_; }
    9090
    9191        private:
    9292            void checkGametype();
    93            
     93
    9494            unsigned int width_;
    9595            unsigned int height_;
    96                         unsigned int tileScale_;
    97                        
     96            unsigned int tileScale_;
     97
    9898            std::string towerTemplate_;
    9999    };
  • code/branches/presentation2012merge/src/modules/towerdefense/TowerDefenseHUDController.cc

    r9271 r9272  
    2525 *      ...
    2626 */
    27  
     27
    2828#include "TowerDefenseHUDController.h"
    2929
     
    3535namespace orxonox
    3636{
    37         CreateFactory(TowerDefenseHUDController);
    38        
     37    CreateFactory(TowerDefenseHUDController);
     38
    3939    TowerDefenseHUDController::TowerDefenseHUDController(BaseObject* creator) : OverlayText(creator)
    40         {
    41                 RegisterObject(TowerDefenseHUDController);
    42         }
    43        
    44         TowerDefenseHUDController::~TowerDefenseHUDController()
    45         {
    46                
    47         }
     40    {
     41        RegisterObject(TowerDefenseHUDController);
     42    }
     43
     44    TowerDefenseHUDController::~TowerDefenseHUDController()
     45    {
     46
     47    }
    4848
    4949    void TowerDefenseHUDController::tick(float dt)
    50         {
    51                 SUPER(TowerDefenseHUDController, tick, dt);
    52         }
    53        
     50    {
     51        SUPER(TowerDefenseHUDController, tick, dt);
     52    }
     53
    5454    void TowerDefenseHUDController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    55         {
    56                 SUPER(TowerDefenseHUDController, XMLPort, xmlelement, mode);
    57         }
    58        
     55    {
     56        SUPER(TowerDefenseHUDController, XMLPort, xmlelement, mode);
     57    }
     58
    5959    void TowerDefenseHUDController::changedOwner()
    6060    {
    6161        SUPER(TowerDefenseHUDController, changedOwner);
    62                 /*
     62        /*
    6363        if (this->getOwner() != NULL && this->getOwner()->getGametype())
    6464            this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype().get());
    6565        else
    6666            this->owner_ = 0;
    67                         */
     67        */
    6868    }
    69        
     69
    7070}
  • code/branches/presentation2012merge/src/modules/towerdefense/TowerDefenseHUDController.h

    r9271 r9272  
    2626 *
    2727 */
    28          
     28
    2929 /**
    30         @brief
    31         This subclass of OverlayText is used to display the stats of the player in the HUD
    32          
    33         @ingroup TowerDefense
     30    @brief
     31        This subclass of OverlayText is used to display the stats of the player in the HUD
     32
     33    @ingroup TowerDefense
    3434 */
    35          
     35
    3636
    3737#ifndef _TowerDefenseHUDController_H__
     
    4848    class _TowerDefenseExport TowerDefenseHUDController : public OverlayText, public Tickable
    4949    {
    50         public:
    51                 TowerDefenseHUDController(BaseObject* creator);
     50    public:
     51        TowerDefenseHUDController(BaseObject* creator);
    5252        virtual ~TowerDefenseHUDController();
    5353
    5454        virtual void tick(float dt);
    5555        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    56                 virtual void changedOwner();
     56        virtual void changedOwner();
    5757    };
    5858}
  • code/branches/presentation2012merge/src/modules/towerdefense/TowerDefensePlayerStats.cc

    r9271 r9272  
    2525 *      ...
    2626 */
    27  
     27
    2828#include "TowerDefensePlayerStats.h"
    2929
    3030namespace orxonox
    3131{
    32         const int kDefaultCredit = 200;
    33        
     32    const int kDefaultCredit = 200;
     33
    3434    TowerDefensePlayerStats::TowerDefensePlayerStats()
    35         {
    36                 this->credit_ = kDefaultCredit;
    37                 this->waveNumber_ = 0;
    38         }
    39         /*
    40         TowerDefensePlayerStats::~TowerDefensePlayerStats()
    41         {
    42         }
    43         */             
     35    {
     36        this->credit_ = kDefaultCredit;
     37        this->waveNumber_ = 0;
     38    }
     39    /*
     40    TowerDefensePlayerStats::~TowerDefensePlayerStats()
     41    {
     42    }
     43    */
    4444}
  • code/branches/presentation2012merge/src/modules/towerdefense/TowerDefensePlayerStats.h

    r9271 r9272  
    2626 *
    2727 */
    28          
     28
    2929 /**
    30         @brief
    31         This manages the stats of the player. It is used by 'TowerDefense', the gametype
    32        
    33         @ingroup TowerDefense
     30    @brief
     31        This manages the stats of the player. It is used by 'TowerDefense', the gametype
     32
     33    @ingroup TowerDefense
    3434 */
    35          
     35
    3636
    3737#ifndef _TowerDefensePlayerStats_H__
     
    4242namespace orxonox
    4343{
    44         typedef enum _TowerCosts {
    45                 // Set to 0 for debug...
    46                 TDDefaultTowerCost = 0
    47         } TowerCost;
    48        
     44    typedef enum _TowerCosts {
     45        // Set to 0 for debug...
     46        TDDefaultTowerCost = 0
     47    } TowerCost;
     48
    4949    class _TowerDefenseExport TowerDefensePlayerStats
    5050    {
    51         public:
    52                 TowerDefensePlayerStats();
    53                
    54                 inline int getCredit()
    55                         { return credit_; }
    56                
    57                 inline void setCredit(int credit)
    58                         { credit_ = credit; }
    59                
    60                 inline void buyTower(TowerCost cost)
    61                         { credit_ -= cost;}
    62                
    63                 inline int getWaveNumber()
    64                         { return waveNumber_; }
    65                
    66                 inline void didLoadNextWave()
    67                         { waveNumber_++; }
    68                
    69         private:
    70                 int credit_;
    71                 int waveNumber_;
    72                 //int baseHealth_;
     51    public:
     52        TowerDefensePlayerStats();
     53
     54        inline int getCredit()
     55            { return credit_; }
     56
     57        inline void setCredit(int credit)
     58            { credit_ = credit; }
     59
     60        inline void buyTower(TowerCost cost)
     61            { credit_ -= cost;}
     62
     63        inline int getWaveNumber()
     64            { return waveNumber_; }
     65
     66        inline void didLoadNextWave()
     67            { waveNumber_++; }
     68
     69    private:
     70        int credit_;
     71        int waveNumber_;
     72        //int baseHealth_;
    7373    };
    7474}
  • code/branches/presentation2012merge/src/modules/towerdefense/TowerDefensePrereqs.h

    r9271 r9272  
    6666{
    6767    class TowerDefense;
    68         class Tower;
     68    class Tower;
    6969    class TowerDefenseCenterpoint;
    70         class TowerDefenseHUDController;
    71         class TowerDefensePlayerStats;
     70    class TowerDefenseHUDController;
     71    class TowerDefensePlayerStats;
    7272}
    7373
  • code/branches/presentation2012merge/src/orxonox/LevelInfo.h

    r9269 r9272  
    2424 *   Co-authors:
    2525 *      ...
    26  *   
     26 *
    2727 */
    2828
     
    7979            */
    8080            inline const std::string& getName(void) const { return this->name_; } // tolua_export
    81        
     81
    8282            /**
    8383            @brief Set the screenshot of the Level.
     
    117117            */
    118118            inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export
    119  
     119
    120120            void setShips(const std::string& ships); //!< Set the starting ship models of the level
    121121            bool addShip(const std::string& ship, bool update = true); //!< Add a model to shipselection
     
    125125            */
    126126            inline const std::string& getShips(void) const
    127                 { return this->startingShipsString_; }   
     127                { return this->startingShipsString_; }
    128128            /**
    129129            @brief Get whether the Level allows a specific starting ship model
     
    131131            @return Returns true if the Level allows the input ship model
    132132            */
    133             inline bool hasShip(const std::string& ship) const { return this->ships_.find(ship) != this->ships_.end(); } // tolua_export       
     133            inline bool hasShip(const std::string& ship) const { return this->ships_.find(ship) != this->ships_.end(); } // tolua_export
    134134            /**
    135135            @brief Get the XML-filename of the Level.
     
    138138
    139139            inline const std::string& getXMLFilename(void) const { return this->xmlfilename_; } // tolua_export
    140             inline void selectShip (const std::string& ship) { this->changeShip(ship); } // tolua_export
     140            inline void selectShip (const std::string& ship) { this->changeShip(ship); } // tolua_export
    141141
    142142
     
    153153        private:
    154154
    155             inline void changeShip (const std::string& model) {
    156                 static std::string shipSelectionTag = "shipselection";
    157                 //HACK: Read Level XML File, find "shipselection", replace with ship model
    158                 std::string levelPath = "../levels/";
    159                 levelPath.append(this->getXMLFilename());
    160                 std::string tempPath = "../levels/";
    161                 tempPath.append("_temp.oxw");
    162                 orxout(user_status) << levelPath << endl;
    163                 orxout(user_status) << tempPath << endl;
    164                 std::ifstream myLevel (levelPath.c_str());
    165                         std::ofstream tempLevel (tempPath.c_str());
    166                         while(!myLevel.eof())
    167                         {
    168                                 std::string buff;
    169                                 std::getline(myLevel, buff);
    170                                 std::string pawndesignString = "pawndesign=";
    171                                 size_t found = buff.find(pawndesignString.append(shipSelectionTag));
    172                                 if (found!= std::string::npos)
    173                                         buff = buff.substr(0, found + 11) + model + buff.substr(found+11+shipSelectionTag.length(), std::string::npos);
    174                                 tempLevel.write(buff.c_str(), buff.length());
    175                                 tempLevel << std::endl;
    176                         }
    177                         myLevel.close();
    178                         tempLevel.close();
    179                         orxout(user_status) << "done" << endl;
    180             }
     155            inline void changeShip (const std::string& model) {
     156                static std::string shipSelectionTag = "shipselection";
     157                //HACK: Read Level XML File, find "shipselection", replace with ship model
     158                std::string levelPath = "../levels/";
     159                levelPath.append(this->getXMLFilename());
     160                std::string tempPath = "../levels/";
     161                tempPath.append("_temp.oxw");
     162                orxout(user_status) << levelPath << endl;
     163                orxout(user_status) << tempPath << endl;
     164                std::ifstream myLevel (levelPath.c_str());
     165                std::ofstream tempLevel (tempPath.c_str());
     166                while(!myLevel.eof())
     167                {
     168                    std::string buff;
     169                    std::getline(myLevel, buff);
     170                    std::string pawndesignString = "pawndesign=";
     171                    size_t found = buff.find(pawndesignString.append(shipSelectionTag));
     172                    if (found!= std::string::npos)
     173                        buff = buff.substr(0, found + 11) + model + buff.substr(found+11+shipSelectionTag.length(), std::string::npos);
     174                    tempLevel.write(buff.c_str(), buff.length());
     175                    tempLevel << std::endl;
     176                }
     177                myLevel.close();
     178                tempLevel.close();
     179                orxout(user_status) << "done" << endl;
     180            }
    181181            void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed.
    182182            void shipsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed.
     
    199199            std::string tagsString_; //!< The comma-seperated string of all the tags the Level is tagged with.
    200200            std::set<std::string> ships_; //!< The set of starting ship models the Level allows.
    201             std::string startingShipsString_; //!< The comma-seperated string of all the allowed ship models for the shipselection.           
     201            std::string startingShipsString_; //!< The comma-seperated string of all the allowed ship models for the shipselection.
    202202    }; // tolua_export
    203203
     
    210210        - @b screenshot The screenshot of the level.
    211211        - @b tags A comma-seperated string of tags. Allowed tags are: <em>test</em>, <em>singleplayer</em>, <em>multiplayer</em>, <em>showcase</em>, <em>tutorial</em>, <em>presentation</em>, <em>shipselection</em>.
    212         - @b (optional) startingships The comma-seperated string of starting ship models 
     212        - @b (optional) startingships The comma-seperated string of starting ship models
    213213        An example would be:
    214214        @code
     
    224224    @author
    225225        Damian 'Mozork' Frick
    226         @edit
    227                 Matthias Hutter
     226    @edit
     227        Matthias Hutter
    228228    @ingroup Orxonox
    229229    */
     
    235235
    236236            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates a LevelInfo object through XML.
    237        
     237
    238238            /**
    239239            @brief Set the screenshot of the Level.
     
    283283            */
    284284            inline const std::string& getShips(void) const
    285                 { return this->LevelInfoItem::getShips(); }             
     285                { return this->LevelInfoItem::getShips(); }
    286286            LevelInfoItem* copy(void); //!< Copies the contents of this LevelInfo object to a new LevelInfoItem object.
    287287    };
     
    302302            }
    303303    };
    304    
     304
    305305} // tolua_export
    306306
  • code/branches/presentation2012merge/src/orxonox/ShipManager.cc

    r9271 r9272  
    2222 *   Author:
    2323 *      Matthias Hutter
    24  *   
     24 *
    2525 */
    2626
     
    2828    @file ShipManager.cc
    2929    @brief Work-in Progress: Implementation of the ShipManager singleton.
    30            Should make SpaceShip info available to lua handlers.
     30           Should make SpaceShip info available to lua handlers.
    3131*/
    3232
     
    7272    }
    7373
    74    
     74
    7575    /**
    7676    @brief
     
    132132    void ShipManager::compileAvailableShipList()
    133133    {
    134                 /*
    135                 // We only want to load as little as possible
    136                 ClassTreeMask mask;
    137                     mask.exclude(Class(BaseObject));
    138                     mask.include(Class(SpaceShip));
    139                 SpaceShip* info = NULL;
    140                 XMLFile file = XMLFile(ship);
    141                 Loader::load(&file, mask, false, true);
    142                 for(ObjectList<SpaceShip>::iterator item = ObjectList<SpaceShip>::begin(); item != ObjectList<SpaceShip>::end(); ++item)
    143                         if(item->getXMLFilename() == *it)
    144                             info = item->copy();
    145                 Loader::unload(&file);
    146                 */
    147    
     134        /*
     135        // We only want to load as little as possible
     136        ClassTreeMask mask;
     137            mask.exclude(Class(BaseObject));
     138            mask.include(Class(SpaceShip));
     139        SpaceShip* info = NULL;
     140        XMLFile file = XMLFile(ship);
     141        Loader::load(&file, mask, false, true);
     142        for(ObjectList<SpaceShip>::iterator item = ObjectList<SpaceShip>::begin(); item != ObjectList<SpaceShip>::end(); ++item)
     143                if(item->getXMLFilename() == *it)
     144                    info = item->copy();
     145        Loader::unload(&file);
     146        */
     147
    148148        // Get all files matching the level criteria
    149149        Ogre::StringVectorPtr levels = Resource::findResourceNames("*.oxw");
  • code/branches/presentation2012merge/src/orxonox/controllers/FormationController.cc

    r9271 r9272  
    5050{
    5151
    52   SetConsoleCommand("FormationController", "formationflight",  &FormationController::formationflight);
    53   SetConsoleCommand("FormationController", "masteraction",     &FormationController::masteraction);
    54   SetConsoleCommand("FormationController", "followme",         &FormationController::followme);
    55   SetConsoleCommand("FormationController", "passivebehaviour", &FormationController::passivebehaviour);
    56   SetConsoleCommand("FormationController", "formationsize",    &FormationController::formationsize);
    57 
    58 
    59 
    60 
    61   static const unsigned int STANDARD_MAX_FORMATION_SIZE = 9;
    62   static const int RADIUS_TO_SEARCH_FOR_MASTERS = 5000;
    63   static const float FORMATION_LENGTH =  110;
    64   static const float FORMATION_WIDTH =  110;
    65   static const int FREEDOM_COUNT = 4; //seconds the slaves in a formation will be set free when master attacks an enemy
    66   static const float SPEED_MASTER = 0.6f;
    67   static const float ROTATEFACTOR_MASTER = 0.2f;
    68   static const float SPEED_FREE = 0.8f;
    69   static const float ROTATEFACTOR_FREE = 0.8f;
    70 
    71   FormationController::FormationController(BaseObject* creator) : Controller(creator)
    72   {
     52    SetConsoleCommand("FormationController", "formationflight",  &FormationController::formationflight);
     53    SetConsoleCommand("FormationController", "masteraction",     &FormationController::masteraction);
     54    SetConsoleCommand("FormationController", "followme",         &FormationController::followme);
     55    SetConsoleCommand("FormationController", "passivebehaviour", &FormationController::passivebehaviour);
     56    SetConsoleCommand("FormationController", "formationsize",    &FormationController::formationsize);
     57
     58
     59
     60
     61    static const unsigned int STANDARD_MAX_FORMATION_SIZE = 9;
     62    static const int RADIUS_TO_SEARCH_FOR_MASTERS = 5000;
     63    static const float FORMATION_LENGTH =  110;
     64    static const float FORMATION_WIDTH =  110;
     65    static const int FREEDOM_COUNT = 4; //seconds the slaves in a formation will be set free when master attacks an enemy
     66    static const float SPEED_MASTER = 0.6f;
     67    static const float ROTATEFACTOR_MASTER = 0.2f;
     68    static const float SPEED_FREE = 0.8f;
     69    static const float ROTATEFACTOR_FREE = 0.8f;
     70
     71    FormationController::FormationController(BaseObject* creator) : Controller(creator)
     72    {
    7373        RegisterObject(FormationController);
    7474
     
    9191        this->team_=-1;
    9292        this->target_.setCallback(createFunctor(&FormationController::targetDied, this));
    93   }
    94 
    95   FormationController::~FormationController()
    96   {
    97     if (this->isInitialized())
     93    }
     94
     95    FormationController::~FormationController()
     96    {
     97        if (this->isInitialized())
    9898        {
    9999            this->removeFromFormation();
     
    123123            }
    124124        }
    125   }
    126 
    127   void FormationController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     125    }
     126
     127    void FormationController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    128128    {
    129129        SUPER(FormationController, XMLPort, xmlelement, mode);
     
    137137
    138138
    139   /**
     139    /**
    140140        @brief Activates / deactivates formationflight behaviour
    141141        @param form activate formflight if form is true
    142142    */
    143   void FormationController::formationflight(const bool form)
     143    void FormationController::formationflight(const bool form)
    144144    {
    145145        for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
     
    168168    }
    169169
    170   /**
     170    /**
    171171        @brief Get all masters to do a "specific master action"
    172172        @param action which action to perform (integer, so it can be called with a console command (tmp solution))
     
    198198    }
    199199
    200   /**
     200    /**
    201201        @brief Sets shooting behaviour of pawns.
    202202        @param passive if true, bots won't shoot.
     
    225225    }
    226226
    227   /**
     227    /**
    228228        @brief Sets maximal formation size
    229229        @param size maximal formation size.
     
    282282        Vector2 coord = get2DViewcoordinates(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
    283283        float distance = (target - this->getControllableEntity()->getPosition()).length();
    284                 if(coord.x < 0.0001 && coord.y < 0.0001)
    285                 {
    286                         // if the ship reaches a direction very close to the direct one, set it to the direct one
    287                         Vector3 v_temp = this->getControllableEntity()->getPosition();
    288                         Quaternion quat = v_temp.getRotationTo(target);
    289                         this->getControllableEntity()->rotate(quat);
    290                 }
     284        if(coord.x < 0.0001 && coord.y < 0.0001)
     285        {
     286            // if the ship reaches a direction very close to the direct one, set it to the direct one
     287            Vector3 v_temp = this->getControllableEntity()->getPosition();
     288            Quaternion quat = v_temp.getRotationTo(target);
     289            this->getControllableEntity()->rotate(quat);
     290        }
    291291
    292292        if(this->state_ == FREE)
     
    324324
    325325        if(this->state_ == SLAVE)
    326                 {
    327 
    328                         this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * coord.x * 2);
    329                         this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * coord.y * 2);
    330 
    331                         if (distance < 300)
    332                         {
    333                                 if (bHasTargetOrientation_)
    334                                 {
    335                                         copyTargetOrientation();
    336                                 }
    337                                 if (distance < 100)
    338                                 { //linear speed reduction
    339                                         this->getControllableEntity()->moveFrontBack(distance/100.0f*0.4f*SPEED_MASTER);
    340 
    341                                 } else this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER);
    342 
    343                         } else {
    344                                 this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER + distance/300.0f);
    345                         }
    346                 }
     326        {
     327
     328            this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * coord.x * 2);
     329            this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * coord.y * 2);
     330
     331            if (distance < 300)
     332            {
     333                if (bHasTargetOrientation_)
     334                {
     335                    copyTargetOrientation();
     336                }
     337                if (distance < 100)
     338                { //linear speed reduction
     339                    this->getControllableEntity()->moveFrontBack(distance/100.0f*0.4f*SPEED_MASTER);
     340                }
     341                else
     342                    this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER);
     343            }
     344            else
     345                this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER + distance/300.0f);
     346        }
    347347
    348348        if (distance < 10)
    349349        {
    350350            this->positionReached();
    351             bHasTargetOrientation_=false;
    352         }
    353     }
    354 
    355 
    356 
    357   void FormationController::moveToTargetPosition()
     351            bHasTargetOrientation_=false;
     352        }
     353    }
     354
     355
     356
     357    void FormationController::moveToTargetPosition()
    358358    {
    359359        this->moveToPosition(this->targetPosition_);
    360360    }
    361361
    362   //copy the Roll orientation of given Quaternion.
    363   void FormationController::copyOrientation(const Quaternion& orient)
     362    //copy the Roll orientation of given Quaternion.
     363    void FormationController::copyOrientation(const Quaternion& orient)
    364364    {
    365365        //roll angle difference in radian
     
    379379
    380380
    381    /**
     381    /**
    382382        @brief Unregisters a slave from its master. Initiated by a slave.
    383383    */
     
    469469        }
    470470    }
    471  /**
     471
     472    /**
    472473        @brief Commands the slaves of a master into a formation. Sufficiently fast not to be called within tick. Initiated by a master.
    473474    */
    474 
    475 void FormationController::commandSlaves()
     475    void FormationController::commandSlaves()
    476476    {
    477477        if(this->state_ != MASTER) return;
     
    487487        }
    488488        else
    489         // formation:
     489        // formation:
    490490        {
    491491            dest += 1.0f*orient*WorldEntity::BACK;
    492492            Vector3 pos = Vector3::ZERO;
    493                  bool left=true;
     493            bool left=true;
    494494            int i = 1;
    495495
     
    689689
    690690        if (specificMasterActionHoldCount_ == 0)
    691          {
     691        {
    692692            this->specificMasterAction_ = NONE;
    693693            this->searchNewTarget();
    694          }
    695         else specificMasterActionHoldCount_--;
     694        }
     695        else
     696            specificMasterActionHoldCount_--;
    696697    }
    697698
     
    717718    void FormationController::turn180()
    718719    {
    719             Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, this->targetPosition_);
    720 
    721             this->getControllableEntity()->rotateYaw(-2.0f * sgn(coord.x) * coord.x*coord.x);
    722             this->getControllableEntity()->rotatePitch(2.0f * sgn(coord.y) * coord.y*coord.y);
    723 
    724             this->getControllableEntity()->moveFrontBack(SPEED_MASTER);
     720        Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, this->targetPosition_);
     721
     722        this->getControllableEntity()->rotateYaw(-2.0f * sgn(coord.x) * coord.x*coord.x);
     723        this->getControllableEntity()->rotatePitch(2.0f * sgn(coord.y) * coord.y*coord.y);
     724
     725        this->getControllableEntity()->moveFrontBack(SPEED_MASTER);
    725726    }
    726727
     
    740741    void FormationController::spin()
    741742    {
    742             this->moveToTargetPosition();
    743             this->getControllableEntity()->rotateRoll(0.8f);
     743        this->moveToTargetPosition();
     744        this->getControllableEntity()->rotateRoll(0.8f);
    744745    }
    745746
     
    779780        if((humanPawn != NULL) && (allMasters.size() != 0))
    780781        {
    781                 float posHuman = humanPawn->getPosition().length();
    782                 float distance = 0.0f;
    783                 float minDistance = FLT_MAX;
    784                 int index = 0;
    785                 int i = 0;
    786 
    787                 for(std::vector<FormationController*>::iterator it = allMasters.begin(); it != allMasters.end(); it++, i++)
    788                     {
    789                         if (!FormationController::sameTeam((*it)->getControllableEntity(), humanPawn, (*it)->getGametype())) continue;
    790                         distance = posHuman - (*it)->getControllableEntity()->getPosition().length();
    791                         if(distance < minDistance) index = i;
    792                     }
    793                 allMasters[index]->followInit(humanPawn);
    794             }
    795 
    796     }
    797 
    798 
    799 
    800 
     782            float posHuman = humanPawn->getPosition().length();
     783            float distance = 0.0f;
     784            float minDistance = FLT_MAX;
     785            int index = 0;
     786            int i = 0;
     787
     788            for(std::vector<FormationController*>::iterator it = allMasters.begin(); it != allMasters.end(); it++, i++)
     789            {
     790                if (!FormationController::sameTeam((*it)->getControllableEntity(), humanPawn, (*it)->getGametype())) continue;
     791                distance = posHuman - (*it)->getControllableEntity()->getPosition().length();
     792                if(distance < minDistance) index = i;
     793            }
     794            allMasters[index]->followInit(humanPawn);
     795        }
     796    }
    801797
    802798    /**
     
    820816    }
    821817
    822    /**
     818    /**
    823819        @brief Master begins to follow a randomly chosen human player of the same team. Is a "specific master action".
    824820    */
     
    848844
    849845
    850   /**
     846    /**
    851847        @brief Master follows target with adjusted speed. Called within tick.
    852848    */
     
    860856
    861857
    862   void FormationController::setTargetPosition(const Vector3& target)
     858    void FormationController::setTargetPosition(const Vector3& target)
    863859    {
    864860        this->targetPosition_ = target;
     
    924920    }
    925921
    926   void FormationController::forgetTarget()
     922    void FormationController::forgetTarget()
    927923    {
    928924        this->target_ = 0;
     
    930926    }
    931927
    932    void FormationController::targetDied()
     928    void FormationController::targetDied()
    933929    {
    934930        this->forgetTarget();
     
    936932    }
    937933
    938   bool FormationController::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
     934    bool FormationController::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
    939935    {
    940936        if (entity1 == entity2)
  • code/branches/presentation2012merge/src/orxonox/gametypes/Mission.cc

    r9271 r9272  
    6363        {
    6464            this->missionAccomplished_ = false;
    65             this->end();
     65            this->end();
    6666        }
    6767    }
     
    7878    {
    7979        Gametype::end();
    80         /*if (this->missionAccomplished_)
     80        /*if (this->missionAccomplished_)
    8181            this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
    82         else
     82        else
    8383            this->gtinfo_->sendAnnounceMessage("Mission failed!");
    84          * */
     84        */
    8585    }
    8686
  • code/branches/presentation2012merge/src/orxonox/infos/PlayerInfo.cc

    r9257 r9272  
    173173        this->changedControllableEntity();
    174174
    175                 RadarViewable* radarviewable = orxonox_cast<RadarViewable*>(entity);
     175        RadarViewable* radarviewable = orxonox_cast<RadarViewable*>(entity);
    176176        if (radarviewable != NULL)
    177177            radarviewable->setRadarName(this->getName());
  • code/branches/presentation2012merge/src/orxonox/interfaces/RadarViewable.h

    r9257 r9272  
    6161        virtual ~RadarViewable();
    6262
    63                 virtual void setRadarName(const std::string& name)
    64                         {
    65                                 if (this->radarName_ != name)
    66                                 {
    67                                         this->radarName_ = name;
    68                                         this->settingsChanged();
    69                                 }
    70                         }
    71                 const std::string& getRadarName() const
    72                         { return this->radarName_; }
     63        virtual void setRadarName(const std::string& name)
     64            {
     65                if (this->radarName_ != name)
     66                {
     67                    this->radarName_ = name;
     68                    this->settingsChanged();
     69                }
     70            }
     71        const std::string& getRadarName() const
     72            { return this->radarName_; }
    7373
    7474        inline void setRadarObjectCamouflage(float camouflage)
     
    163163        ColourValue radarObjectColour_;
    164164        float scale_;
    165                 std::string radarName_;
     165        std::string radarName_;
    166166    };
    167167}
  • code/branches/presentation2012merge/src/orxonox/worldentities/ControllableEntity.cc

    r9016 r9272  
    8787        this->setPriority( Priority::VeryHigh );
    8888        this->registerVariables();
    89         this->team_ = -1;
     89        this->team_ = -1;
    9090    }
    9191
  • code/branches/presentation2012merge/src/orxonox/worldentities/ControllableEntity.h

    r9255 r9272  
    164164            void setTargetInternal( uint32_t targetID );
    165165
    166             inline void setTeam(int team)
    167                 { this->team_ = team; }
    168             inline int getTeam() const
    169                 { return this->team_; }
     166            inline void setTeam(int team)
     167                { this->team_ = team; }
     168            inline int getTeam() const
     169                { return this->team_; }
    170170
    171171        protected:
     
    243243            WeakPtr<WorldEntity> target_;
    244244
    245             int team_ ; //<! teamnumber
     245            int team_ ; //<! teamnumber
    246246    };
    247247}
  • code/branches/presentation2012merge/src/orxonox/worldentities/pawns/Pawn.cc

    r9269 r9272  
    232232    {
    233233        //Applies multiplier given by the DamageBoost Pickup.
    234         Pawn *test = dynamic_cast<Pawn *>(originator);
    235         if( test != NULL )
    236         {
    237           damage *= originator->getDamageMultiplier();
    238         }
    239 
    240         if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
     234        Pawn *test = dynamic_cast<Pawn *>(originator);
     235        if( test != NULL )
     236        {
     237            damage *= originator->getDamageMultiplier();
     238        }
     239
     240        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
    241241        {
    242242            if (shielddamage >= this->getShieldHealth())
  • code/branches/presentation2012merge/src/orxonox/worldentities/pawns/SpaceShip.cc

    r8892 r9272  
    133133    {
    134134        SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down).");
    135        
     135
    136136        SetConfigValueExternal(bEnableMotionBlur_, "GraphicsSettings", "enableMotionBlur", true)
    137137            .description("Enable or disable the motion blur effect when moving very fast")
     
    503503    void SpaceShip::resetCamera()
    504504    {
    505         if(this->hasLocalController() && this->hasHumanController())
    506         {
     505        if(this->hasLocalController() && this->hasHumanController())
     506        {
    507507            Camera *camera = this->getCamera();
    508508            if (camera == 0)
     
    514514            camera->setPosition(this->cameraOriginalPosition_);
    515515            camera->setOrientation(this->cameraOriginalOrientation_);
    516         }
     516        }
    517517    }
    518518
Note: See TracChangeset for help on using the changeset viewer.