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
|
#ifndef NPC_H
#define NPC_H
#include <bitset>
#include "Ship.h"
#include "Enemy_Help.hpp"
#include "Globals.h"
#include "MathFuncs.h"
class ANPC
{
public:
enum Strength {EMPTY, WEAK_ENEMY, MEDIUMWEAK_ENEMY, AVERAGE_ENEMY, MEDIUMHARD_ENEMY, HARD_ENEMY, WEAK_BOSS = 101, MEDIUMWEAK_BOSS = 102, AVERAGE_BOSS = 103, MEDIUMHARD_BOSS = 104, HARD_BOSS = 105};
protected:
int des_x, des_y;
AI_parameter* m_parameter;
int desired_distance;
int desired_center;
CShip* m_Ship;
private:
unsigned int m_starttime;
int rest_x, rest_y;
Strength m_strength;
int m_firedist;
std::string m_shipfile;
protected:
float get_fancy(float* farray, int start, int end);
private:
//////////
//Virtuelle Funktionen
//////////
/*
*result muss ein int [3] sein, Inhalt ist am Schluss die Zahl der jeweiligen Gegner in die Richtung
*[0] für links [1] für mitte [2] für rechts
*/
virtual void number_enemys(int* results, std::list<ANPC*>& r_Enemys) = 0;
/*Berechnet, in welche Y-Richtung sich der NPC optimalerweise bewegt*/
virtual bool calculate_y(float* down_up) = 0;
//////////
//Implementierte Funktionen
//////////
/*Bewegt das Schiff in y-Richtung, überprüft dabei ob die Wartezeit abgelaufen ist*/
void steer_y(int direction);
/*Bewegt das Schiff in x-Richtung, überprüft dabei ob die Wartezeit abgelaufen ist*/
void steer_x(int direction);
/*Berechnung der "beliebtheit" jedes Pixels für den NPC*/
void update_array(float* fancy, std::list<projectileData>& r_Projectiles);
/*Diese Funktion sorgt dafür, dass die NPC einen minimalabstand halten*/
void separation(std::list<ANPC*>& r_activeEnemys, float* xseparate, float* yseparate);
/*Berechnet, in welche X-Richtung sich der NPC optimalerweise bewegt*/
bool calculate_x(float* fancy, float* fancy_dir, std::list<projectileData>& r_Projectiles, std::list<ANPC*>& r_activeEnemys);
public:
//Konstruktor/Destruktor usw.
ANPC(unsigned int starttime, int posx, int posy, Strength theStrength, std::string shipfile);
~ANPC()
{if (m_Ship) delete m_Ship;}
bool init(global_data_pointers Data, AI_parameter* parameter, strength* tStrength);
//Berechnungsfunktionen
/*Berechnung der Bewegungsrichtung des NPC, wird seltener aufgerufen als update()*/
void calculate(float* fancy, std::list<projectileData>& r_Projectiles, std::list<ANPC*>& r_activeEnemys);
/*Führt jeden Frame die in calculate berechnete Bewegung durch, schießt bei Bedarf*/
void update(const std::bitset<800>& owned);
void Draw()
{m_Ship->Draw();}
//Elementzugriff
CShip* getShip()
{return m_Ship;}
unsigned int getStarttime()
{return m_starttime;}
int getPower()
{return (m_strength > 100) ? m_parameter->max_power : 1;}
int getStrength()
{return m_strength;}
};
#endif
|