Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/presentation/src/world_entities/weapons/light_blaster.cc @ 10771

Last change on this file since 10771 was 10771, checked in by nicolasc, 17 years ago

huge diff
cleaned the individual weapons, moved stuff to weapon.{cc,h}
and some minor fixes which popped up then and when

File size: 4.1 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004-2006 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific
12   main-programmer: Marc Schaerrer, Nicolas Schlumberger
13   co-programmer:
14
15*/
16
17#include "light_blaster.h"
18#include "world_entities/projectiles/projectile.h"
19
20#include "world_entity.h"
21#include "static_model.h"
22#include "weapon_manager.h"
23#include "util/loading/factory.h"
24
25#include "animation3d.h"
26
27#include "loading/fast_factory.h"
28
29#include "elements/glgui_energywidgetvertical.h"
30
31CREATE_FACTORY(LightBlaster);
32/**
33 * Standard constructor
34 */
35LightBlaster::LightBlaster ()
36 : Weapon()
37{
38    this->init();
39}
40
41LightBlaster::LightBlaster (const TiXmlElement* root = NULL)
42 : Weapon()
43{
44    this->init();
45    if (root != NULL)
46      this->loadParams(root);
47}
48
49/**
50 * Default destructor
51 */
52LightBlaster::~LightBlaster()
53{
54
55}
56
57void LightBlaster::loadParams(const TiXmlElement* root)
58{
59  Weapon::loadParams(root);
60}
61
62void LightBlaster::init()
63{
64
65  this->loadModel("models/guns/gatling.obj", 0.333);
66
67
68  this->setStateDuration(WS_SHOOTING, 0.05);  // 20 Schuss pro Sekunde
69  this->setStateDuration(WS_RELOADING, 0);
70  this->setStateDuration(WS_ACTIVATING, .5);
71  this->setStateDuration(WS_DEACTIVATING, 1);
72
73  this->setEnergyMax(500);
74  this->increaseEnergy(500);
75  //this->minCharge = 2;
76
77  this->setActionSound(WA_SHOOT, "sounds/guns/laser.wav");
78//   this->setActionSound(WA_ACTIVATE, "sounds/voices/lasers.wav");
79  this->setActionSound(WA_RELOAD, "sounds/spawn/alien_generator.wav");
80
81  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_LIGHT);
82  this->setProjectileTypeC("LBolt");
83  this->prepareProjectiles(25);
84
85  this->setBarrels(3);
86  this->setSegs(1); //could be left out
87
88  this->setEmissionPoint(Vector(2.2, 0.0, 0.1), 0);
89  this->setEmissionPoint(Vector(2.2, -0.07, -0.05), 1);
90  this->setEmissionPoint(Vector(2.2, 0.07, -0.05), 2);
91
92//   Animation3D* animation1 = this->getAnimation(WS_SHOOTING, this);
93  Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this);
94  Animation3D* animation3 = this->getAnimation(WS_DEACTIVATING, this);
95
96//   animation1->setInfinity(ANIM_INF_CONSTANT);
97  animation2->setInfinity(ANIM_INF_CONSTANT);
98  animation3->setInfinity(ANIM_INF_CONSTANT);
99
100
101  animation2->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
102  animation2->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL);
103
104  animation3->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL);
105  animation3->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
106}
107
108void LightBlaster::fire()
109{
110  Projectile* pj =  this->getProjectile();
111  if (pj == NULL)
112    return;
113
114  // set the owner
115  pj->setOwner(this->getOwner());
116
117  pj->setParent(PNode::getNullParent());
118
119//   pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5));
120  pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*180);
121
122  pj->setAbsCoor(this->getEmissionPoint());
123  pj->setAbsDir(this->getAbsDir());
124//   pj->toList(OM_GROUP_01_PROJ);
125  pj->activate();
126
127  this->cycleBarrel();
128}
129
130/**
131 *  this activates the weapon
132*/
133void LightBlaster::activate()
134{
135}
136
137/**
138 *  this deactivates the weapon
139*/
140void LightBlaster::deactivate()
141{
142}
143
144void LightBlaster::draw() const
145{
146  glMatrixMode(GL_MODELVIEW);
147  glPushMatrix();
148    glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
149    Vector tmpRot = this->getAbsDir().getSpacialAxis();
150    glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
151    static_cast<StaticModel*>(this->getModel())->draw();
152  glPopMatrix();
153
154}
155
156void LightBlaster::tick(float dt)
157{
158  if (!Weapon::tickW(dt))
159    return;
160  if (this->energyWidget != NULL && !this->isEnergyWidgetInitialized)
161  {
162    this->energyWidget->setDisplayedImage("textures/gui/gui_light_bolt.png");
163    this->setEnergyWidgetInitialized(true);
164  }
165}
Note: See TracBrowser for help on using the repository browser.