-
Notifications
You must be signed in to change notification settings - Fork 0
/
Agent.h
71 lines (56 loc) · 2.02 KB
/
Agent.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Survival
*
* Copyright (C) 2009-2011 Vishesh Handa <me@vhanda.in>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AGENT_H
#define AGENT_H
#include "Box2DEntity.h"
class Map;
class Projectile;
class Agent : public Box2DEntity
{
protected :
Map * m_pMap;
SDL_SurfacePtr m_pImage;
float m_fBulletTime; //This is the time remaining untill another bullet may be fired.
float m_fShieldTime; //Same as above for Shields.
float m_fBulletDelay;
float m_fShieldDelay;
float m_fSpeed;
float m_fLife;
float m_fMaxLife;
void initFromXMLFile(std::string fileName, const b2Vec2 & startPos);
public:
Agent(Map * pMap);
virtual ~Agent() {deinit();}
virtual void init() = 0;
virtual void update(float timeElapsed)=0;
virtual void render() =0;
virtual bool handleMessage(const Message & msg) { return false; }
Map * getMap() const { return m_pMap; }
virtual bool isPlayer() const =0;
//Life Functions
bool done() const { return m_fLife <= 0.0f; }
void reduceLife(float amt) { m_fLife -= amt; }
float getLife() const { return m_fLife; }
float getSpeed() const { return m_fSpeed; }
virtual void handleProjectile(Projectile * proj);
std::string getType() { return "Agent"; }
float getPercentLife() const { return m_fLife/m_fMaxLife; }
};
#endif // AGENT_H