Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc @ 2272

Last change on this file since 2272 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.9 KB
RevLine 
[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 "Weapon.h"
36
[2049]37namespace orxonox
38{
[2097]39    Weapon::Weapon(BaseObject* creator) : BaseObject(creator)
[2049]40    {
41        RegisterObject(Weapon);
[2232]42        this->bulletReadyToShoot_ = true;
43        this->magazineReadyToShoot_ = true;
[2186]44        this->setParentWeaponSystem();
[2049]45    }
46
47    Weapon::~Weapon()
48    {
49    }
[2096]50
[2145]51
52    void Weapon::XMLPort(Element& xmlelement, XMLPort::Mode mode)
[2096]53    {
[2232]54        SUPER(Weapon, XMLPort, xmlelement, mode);
[2049]55    }
[2096]56
[2145]57    void Weapon::fire()
[2096]58    {
59
60    }
[2232]61
62
63    void Weapon::bulletTimer()
[2203]64    {
[2232]65        this->bulletReloadTimer_.setTimer( this->bulletLoadingTime_ , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded)));
[2203]66    }
[2232]67    void Weapon::magazineTimer()
[2097]68    {
[2232]69        this->magazineReloadTimer_.setTimer( this->magazineLoadingTime_ , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded)));
[2145]70    }
[2097]71
[2232]72    void Weapon::bulletReloaded()
73    { this->bulletReadyToShoot_ = true; }
74
75    void Weapon::magazineReloaded()
76    { this->magazineReadyToShoot_ = true; }
77
78
[2203]79    void Weapon::attachNeededMunition(std::string munitionName)
[2145]80    {
[2232]81        //if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem
[2203]82        if ( this->parentWeaponSystem_->getMunitionType(munitionName) )
83            this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionName);
[2186]84        else
85        {
[2203]86            //create new munition with identifier
87            this->munitionIdentifier_ = ClassByString(munitionName);
88            this->munition_ = this->munitionIdentifier_.fabricate(this);
89            this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_);
[2186]90        }
[2097]91    }
[2186]92
[2203]93
94    /*get and set functions
95     *
96     */
[2145]97    void Weapon::setParentWeaponSystem()
[2203]98    {   this->parentWeaponSystem_ = this->parentWeaponSlot_->getParentWeaponSet()->getParentWeaponSystem(); }
[2145]99
[2203]100    Munition * Weapon::getAttachedMunition()
101    {   return this->munition_; }
102
[2232]103    void Weapon::setBulletLoadingTime(float loadingTime)
104    {   this->bulletLoadingTime_ = loadingTime;   }
[2203]105
[2232]106    float Weapon::getBulletLoadingTime()
107    {   return this->bulletLoadingTime_;  }
[2203]108
[2232]109    void Weapon::setMagazineLoadingTime(float loadingTime)
110    {   this->magazineLoadingTime_ = loadingTime;   }
[2203]111
[2232]112    float Weapon::getMagazineLoadingTime()
113    {   return this->magazineLoadingTime_;  }
114
115    void Weapon::setBulletReadyToShoot(bool b)
116    {   this->bulletReadyToShoot_ = b;   }
117
118    bool Weapon::getBulletReadyToShoot()
119    {   return this->bulletReadyToShoot_;    }
120
121    void Weapon::setMagazineReadyToShoot(bool b)
122    {   this->magazineReadyToShoot_ = b;   }
123
124    bool Weapon::getMagazineReadyToShoot()
125    {   return this->magazineReadyToShoot_;    }
126
127    Timer<Weapon> * Weapon::getBulletTimer()
128    {   return &this->bulletReloadTimer_;   }
129
130    Timer<Weapon> * Weapon::getMagazineTimer()
131    {   return &this->magazineReloadTimer_;   }
[2096]132}
Note: See TracBrowser for help on using the repository browser.