OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
DogfightState.h
1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_DOGFIGHTSTATE_H
20 #define OPENXCOM_DOGFIGHTSTATE_H
21 
22 #include "../Engine/State.h"
23 #include <vector>
24 #include <string>
25 
26 namespace OpenXcom
27 {
28 
29 const int STANDOFF_DIST = 560;
30 
31 class ImageButton;
32 class Text;
33 class Surface;
34 class InteractiveSurface;
35 class Timer;
36 class Globe;
37 class Craft;
38 class Ufo;
39 class CraftWeaponProjectile;
40 
45 class DogfightState : public State
46 {
47 private:
48  Timer *_animTimer, *_moveTimer, *_w1Timer, *_w2Timer, *_ufoWtimer, *_ufoEscapeTimer, *_craftDamageAnimTimer;
49  Surface *_window, *_battle, *_range1, *_range2, *_damage;
50  InteractiveSurface *_btnMinimize, *_preview, *_weapon1, *_weapon2;
51  ImageButton *_btnStandoff, *_btnCautious, *_btnStandard, *_btnAggressive, *_btnDisengage, *_btnUfo;
52  ImageButton *_mode;
53  InteractiveSurface *_btnMinimizedIcon;
54  Text *_txtAmmo1, *_txtAmmo2, *_txtDistance, *_txtStatus, *_txtInterceptionNumber;
55  Globe *_globe;
56  Craft *_craft;
57  Ufo *_ufo;
58  int _timeout, _currentDist, _targetDist, _ufoFireInterval;
59  bool _end, _destroyUfo, _destroyCraft, _ufoBreakingOff, _weapon1Enabled, _weapon2Enabled, _minimized, _endDogfight, _animatingHit;
60  std::vector<CraftWeaponProjectile*> _projectiles;
61  static const int _ufoBlobs[8][13][13];
62  static const int _projectileBlobs[4][6][3];
63  int _timeScale;
64  int _ufoSize, _craftHeight, _currentCraftDamageColor, _interceptionNumber;
65  size_t _interceptionsCount;
66  int _x, _y, _minimizedIconX, _minimizedIconY;
67 
68  // Ends the dogfight.
69  void endDogfight();
70 
71 public:
73  DogfightState(Game *game, Globe *globe, Craft *craft, Ufo *ufo);
77  void think();
79  void animate();
81  void move();
82  // Fires the first weapon.
83  void fireWeapon1();
84  // Fires the second weapon.
85  void fireWeapon2();
86  // Fires UFO weapon.
87  void ufoFireWeapon();
88  // Sets the craft to minimum distance.
89  void minimumDistance();
90  // Sets the craft to maximum distance.
91  void maximumDistance();
93  void setStatus(const std::string &status);
95  void btnMinimizeClick(Action *action);
97  void btnStandoffClick(Action *action);
99  void btnCautiousClick(Action *action);
101  void btnStandardClick(Action *action);
103  void btnAggressiveClick(Action *action);
105  void btnDisengageClick(Action *action);
107  void btnUfoClick(Action *action);
109  void previewClick(Action *action);
111  void ufoBreakOff();
113  void drawUfo();
115  void drawProjectile(const CraftWeaponProjectile* p);
117  void animateCraftDamage();
119  void drawCraftDamage();
121  void weapon1Click(Action *action);
123  void weapon2Click(Action *action);
125  void recolor(const int weaponNo, const bool currentState);
127  bool isMinimized() const;
129  void setMinimized(const bool minimized);
131  void btnMinimizedIconClick(Action *action);
133  int getInterceptionNumber() const;
135  void setInterceptionNumber(const int number);
137  void setInterceptionsCount(const size_t count);
141  void moveWindow();
143  bool dogfightEnded() const;
145  Ufo* getUfo() const;
146 
147 };
148 
149 }
150 
151 #endif
Represents a craft stored in a base.
Definition: Craft.h:44
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:34
void btnAggressiveClick(Action *action)
Handler for clicking the Aggressive Attack button.
Definition: DogfightState.cpp:1376
void move()
Moves the craft.
Definition: DogfightState.cpp:735
A game state that receives user input and reacts accordingly.
Definition: State.h:44
void setMinimized(const bool minimized)
Sets state minimized or maximized.
Definition: DogfightState.cpp:1633
Timer used to run code in fixed intervals.
Definition: Timer.h:37
DogfightState(Game *game, Globe *globe, Craft *craft, Ufo *ufo)
Creates the Dogfight state.
Definition: DogfightState.cpp:237
Surface that the user can interact with.
Definition: InteractiveSurface.h:39
bool dogfightEnded() const
Checks if the dogfight should be ended.
Definition: DogfightState.cpp:1803
void ufoBreakOff()
Makes the UFO break off the interception... or at least tries to.
Definition: DogfightState.cpp:1451
void drawCraftDamage()
Updates craft damage.
Definition: DogfightState.cpp:612
Interactive globe view of the world.
Definition: Globe.h:44
void maximumDistance()
Sets the craft to the maximum distance required to fire a weapon.
Definition: DogfightState.cpp:1237
Text string displayed on screen.
Definition: Text.h:41
void btnCautiousClick(Action *action)
Handler for clicking the Cautious Attack button.
Definition: DogfightState.cpp:1330
void btnStandoffClick(Action *action)
Handler for clicking the Standoff button.
Definition: DogfightState.cpp:1316
void minimumDistance()
Sets the craft to the minimum distance required to fire a weapon.
Definition: DogfightState.cpp:1211
void setInterceptionsCount(const size_t count)
Sets interceptions count.
Definition: DogfightState.cpp:1681
bool isMinimized() const
Returns true if state is minimized.
Definition: DogfightState.cpp:1624
void drawProjectile(const CraftWeaponProjectile *p)
Draws projectiles.
Definition: DogfightState.cpp:1506
void previewClick(Action *action)
Handler for clicking the Preview graphic.
Definition: DogfightState.cpp:1433
void ufoFireWeapon()
Each time a UFO will try to fire it's cannons a calculation is made.
Definition: DogfightState.cpp:1189
void animate()
Animates the window.
Definition: DogfightState.cpp:664
int getInterceptionNumber() const
Gets interception number.
Definition: DogfightState.cpp:1831
void moveWindow()
Moves window to new position.
Definition: DogfightState.cpp:1774
Regular image that works like a button.
Definition: ImageButton.h:34
void btnDisengageClick(Action *action)
Handler for clicking the Disengage button.
Definition: DogfightState.cpp:1399
void animateCraftDamage()
Animates craft damage.
Definition: DogfightState.cpp:595
void btnUfoClick(Action *action)
Handler for clicking the Ufo button.
Definition: DogfightState.cpp:1414
void weapon2Click(Action *action)
Toggles usage of weapon 2.
Definition: DogfightState.cpp:1572
void btnMinimizeClick(Action *action)
Handler for clicking the Minimize button.
Definition: DogfightState.cpp:1274
Shows a dogfight (interception) between a player craft and an UFO.
Definition: DogfightState.h:45
void btnMinimizedIconClick(Action *action)
Handler for clicking the minimized interception window icon.
Definition: DogfightState.cpp:1642
Element that is blit (rendered) onto the screen.
Definition: Surface.h:39
void setInterceptionNumber(const int number)
Sets interception number.
Definition: DogfightState.cpp:1672
void drawUfo()
Draws UFO.
Definition: DogfightState.cpp:1465
void weapon1Click(Action *action)
Toggles usage of weapon 1.
Definition: DogfightState.cpp:1562
Represents an alien UFO on the map.
Definition: Ufo.h:41
The core of the game engine, manages the game's entire contents and structure.
Definition: Game.h:44
void setStatus(const std::string &status)
Changes the status text.
Definition: DogfightState.cpp:1264
void recolor(const int weaponNo, const bool currentState)
Changes colors of weapon icons, range indicators and ammo texts base on current weapon state...
Definition: DogfightState.cpp:1583
void calculateWindowPosition()
Calculates window position according to opened interception windows.
Definition: DogfightState.cpp:1692
~DogfightState()
Cleans up the Dogfight state.
Definition: DogfightState.cpp:550
void fireWeapon1()
Fires a shot from the first weapon equipped on the craft.
Definition: DogfightState.cpp:1136
void think()
Runs the timers.
Definition: DogfightState.cpp:571
void btnStandardClick(Action *action)
Handler for clicking the Standard Attack button.
Definition: DogfightState.cpp:1353
Ufo * getUfo() const
Gets pointer to the UFO in this dogfight.
Definition: DogfightState.cpp:1812
void fireWeapon2()
Fires a shot from the second weapon equipped on the craft.
Definition: DogfightState.cpp:1162
Definition: CraftWeaponProjectile.h:36