1 #pragma once
2 // Description:
3 //   Our Hero!
4 //
5 // Copyright (C) 2001 Frank Becker
6 //
7 // This program is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU General Public License as published by the Free Software
9 // Foundation;  either version 2 of the License,  or (at your option) any  later
10 // version.
11 //
12 // This program is distributed in the hope that it will be useful,  but  WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
15 //
16 
17 #include <Singleton.hpp>
18 #include <Model.hpp>
19 #include <Direction.hpp>
20 #include <ParticleType.hpp>
21 #include <Skill.hpp>
22 
23 #include <string>
24 
25 class Weapon;
26 
27 class Hero: public ParticleType
28 {
29 friend class Singleton<Hero>;
30 public:
31     enum MountedWeapon
32     {
33        PRIMARY_WEAPON,
34        SECONDARY_WEAPON,
35        TERTIARY_WEAPON,
36        MAX_WEAPONS
37     };
38 
39     bool init( void);
40     void reset( void);
41 
42 
43     virtual void init( ParticleInfo *p);
44     virtual bool update( ParticleInfo *p);
45     virtual void hit( ParticleInfo *p, ParticleInfo *p2, int /*radIndex*/);
draw(ParticleInfo *)46     virtual void draw( ParticleInfo *){ /* not used, see other draw */; }
47     virtual void draw( void);
48     void drawWeapon( unsigned int weapNum);
49 
50     void move( float dx, float dy);
51     void move( Direction::DirectionEnum d, bool isDown);
52     void allowVerticalMovement(bool allow);
53 
54     bool weaponLoaded( int weapNum);
55     void weaponFire( bool isDown, int weapNum=0);
56 
alive(void)57     bool alive( void)
58     {
59         return _isAlive;
60     }
61 
alive(bool a)62     void alive( bool a)
63     {
64         _isAlive = a;
65     }
66 
67     void addEnergy( int val);
68     void addShield( int val);
69 
getEnergy(void)70     float getEnergy( void)
71     {
72         return (float)_energy;
73     }
74 
getShieldEnergy(void)75     float getShieldEnergy( void)
76     {
77         return (float)_shieldEnergy;
78     }
79 
getWeaponEnergy(void)80     float getWeaponEnergy( void)
81     {
82         return _weaponEnergy;
83     }
84 
getMaxWeaponEnergy(void)85     float getMaxWeaponEnergy( void)
86     {
87         return _maxWeaponEnergy;
88     }
89 
90     void setArmorPierce( float damageMultiplier);
getArmorPierce(void)91     float getArmorPierce( void)
92     {
93 	return _damageMultiplier;
94     }
95 
96     void assignWeapons( Skill::SkillEnum skill);
97 
98     float lastXPos;
99     float lastYPos;
100 
101 private:
102     virtual ~Hero();
103     Hero( void);
104 
105     Hero( const Hero&);
106     Hero &operator=(const Hero&);
107 
108     void spawnSparks( int spawnCount, float r, ParticleInfo &pi);
109 
110     Model *_model;
111     ParticleInfo *pInfo;
112 
113     float _moveLeft;
114     float _moveRight;
115     float _moveUp;
116     float _moveDown;
117     float _maxY;
118     bool _isAlive;
119     bool _isDying;
120     int _isDyingDelay;
121 
122     int _energy;
123     int _shieldEnergy;
124     float _weaponEnergy;
125     float _maxWeaponEnergy;
126 
127     int _weaponPowerup;
128     int _bonusStreak;
129 
130     float _weaponReload[ MAX_WEAPONS];
131     bool _weaponAutofire[ MAX_WEAPONS];
132     Weapon *_weapon[ MAX_WEAPONS];
133     int _weaponAmmo[ MAX_WEAPONS];
134     float _damageMultiplier;
135     bool _autofireOn;
136 
137     float _sint[360];
138     float _cost[360];
139 };
140 
141 typedef Singleton<Hero> HeroS;
142