src/weapon/mine.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  * Mine : Detect if character is close and explode after a shot time.
00020  * Sometime the mine didn't explode randomly.
00021  *****************************************************************************/
00022 #ifndef MINE_H
00023 #define MINE_H
00024 
00025 #include <SDL.h>
00026 #include "launcher.h"
00027 #include "../graphic/surface.h"
00028 #include "../graphic/sprite.h"
00029 #include "../include/base.h"
00030 #include "../object/physical_obj.h"
00031 #include "../character/character.h"
00032 
00033 class Mine;
00034 class MineConfig;
00035 
00036 class ObjMine : public WeaponProjectile
00037 {
00038   private:
00039   // channel used for sound
00040     int channel;
00041 
00042   // this is a fake mine ?
00043     bool fake;
00044 
00045   // Is this mine active ?
00046     bool is_active;
00047 
00048   // Activation des mines ?
00049     bool animation;
00050     uint attente;
00051     uint escape_time;
00052 
00053   protected:
00054     void FakeExplosion();
00055   public:
00056     ObjMine(MineConfig &cfg,
00057             WeaponLauncher * p_launcher = NULL);
00058 
00059     void StartTimeout();
00060     void Detection();
00061     virtual bool IsImmobile() const;
00062 
00063     void Draw();
00064     void Refresh();
00065 };
00066 
00067 class MineConfig : public ExplosiveWeaponConfig
00068 { 
00069   private:
00070     static MineConfig * singleton;
00071   public: 
00072     uint escape_time;
00073     double detection_range;
00074 
00075   private:
00076     MineConfig();
00077   public:
00078     static MineConfig * GetInstance();
00079     virtual void LoadXml(xmlpp::Element *elem);
00080 };
00081 
00082 class Mine : public WeaponLauncher
00083 {
00084   private:
00085     void Add (int x, int y);
00086   protected:
00087     WeaponProjectile * GetProjectileInstance();
00088     bool p_Shoot();
00089   public:
00090     Mine();
00091     MineConfig& cfg();
00092   
00093 };
00094 
00095 #endif /* MINE_H */

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