Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/weapons/acid_launcher.cc @ 10536

Last change on this file since 10536 was 10516, checked in by patrick, 18 years ago

merged playability back to trunk

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