#include <mine.h>
Inheritance diagram for ObjMine:
Public Member Functions | |
ObjMine (MineConfig &cfg, WeaponLauncher *p_launcher=NULL) | |
void | StartTimeout () |
void | Detection () |
virtual bool | IsImmobile () const |
void | Draw () |
void | Refresh () |
Protected Member Functions | |
void | FakeExplosion () |
Private Attributes | |
int | channel |
bool | fake |
bool | is_active |
bool | animation |
uint | attente |
uint | escape_time |
Definition at line 36 of file mine.h.
ObjMine::ObjMine | ( | MineConfig & | cfg, | |
WeaponLauncher * | p_launcher = NULL | |||
) |
Definition at line 47 of file mine.cpp.
00048 : 00049 WeaponProjectile("mine", cfg, p_launcher) 00050 { 00051 m_allow_negative_y = true; 00052 animation = false; 00053 channel = -1; 00054 is_active = true; 00055 explode_with_collision = false; 00056 00057 escape_time = 0; 00058 00059 // is it a fake mine ? 00060 fake = !(randomSync.GetLong(0, 9)); 00061 }
Here is the call graph for this function:
void ObjMine::Detection | ( | ) |
Definition at line 95 of file mine.cpp.
00096 { 00097 uint current_time = Time::GetInstance()->ReadSec(); 00098 00099 if (escape_time == 0) 00100 { 00101 escape_time = current_time + static_cast<MineConfig&>(cfg).escape_time; 00102 MSG_DEBUG("mine", "Initialize escape_time : %d", current_time); 00103 return; 00104 } 00105 00106 if (current_time < escape_time) return; 00107 00108 MSG_DEBUG("mine", "Escape_time is finished : %d", current_time); 00109 00110 FOR_ALL_LIVING_CHARACTERS(equipe, ver) 00111 { 00112 if (MeterDistance (GetCenter(), ver->GetCenter()) < static_cast<MineConfig&>(cfg).detection_range 00113 && !animation) 00114 { 00115 std::string txt = Format(_("%s is next to a mine!"), 00116 ver -> GetName().c_str()); 00117 GameMessages::GetInstance()->Add (txt); 00118 StartTimeout(); 00119 return; 00120 } 00121 } 00122 }
Here is the call graph for this function:
Here is the caller graph for this function:
void ObjMine::Draw | ( | ) | [virtual] |
Reimplemented from WeaponProjectile.
Definition at line 164 of file mine.cpp.
00165 { 00166 image->Draw(GetPosition()); 00167 }
Here is the call graph for this function:
void ObjMine::FakeExplosion | ( | ) | [protected] |
Definition at line 63 of file mine.cpp.
00064 { 00065 MSG_DEBUG("mine", "Fake explosion"); 00066 00067 jukebox.Play("share", "weapon/mine_fake"); 00068 ParticleEngine::AddNow(GetPosition(), 5, particle_SMOKE, true); 00069 00070 if ( animation ) 00071 { 00072 MSG_DEBUG("mine", "Desactive detection.."); 00073 00074 animation = false; 00075 image->SetCurrentFrame(0); 00076 } 00077 if (launcher != NULL) launcher->SignalProjectileTimeout(); 00078 // Mine fall into the ground after a fake explosion 00079 SetCollisionModel(false, false, false); 00080 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool ObjMine::IsImmobile | ( | ) | const [virtual] |
Reimplemented from WeaponProjectile.
Definition at line 158 of file mine.cpp.
00159 { 00160 if (is_active && animation) return false; 00161 return PhysicalObj::IsImmobile(); 00162 }
Here is the call graph for this function:
void ObjMine::Refresh | ( | ) | [virtual] |
Reimplemented from WeaponProjectile.
Definition at line 124 of file mine.cpp.
00125 { 00126 // the mine is now out of the map 00127 // or it's a fake mine that has already exploded! 00128 if (!is_active) 00129 { 00130 jukebox.Stop(channel); 00131 channel = -1; 00132 escape_time = 0; 00133 return; 00134 } 00135 00136 // try to detect a character near the mine 00137 if (!animation) 00138 { 00139 Detection(); 00140 } 00141 else 00142 { 00143 image->Update(); 00144 00145 // the timeout is finished !! 00146 if (attente < Time::GetInstance()->ReadSec()) 00147 { 00148 is_active = false; 00149 jukebox.Stop(channel); 00150 channel = -1; 00151 if (!fake) Explosion(); 00152 else FakeExplosion(); 00153 if (launcher != NULL) launcher->SignalProjectileTimeout(); 00154 } 00155 } 00156 }
Here is the call graph for this function:
void ObjMine::StartTimeout | ( | ) |
Definition at line 82 of file mine.cpp.
00083 { 00084 if (!animation) 00085 { 00086 animation=true; 00087 MSG_DEBUG("mine", "EnableDetection - CurrentTime : %d",Time::GetInstance()->ReadSec() ); 00088 attente = Time::GetInstance()->ReadSec() + cfg.timeout; 00089 MSG_DEBUG("mine", "EnableDetection : %d", attente); 00090 00091 channel = jukebox.Play("share", "weapon/mine_beep", -1); 00092 } 00093 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool ObjMine::animation [private] |
uint ObjMine::attente [private] |
int ObjMine::channel [private] |
uint ObjMine::escape_time [private] |
bool ObjMine::fake [private] |
bool ObjMine::is_active [private] |