Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3086 for code/trunk


Ignore:
Timestamp:
May 27, 2009, 1:44:48 AM (16 years ago)
Author:
landauf
Message:

added bot-support for TeamBaseMatch (and some small fixes)

Location:
code/trunk/src/orxonox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/controllers/ArtificialController.cc

    r3049 r3086  
    3636#include "objects/gametypes/TeamDeathmatch.h"
    3737#include "objects/controllers/WaypointPatrolController.h"
     38#include "objects/worldentities/pawns/TeamBaseMatchBase.h"
    3839
    3940namespace orxonox
     
    203204        }
    204205
     206        TeamBaseMatchBase* base = 0;
     207        base = dynamic_cast<TeamBaseMatchBase*>(entity1);
     208        if (base)
     209        {
     210            switch (base->getState())
     211            {
     212                case BaseState::controlTeam1:
     213                    team1 = 0;
     214                    break;
     215                case BaseState::controlTeam2:
     216                    team1 = 1;
     217                    break;
     218                case BaseState::uncontrolled:
     219                default:
     220                    team1 = -1;
     221            }
     222        }
     223        base = dynamic_cast<TeamBaseMatchBase*>(entity2);
     224        if (base)
     225        {
     226            switch (base->getState())
     227            {
     228                case BaseState::controlTeam1:
     229                    team2 = 0;
     230                    break;
     231                case BaseState::controlTeam2:
     232                    team2 = 1;
     233                    break;
     234                case BaseState::uncontrolled:
     235                default:
     236                    team2 = -1;
     237            }
     238        }
     239
    205240        return (team1 == team2 && team1 != -1);
    206241    }
  • code/trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc

    r3033 r3086  
    4141
    4242        this->scoreTimer_.setTimer(10, true, this, createExecutor(createFunctor(&TeamBaseMatch::winPoints)));
    43         this->outputTimer_.setTimer(30, true, this, createExecutor(createFunctor(&TeamBaseMatch::showPoints)));
     43        this->outputTimer_.setTimer(10, true, this, createExecutor(createFunctor(&TeamBaseMatch::showPoints)));
    4444
    4545        this->pointsTeam1_ = 0;
     
    7979            std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.find(base);
    8080            if (it != this->bases_.end())
    81                 return (!this->pawnsAreInTheSameTeam(victim, base));
    82         }
    83         return (!this->pawnsAreInTheSameTeam(victim, originator));
     81                return (!this->pawnsAreInTheSameTeam(originator, base));
     82        }
     83        return TeamDeathmatch::allowPawnDamage(victim, originator);
    8484    }
    8585
     
    9090            std::map<PlayerInfo*, int>::const_iterator it1 = this->teamnumbers_.find(pawn1->getPlayer());
    9191            int teamnrbase = -1;
    92             int teamnrplayer = getTeam(pawn1->getPlayer());
     92            int teamnrplayer = this->getTeam(pawn1->getPlayer());
    9393
    9494            switch (base->getState())
     
    106106
    107107            if (teamnrbase == teamnrplayer)
    108                 return false;
    109         }
    110         return true;
     108                return true;
     109        }
     110        return false;
    111111    }
    112112
     
    126126    {
    127127        COUT(0) << "Points standing:" << std::endl << "Team 1: "<< pointsTeam1_ << std::endl << "Team 2: " << pointsTeam2_ << std::endl;
    128         if(pointsTeam1_ >=1700) COUT(0) << "Team 1 is near victory!" << std::endl;
    129         if(pointsTeam2_ >=1700) COUT(0) << "Team 2 is near victory!" << std::endl;
     128        if(pointsTeam1_ >=1700 && pointsTeam1_ < 2000) COUT(0) << "Team 1 is near victory!" << std::endl;
     129        if(pointsTeam2_ >=1700 && pointsTeam2_ < 2000) COUT(0) << "Team 2 is near victory!" << std::endl;
    130130    }
    131131
     
    157157    void TeamBaseMatch::endGame()
    158158    {
    159         if(this->pointsTeam1_>=2000 || this->pointsTeam2_ >=2000)
    160         {
     159        if (this->pointsTeam1_ >= 2000 || this->pointsTeam2_ >= 2000)
     160        {
     161            if (this->pointsTeam1_ > this->pointsTeam2_)
     162                COUT(0) << "Team 1 has won the match" << std::endl;
     163            else
     164                COUT(0) << "Team 2 has won the match" << std::endl;
     165
    161166            this->end();
     167            this->scoreTimer_.stopTimer();
     168            this->outputTimer_.stopTimer();
    162169        }
    163170    }
  • code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.h

    r3084 r3086  
    147147    class _OrxonoxExport PawnListener : virtual public OrxonoxClass
    148148    {
    149         friend class Pawn;
    150 
    151149        public:
    152150            PawnListener();
    153151            virtual ~PawnListener() {}
    154152
    155         protected:
    156153            virtual void destroyedPawn(Pawn* pawn) = 0;
    157154    };
  • code/trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc

    r3033 r3086  
    4848            gametype->addBase(this);
    4949        }
     50
     51        this->setRadarObjectShape(RadarViewable::Triangle);
    5052    }
    5153
     
    7072            case BaseState::uncontrolled:
    7173            default:
    72                 colour = ColourValue(0.5, 0.5, 0.7, 1.0);
     74                colour = ColourValue(0.5, 0.5, 0.5, 1.0);
    7375                break;
    7476        }
     
    8486            }
    8587        }
     88
     89        this->setRadarObjectColour(colour);
     90
     91        // Call this so bots stop shooting at the base after they converted it
     92        for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it)
     93            it->destroyedPawn(this);
    8694    }
    8795}
  • code/trunk/src/orxonox/overlays/hud/HUDRadar.cc

    r2896 r3086  
    6464
    6565        this->shapeMaterials_[RadarViewable::Dot]      = "RadarDot.tga";
    66         this->shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga";
     66        this->shapeMaterials_[RadarViewable::Triangle] = "RadarTriangle.tga";
    6767        this->shapeMaterials_[RadarViewable::Square]   = "RadarSquare.tga";
    6868
Note: See TracChangeset for help on using the changeset viewer.