Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/cleanup/src/world_entities/weapons/acid_launcher.cc @ 10579

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

fixed some headers
commeted none existing sounds, to remove warnings

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
13   co-programmer:
14*/
15//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
16
17#include "acid_launcher.h"
18
19#include "weapon_manager.h"
20#include "world_entities/projectiles/acid_splash.h"
21
22#include "model.h"
23
24#include "state.h"
25#include "animation3d.h"
26
27#include <list>
28#include <iterator>
29#include "util/state.h"
30
31#include "util/loading/factory.h"
32
33#include "elements/glgui_energywidgetvertical.h"
34
35
36
37using namespace std;
38
39ObjectListDefinition(AcidLauncher);
40CREATE_FACTORY(AcidLauncher);
41
42/**
43 *  standard constructor
44 *
45 * creates a new AcidLauncher
46 */
47AcidLauncher::AcidLauncher()
48  : Weapon()
49{
50  this->init();
51}
52
53/**
54 * creates a new AcidLauncher from a TiXmlElement
55 */
56AcidLauncher::AcidLauncher(const TiXmlElement* root)
57{
58  this->init();
59  if (root != NULL)
60    this->loadParams(root);
61}
62
63/**
64 *  standard deconstructor
65*/
66AcidLauncher::~AcidLauncher ()
67{
68  // model will be deleted from WorldEntity-destructor
69}
70
71void AcidLauncher::init()
72{
73  this->registerObject(this, AcidLauncher::_objectList);
74/*
75  Animation3D* animation1 = this->getAnimation(WS_ACTIVATING, this);
76  Animation3D* animation2 = this->getAnimation(WS_DEACTIVATING, this);
77
78  animation1->addKeyFrame(Vector(0, -.5, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
79  animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
80  animation2->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
81  animation2->addKeyFrame(Vector(0, -.5, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
82
83  animation1->setInfinity(ANIM_INF_CONSTANT);
84  animation2->setInfinity(ANIM_INF_CONSTANT);
85*/
86  this->setStateDuration(WS_SHOOTING, 1.0f);
87
88  this->setStateDuration(WS_RELOADING, 1.0f);
89  this->setStateDuration(WS_ACTIVATING, .4);
90  this->setStateDuration(WS_DEACTIVATING, .4);
91
92  this->setEnergyMax(100);
93  this->increaseEnergy(100);
94  //this->minCharge = 2;
95
96  this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET | WTYPE_DIRECTIONAL | WTYPE_LIGHT);
97  this->setProjectileTypeC("AcidSplash");
98//   this->loadModel("models/guns/turret1.obj", 1.0);
99
100  this->setEmissionPoint(2.0, 0, 0);
101  this->getProjectileFactory()->prepare(10);
102
103  this->setActionSound(WA_SHOOT, "sounds/explosions/explosion_1.wav");
104  this->setActionSound(WA_ACTIVATE, "sounds/voices/rockets.wav");
105//   this->setActionSound(WA_RELOAD, "sounds/voices/reload.wav");
106
107}
108
109void AcidLauncher::loadParams(const TiXmlElement* root)
110{
111  Weapon::loadParams(root);
112}
113
114void AcidLauncher::activate()
115{
116}
117
118void AcidLauncher::deactivate()
119{
120}
121
122void AcidLauncher::tick(float dt)
123{
124  if (!Weapon::tickW(dt))
125    return;
126  if (this->energyWidget != NULL && !this->isEnergyWidgetInitialized)
127  {
128    this->energyWidget->setDisplayedImage("textures/gui/gui_acid.png");
129    this->isEnergyWidgetInitialized = true;
130  }
131
132
133  /*
134  Quaternion quat;
135  Vector direction;
136  if (this->getDefaultTarget() == NULL)
137    direction = this->getAbsCoor();
138  else
139    direction = this->getDefaultTarget()->getAbsCoor() - this->getAbsCoor();
140
141  direction.normalize();
142
143  if (likely (this->getParent() != NULL))
144    quat = Quaternion(direction, this->getParent()->getAbsDir().apply(Vector(0,1,0))) * Quaternion ( -M_PI_2, Vector(0,1,0)) ;
145  else
146    quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ;
147
148  this->setAbsDirSoft(quat, 5);
149  */
150}
151
152void AcidLauncher::fire()
153{
154  bool fired  = false;
155
156  Projectile* pj = NULL;
157  for( int i=0; i < 1; i++)
158  {
159      pj  = this->getProjectile();
160      if (pj == NULL)
161        return;
162
163      fired = true;
164      pj->setVelocity(this->getVelocity()+(this->getAbsDir().apply(Vector(1,0,0))*165.0 + VECTOR_RAND(10)));
165
166      pj->setParent(PNode::getNullParent());
167      pj->setAbsCoor(this->getEmissionPoint() + VECTOR_RAND(.1));
168      pj->setAbsDir(this->getAbsDir()+Quaternion(0,VECTOR_RAND(5)));
169      pj->activate();
170  }
171}
Note: See TracBrowser for help on using the repository browser.