Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 2357 was 2232, checked in by polakma, 16 years ago

added new features to munition.h and weapon.h. tried to fix projectiles (still doesn't compile)

  • Property svn:eol-style set to native
File size: 3.0 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::getBullets()
49    { return this->bullets_; }
50
51    unsigned int Munition::getMagazines()
52    { return this->magazines_; }
53
54    void Munition::setMaxBullets(unsigned int amount)
55    { this->maxBullets_ = amount; }
56
57    void Munition::setMaxMagazines(unsigned int amount)
58    { this->maxMagazines_ = amount; }
59
60    void Munition::removeBullets(unsigned int amount, Weapon * parentWeapon)
61    {
62        //if actual magazine is empty, decrement it and set the bullets amount to full (masBullets_)
63        if ( this->bullets_ == 0 )
64        {
65            this->removeMagazines(1);
66            parentWeapon->magazineTimer();
67            this->bullets_ = this->maxBullets_;
68        }
69        else
70            this->bullets_ = this->bullets_ - amount;
71    }
72
73    void Munition::removeMagazines(unsigned int amount)
74    {
75        if ( this->magazines_ == 0 )
76        {
77            if ( this->bullets_ == 0 )
78                {
79                    //no bullets and no magazines
80                }
81            else
82            {
83                //what to do when there are no more magazines?
84            }
85        }
86        else
87            this->magazines_ = this->magazines_ - amount; }
88
89    void Munition::addBullets(unsigned int amount)
90    {
91        if ( this->bullets_ == this->maxBullets_ )
92        {
93            //cannot add bullets to actual magazine
94        }
95        else
96            this->bullets_ = this->bullets_ + amount;
97    }
98
99    void Munition::addMagazines(unsigned int amount)
100    {
101        if ( this->magazines_ == this->maxMagazines_ )
102        {
103            //no more capacity for another magazine
104        }
105        else
106            this->magazines_ = this->magazines_ + amount;
107    }
108
109
110    void Munition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
111    {
112
113    }
114
115}
Note: See TracBrowser for help on using the repository browser.