-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameStateService.h
158 lines (131 loc) · 4.05 KB
/
GameStateService.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#ifndef GAMESTATESERVICE_H_
#define GAMESTATESERVICE_H_
#include "entity/Service.h"
#include "util/AnimationHelper.h"
#include "assets/Texture.h"
#include "entity/Container.h"
#include "entity/Marker.h"
#include "entity/PointVisualizer.h"
#include "GameState.h"
#include "Statusbox.h"
#include "Nametag.h"
#include "Textbox.h"
#include "Hexmap.h"
#include "Laser.h"
#include "Meteor.h"
#include "SoundManager.h"
#include "Fader.h"
using namespace anengine;
class GameStateService : public Service, public AnimationHelperListner
{
static const uint MeteorCount = 1;
struct Player
{
uint Index;
std::string Name;
uint Health;
uint Score;
VectorI2 Position;
Movable *PlayerMovable;
Visual *PlayerVisual;
Movable *NametagMovable;
MultiContainer *PlayerContainer;
Nametag *PlayerNametag;
bool IsDead;
bool Died;
bool Spawned;
Player(uint index, std::string name, Movable *playerMovable,
Visual *playerVisual, Movable *nametagMovable,
MultiContainer *playerContainer, Nametag *nametag)
: Index(index), Name(name),
Health(0), Score(0), Position(ZeroI2),
PlayerMovable(playerMovable), PlayerVisual(playerVisual),
NametagMovable(nametagMovable), PlayerContainer(playerContainer),
PlayerNametag(nametag), IsDead(true), Died(false), Spawned(false) { }
~Player() { }
void Update(const PlayerState &other);
bool GetDied()
{
bool d = Died;
Died = false;
return d;
}
bool GetSpawned()
{
bool d = Spawned;
Spawned = false;
return d;
}
};
void Update(const GameState &state);
AnimationHelper myAnimations;
OutPin myDonePin;
OutPin mySoundPin;
AssetRef<Program> myPlayerProgram;
int Turn;
std::vector<Player> Players;
MultiContainer *myContainer;
Hexmap *myMap;
Statusbox myStats;
Textbox myTitle;
Textbox mySubtitle;
std::vector<Player>::iterator myCurrentPlayer;
AssetRef<Texture> myFigureTexture;
uint myActionCount;
uint myActionCursor;
ActionState myActionStates[3];
AnimationHelper::AnimationIndex mySubtitleAnimation;
bool myAnimatingDying;
std::vector<int> myDyingPlayers;
Movable myCamMov;
Camera *myCamera;
MultiContainer myCamMarkerC;
Movable myCamMarkerMov;
Marker myCamMarker;
Meteor myMeteors[MeteorCount];
Movable myMeteorMovs[MeteorCount];
Movable myLaserMov;
Laser myLaser;
MatrixF4 myLaserBaseTransform;
Movable myMortarMov;
Billboard myMortar;
bool myInMortar;
Movable myDroidMov;
Billboard myDroid;
int myDroidSequenceCounter;
bool myDoExplode;
Movable myExplosionMov;
MultiContainer myExplosionC;
Billboard myExplosion;
Movable myBiexplosionMoves[6];
Billboard myBiexplosions[6];
VectorF4 myDefaultLookat;
VectorF4 myDefaultCamera;
VectorF4 myCameraTarget;
VectorF4 myOldCamera;
Movable myIconMov;
Billboard myIcon;
Fader myFader;
void SetCurrentPlayer();
bool StateUpdate(Event &event, InPin pin);
void PlayAnimation();
void MoveCamera(real angle = 0, real time = 1, real dragTime = 0.5);
bool ForceMoveCamera(real angle = 0, real time = 1, real dragTime = 0.5, real height = 10);
void PlaySound(Sound sound, real duration = 0);
void Explode(VectorF4 pos);
void PlayDroid();
virtual void AnimationDone();
public:
GameStateService(MultiContainer *container, Hexmap *map,
AssetRef<Program> playerTexture,
AssetRef<Texture> figureTexture, AssetRef<Texture> laserTexture,
AssetRef<Texture> mortarTexture, AssetRef<Texture> droidTexture,
AssetRef<Texture> explosionTexture, AssetRef<Texture> iconTexture,
Camera *camera);
virtual ~GameStateService();
virtual void OnUpdate(FrameTime time)
{
myAnimations.Update(time);
}
};
#endif