#include <jetpack.h>
Inheritance diagram for JetPack:
Public Member Functions | |
JetPack () | |
void | Reset () |
void | HandleKeyEvent (Action::Action_t action, Keyboard::Key_Event_t event_type) |
void | SignalTurnEnd () |
void | ActionStopUse () |
Protected Member Functions | |
void | Refresh () |
void | p_Select () |
void | p_Deselect () |
bool | p_Shoot () |
void | GoUp () |
void | GoLeft () |
void | GoRight () |
void | StopUp () |
void | StopLeft () |
void | StopRight () |
void | StartUse () |
void | StopUse () |
Private Attributes | |
double | m_x_force |
double | m_y_force |
int | channel |
uint | m_last_fuel_down |
Definition at line 27 of file jetpack.h.
JetPack::JetPack | ( | ) |
Definition at line 42 of file jetpack.cpp.
00042 : Weapon(WEAPON_JETPACK, "jetpack", 00043 new WeaponConfig(), 00044 NEVER_VISIBLE) 00045 { 00046 m_name = _("Jetpack"); 00047 m_unit_visibility = VISIBLE_ONLY_WHEN_ACTIVE; 00048 00049 override_keys = true ; 00050 use_unit_on_first_shoot = false; 00051 00052 m_x_force = 0.0; 00053 m_y_force = 0.0; 00054 channel = -1; 00055 }
void JetPack::ActionStopUse | ( | ) | [virtual] |
Reimplemented from Weapon.
Definition at line 230 of file jetpack.cpp.
00231 { 00232 p_Deselect(); 00233 }
Here is the call graph for this function:
void JetPack::GoLeft | ( | ) | [protected] |
Definition at line 149 of file jetpack.cpp.
00150 { 00151 StartUse(); 00152 m_x_force = - JETPACK_FORCE ; 00153 if(ActiveCharacter().GetDirection() == Body::DIRECTION_RIGHT) 00154 ActiveCharacter().SetDirection(Body::DIRECTION_LEFT); 00155 }
Here is the call graph for this function:
Here is the caller graph for this function:
void JetPack::GoRight | ( | ) | [protected] |
Definition at line 157 of file jetpack.cpp.
00158 { 00159 StartUse(); 00160 m_x_force = JETPACK_FORCE ; 00161 if(ActiveCharacter().GetDirection() == Body::DIRECTION_LEFT) 00162 ActiveCharacter().SetDirection(Body::DIRECTION_RIGHT); 00163 }
Here is the call graph for this function:
Here is the caller graph for this function:
void JetPack::GoUp | ( | ) | [protected] |
Definition at line 143 of file jetpack.cpp.
00144 { 00145 StartUse(); 00146 m_y_force = -(ActiveCharacter().GetMass() * GameMode::GetInstance()->gravity + JETPACK_FORCE) ; 00147 }
Here is the call graph for this function:
Here is the caller graph for this function:
void JetPack::HandleKeyEvent | ( | Action::Action_t | action, | |
Keyboard::Key_Event_t | event_type | |||
) | [virtual] |
Reimplemented from Weapon.
Definition at line 183 of file jetpack.cpp.
00184 { 00185 switch (action) { 00186 case Action::ACTION_UP: 00187 if (event_type == Keyboard::KEY_PRESSED) 00188 GoUp(); 00189 else if (event_type == Keyboard::KEY_RELEASED) 00190 StopUp(); 00191 break ; 00192 00193 case Action::ACTION_MOVE_LEFT: 00194 if (event_type == Keyboard::KEY_PRESSED) 00195 GoLeft(); 00196 else if (event_type == Keyboard::KEY_RELEASED) 00197 StopLeft(); 00198 break ; 00199 00200 case Action::ACTION_MOVE_RIGHT: 00201 if (event_type == Keyboard::KEY_PRESSED) 00202 GoRight(); 00203 else if (event_type == Keyboard::KEY_RELEASED) 00204 StopRight(); 00205 break ; 00206 00207 case Action::ACTION_SHOOT: 00208 if (event_type == Keyboard::KEY_PRESSED) 00209 ActionHandler::GetInstance()->NewAction(new Action(Action::ACTION_WEAPON_STOP_USE)); 00210 break ; 00211 00212 default: 00213 break ; 00214 } ; 00215 }
Here is the call graph for this function:
void JetPack::p_Deselect | ( | ) | [protected, virtual] |
Reimplemented from Weapon.
Definition at line 105 of file jetpack.cpp.
00106 { 00107 m_is_active = false; 00108 m_x_force = 0; 00109 m_y_force = 0; 00110 ActiveCharacter().SetExternForce(0,0); 00111 StopUse(); 00112 camera.SetCloseFollowing(false); 00113 ActiveCharacter().SetClothe("normal"); 00114 ActiveCharacter().SetMovement("walk"); 00115 }
Here is the call graph for this function:
Here is the caller graph for this function:
void JetPack::p_Select | ( | ) | [protected, virtual] |
Reimplemented from Weapon.
Definition at line 100 of file jetpack.cpp.
00101 { 00102 ActiveCharacter().SetClothe("jetpack"); 00103 }
Here is the call graph for this function:
bool JetPack::p_Shoot | ( | ) | [protected, virtual] |
Implements Weapon.
Definition at line 217 of file jetpack.cpp.
00218 { 00219 m_is_active = true; 00220 ActiveCharacter().SetClothe("jetpack-fire"); 00221 00222 return true; 00223 }
Here is the call graph for this function:
void JetPack::Refresh | ( | ) | [protected, virtual] |
Implements Weapon.
Definition at line 57 of file jetpack.cpp.
00058 { 00059 if(!ActiveTeam().IsLocal()) 00060 return; 00061 00062 Point2d F; 00063 00064 if (m_is_active) 00065 { 00066 F.x = m_x_force ; 00067 F.y = m_y_force ; 00068 00069 ActiveCharacter().SetExternForceXY(F); 00070 ActiveCharacter().UpdatePosition(); 00071 SendCharacterPosition(); 00072 Action a(Action::ACTION_SET_CHARACTER_PHYSICS); 00073 a.StoreActiveCharacter(); 00074 network.SendAction(&a); 00075 00076 if( !F.IsNull() ) 00077 { 00078 // We are using fuel !!! 00079 uint current = Time::GetInstance()->Read() ; 00080 double delta = (double)(current - m_last_fuel_down); 00081 00082 while (delta >= DELTA_FUEL_DOWN) 00083 { 00084 if (EnoughAmmoUnit()) 00085 { 00086 UseAmmoUnit(); 00087 m_last_fuel_down += DELTA_FUEL_DOWN ; 00088 delta -= DELTA_FUEL_DOWN ; 00089 } 00090 else 00091 { 00092 p_Deselect(); 00093 break; 00094 } 00095 } 00096 } 00097 } 00098 }
Here is the call graph for this function:
void JetPack::Reset | ( | ) |
void JetPack::SignalTurnEnd | ( | ) | [virtual] |
Reimplemented from Weapon.
Definition at line 225 of file jetpack.cpp.
00226 { 00227 p_Deselect(); 00228 }
Here is the call graph for this function:
void JetPack::StartUse | ( | ) | [protected] |
Definition at line 117 of file jetpack.cpp.
00118 { 00119 ActiveCharacter().SetMovement("jetpack-fire"); 00120 if ( (m_x_force == 0) && (m_y_force == 0)) 00121 { 00122 m_last_fuel_down = Time::GetInstance()->Read(); 00123 channel = jukebox.Play(ActiveTeam().GetSoundProfile(),"weapon/jetpack", -1); 00124 00125 camera.FollowObject (&ActiveCharacter(),true, true, true); 00126 camera.SetCloseFollowing(true); 00127 // bool suit, bool recentre, 00128 // bool force_recentrage=false); 00129 } 00130 }
Here is the call graph for this function:
Here is the caller graph for this function:
void JetPack::StopLeft | ( | ) | [protected] |
Definition at line 171 of file jetpack.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
void JetPack::StopRight | ( | ) | [protected] |
Definition at line 177 of file jetpack.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
void JetPack::StopUp | ( | ) | [protected] |
Definition at line 165 of file jetpack.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
void JetPack::StopUse | ( | ) | [protected] |
Definition at line 132 of file jetpack.cpp.
00133 { 00134 ActiveCharacter().SetMovement("jetpack-nofire"); 00135 if (m_x_force == 0.0 && m_y_force == 0.0) 00136 { 00137 if(channel != -1) 00138 jukebox.Stop(channel); 00139 channel = -1; 00140 } 00141 }
Here is the call graph for this function:
Here is the caller graph for this function:
int JetPack::channel [private] |
uint JetPack::m_last_fuel_down [private] |
double JetPack::m_x_force [private] |
double JetPack::m_y_force [private] |