Repository navigation
Expand file tree
/
Copy pathDogfightState.h
More file actions
155 lines (149 loc) · 5.31 KB
/
Copy pathDogfightState.h
File metadata and controls
155 lines (149 loc) · 5.31 KB
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
#pragma once
/*
* Copyright 2010-2016 OpenXcom Developers.
*
* This file is part of OpenXcom.
*
* OpenXcom is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenXcom is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../Engine/State.h"
#include <vector>
#include <string>
namespace OpenXcom
{
const int STANDOFF_DIST = 560;
enum ColorNames { CRAFT_MIN, CRAFT_MAX, RADAR_MIN, RADAR_MAX, DAMAGE_MIN, DAMAGE_MAX, BLOB_MIN, RANGE_METER, DISABLED_WEAPON, DISABLED_AMMO, DISABLED_RANGE };
class ImageButton;
class Text;
class Surface;
class InteractiveSurface;
class Timer;
class GeoscapeState;
class Craft;
class Ufo;
class CraftWeaponProjectile;
/**
* Shows a dogfight (interception) between a
* player craft and an UFO.
*/
class DogfightState : public State
{
private:
GeoscapeState *_state;
Timer *_craftDamageAnimTimer;
Surface *_window, *_battle, *_range1, *_range2, *_damage;
InteractiveSurface *_btnMinimize, *_preview, *_weapon1, *_weapon2;
ImageButton *_btnStandoff, *_btnCautious, *_btnStandard, *_btnAggressive, *_btnDisengage, *_btnUfo;
ImageButton *_mode;
InteractiveSurface *_btnMinimizedIcon;
Text *_txtAmmo1, *_txtAmmo2, *_txtDistance, *_txtStatus, *_txtInterceptionNumber;
Craft *_craft;
Ufo *_ufo;
int _timeout, _currentDist, _targetDist, _w1FireInterval, _w2FireInterval, _w1FireCountdown, _w2FireCountdown;
bool _end, _destroyUfo, _destroyCraft, _ufoBreakingOff, _weapon1Enabled, _weapon2Enabled;
bool _minimized, _endDogfight, _animatingHit, _waitForPoly, _waitForAltitude;
std::vector<CraftWeaponProjectile*> _projectiles;
static const int _ufoBlobs[8][13][13];
static const int _projectileBlobs[4][6][3];
int _ufoSize, _craftHeight, _currentCraftDamageColor, _interceptionNumber;
size_t _interceptionsCount;
int _x, _y, _minimizedIconX, _minimizedIconY;
int _colors[11];
// Ends the dogfight.
void endDogfight();
public:
/// Creates the Dogfight state.
DogfightState(GeoscapeState *state, Craft *craft, Ufo *ufo);
/// Cleans up the Dogfight state.
~DogfightState();
/// Runs the timers.
void think();
/// Animates the window.
void animate();
/// Moves the craft.
void update();
// Fires the first weapon.
void fireWeapon1();
// Fires the second weapon.
void fireWeapon2();
// Fires UFO weapon.
void ufoFireWeapon();
// Sets the craft to minimum distance.
void minimumDistance();
// Sets the craft to maximum distance.
void maximumDistance();
/// Changes the status text.
void setStatus(const std::string &status);
/// Handler for clicking the Minimize button.
void btnMinimizeClick(Action *action);
/// Handler for pressing the Standoff button.
void btnStandoffPress(Action *action);
/// Handler for pressing the Cautious Attack button.
void btnCautiousPress(Action *action);
/// Handler for pressing the Standard Attack button.
void btnStandardPress(Action *action);
/// Handler for pressing the Aggressive Attack button.
void btnAggressivePress(Action *action);
/// Handler for pressing the Disengage button.
void btnDisengagePress(Action *action);
/// Handler for clicking the Ufo button.
void btnUfoClick(Action *action);
/// Handler for clicking the Preview graphic.
void previewClick(Action *action);
/// Draws UFO.
void drawUfo();
/// Draws projectiles.
void drawProjectile(const CraftWeaponProjectile* p);
/// Animates craft damage.
void animateCraftDamage();
/// Updates craft damage.
void drawCraftDamage();
/// Toggles usage of weapon 1.
void weapon1Click(Action *action);
/// Toggles usage of weapon 2.
void weapon2Click(Action *action);
/// Changes colors of weapon icons, range indicators and ammo texts base on current weapon state.
void recolor(const int weaponNo, const bool currentState);
/// Returns true if state is minimized.
bool isMinimized() const;
/// Sets state minimized or maximized.
void setMinimized(const bool minimized);
/// Handler for clicking the minimized interception window icon.
void btnMinimizedIconClick(Action *action);
/// Gets interception number.
int getInterceptionNumber() const;
/// Sets interception number.
void setInterceptionNumber(const int number);
/// Sets interceptions count.
void setInterceptionsCount(const size_t count);
/// Calculates window position according to opened interception windows.
void calculateWindowPosition();
/// Moves window to new position.
void moveWindow();
/// Checks if the dogfight should be ended.
bool dogfightEnded() const;
/// Gets pointer to the UFO in this dogfight.
Ufo *getUfo() const;
/// Gets pointer to the craft in this dogfight.
Craft *getCraft() const;
/// Waits until the UFO reaches a polygon.
void setWaitForPoly(bool wait);
/// Waits until the UFO reaches a polygon.
bool getWaitForPoly() const;
/// Waits until the UFO reaches the right altitude.
void setWaitForAltitude(bool wait);
/// Waits until the UFO reaches the right altitude.
bool getWaitForAltitude() const;
};
}