Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3099 for code/trunk/src


Ignore:
Timestamp:
May 28, 2009, 1:58:22 AM (16 years ago)
Author:
landauf
Message:

Added Gameplay messages (Announces, Killmessages and Deathmessages)

Location:
code/trunk/src/orxonox
Files:
10 added
13 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/OrxonoxPrereqs.h

    r3089 r3099  
    268268    class OverlayGroup;
    269269    class OverlayText;
     270    class FadeoutText;
    270271    class GametypeStatus;
     272    class AnnounceMessage;
     273    class KillMessage;
     274    class DeathMessage;
    271275    class CreateLines;
    272276    class Scoreboard;
  • code/trunk/src/orxonox/objects/CMakeLists.txt

    r3084 r3099  
    33  EventDispatcher.cc
    44  EventTarget.cc
     5  GametypeMessageListener.cc
    56  GlobalShader.cc
    67  Level.cc
  • code/trunk/src/orxonox/objects/gametypes/Asteroids.cc

    r3056 r3099  
    5757        if (this->time_ < 0 && !this->hasEnded() && this->timerIsActive_)
    5858        {
     59            this->gtinfo_.sendAnnounceMessage("Time's up - you have lost the match!");
    5960            this->end();
    6061        }
     
    6566        if (victim && victim->getPlayer())
    6667        {
     68            this->gtinfo_.sendAnnounceMessage("You're dead - you have lost the match!");
    6769            this->end();
    6870        }
     
    7375        Gametype::start();
    7476
    75         std::string message = "The match has started! Reach the first chekpoint within 60 seconds! But be aware, there may be pirates around...";
     77        std::string message = "The match has started! Reach the first chekpoint within 15 seconds! But be aware, there may be pirates around...";
    7678        COUT(0) << message << std::endl;
    7779        Host::Broadcast(message);
  • code/trunk/src/orxonox/objects/gametypes/Gametype.cc

    r3038 r3099  
    236236
    237237                // Reward killer
    238                 if (killer)
     238                if (killer && killer->getPlayer())
    239239                {
    240240                    std::map<PlayerInfo*, Player>::iterator it = this->players_.find(killer->getPlayer());
    241241                    if (it != this->players_.end())
     242                    {
    242243                        it->second.frags_++;
     244
     245                        if (killer->getPlayer()->getClientID() != CLIENTID_UNKNOWN)
     246                            this->gtinfo_.sendKillMessage("You killed " + victim->getPlayer()->getName(), killer->getPlayer()->getClientID());
     247                        if (victim->getPlayer()->getClientID() != CLIENTID_UNKNOWN)
     248                            this->gtinfo_.sendDeathMessage("You were killed by " + killer->getPlayer()->getName(), victim->getPlayer()->getClientID());
     249                    }
    243250                }
    244251
  • code/trunk/src/orxonox/objects/gametypes/Pong.cc

    r2890 r3099  
    160160        {
    161161            this->center_->fireEvent();
     162
     163            if (player)
     164                this->gtinfo_.sendAnnounceMessage(player->getName() + " scored");
    162165        }
    163166
  • code/trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc

    r3086 r3099  
    3131#include "objects/worldentities/pawns/TeamBaseMatchBase.h"
    3232#include "core/CoreIncludes.h"
     33#include "objects/infos/PlayerInfo.h"
    3334
    3435namespace orxonox
     
    5859                int teamnr = this->getTeam(originator->getPlayer());
    5960                if (teamnr == 0)
     61                {
    6062                    base->setState(BaseState::controlTeam1);
     63                    this->gtinfo_.sendAnnounceMessage("The red team captured a base");
     64                }
    6165                if (teamnr == 1)
     66                {
    6267                    base->setState(BaseState::controlTeam2);
     68                    this->gtinfo_.sendAnnounceMessage("The blue team captured a base");
     69                }
    6370            }
    6471
     
    125132    void TeamBaseMatch::showPoints()
    126133    {
     134        if (!this->hasStarted() || this->hasEnded())
     135            return;
     136
    127137        COUT(0) << "Points standing:" << std::endl << "Team 1: "<< pointsTeam1_ << std::endl << "Team 2: " << pointsTeam2_ << std::endl;
    128138        if(pointsTeam1_ >=1700 && pointsTeam1_ < 2000) COUT(0) << "Team 1 is near victory!" << std::endl;
     
    159169        if (this->pointsTeam1_ >= 2000 || this->pointsTeam2_ >= 2000)
    160170        {
     171            int winningteam = -1;
     172
    161173            if (this->pointsTeam1_ > this->pointsTeam2_)
     174            {
    162175                COUT(0) << "Team 1 has won the match" << std::endl;
     176                winningteam = 0;
     177            }
    163178            else
     179            {
    164180                COUT(0) << "Team 2 has won the match" << std::endl;
     181                winningteam = 1;
     182            }
     183
     184            for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
     185            {
     186                if (it->first->getClientID() == CLIENTID_UNKNOWN)
     187                    continue;
     188
     189                if (it->second == winningteam)
     190                    this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID());
     191                else
     192                    this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID());
     193            }
    165194
    166195            this->end();
  • code/trunk/src/orxonox/objects/gametypes/UnderAttack.cc

    r3057 r3099  
    3636
    3737#include "objects/worldentities/pawns/Destroyer.h"
     38#include "objects/infos/PlayerInfo.h"
    3839
    3940namespace orxonox
     
    7374            Host::Broadcast(message);
    7475            this->gameEnded_ = true;
     76
     77            for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
     78            {
     79                if (it->first->getClientID() == CLIENTID_UNKNOWN)
     80                    continue;
     81
     82                if (it->second == 0)
     83                    this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID());
     84                else
     85                    this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID());
     86            }
    7587        }
    7688    }
     
    145157                COUT(0) << message << std::endl;
    146158                Host::Broadcast(message);
     159
     160                for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
     161                {
     162                    if (it->first->getClientID() == CLIENTID_UNKNOWN)
     163                        continue;
     164
     165                    if (it->second == 1)
     166                        this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID());
     167                    else
     168                        this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID());
     169                }
    147170            }
    148171
    149172             //prints gametime
    150             if ( gameTime_ <= timesequence_)
     173            if ( gameTime_ <= timesequence_ && gameTime_ > 0)
    151174            {
    152                 std::string message = convertToString(timesequence_) + " sec left!";
     175                std::string message = convertToString(timesequence_) + " seconds left!";
     176/*
    153177                COUT(0) << message << std::endl;
    154178                Host::Broadcast(message);
     179*/
     180                this->gtinfo_.sendAnnounceMessage(message);
     181
    155182                if (timesequence_ >= 30 && timesequence_ <= 60)
    156183                {
  • code/trunk/src/orxonox/objects/infos/GametypeInfo.cc

    r2826 r3099  
    3131
    3232#include "core/CoreIncludes.h"
     33#include "core/GameMode.h"
     34#include "network/NetworkFunction.h"
     35#include "network/Host.h"
     36#include "objects/GametypeMessageListener.h"
    3337
    3438namespace orxonox
    3539{
    3640    CreateUnloadableFactory(GametypeInfo);
     41
     42    registerMemberNetworkFunction(GametypeInfo, dispatchAnnounceMessage);
     43    registerMemberNetworkFunction(GametypeInfo, dispatchKillMessage);
     44    registerMemberNetworkFunction(GametypeInfo, dispatchDeathMessage);
    3745
    3846    GametypeInfo::GametypeInfo(BaseObject* creator) : Info(creator)
     
    6068        registerVariable(this->hudtemplate_,            variableDirection::toclient);
    6169    }
     70
     71    void GametypeInfo::sendAnnounceMessage(const std::string& message) const
     72    {
     73        if (GameMode::isMaster())
     74        {
     75            callMemberNetworkFunction(GametypeInfo, dispatchAnnounceMessage, this->getObjectID(), CLIENTID_UNKNOWN, message);
     76            this->dispatchAnnounceMessage(message);
     77        }
     78    }
     79
     80    void GametypeInfo::sendAnnounceMessage(const std::string& message, unsigned int clientID) const
     81    {
     82        if (GameMode::isMaster())
     83        {
     84            if (clientID == CLIENTID_SERVER)
     85                this->dispatchAnnounceMessage(message);
     86            else
     87                callMemberNetworkFunction(GametypeInfo, dispatchAnnounceMessage, this->getObjectID(), clientID, message);
     88        }
     89    }
     90
     91    void GametypeInfo::sendKillMessage(const std::string& message, unsigned int clientID) const
     92    {
     93        if (GameMode::isMaster())
     94        {
     95            if (clientID == CLIENTID_SERVER)
     96                this->dispatchKillMessage(message);
     97            else
     98                callMemberNetworkFunction(GametypeInfo, dispatchKillMessage, this->getObjectID(), clientID, message);
     99        }
     100    }
     101
     102    void GametypeInfo::sendDeathMessage(const std::string& message, unsigned int clientID) const
     103    {
     104        if (GameMode::isMaster())
     105        {
     106            if (clientID == CLIENTID_SERVER)
     107                this->dispatchDeathMessage(message);
     108            else
     109                callMemberNetworkFunction(GametypeInfo, dispatchDeathMessage, this->getObjectID(), clientID, message);
     110        }
     111    }
     112
     113    void GametypeInfo::dispatchAnnounceMessage(const std::string& message) const
     114    {
     115        for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
     116            it->announcemessage(this, message);
     117    }
     118
     119    void GametypeInfo::dispatchKillMessage(const std::string& message) const
     120    {
     121        for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
     122            it->killmessage(this, message);
     123    }
     124
     125    void GametypeInfo::dispatchDeathMessage(const std::string& message) const
     126    {
     127        for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
     128            it->deathmessage(this, message);
     129    }
    62130}
  • code/trunk/src/orxonox/objects/infos/GametypeInfo.h

    r2826 r3099  
    5959                { return this->hudtemplate_; }
    6060
     61            void sendAnnounceMessage(const std::string& message) const;
     62            void sendAnnounceMessage(const std::string& message, unsigned int clientID) const;
     63            void sendKillMessage(const std::string& message, unsigned int clientID) const;
     64            void sendDeathMessage(const std::string& message, unsigned int clientID) const;
     65
     66            void dispatchAnnounceMessage(const std::string& message) const;
     67            void dispatchKillMessage(const std::string& message) const;
     68            void dispatchDeathMessage(const std::string& message) const;
     69
    6170        private:
    6271            bool bStarted_;
  • code/trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc

    r3067 r3099  
    7272    {
    7373        SUPER(CheckPoint, changedActivity);
    74        
     74
    7575        if (this->BaseObject::isActive())
    7676        {
     
    9393            this->setRadarVisibility(false);
    9494
    95             if (bIsTriggered && bIsFirst_)
     95            if (bIsTriggered)
    9696            {
    97                 gametype->setTimeLimit(addTime_);
    98                 gametype->firstCheckpointReached(true);
    99             }
     97                if (bIsFirst_)
     98                {
     99                    gametype->setTimeLimit(addTime_);
     100                    gametype->firstCheckpointReached(true);
     101                }
    100102
    101             if (bIsTriggered && bIsDestination_)
    102             {
    103                 gametype->end();
     103                if (bIsDestination_)
     104                {
     105                    const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage("Congratulations - you have won the match!");
     106                    gametype->end();
     107                }
     108
     109                if (!bIsFirst_ && !bIsDestination_)
     110                {
     111                    const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage("Checkpoint reached");
     112                }
    104113            }
    105114        }
  • code/trunk/src/orxonox/overlays/CMakeLists.txt

    r3089 r3099  
    33  OverlayGroup.cc
    44  OverlayText.cc
     5  FadeoutText.cc
    56  GUIOverlay.cc
    67)
  • code/trunk/src/orxonox/overlays/OverlayText.h

    r2662 r3099  
    4747        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
    4848
    49         inline void setCaption(const std::string& caption) { this->text_->setCaption(caption); }
     49        inline void setCaption(const std::string& caption) { this->text_->setCaption(caption); this->changedCaption(); }
    5050        inline std::string getCaption() const              { return this->text_->getCaption(); }
    5151
     
    5656        inline float getSpaceWidth() const     { return this->text_->getSpaceWidth(); }
    5757
    58         inline void setColour(const ColourValue& colour) { this->text_->setColour(colour); }
     58        inline void setColour(const ColourValue& colour) { this->text_->setColour(colour); this->changedColour(); }
    5959        inline const ColourValue& getColour() const      { return this->text_->getColour(); }
    6060
     
    7070    protected:
    7171        virtual void sizeChanged();
     72        virtual void changedColour() {}
     73        virtual void changedCaption() {}
    7274
    7375        Ogre::TextAreaOverlayElement* text_;
  • code/trunk/src/orxonox/overlays/hud/CMakeLists.txt

    r3033 r3099  
    88  ChatOverlay.cc
    99  GametypeStatus.cc
     10  AnnounceMessage.cc
     11  KillMessage.cc
     12  DeathMessage.cc
    1013  PongScore.cc
    1114)
Note: See TracChangeset for help on using the changeset viewer.