00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "anvil.h"
00023
00024 #include <sstream>
00025 #include "../game/time.h"
00026 #include "../team/teams_list.h"
00027 #include "../graphic/video.h"
00028 #include "../tool/math_tools.h"
00029 #include "../map/camera.h"
00030 #include "../weapon/explosion.h"
00031 #include "../interface/game_msg.h"
00032 #include "../tool/i18n.h"
00033 #include "../object/objects_list.h"
00034 #include "../map/map.h"
00035
00036
00037 Anvil::Anvil(ExplosiveWeaponConfig& cfg,
00038 WeaponLauncher * p_launcher) :
00039 WeaponProjectile ("anvil", cfg, p_launcher)
00040 {
00041 explode_with_collision = false;
00042 explode_colliding_character = false;
00043 merge_time = 0;
00044 }
00045
00046 void Anvil::SignalObjectCollision(PhysicalObj * obj)
00047 {
00048 if(typeid(*obj) == typeid(Character)) {
00049 Character * tmp = (Character *)(obj);
00050 tmp -> SetEnergyDelta (-200);
00051 }
00052 }
00053
00054 void Anvil::SignalGroundCollision()
00055 {
00056 merge_time = Time::GetInstance()->Read() + 5000;
00057 }
00058
00059 void Anvil::Refresh()
00060 {
00061 if(merge_time != 0 && merge_time < Time::GetInstance()->Read()) {
00062 world.MergeSprite(GetPosition(),image);
00063 Ghost();
00064 } else {
00065 WeaponProjectile::Refresh();
00066 }
00067 }
00068
00069
00070
00071 AnvilLauncher::AnvilLauncher() :
00072 WeaponLauncher(WEAPON_ANVIL, "anvil_launcher", new ExplosiveWeaponConfig(), VISIBLE_ONLY_WHEN_INACTIVE)
00073 {
00074 m_name = _("Anvil");
00075 mouse_character_selection = false;
00076 can_be_used_on_closed_map = false;
00077 ReloadLauncher();
00078 target_chosen = false;
00079 }
00080
00081 void AnvilLauncher::ChooseTarget(Point2i mouse_pos)
00082 {
00083 mouse_pos.y = 0;
00084 target = mouse_pos - (projectile->GetSize() / 2);
00085 target_chosen = true;
00086 Shoot();
00087 }
00088
00089 bool AnvilLauncher::p_Shoot ()
00090 {
00091 if(!target_chosen)
00092 return false;
00093 projectile->SetXY(target);
00094 lst_objects.AddObject(projectile);
00095 camera.FollowObject(projectile,true,true);
00096 projectile = NULL;
00097 ReloadLauncher();
00098 return true;
00099 }
00100
00101 WeaponProjectile * AnvilLauncher::GetProjectileInstance()
00102 {
00103 return dynamic_cast<WeaponProjectile *>
00104 (new Anvil(cfg(),dynamic_cast<WeaponLauncher *>(this)));
00105 }