src/weapon/launcher.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *  Wormux is a convivial mass murder game.
00003  *  Copyright (C) 2001-2004 Lawrence Azzoug.
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00018  ******************************************************************************
00019  * WeaponLauncher: generic weapon to launch a projectile
00020  *****************************************************************************/
00021 
00022 #ifndef WEAPON_LAUNCHER_H
00023 #define WEAPON_LAUNCHER_H
00024 #include "weapon.h"
00025 #include "../graphic/surface.h"
00026 #include "../gui/progress_bar.h"
00027 #include "../include/base.h"
00028 #include "../object/physical_obj.h"
00029 
00030 class WeaponLauncher;
00031 
00032 class WeaponProjectile : public PhysicalObj
00033 {
00034   protected:
00035     Sprite *image;
00036 
00037     bool explode_colliding_character; // before timeout.
00038     bool explode_with_timeout;
00039     bool explode_with_collision;
00040     double begin_time;
00041 
00042     ExplosiveWeaponConfig& cfg;
00043 
00044   public:
00045     Character* dernier_ver_touche;
00046     PhysicalObj* dernier_obj_touche;
00047     WeaponLauncher * launcher;
00048     int m_timeout_modifier;
00049 
00050   public:
00051     WeaponProjectile(const std::string &nom,
00052                      ExplosiveWeaponConfig& cfg,
00053                      WeaponLauncher * p_launcher);
00054     virtual ~WeaponProjectile();
00055 
00056     virtual void Draw();
00057     virtual void Refresh();
00058     virtual void Shoot(double strength);
00059     virtual bool IsImmobile() const;
00060 
00061     void IncrementTimeOut();
00062     void DecrementTimeOut();
00063     void SetTimeOut(int timeout);
00064     int GetTotalTimeout() const;
00065     void ResetTimeOut();
00066     bool change_timeout_allowed();
00067   protected:
00068     virtual void SignalObjectCollision(PhysicalObj * obj);
00069     virtual void SignalGroundCollision();
00070     virtual void SignalCollision();
00071     virtual void SignalOutOfMap();
00072     virtual void SignalTimeout();
00073     virtual void SignalExplosion();
00074     void SignalDrowning();
00075     void SignalGhostState (bool was_dead);
00076 
00077     virtual void ShootSound();
00078     virtual void Explosion();
00079     virtual void RandomizeShoot(double &angle,double &strength);
00080     virtual void DoExplosion();
00081 };
00082 
00083 class WeaponBullet : public WeaponProjectile
00084 {
00085   public:
00086     WeaponBullet(const std::string &name,
00087                  ExplosiveWeaponConfig& cfg,
00088                  WeaponLauncher * p_launcher);
00089     virtual ~WeaponBullet(){};
00090     virtual void Refresh();
00091   protected:
00092     virtual void SignalGroundCollision();
00093     virtual void SignalOutOfMap();
00094     virtual void SignalObjectCollision(PhysicalObj * obj);
00095     void DoExplosion();
00096 };
00097 
00098 
00099 class WeaponLauncher : public Weapon
00100 {
00101   public:
00102     bool ignore_timeout_signal;
00103     bool ignore_collision_signal;
00104     bool ignore_explosion_signal;
00105     bool ignore_ghost_state_signal;
00106     bool ignore_drowning_signal;
00107   protected:
00108     WeaponProjectile * projectile;
00109     uint nb_active_projectile;
00110     bool m_allow_change_timeout;
00111     int missed_shots;
00112     bool announce_missed_shots;
00113   protected:
00114     virtual bool p_Shoot();
00115     virtual void p_Select();
00116     virtual void p_Deselect();
00117     virtual WeaponProjectile * GetProjectileInstance() = 0;
00118     virtual bool ReloadLauncher();
00119     void Refresh();
00120   private:
00121     void DirectExplosion();
00122 
00123   public:
00124     WeaponLauncher(Weapon_type type,
00125                    const std::string &id,
00126                    EmptyWeaponConfig * params,
00127                    weapon_visibility_t visibility = ALWAYS_VISIBLE);
00128     virtual ~WeaponLauncher();
00129 
00130     virtual void Draw();
00131     virtual void HandleKeyEvent(Action::Action_t action, Keyboard::Key_Event_t event_type);
00132 
00133   // Handle of projectile events
00134     virtual void SignalProjectileExplosion();
00135     virtual void SignalProjectileCollision();
00136     virtual void SignalProjectileDrowning();
00137     virtual void SignalProjectileGhostState();
00138     virtual void SignalProjectileTimeout();
00139 
00140     void IncActiveProjectile();
00141     void DecActiveProjectile();
00142 
00143     virtual void IncMissedShots();
00144 
00145   //Misc actions
00146     virtual void ActionUp ();    // called by mouse.cpp when mouse wheel up
00147     virtual void ActionDown ();  // called by mouse.cpp when mouse wheel down
00148 
00149     WeaponProjectile* GetProjectile() { return projectile; };
00150     ExplosiveWeaponConfig& cfg();
00151 };
00152 
00153 #endif /* WEAPON_LAUNCHER_H */

Generated on Mon Jan 1 13:11:00 2007 for Wormux by  doxygen 1.4.7