00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef NPC_H
00019 #define NPC_H
00020
00021 #include <bitset>
00022 #include <iostream>
00023
00024 #include "Ship.hpp"
00025 #include "Enemy_Help.hpp"
00026 #include "Globals.hpp"
00027
00031 class ANPC
00032 {
00033 public:
00034 enum Strength
00035 {
00036 EMPTY,
00037 WEAK_ENEMY,
00038 MEDIUMWEAK_ENEMY,
00039 AVERAGE_ENEMY,
00040 MEDIUMHARD_ENEMY,
00041 HARD_ENEMY,
00042 WEAK_BOSS = 101,
00043 MEDIUMWEAK_BOSS = 102,
00044 AVERAGE_BOSS = 103,
00045 MEDIUMHARD_BOSS = 104,
00046 HARD_BOSS = 105
00047 };
00048 protected:
00049 int des_x, des_y;
00050 AI_parameter* m_parameter;
00051 int desired_distance;
00052 int desired_center;
00053 CShip* m_Ship;
00054 int m_weapon_offset;
00055 private:
00056 unsigned int m_starttime;
00057 int rest_x, rest_y;
00058 Strength m_strength;
00059 int m_firedist;
00060 std::string m_shipfile;
00061 int m_posx, m_posy;
00062 protected:
00063 float get_fancy(float* farray, std::size_t start, std::size_t end);
00064 private:
00066
00068
00069
00070
00071
00072 virtual void number_enemys(int* results, std::list<ANPC*>& r_Enemys) =0;
00073
00074
00075 virtual bool calculate_y(float* down_up) =0;
00076
00078
00080
00081 void steer_y(int direction);
00082
00083 void steer_x(int direction);
00084
00085 void update_array(float* fancy, std::list<projectileData>& r_Projectiles);
00086
00087 void separation(std::list<ANPC*>& r_activeEnemys, float* xseparate, float* yseparate);
00088
00089 bool calculate_x(float* fancy, float* fancy_dir, std::list<projectileData>& r_Projectiles, std::list<ANPC*>& r_activeEnemys);
00090 public:
00091
00092 ANPC(unsigned int starttime, int posx, int posy, Strength theStrength, std::string shipfile, AI_parameter* parameter);
00093 ~ANPC()
00094 {if (m_Ship) delete m_Ship;}
00095 bool init(global_data_pointers Data, strength* tStrength);
00096
00097
00098
00099 void calculate(float* fancy, std::list<projectileData>& r_Projectiles, std::list<ANPC*>& r_myEnemys, std::list<ANPC*>& r_myAllys);
00100
00101 void update(const std::bitset<SCREEN_X_SIZE - HUD_SIZE_X>& owned);
00102 void Draw()
00103 {m_Ship->Draw();}
00104
00105
00106 CShip* getShip()
00107 {return m_Ship;}
00108 unsigned int getStarttime()
00109 {return m_starttime;}
00110 int getPower()
00111 {return (m_strength > 100) ? m_parameter->max_power : 1;}
00112 int getStrength()
00113 {return m_strength;}
00114 };
00115
00116
00117
00118 #endif