Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 18, 2011, 6:52:21 PM (13 years ago)
Author:
jo
Message:

Pawn&SpaceShip Colouring via XML works. Quick&Dirty implementation though. A clean version is going to follow.

Location:
code/branches/gamecontent/src/orxonox
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gamecontent/src/orxonox/controllers/ArtificialController.cc

    r8923 r8942  
    4242#include "gametypes/TeamDeathmatch.h"
    4343#include "gametypes/Dynamicmatch.h"
     44#include "gametypes/Mission.h"
    4445#include "controllers/WaypointPatrolController.h"
    4546#include "controllers/NewHumanController.h"
     
    996997            if (entity2->getPlayer())
    997998                team2 = tdm->getTeam(entity2->getPlayer());
     999        }
     1000
     1001        Mission* miss = orxonox_cast<Mission*>(gametype);
     1002        if (miss)
     1003        {
     1004            if (entity1->getPlayer())
     1005                team1 = miss->getTeam(entity1->getPlayer());
     1006
     1007            if (entity2->getPlayer())
     1008                team2 = miss->getTeam(entity2->getPlayer());
    9981009        }
    9991010
  • code/branches/gamecontent/src/orxonox/controllers/HumanController.cc

    r8858 r8942  
    195195            this->boosting_ = true;
    196196            this->boostingTimeout_.startTimer();
    197            
    198             this->controllableEntity_->boost(this->boosting_);
     197            if(this->controllableEntity_)
     198                this->controllableEntity_->boost(this->boosting_);
    199199//            orxout() << "Start boosting" << endl;
    200200        }
     
    209209        this->boosting_ = false;
    210210        this->boostingTimeout_.stopTimer();
    211 
    212         this->controllableEntity_->boost(this->boosting_);
     211        if(this->controllableEntity_)
     212            this->controllableEntity_->boost(this->boosting_);
    213213//        orxout() << "Stop boosting" << endl;
    214214    }
  • code/branches/gamecontent/src/orxonox/gametypes/Mission.cc

    r8941 r8942  
    9090
    9191    void Mission::setTeams()
    92     {
     92    {//Set pawn-colours
    9393        for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
    94             this->setObjectColour(*it);
     94        {
     95            Pawn* pawn = static_cast<Pawn*>(*it);
     96            if(!pawn) continue;
     97                this->setDefaultObjectColour(pawn);
     98        }
    9599    }
    96100
  • code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.cc

    r8941 r8942  
    3535#include "worldentities/TeamSpawnPoint.h"
    3636#include "worldentities/pawns/Pawn.h"
     37#include "worldentities/ControllableEntity.h"
    3738#include "controllers/ArtificialController.h"
    3839
     
    117118        {
    118119            if(true)//check if dead player is allowed to enter -> if maximum nr of players is exceeded & player was not in game before: disallow
    119                 continue;
     120                //continue;
    120121            if (it->second.state_ == PlayerState::Dead)
    121122            {
     
    249250        if (it_player != this->teamnumbers_.end() && it_player->second >= 0 && it_player->second < static_cast<int>(this->teamcolours_.size()))
    250251        {
    251             if (pawn)
    252             {
    253                 pawn->setRadarObjectColour(this->teamcolours_[it_player->second]);
    254 
    255                 std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects();
    256                 for (std::set<WorldEntity*>::iterator it = pawnAttachments.begin(); it != pawnAttachments.end(); ++it)
    257                 {
    258                     if ((*it)->isA(Class(TeamColourable)))
    259                     {
    260                         TeamColourable* tc = orxonox_cast<TeamColourable*>(*it);
    261                         tc->setTeamColour(this->teamcolours_[it_player->second]);
    262                     }
    263                 }
    264             }
    265         }
    266     }
    267 
    268     void TeamGametype::setObjectColour(Pawn* pawn)
     252            this->colourPawn(pawn, it_player->second);
     253        }
     254    }
     255
     256    void TeamGametype::setDefaultObjectColour(Pawn* pawn)
    269257    {
    270258        if(pawn == NULL)
    271259            return;
     260       
     261        int teamnumber = pawn->getTeam();
     262
     263        if(teamnumber >= 0)
     264        {
     265            this->colourPawn(pawn, teamnumber); return;
     266        }
    272267        //get Pawn's controller
    273         ArtificialController* controller = orxonox_cast<ArtificialController*>(pawn);
    274         if(controller == NULL)
     268        ControllableEntity* entity = orxonox_cast<ControllableEntity*>(pawn);
     269
     270        Controller* controller = 0;
     271        if (entity->getController())
     272            controller = entity->getController();
     273        else if (entity->getXMLController())
     274            controller = entity->getXMLController();
     275        else
    275276            return;
     277
     278        ArtificialController* artificial =  orxonox_cast<ArtificialController*>(controller);
    276279        //get Teamnumber - get the data
    277         int teamnumber= controller->getTeam();
    278         if(teamnumber < 0)
     280        if(artificial == NULL)
    279281            return;
     282        teamnumber= artificial->getTeam();
     283
    280284        //set ObjectColour
    281         pawn->setRadarObjectColour(this->teamcolours_[teamnumber]);
     285        this->colourPawn(pawn, teamnumber);
     286    }
     287
     288    void TeamGametype::colourPawn(Pawn* pawn, int teamNr)
     289    {// catch no-colouring-case and wrong input
     290        if(teamNr < 0 || pawn == NULL) return;
     291        pawn->setRadarObjectColour(this->teamcolours_[teamNr]);
    282292
    283293        std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects();
     
    287297            {
    288298                TeamColourable* tc = orxonox_cast<TeamColourable*>(*it);
    289                 tc->setTeamColour(this->teamcolours_[teamnumber]);
     299                tc->setTeamColour(this->teamcolours_[teamNr]);
    290300            }
    291301         }
    292302    }
    293303
    294 
    295304}
  • code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.h

    r8941 r8942  
    7575            std::map<PlayerInfo*, bool> allowedInGame_; //!< Only those players are allowed to spawn which are listed here as 'true'.
    7676            void setTeamColour(PlayerInfo* player, Pawn* pawn);
    77             void setObjectColour(Pawn* pawn);
     77            void setDefaultObjectColour(Pawn* pawn);
     78            void colourPawn(Pawn* pawn, int teamNr);
    7879    };
    7980}
  • code/branches/gamecontent/src/orxonox/interfaces/CMakeLists.txt

    r8706 r8942  
    66  PickupListener.cc
    77  RadarViewable.cc
     8  PartyMember.cc
    89)
  • code/branches/gamecontent/src/orxonox/interfaces/PartyMember.h

    r8907 r8942  
    5252        public:
    5353            PartyMember();
    54             virtual ~PartyMember() {}
     54            virtual ~PartyMember();
    5555
    5656            /**
  • code/branches/gamecontent/src/orxonox/worldentities/pawns/Pawn.cc

    r8904 r8942  
    6060        this->bReload_ = false;
    6161
     62        this->team_ = -1;
    6263        this->health_ = 0;
    6364        this->maxHealth_ = 0;
     
    110111        SUPER(Pawn, XMLPort, xmlelement, mode);
    111112
     113        XMLPortParam(Pawn, "team", setTeam, getTeam, xmlelement, mode).defaultValues(-1);
     114
    112115        XMLPortParam(Pawn, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100);
    113116        XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200);
     
    129132        XMLPortParam(Pawn, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);
    130133        XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);
     134
     135
    131136    }
    132137
  • code/branches/gamecontent/src/orxonox/worldentities/pawns/Pawn.h

    r8891 r8942  
    3535#include "interfaces/PickupCarrier.h"
    3636#include "interfaces/RadarViewable.h"
     37#include "interfaces/PartyMember.h"
    3738#include "worldentities/ControllableEntity.h"
    3839
     
    4041{ // tolua_export
    4142    class _OrxonoxExport Pawn // tolua_export
    42         : public ControllableEntity, public RadarViewable, public PickupCarrier
     43        : public ControllableEntity, public RadarViewable, public PickupCarrier//, public PartyMember
    4344    { // tolua_export
    4445        friend class WeaponSystem;
     
    5354            inline bool isAlive() const
    5455                { return this->bAlive_; }
     56
     57            inline void setTeam(int team)
     58                { this->team_ = team; }
     59            inline float getTeam() const
     60                { return this->team_; }
    5561
    5662            virtual void setHealth(float health);
     
    194200                { return NULL; }
    195201
     202            int team_;
     203
    196204            float health_;
    197205            float maxHealth_;
Note: See TracChangeset for help on using the changeset viewer.