Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2985


Ignore:
Timestamp:
May 18, 2009, 5:01:45 PM (15 years ago)
Author:
vmikos
Message:

final version

Location:
code/branches/gametypes/src/orxonox/objects
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gametypes/src/orxonox/objects/gametypes/TeamBaseMatch.cc

    r2934 r2985  
    2020 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    2121 *
    22  *   Author:
     22 *   Author: Val Mikos
    2323 */
    2424 
     
    2828
    2929
    30 //implement this! not done yet!
    3130#include "objects/worldentities/pawns/TeamBaseMatchBase.h"
    3231#include "core/CoreIncludes.h"
     
    9998    }
    10099
     100
     101    // if the player is in the same team as the base, he can't make any damage to it
     102    bool TeamBaseMatch::allowPawnDamage(Pawn* victim, Pawn* originator)
     103    {
     104        TeamBaseMatchBase* base = dynamic_cast<TeamBaseMatchBase*>(victim);
     105        if (base)
     106        {
     107            std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.find(base);
     108            if (it != this->bases_.end())
     109                return (!this->pawnsAreInTheSameTeam(victim, base));
     110        }
     111        return (!this->pawnsAreInTheSameTeam(victim, originator));
     112    }
     113
     114    bool TeamBaseMatch::pawnsAreInTheSameTeam(Pawn* pawn1, TeamBaseMatchBase* base)
     115    {
     116        if (pawn1 && base)
     117        {
     118            std::map<PlayerInfo*, int>::const_iterator it1 = this->teamnumbers_.find(pawn1->getPlayer());
     119            int teamnrbase = -1;
     120            int teamnrplayer = getTeam(pawn1->getPlayer());
     121
     122            switch(base->getState())
     123            {
     124                case BaseState::controlTeam1:
     125                    teamnrbase = 0;
     126                    break;
     127                case BaseState::controlTeam2:
     128                    teamnrbase = 1;
     129                    break;
     130                case BaseState::uncontrolled:
     131                default:
     132                    teamnrbase = -1;
     133            }
     134
     135
     136            if(teamnrbase == teamnrplayer){
     137                return false;
     138            }
     139        }
     140        return true;
     141    }
     142
     143
     144
     145
     146
    101147    // collect Points for killing oppenents
    102148    void TeamBaseMatch::playerScored(PlayerInfo* player)
     
    181227        return 0;
    182228    }
    183 
    184 
    185     // declare the functions 'getshape' and 'setshape' from the XML function here
    186  
    187 
    188 
    189 
    190229   
    191230}
    192231
    193232 
    194 
    195  
  • code/branches/gametypes/src/orxonox/objects/gametypes/TeamBaseMatch.h

    r2934 r2985  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Val Mikos
    2626 *
    2727 */
     
    5959            virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);
    6060
     61            virtual bool allowPawnDamage(Pawn* victim, Pawn* originator);
     62
     63
     64
    6165            // give information about the state of a base
    6266            // (this should be pretty useless atm)
     
    7882            void winPoints();
    7983
     84
     85            bool pawnsAreInTheSameTeam(Pawn* pawn1, TeamBaseMatchBase* base);
     86            using TeamDeathmatch::pawnsAreInTheSameTeam;
     87
    8088            std::set<TeamBaseMatchBase*> bases_;
    8189            Timer<TeamBaseMatch> scoreTimer_;
  • code/branches/gametypes/src/orxonox/objects/gametypes/TeamDeathmatch.h

    r2903 r2985  
    5555            virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);
    5656
     57            inline const ColourValue& getTeamColour(int teamnr) const
     58                { return this->teamcolours_[teamnr]; }
     59
    5760        protected:
    5861            virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
  • code/branches/gametypes/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc

    r2934 r2985  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Val Mikos
    2626 *
    2727 */
     
    3131#include "core/CoreIncludes.h"
    3232#include "objects/gametypes/TeamBaseMatch.h"
     33#include "objects/Teamcolourable.h"
    3334
    3435namespace orxonox
     
    4849        }
    4950    }
     51
     52    void TeamBaseMatchBase::changeTeamColour()
     53    {
     54        this->fireEvent();
     55
     56        TeamDeathmatch* gametype = dynamic_cast<TeamDeathmatch*>(this->getGametype());
     57        if (!gametype)
     58            return;
     59
     60        ColourValue colour;
     61
     62        switch (this->state_)
     63        {
     64            case BaseState::controlTeam1:
     65                colour = gametype->getTeamColour(0);
     66                break;
     67            case BaseState::controlTeam2:
     68                colour = gametype->getTeamColour(1);
     69                break;
     70            case BaseState::uncontrolled:
     71            default:
     72                colour = ColourValue(0.5, 0.5, 0.7, 1.0);
     73                break;
     74        }
     75
     76       
     77        std::set<WorldEntity*> attachments = this->getAttachedObjects();
     78        for (std::set<WorldEntity*>::iterator it = attachments.begin(); it != attachments.end(); ++it)
     79        {
     80            if ((*it)->isA(Class(Teamcolourable)))
     81            {
     82                Teamcolourable* tc = dynamic_cast<Teamcolourable*>(*it);
     83                tc->setTeamColour(colour);
     84            }
     85        }
     86    }
    5087}
    5188
  • code/branches/gametypes/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.h

    r2934 r2985  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Val Mikos
    2626 *
    2727 */
     
    7070            {
    7171                this->state_ = state;
     72                this->changeTeamColour();
    7273            }
    7374
     
    8182
    8283        protected:
     84            void changeTeamColour();
    8385
    8486            BaseState::Enum state_;
Note: See TracChangeset for help on using the changeset viewer.