| 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 "objModel.h" |
|---|
| 24 | #include "projectile.h" |
|---|
| 25 | |
|---|
| 26 | using namespace std; |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | /** |
|---|
| 30 | \brief standard constructor |
|---|
| 31 | |
|---|
| 32 | creates a new weapon |
|---|
| 33 | */ |
|---|
| 34 | Weapon::Weapon () : WorldEntity() |
|---|
| 35 | {} |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | /** |
|---|
| 39 | \brief standard deconstructor |
|---|
| 40 | */ |
|---|
| 41 | Weapon::~Weapon () |
|---|
| 42 | { |
|---|
| 43 | // model will be deleted from WorldEntity-destructor |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | /** |
|---|
| 48 | \brief enables the weapon |
|---|
| 49 | |
|---|
| 50 | a weapon can be enabled/disabled because of various reasons. if a weapon is |
|---|
| 51 | been enabled, it can interact in a world. elswhere it wont react to any |
|---|
| 52 | action. |
|---|
| 53 | */ |
|---|
| 54 | void Weapon::enable() |
|---|
| 55 | { |
|---|
| 56 | this->enabled = true; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | /** |
|---|
| 61 | \brief disables the weapon |
|---|
| 62 | |
|---|
| 63 | a weapon can be enabled/disabled because of various reasons. if a weapon is |
|---|
| 64 | been enabled, it can interact in a world. elswhere it wont react to any |
|---|
| 65 | action. |
|---|
| 66 | */ |
|---|
| 67 | void Weapon::disable() |
|---|
| 68 | { |
|---|
| 69 | this->enabled = false; |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | /** |
|---|
| 74 | \brief checks if the weapon is enabled |
|---|
| 75 | \returns true if enabled |
|---|
| 76 | |
|---|
| 77 | a weapon can be ebabled/disabled because of various reasons. if a weapon is |
|---|
| 78 | been enabled, it can interact in a world. elswhere it wont react to any |
|---|
| 79 | action. |
|---|
| 80 | */ |
|---|
| 81 | bool Weapon::isEnabled() |
|---|
| 82 | { |
|---|
| 83 | return this->enabled; |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | /** |
|---|
| 88 | \brief sets a new projectile to the weapon |
|---|
| 89 | \param new projectile for this weapon |
|---|
| 90 | |
|---|
| 91 | weapon an projectile are independent, so you can combine them as you want |
|---|
| 92 | */ |
|---|
| 93 | void Weapon::setProjectile(Projectile* projectile) |
|---|
| 94 | { |
|---|
| 95 | this->projectile = projectile; |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | /** |
|---|
| 100 | \brief sets a new projectile to the weapon |
|---|
| 101 | \returns the current projectile of this weapon |
|---|
| 102 | |
|---|
| 103 | weapon an projectile are independent, so you can combine them as you want |
|---|
| 104 | */ |
|---|
| 105 | Projectile* Weapon::getProjectile() |
|---|
| 106 | { |
|---|
| 107 | return this->projectile; |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | /** |
|---|
| 112 | \brief this activates the weapon |
|---|
| 113 | |
|---|
| 114 | This is needed, since there can be more than one weapon on a ship. the |
|---|
| 115 | activation can be connected with an animation. for example the weapon is |
|---|
| 116 | been armed out. |
|---|
| 117 | */ |
|---|
| 118 | void Weapon::activate() |
|---|
| 119 | {} |
|---|
| 120 | |
|---|
| 121 | |
|---|
| 122 | /** |
|---|
| 123 | \brief this deactivates the weapon |
|---|
| 124 | |
|---|
| 125 | This is needed, since there can be more than one weapon on a ship. the |
|---|
| 126 | activation can be connected with an animation. for example the weapon is |
|---|
| 127 | been armed out. |
|---|
| 128 | */ |
|---|
| 129 | void Weapon::deactivate() |
|---|
| 130 | {} |
|---|
| 131 | |
|---|
| 132 | /** |
|---|
| 133 | \brief asks if the current weapon is active |
|---|
| 134 | \returns true if it the weapon is active |
|---|
| 135 | */ |
|---|
| 136 | bool Weapon::isActive() |
|---|
| 137 | {} |
|---|
| 138 | |
|---|
| 139 | /** |
|---|
| 140 | \brief sets a weapon idle time |
|---|
| 141 | \param idle time in ms |
|---|
| 142 | |
|---|
| 143 | a weapon idle time is the time spend after a shoot until the weapon can |
|---|
| 144 | shoot again |
|---|
| 145 | */ |
|---|
| 146 | void Weapon::setWeaponIdleTime(float time) |
|---|
| 147 | {} |
|---|
| 148 | |
|---|
| 149 | /** |
|---|
| 150 | \brief gets the weapon idle time |
|---|
| 151 | \returns idle time in ms |
|---|
| 152 | |
|---|
| 153 | a weapon idle time is the time spend after a shoot until the weapon can |
|---|
| 154 | shoot again |
|---|
| 155 | */ |
|---|
| 156 | float Weapon::getWeaponIdleTime(void) |
|---|
| 157 | {} |
|---|
| 158 | |
|---|
| 159 | /** |
|---|
| 160 | \brief checks if the idle time is elapsed |
|---|
| 161 | \return true if time is elapsed |
|---|
| 162 | |
|---|
| 163 | a weapon idle time is the time spend after a shoot until the weapon can |
|---|
| 164 | shoot again |
|---|
| 165 | */ |
|---|
| 166 | bool Weapon::hasWeaponIdleTimeElapsed(void) |
|---|
| 167 | {} |
|---|
| 168 | |
|---|
| 169 | |
|---|
| 170 | /** |
|---|
| 171 | \brief fires the weapon |
|---|
| 172 | |
|---|
| 173 | this is called from the player.cc, when fire-button is been pushed |
|---|
| 174 | */ |
|---|
| 175 | void Weapon::fire() |
|---|
| 176 | {} |
|---|
| 177 | |
|---|
| 178 | |
|---|
| 179 | /** |
|---|
| 180 | \brief is called, when the weapon gets hit (=collide with something) |
|---|
| 181 | \param from which entity it is been hit |
|---|
| 182 | \param where it is been hit |
|---|
| 183 | |
|---|
| 184 | this may not be used, since it would make the game relay complicated when one |
|---|
| 185 | can destroy the weapons of enemies or vice versa. |
|---|
| 186 | */ |
|---|
| 187 | void Weapon::hit (WorldEntity* entity, Vector* position) |
|---|
| 188 | {} |
|---|
| 189 | |
|---|
| 190 | |
|---|
| 191 | /** |
|---|
| 192 | \brief is called, when the weapon is destroyed |
|---|
| 193 | |
|---|
| 194 | this is in conjunction with the hit function, so when a weapon is able to get |
|---|
| 195 | hit, it can also be destoryed. |
|---|
| 196 | */ |
|---|
| 197 | void Weapon::destroy () |
|---|
| 198 | {} |
|---|
| 199 | |
|---|
| 200 | |
|---|
| 201 | /** |
|---|
| 202 | \brief tick signal for time dependent/driven stuff |
|---|
| 203 | */ |
|---|
| 204 | void Weapon::tick (float time) |
|---|
| 205 | {} |
|---|
| 206 | |
|---|
| 207 | |
|---|
| 208 | /** |
|---|
| 209 | \brief is called, when there is no fire button pressed |
|---|
| 210 | */ |
|---|
| 211 | void Weapon::weaponIdle() |
|---|
| 212 | {} |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | /** |
|---|
| 216 | \brief this will draw the weapon |
|---|
| 217 | */ |
|---|
| 218 | void Weapon::draw () |
|---|
| 219 | {} |
|---|
| 220 | |
|---|