00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "dynamite.h"
00025 #include "explosion.h"
00026 #include "../game/config.h"
00027 #include "../include/app.h"
00028 #include "../object/objects_list.h"
00029 #include "../team/teams_list.h"
00030 #include "../tool/i18n.h"
00031 #include "../tool/resource_manager.h"
00032 #include "../tool/debug.h"
00033
00034 #ifdef __MINGW32__
00035 #undef LoadImage
00036 #endif
00037
00038 DynamiteStick::DynamiteStick(ExplosiveWeaponConfig& cfg,
00039 WeaponLauncher * p_launcher) :
00040 WeaponProjectile("dynamite_bullet", cfg, p_launcher)
00041 {
00042 channel = -1;
00043 explode_with_collision = false;
00044
00045 image->animation.SetLoopMode(false);
00046 SetSize(image->GetSize());
00047 SetTestRect (0, 0, 2, 3);
00048 }
00049
00050 void DynamiteStick::Shoot(double strength)
00051 {
00052 unsigned int delay = (1000 * WeaponProjectile::GetTotalTimeout())/image->GetFrameCount();
00053 image->SetFrameSpeed(delay);
00054
00055 image->Scale(ActiveCharacter().GetDirection(), 1);
00056 image->SetCurrentFrame(0);
00057 image->Start();
00058 WeaponProjectile::Shoot(strength);
00059 }
00060
00061 void DynamiteStick::Refresh()
00062 {
00063 image->Update();
00064 if (image->IsFinished()) Explosion();
00065 }
00066
00067 void DynamiteStick::ShootSound()
00068 {
00069 channel = jukebox.Play("share","weapon/dynamite_fuze", -1);
00070 }
00071
00072 void DynamiteStick::SignalExplosion()
00073 {
00074 jukebox.Stop(channel);
00075 }
00076
00077 void DynamiteStick::SignalOutOfMap()
00078 {
00079 jukebox.Stop(channel);
00080 }
00081
00082 void DynamiteStick::SignalDrowning()
00083 {
00084 jukebox.Stop(channel);
00085 }
00086
00087
00088 Dynamite::Dynamite() :
00089 WeaponLauncher(WEAPON_DYNAMITE, "dynamite", new ExplosiveWeaponConfig(), VISIBLE_ONLY_WHEN_INACTIVE)
00090 {
00091 m_name = _("Dynamite");
00092 ReloadLauncher();
00093 }
00094
00095 WeaponProjectile * Dynamite::GetProjectileInstance()
00096 {
00097 return dynamic_cast<WeaponProjectile *>
00098 (new DynamiteStick(cfg(),dynamic_cast<WeaponLauncher *>(this)));
00099 }
00100
00101
00102 bool Dynamite::p_Shoot ()
00103 {
00104 projectile->Shoot(0);
00105
00106
00107 if(ActiveCharacter().GetDirection() == 1)
00108 projectile->SetSpeed(3.0, -M_PI_4);
00109 else
00110 projectile->SetSpeed(3.0, -3.0 * M_PI_4);
00111
00112 return true;
00113 }