Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pch/src/orxonox/objects/gametypes/Deathmatch.cc @ 3179

Last change on this file since 3179 was 3179, checked in by rgrieder, 15 years ago

Cleanup in gametypes, infos and items

  • Property svn:eol-style set to native
File size: 3.6 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 "Deathmatch.h"
30
31#include "util/Debug.h"
32#include "core/CoreIncludes.h"
33#include "network/Host.h"
34#include "objects/infos/PlayerInfo.h"
35#include "objects/worldentities/pawns/Pawn.h"
36
37namespace orxonox
38{
39    CreateUnloadableFactory(Deathmatch);
40
41    Deathmatch::Deathmatch(BaseObject* creator) : Gametype(creator)
42    {
43        RegisterObject(Deathmatch);
44    }
45
46    void Deathmatch::start()
47    {
48        Gametype::start();
49
50        std::string message = "The match has started!";
51        COUT(0) << message << std::endl;
52        Host::Broadcast(message);
53    }
54
55    void Deathmatch::end()
56    {
57        Gametype::end();
58
59        std::string message = "The match has ended.";
60        COUT(0) << message << std::endl;
61        Host::Broadcast(message);
62    }
63
64    void Deathmatch::playerEntered(PlayerInfo* player)
65    {
66        Gametype::playerEntered(player);
67
68        std::string message = player->getName() + " entered the game";
69        COUT(0) << message << std::endl;
70        Host::Broadcast(message);
71    }
72
73    bool Deathmatch::playerLeft(PlayerInfo* player)
74    {
75        bool valid_player = Gametype::playerLeft(player);
76
77        if (valid_player)
78        {
79            std::string message = player->getName() + " left the game";
80            COUT(0) << message << std::endl;
81            Host::Broadcast(message);
82        }
83
84        return valid_player;
85    }
86
87    bool Deathmatch::playerChangedName(PlayerInfo* player)
88    {
89        bool valid_player = Gametype::playerChangedName(player);
90
91        if (valid_player)
92        {
93            std::string message = player->getOldName() + " changed name to " + player->getName();
94            COUT(0) << message << std::endl;
95            Host::Broadcast(message);
96        }
97
98        return valid_player;
99    }
100
101    void Deathmatch::pawnKilled(Pawn* victim, Pawn* killer)
102    {
103        if (victim && victim->getPlayer())
104        {
105            std::string message;
106            if (killer)
107            {
108                if (killer->getPlayer())
109                    message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
110                else
111                    message = victim->getPlayer()->getName() + " was killed";
112            }
113            else
114                message = victim->getPlayer()->getName() + " died";
115
116            COUT(0) << message << std::endl;
117            Host::Broadcast(message);
118        }
119
120        Gametype::pawnKilled(victim, killer);
121    }
122
123    void Deathmatch::playerScored(PlayerInfo* player)
124    {
125        Gametype::playerScored(player);
126
127        if (player)
128        {
129            std::string message = player->getName() + " scores!";
130            COUT(0) << message << std::endl;
131            Host::Broadcast(message);
132        }
133    }
134}
Note: See TracBrowser for help on using the repository browser.