Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/resource2/src/orxonox/objects/weaponsystem/weaponmodes/EnergyDrink.cc @ 3373

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

Merged pch branch back to trunk.

  • Property svn:eol-style set to native
File size: 3.4 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 *      Hagen Seifert
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "EnergyDrink.h"
30
31#include "core/CoreIncludes.h"
32#include "core/Executor.h"
33#include "core/XMLPort.h"
34#include "objects/worldentities/Model.h"
35
36#include "objects/weaponsystem/projectiles/Projectile.h"
37#include "objects/weaponsystem/MuzzleFlash.h"
38#include "objects/weaponsystem/Weapon.h"
39#include "objects/weaponsystem/WeaponPack.h"
40#include "objects/weaponsystem/WeaponSystem.h"
41
42namespace orxonox
43{
44    CreateFactory(EnergyDrink);
45
46    EnergyDrink::EnergyDrink(BaseObject* creator) : WeaponMode(creator)
47    {
48        RegisterObject(EnergyDrink);
49
50        this->reloadTime_ = 0.25;
51        this->damage_ = 15;
52        this->speed_ = 2500;
53        this->delay_ = 0;
54        this->setMunitionName("FusionMunition");
55
56        this->delayTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&EnergyDrink::shot)));
57        this->delayTimer_.stopTimer();
58    }
59
60    void EnergyDrink::XMLPort(Element& xmlelement, XMLPort::Mode mode)
61    {
62        SUPER(EnergyDrink, XMLPort, xmlelement, mode);
63
64        XMLPortParam(EnergyDrink, "delay", setDelay, getDelay, xmlelement, mode);
65        XMLPortParam(EnergyDrink, "material", setMaterial, getMaterial, xmlelement, mode);
66
67    }
68
69    void EnergyDrink::setMaterial(const std::string& material)
70    {
71        this->material_ = material;
72    }
73
74    void EnergyDrink::setDelay(float d)
75    {
76        this->delay_ = d;
77        this->delayTimer_.setInterval(this->delay_);
78    }
79
80    float EnergyDrink::getDelay() const
81    {
82        return this->delay_;
83    }
84
85    void EnergyDrink::fire()
86    {
87        this->delayTimer_.startTimer();
88    }
89
90    void EnergyDrink::muendungsfeuer()
91    {
92        MuzzleFlash *muzzleFlash = new MuzzleFlash(this);
93        this->getWeapon()->attach(muzzleFlash);
94        muzzleFlash->setPosition(this->getMuzzleOffset());
95        muzzleFlash->setMaterial(this->material_);
96    }
97
98    void EnergyDrink::shot()
99    {
100        Projectile* projectile = new Projectile(this);
101        Model* model = new Model(projectile);
102        model->setMeshSource("can.mesh");
103        model->setCastShadows(false);
104        projectile->attach(model);
105        model->setScale(5);
106
107        projectile->setOrientation(this->getMuzzleOrientation());
108        projectile->setPosition(this->getMuzzlePosition());
109        projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
110
111        projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
112        projectile->setDamage(this->getDamage());
113
114        EnergyDrink::muendungsfeuer();
115    }
116}
Note: See TracBrowser for help on using the repository browser.