Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/steering/src/modules/weapons/weaponmodes/HsW01.cc @ 6045

Last change on this file since 6045 was 6045, checked in by wirthmi, 15 years ago

First implementation of direction shooting.

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