[2049] | 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 | |
---|
[2096] | 35 | #include "Munition.h" |
---|
| 36 | |
---|
[2049] | 37 | namespace orxonox |
---|
| 38 | { |
---|
[2410] | 39 | CreateFactory(Munition); |
---|
| 40 | |
---|
[2097] | 41 | Munition::Munition(BaseObject* creator) : BaseObject(creator) |
---|
[2049] | 42 | { |
---|
| 43 | RegisterObject(Munition); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | Munition::~Munition() |
---|
| 47 | { |
---|
| 48 | } |
---|
| 49 | |
---|
[2391] | 50 | unsigned int Munition::bullets() |
---|
[2410] | 51 | { |
---|
[2379] | 52 | if (this->bullets_ > 0) |
---|
[2391] | 53 | return bullets_; |
---|
[2379] | 54 | else |
---|
[2391] | 55 | return 0; |
---|
[2379] | 56 | } |
---|
[2203] | 57 | |
---|
[2391] | 58 | unsigned int Munition::magazines() |
---|
[2410] | 59 | { |
---|
[2379] | 60 | if (this->magazines_ > 0) |
---|
[2391] | 61 | return magazines_; |
---|
[2379] | 62 | else |
---|
[2391] | 63 | return 0; |
---|
[2379] | 64 | } |
---|
[2232] | 65 | |
---|
| 66 | void Munition::setMaxBullets(unsigned int amount) |
---|
| 67 | { this->maxBullets_ = amount; } |
---|
| 68 | |
---|
| 69 | void Munition::setMaxMagazines(unsigned int amount) |
---|
| 70 | { this->maxMagazines_ = amount; } |
---|
| 71 | |
---|
[2391] | 72 | void Munition::removeBullets(unsigned int amount) |
---|
[2203] | 73 | { |
---|
[2391] | 74 | if ( this->bullets_ != 0 ) |
---|
[2232] | 75 | this->bullets_ = this->bullets_ - amount; |
---|
[2203] | 76 | } |
---|
[2232] | 77 | |
---|
| 78 | void Munition::removeMagazines(unsigned int amount) |
---|
[2203] | 79 | { |
---|
[2391] | 80 | if ( this->magazines_ != 0 ) |
---|
[2379] | 81 | this->magazines_ = this->magazines_ - amount; |
---|
| 82 | } |
---|
[2232] | 83 | |
---|
| 84 | void Munition::addBullets(unsigned int amount) |
---|
[2203] | 85 | { |
---|
[2232] | 86 | if ( this->bullets_ == this->maxBullets_ ) |
---|
| 87 | { |
---|
| 88 | //cannot add bullets to actual magazine |
---|
| 89 | } |
---|
| 90 | else |
---|
| 91 | this->bullets_ = this->bullets_ + amount; |
---|
[2203] | 92 | } |
---|
[2232] | 93 | |
---|
| 94 | void Munition::addMagazines(unsigned int amount) |
---|
[2203] | 95 | { |
---|
[2232] | 96 | if ( this->magazines_ == this->maxMagazines_ ) |
---|
| 97 | { |
---|
| 98 | //no more capacity for another magazine |
---|
| 99 | } |
---|
| 100 | else |
---|
| 101 | this->magazines_ = this->magazines_ + amount; |
---|
[2203] | 102 | } |
---|
| 103 | |
---|
| 104 | |
---|
[2379] | 105 | void Munition::fillBullets() |
---|
| 106 | { |
---|
[2391] | 107 | COUT(0) << "Munition::fillBullets maxBullets_=" << this->maxBullets_ << std::endl; |
---|
[2379] | 108 | this->bullets_ = this->maxBullets_; |
---|
| 109 | } |
---|
[2410] | 110 | |
---|
[2379] | 111 | void Munition::fillMagazines() |
---|
| 112 | { |
---|
| 113 | this->magazines_ = this->maxMagazines_; |
---|
| 114 | } |
---|
[2410] | 115 | |
---|
[2096] | 116 | void Munition::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 117 | { |
---|
[2391] | 118 | SUPER(Munition, XMLPort, xmlelement, mode); |
---|
[2096] | 119 | } |
---|
| 120 | |
---|
| 121 | } |
---|