00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020
00021
00022
00024
00025
00027
00028 #ifndef WEAPON_H
00029 #define WEAPON_H
00030
00031 #include "Projectile.hpp"
00032
00033 #include <SFML/Audio.hpp>
00034 #include <cstdio>
00035 #include <log4cxx/logger.h>
00037
00041 class CWeapon
00042 {
00043 public:
00045 CWeapon();
00046 ~CWeapon();
00047
00049 void Init(const std::string& Name)
00050 {
00051 ReadData(Name);
00052 }
00053
00055 const std::string& GetName() const { return m_Name; }
00056
00058 float GetProjectileSpeedX() const { return m_ProjectileSpeedX; }
00059
00061 float GetProjectileSpeedY() const { return m_ProjectileSpeedY; }
00062
00064 int GetShootSpeed() const { return m_ShootSpeed; }
00065
00067 int GetDamage() const { return m_Damage; }
00068
00070 int GetGroupID() const { return m_WeaponGroupID; }
00071
00072
00074 void Equip(bool Equip = true) { m_Equiped = Equip; }
00075
00077 bool IsEquiped() const { return m_Equiped; }
00078
00080 void Reset() { m_Equiped = m_InitiallyEquiped; }
00081
00082
00084 void Shoot(float X, float Y);
00085
00087 int GetProjectilCount() const { return m_Projectiles.size(); }
00088
00090 float GetProjectilX(int Projectil) const { return m_Projectiles[Projectil]->GetXPosition(); }
00091
00093 float GetProjectilY(int Projectil) const { return m_Projectiles[Projectil]->GetYPosition(); }
00094
00096 float GetProjectilWidth(int Projectil) const { return m_Projectiles[Projectil]->GetCollisionSystemWidth(); }
00097
00098
00100 void DrawProjectiles();
00101
00104 int CheckCollision(const CCollisionSystem * CounterPart);
00105
00106
00108 void ClearProjectils();
00109
00110
00112 int GetProjectilXRel(int YDistance) const;
00113
00114
00116 bool IsForeground() const { return m_Foreground; }
00117 private:
00118
00119 void ReadData(const std::string& file);
00120
00121 std::string m_Name;
00122 float m_ProjectileSpeedX;
00123 float m_ProjectileSpeedY;
00124 float m_ProjectileAccelX;
00125 float m_ProjectileAccelY;
00126
00127 float m_SpeedLimitX;
00128 float m_SpeedLimitY;
00129
00130 bool m_SpeedLimitXSmaller;
00131 bool m_SpeedLimitYSmaller;
00132
00133 std::string m_ProjectileImageName;
00134 int m_ShootSpeed;
00135 int m_LastShot;
00136 int m_Damage;
00137 int m_WeaponGroupID;
00138
00139 bool m_ProjectileAutoRotate;
00140
00141 bool m_InitiallyEquiped;
00142 bool m_Equiped;
00143
00144 bool m_Foreground;
00145
00146 float m_X;
00147 float m_Y;
00148
00149 std::string m_ShootSoundFile;
00150 sf::Sound m_ShootSound;
00151 std::string m_HitSoundFile;
00152 sf::Sound m_HitSound;
00153
00154 std::vector<CProjectile*> m_Projectiles;
00155
00156 sProjectileData m_ProjectileData;
00157
00158 log4cxx::LoggerPtr log_;
00159 };
00160
00161 #endif