Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pch/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.cc @ 3114

Last change on this file since 3114 was 3110, checked in by rgrieder, 16 years ago

Removed old msvc specific support for precompiled header files.

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