Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/weapon2/src/orxonox/objects/weaponSystem/Munition.cc @ 2391

Last change on this file since 2391 was 2391, checked in by polakma, 15 years ago

fixed projectile, particle effect, reloadingTimer and magazineTimer

  • Property svn:eol-style set to native
File size: 2.9 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 *      Martin Polak
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "OrxonoxStableHeaders.h"
30
31#include "core/CoreIncludes.h"
32#include "core/XMLPort.h"
33#include "util/Debug.h"
34
35#include "Munition.h"
36
37namespace orxonox
38{
39    Munition::Munition(BaseObject* creator) : BaseObject(creator)
40    {
41        RegisterObject(Munition);
42    }
43
44    Munition::~Munition()
45    {
46    }
47
48    unsigned int Munition::bullets()
49    { 
50        if (this->bullets_ > 0)
51            return bullets_;
52        else
53            return 0;
54    }
55
56    unsigned int Munition::magazines()
57    { 
58        if (this->magazines_ > 0)
59            return magazines_;
60        else
61            return 0;
62    }
63
64    void Munition::setMaxBullets(unsigned int amount)
65    { this->maxBullets_ = amount; }
66
67    void Munition::setMaxMagazines(unsigned int amount)
68    { this->maxMagazines_ = amount; }
69
70    void Munition::removeBullets(unsigned int amount)
71    {
72        if ( this->bullets_ != 0 )
73            this->bullets_ = this->bullets_ - amount;
74    }
75
76    void Munition::removeMagazines(unsigned int amount)
77    {
78        if ( this->magazines_ != 0 )
79            this->magazines_ = this->magazines_ - amount;
80    }
81
82    void Munition::addBullets(unsigned int amount)
83    {
84        if ( this->bullets_ == this->maxBullets_ )
85        {
86            //cannot add bullets to actual magazine
87        }
88        else
89            this->bullets_ = this->bullets_ + amount;
90    }
91
92    void Munition::addMagazines(unsigned int amount)
93    {
94        if ( this->magazines_ == this->maxMagazines_ )
95        {
96            //no more capacity for another magazine
97        }
98        else
99            this->magazines_ = this->magazines_ + amount;
100    }
101
102
103    void Munition::fillBullets()
104    {
105COUT(0) << "Munition::fillBullets maxBullets_=" << this->maxBullets_ << std::endl;
106        this->bullets_ = this->maxBullets_;
107    }
108   
109    void Munition::fillMagazines()
110    {
111        this->magazines_ = this->maxMagazines_;
112    }
113   
114    void Munition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
115    {
116        SUPER(Munition, XMLPort, xmlelement, mode);
117    }
118
119}
Note: See TracBrowser for help on using the repository browser.