Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/playability/src/world_entities/weapons/light_blaster.cc @ 10049

Last change on this file since 10049 was 10046, checked in by nicolasc, 18 years ago

bump

File size: 2.8 KB
Line 
1#include "light_blaster.h"
2#include "world_entities/projectiles/projectile.h"
3
4#include "world_entity.h"
5#include "static_model.h"
6#include "weapon_manager.h"
7#include "util/loading/factory.h"
8
9#include "animation3d.h"
10
11#include "loading/fast_factory.h"
12
13CREATE_FACTORY(LightBlaster);
14/**
15 * Standard constructor
16 */
17LightBlaster::LightBlaster ()
18 : Weapon()
19{
20    this->init();
21}
22
23LightBlaster::LightBlaster (const TiXmlElement* root = NULL)
24 : Weapon()
25{
26    this->init();
27    if (root != NULL)
28      this->loadParams(root);
29}
30
31/**
32 * Default destructor
33 */
34LightBlaster::~LightBlaster()
35{
36      // model will be deleted from WorldEntity-destructor
37}
38
39void LightBlaster::loadParams(const TiXmlElement* root)
40{
41  Weapon::loadParams(root);
42}
43
44void LightBlaster::init()
45{
46
47  this->loadModel("models/guns/plasmadriver_#.obj", 1.0);
48 
49
50  this->setStateDuration(WS_SHOOTING, 0.05);  // 20 Schuss pro Sekunde
51  this->setStateDuration(WS_RELOADING, 0);
52  this->setStateDuration(WS_ACTIVATING, .5);
53  this->setStateDuration(WS_DEACTIVATING, 1);
54
55  this->setEnergyMax(500);
56  this->increaseEnergy(500);
57  //this->minCharge = 2;
58
59  this->setActionSound(WA_SHOOT, "sound/laser.wav");
60  this->setActionSound(WA_ACTIVATE, "sound/voices/lasers.wav");
61  this->setActionSound(WA_RELOAD, "sound/spawn/alien_generator.wav");
62
63  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_LIGHT);
64  //this->setProjectileTypeC("RailProjectile");   // FIXME temp project type until the blaste class exist
65  this->setProjectileTypeC("LBolt");   // Working; FIXME: add textures
66  this->prepareProjectiles(100);
67
68  Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this);
69  Animation3D* animation3 = this->getAnimation(WS_DEACTIVATING, this);
70
71  animation2->setInfinity(ANIM_INF_CONSTANT);
72  animation3->setInfinity(ANIM_INF_CONSTANT);
73
74  this->setEmissionPoint(3.8, 1.2, 0);
75
76  animation2->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
77  animation2->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL);
78
79  animation3->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL);
80  animation3->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
81}
82
83
84void LightBlaster::fire()
85{
86  Projectile* pj =  this->getProjectile();
87  if (pj == NULL)
88    return;
89
90  // set the owner
91  pj->setOwner(this->getOwner());
92
93  pj->setParent(PNode::getNullParent());
94
95//   pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5));
96  pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*180);
97
98  pj->setAbsCoor(this->getEmissionPoint());
99  pj->setAbsDir(this->getAbsDir());
100  pj->activate();
101}
102
103/**
104 *  this activates the weapon
105*/
106void LightBlaster::activate()
107{
108}
109
110/**
111 *  this deactivates the weapon
112*/
113void LightBlaster::deactivate()
114{
115}
116
117void LightBlaster::draw() const
118{
119}
Note: See TracBrowser for help on using the repository browser.