#include <airhammer.h>
Inheritance diagram for Airhammer:
Public Member Functions | |
Airhammer () | |
void | HandleKeyEvent (Action::Action_t action, Keyboard::Key_Event_t event_type) |
AirhammerConfig & | cfg () |
Protected Member Functions | |
void | p_Deselect () |
bool | p_Shoot () |
void | Refresh () |
Private Member Functions | |
void | RepeatShoot () |
Private Attributes | |
uint | m_last_jolt |
Surface | impact |
Definition at line 42 of file airhammer.h.
Airhammer::Airhammer | ( | ) |
Definition at line 44 of file airhammer.cpp.
00044 : Weapon(WEAPON_AIR_HAMMER,"airhammer",new AirhammerConfig()) 00045 { 00046 m_name = _("Airhammer"); 00047 override_keys = true ; 00048 00049 impact = resource_manager.LoadImage( weapons_res_profile, "airhammer_impact"); 00050 m_last_jolt = 0; 00051 }
Here is the call graph for this function:
AirhammerConfig & Airhammer::cfg | ( | ) |
void Airhammer::HandleKeyEvent | ( | Action::Action_t | action, | |
Keyboard::Key_Event_t | event_type | |||
) | [virtual] |
Reimplemented from Weapon.
Definition at line 139 of file airhammer.cpp.
00140 { 00141 switch (action) { 00142 00143 case Action::ACTION_SHOOT: 00144 00145 if (event_type == Keyboard::KEY_RELEASED || ActiveCharacter().GotInjured()) { 00146 // stop when key is released or character got injured 00147 ActiveTeam().AccessNbUnits() = 0; 00148 m_is_active = false; 00149 GameLoop::GetInstance()->SetState(GameLoop::HAS_PLAYED); 00150 } 00151 00152 if (event_type == Keyboard::KEY_REFRESH) 00153 RepeatShoot(); 00154 00155 break ; 00156 00157 default: 00158 break ; 00159 } 00160 00161 }
Here is the call graph for this function:
void Airhammer::p_Deselect | ( | ) | [protected, virtual] |
Reimplemented from Weapon.
Definition at line 55 of file airhammer.cpp.
00056 { 00057 m_is_active = false; 00058 }
bool Airhammer::p_Shoot | ( | ) | [protected, virtual] |
Implements Weapon.
Definition at line 62 of file airhammer.cpp.
00063 { 00064 jukebox.Play("share","weapon/airhammer"); 00065 00066 // initiate movement ;-) 00067 ActiveCharacter().SetRebounding(false); 00068 00069 // Little hack, so the character notices he is in the vaccum and begins to fall in the hole 00070 ActiveCharacter().SetXY( ActiveCharacter().GetPosition() ); 00071 00072 Point2i pos = Point2i(ActiveCharacter().GetX() + ActiveCharacter().GetWidth()/2 - impact.GetWidth()/2, 00073 ActiveCharacter().GetTestRect().GetPositionY() + 00074 ActiveCharacter().GetHeight() -15); 00075 00076 ParticleEngine::AddNow(pos + Point2i(impact.GetWidth()/4,9), 1, particle_AIR_HAMMER, 00077 true, -3.0 * M_PI_4, 5.0 + Time::GetInstance()->Read() % 5); 00078 ParticleEngine::AddNow(pos + Point2i(3*impact.GetWidth()/4,9), 1, particle_AIR_HAMMER, 00079 true, -M_PI_4, 5.0 + Time::GetInstance()->Read() % 5); 00080 world.Dig( pos, impact ); 00081 00082 uint range = 0; 00083 int x,y; // Testing coordinates 00084 bool end = false; 00085 do 00086 { 00087 // Did we have finished the computation 00088 range += 1; 00089 if (range > cfg().range) 00090 { 00091 range = cfg().range; 00092 end = true; 00093 } 00094 00095 // Compute point coordinates 00096 y = ActiveCharacter().GetHandPosition().y + range; 00097 x = ActiveCharacter().GetHandPosition().x; 00098 00099 FOR_ALL_LIVING_CHARACTERS(team, character) 00100 if (&(*character) != &ActiveCharacter()) 00101 { 00102 // Did we touch somebody ? 00103 if( character->ObjTouche(Point2i(x, y)) ) 00104 { 00105 // Apply damage (*ver).SetEnergyDelta (-cfg().damage); 00106 character->SetEnergyDelta(-cfg().damage); 00107 end = true; 00108 } 00109 } 00110 } while (!end); 00111 00112 return true; 00113 }
Here is the call graph for this function:
void Airhammer::Refresh | ( | ) | [protected, virtual] |
void Airhammer::RepeatShoot | ( | ) | [private] |
Definition at line 117 of file airhammer.cpp.
00118 { 00119 uint time = Time::GetInstance()->Read() - m_last_jolt; 00120 uint tmp = Time::GetInstance()->Read(); 00121 00122 if (time >= MIN_TIME_BETWEEN_JOLT) 00123 { 00124 m_is_active = false; 00125 NewActionShoot(); 00126 m_last_jolt = tmp; 00127 } 00128 00129 }
Here is the call graph for this function:
Here is the caller graph for this function:
Surface Airhammer::impact [private] |
Definition at line 46 of file airhammer.h.
uint Airhammer::m_last_jolt [private] |
Definition at line 45 of file airhammer.h.