Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/world_entities/weapon.cc @ 3710

Last change on this file since 3710 was 3685, checked in by patrick, 20 years ago

orxonox/trunk: fixed a gc issue and implemented firing-frequency. still got some speed problems…

File size: 4.6 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific
14   main-programmer: Patrick Boenzli
15   co-programmer:
16*/
17
18
19#include "weapon.h"
20#include "stdincl.h"
21#include "world_entity.h"
22#include "vector.h"
23#include "model.h"
24#include "projectile.h"
25#include "list.h"
26#include "world.h"
27
28using namespace std;
29
30
31/**
32   \brief standard constructor
33
34   creates a new weapon
35*/
36Weapon::Weapon (PNode* parent, Vector* coordinate, Quaternion* direction) 
37  : WorldEntity()
38{
39  parent->addChild(this, PNODE_ROTATE_AND_MOVE);
40  this->setRelCoor(coordinate);
41  this->setRelDir(direction);
42  WorldInterface* wi = WorldInterface::getInstance();
43  this->worldEntities = wi->getEntityList();
44}
45
46
47/**
48   \brief standard deconstructor
49*/
50Weapon::~Weapon () 
51{
52  // model will be deleted from WorldEntity-destructor
53}
54
55
56/**
57    \brief enables the weapon
58
59    a weapon can be enabled/disabled because of various reasons. if a weapon is
60    been enabled, it can interact in a world. elswhere it wont react to any
61    action.
62*/
63void Weapon::enable()
64{
65  this->enabled = true;
66}
67
68
69/**
70    \brief disables the weapon
71
72    a weapon can be enabled/disabled because of various reasons. if a weapon is
73    been enabled, it can interact in a world. elswhere it wont react to any
74    action.
75*/
76void Weapon::disable()
77{
78  this->enabled = false;
79}
80
81
82/**
83    \brief checks if the weapon is enabled
84    \returns true if enabled
85
86    a weapon can be ebabled/disabled because of various reasons. if a weapon is
87    been enabled, it can interact in a world. elswhere it wont react to any
88    action.
89*/
90bool Weapon::isEnabled()
91{
92  return this->enabled;
93}
94
95
96/**
97   \brief sets a new projectile to the weapon
98   \param new projectile for this weapon
99
100   weapon an projectile are independent, so you can combine them as you want
101*/
102void Weapon::setProjectile(Projectile* projectile)
103{
104  this->projectile = projectile;
105}
106
107
108/**
109   \brief sets a new projectile to the weapon
110   \returns the current projectile of this weapon
111
112   weapon an projectile are independent, so you can combine them as you want
113*/
114Projectile* Weapon::getProjectile()
115{
116  return this->projectile;
117}
118
119
120/**
121   \brief this activates the weapon
122
123   This is needed, since there can be more than one weapon on a ship. the
124   activation can be connected with an animation. for example the weapon is
125   been armed out.
126*/
127void Weapon::activate()
128{}
129
130
131/**
132   \brief this deactivates the weapon
133
134   This is needed, since there can be more than one weapon on a ship. the
135   activation can be connected with an animation. for example the weapon is
136   been armed out.
137*/
138void Weapon::deactivate()
139{}
140
141/**
142   \brief asks if the current weapon is active
143   \returns true if it the weapon is active
144*/
145bool Weapon::isActive()
146{}
147
148/**
149   \brief sets a weapon idle time
150   \param idle time in ms
151
152   a weapon idle time is the time spend after a shoot until the weapon can
153   shoot again
154*/
155void Weapon::setWeaponIdleTime(float time)
156{
157  this->idleTime = time;
158}
159
160/**
161   \brief gets the weapon idle time
162   \returns idle time in ms
163
164   a weapon idle time is the time spend after a shoot until the weapon can
165   shoot again
166*/
167float Weapon::getWeaponIdleTime(void)
168{
169  return this->idleTime;
170}
171
172/**
173   \brief checks if the idle time is elapsed
174   \return true if time is elapsed
175
176   a weapon idle time is the time spend after a shoot until the weapon can
177   shoot again
178*/
179bool Weapon::hasWeaponIdleTimeElapsed(void)
180{
181  return (this->localTime>this->idleTime)?true:false;
182}
183
184
185/**
186   \brief fires the weapon
187   
188   this is called from the player.cc, when fire-button is been pushed
189*/
190void Weapon::fire()
191{}
192
193
194/**
195   \brief is called, when the weapon gets hit (=collide with something)
196   \param from which entity it is been hit
197   \param where it is been hit
198
199   this may not be used, since it would make the game relay complicated when one
200   can destroy the weapons of enemies or vice versa.
201*/
202void Weapon::hit (WorldEntity* entity, Vector* position) 
203{}
204
205
206/**
207   \brief is called, when the weapon is destroyed
208
209   this is in conjunction with the hit function, so when a weapon is able to get
210   hit, it can also be destoryed.
211*/
212void Weapon::destroy () 
213{}
214
215
216/**
217   \brief tick signal for time dependent/driven stuff
218*/
219void Weapon::tick (float time) 
220{}
221
222
223/**
224   \brief is called, when there is no fire button pressed
225*/
226void Weapon::weaponIdle()
227{}
228
229
230/**
231   \brief this will draw the weapon
232*/
233void Weapon::draw () 
234{}
235
Note: See TracBrowser for help on using the repository browser.