-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenemy.h
131 lines (107 loc) · 3.53 KB
/
enemy.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// -----------------------------------------------------------------
// Learning Team B
// Members:
// Adam LeMmon
// Faith Satterthwaite
// Tom Fletcher
// Justin Ball
// CS 4280 – 11:30 am
// Final Project
// Dr. Rague
// Due: 12/06/12
// Version: 2.4
// -----------------------------------------------------------------
// We made five major improvements to this game
// 1) New controls
// 2) Enemy attack
// 3) HUD (heads up display)
// 4) Enemy health bars
// 5) New Weapon
// -----------------------------------------------------------------
#ifndef __ENEMY_H
#define __ENEMY_H
/*
ENEMY.H
The CEnemy class
OpenGL Game Programming
Author: Kevin Hawkins
Date: 3/30/2001
Description: The CEnemy class
*/
#include "entity.h"
// Phase 15 - Comment out the following
// Phase 19 - Uncomment the following
#include "DirectXAudio.h"
#include "vector.h"
class CPlayer;
class CTerrain;
enum AIState_t
{
AI_UNCARING, // enemy is not scared and does not care
AI_SCARED, // enemy is scared and running away
AI_DEAD,
/**************************Faith Satterthwaite 11/27/2012************************/
AI_ATTACK, // enemy attacks player
AI_BACKUP
/*******************************************************************************/
};
class CEnemy : public CEntity
{
private:
protected:
int hitPoints; // hit points the enemy has left
///// -- Adam
int maxHP;
float dirToPlayer; // the angle of the enemy-player vector
bool beenShot;
///// -- Adam
float distFromPlayer; // distance this enemy is from player
float runSpeed; // speed of enemy when running
AIState_t aiState; // state of enemy thought
virtual void OnProcessAI() {}
void OnCollision(CObject *collisionObject)
{
// if this enemy collides with another enemy
if (typeid(*collisionObject) == typeid(CEnemy))
{
modelState = MODEL_IDLE;
velocity = CVector(0.0, 0.0, 0.0);
}
// if this enemy collides with the terrain (always)
else if (typeid(*collisionObject) == typeid(CTerrain))
{
position.y = ((CTerrain*)collisionObject)->GetHeight(position.x, position.z) + size;
}
else
{
}
}
///// -- Adam
void OnDraw(CCamera *camera) { CEntity::OnDraw(camera); }
///// -- Adam
public:
CPlayer *player;
CEnemy()
{
hitPoints = 100; // start with 100 hit points
///// -- Adam
maxHP = 100;
dirToPlayer = 0; // the angle of the enemy-player vector
beenShot = false; //not been shot yet
///// -- Adam
isDead = false; // enemy starts off alive
velocity = CVector(0.0, 0.0, 0.0); // speed of enemy
runSpeed = velocity.z;
SetState(MODEL_IDLE); // idle state
direction = 0.0f; // point north
player = NULL;
}
~CEnemy() {}
void ProcessAI() { OnProcessAI(); }
void SetPlayer(CPlayer *p) { player = p; }
///// -- Adam
//This is needed for figuring out if the enemy is dead before putting them on the radar in gui.cpp
int getAIState() { return aiState; }
///// -- Adam
};
#endif