Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc @ 9348

Last change on this file since 9348 was 9348, checked in by landauf, 12 years ago

merged branch presentation2012merge back to trunk

  • Property svn:eol-style set to native
File size: 3.5 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "TeamDeathmatch.h"
30
31#include "core/CoreIncludes.h"
32#include "chat/ChatManager.h"
33#include "infos/PlayerInfo.h"
34#include "worldentities/pawns/Pawn.h"
35
36namespace orxonox
37{
38    CreateUnloadableFactory(TeamDeathmatch);
39
40    TeamDeathmatch::TeamDeathmatch(BaseObject* creator) : TeamGametype(creator)
41    {
42        RegisterObject(TeamDeathmatch);
43    }
44
45    void TeamDeathmatch::start()
46    {
47        TeamGametype::start();
48
49        std::string message("The match has started!");
50        ChatManager::message(message);
51    }
52
53    void TeamDeathmatch::end()
54    {
55        TeamGametype::end();
56
57        std::string message("The match has ended.");
58        ChatManager::message(message);
59    }
60
61    void TeamDeathmatch::playerEntered(PlayerInfo* player)
62    {
63        TeamGametype::playerEntered(player);
64
65        const std::string& message = player->getName() + " entered the game";
66        ChatManager::message(message);
67    }
68
69    bool TeamDeathmatch::playerLeft(PlayerInfo* player)
70    {
71        bool valid_player = TeamGametype::playerLeft(player);
72
73        if (valid_player)
74        {
75            const std::string& message = player->getName() + " left the game";
76            ChatManager::message(message);
77        }
78
79        return valid_player;
80    }
81    bool TeamDeathmatch::playerChangedName(PlayerInfo* player)
82    {
83        bool valid_player = TeamGametype::playerChangedName(player);
84
85        if (valid_player)
86        {
87            const std::string& message = player->getOldName() + " changed name to " + player->getName();
88            ChatManager::message(message);
89        }
90
91        return valid_player;
92    }
93
94    void TeamDeathmatch::pawnKilled(Pawn* victim, Pawn* killer)
95    {
96        if (victim && victim->getPlayer())
97        {
98            std::string message;
99            if (killer)
100            {
101                if (killer->getPlayer())
102                    message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
103                else
104                    message = victim->getPlayer()->getName() + " was killed";
105            }
106            else
107                message = victim->getPlayer()->getName() + " died";
108
109            ChatManager::message(message);
110        }
111
112        Gametype::pawnKilled(victim, killer);
113    }
114
115    void TeamDeathmatch::playerScored(PlayerInfo* player, int score)
116    {
117        TeamGametype::playerScored(player, score);
118
119        if (player)
120        {
121            const std::string& message = player->getName() + " scores!";
122            ChatManager::message(message);
123        }
124    }
125
126}
Note: See TracBrowser for help on using the repository browser.