-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWaveSpawner.h
72 lines (59 loc) · 1.51 KB
/
WaveSpawner.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
#ifndef WAVE_SPAWNER_H
#define WAVE_SPAWNER_H
#include <vector>
#include <array> // std::array
#include "2D\Vector2D.h"
#include "Misc\Util.h"
#include "GameEntities\EnemyPlayer.h"
class EnemyPlayer;
class WaveSpawner
{
public:
enum State {None, Spawn, Battle, Reward, Evaluate};
WaveSpawner()
:populationSize(10),
generation(1),
m_fGenerateTime(0.f),
m_fDestroyedTime(0.f),
m_fGenerateWait(0.5f),
m_fRewardWait(0.5f),
Enemies{nullptr},
EnemyDNAs{nullptr},
GenerationHeights{ 1, 4, 7 },
MeteoriteSpawnPoses{},
State(None)
{}
~WaveSpawner()
{
DeleteSTLContainer(Enemies);
Enemies.clear();
}
void Update();
protected:
//////////////////////////////////////////////////////////////////////////
// State Machine Transitions
bool OnSpawn();
bool OnBattle();
bool OnReward();
bool OnEvaluate();
//////////////////////////////////////////////////////////////////////////
bool RandomGenEnemies();
bool GenerateEnemies();
Vector2D RandomSpawnPosition(GameConfig::Positions position = GameConfig::Positions::None);
int RandomLevel() { return RandInt(0, 2); }
void ShuffleHeights();
private:
int populationSize;
int generation;
float m_fGenerateTime;
float m_fDestroyedTime;
const float m_fGenerateWait;
const float m_fRewardWait;
std::vector<EnemyPlayer*> Enemies;
std::vector<EnemyPlayer::EnemyDNA*> EnemyDNAs;
std::vector<EnemyPlayer::EnemyDNA*>::iterator curDNA;
std::array<int, 3> GenerationHeights;
std::vector<Vector2D> MeteoriteSpawnPoses;
WaveSpawner::State State;
};
#endif