| 1 |
|
| 2 |
|
| 3 |
#ifndef PLANETS_H |
| 4 |
#define PLANETS_H |
| 5 |
|
| 6 |
#include <list> |
| 7 |
|
| 8 |
#include "actions.h" |
| 9 |
#include "coordinate.h" |
| 10 |
|
| 11 |
class Ship; |
| 12 |
class Universe; |
| 13 |
class Player; |
| 14 |
class Selection; |
| 15 |
|
| 16 |
class Planet { |
| 17 |
private: |
| 18 |
Universe* universe; |
| 19 |
Player* owner; |
| 20 |
int rotationSpeed, rotationOffset; |
| 21 |
double rotationDistance; |
| 22 |
int shipCreationSpeed; |
| 23 |
int size; |
| 24 |
bool isAMoon, selected, sourceSelected, nearestPlanet; |
| 25 |
Planet* mother; |
| 26 |
std::list< Ship* > residentShips; |
| 27 |
Uint32 buildStartTime, buildEndTime; |
| 28 |
|
| 29 |
Coordinate locationVector; |
| 30 |
|
| 31 |
public: |
| 32 |
Planet(); |
| 33 |
|
| 34 |
void makeMoon( Planet* ); |
| 35 |
Coordinate getLocation() const; |
| 36 |
|
| 37 |
void addResident( Ship* ship, Uint32 time ); |
| 38 |
void createShip( const Uint32& time); |
| 39 |
void removeResident( Ship* ship ); |
| 40 |
|
| 41 |
void render(Uint32) const; |
| 42 |
void renderOrbit( ) const; |
| 43 |
void renderBuildProgress(Uint32) const; |
| 44 |
|
| 45 |
void update(Uint32); |
| 46 |
void updateShipLocations(Uint32); |
| 47 |
|
| 48 |
double distance( Planet* planet ); |
| 49 |
|
| 50 |
int numberOfResidentShips() { return residentShips.size(); } |
| 51 |
void setSourceSelected( bool selected ); |
| 52 |
bool isSourceSelected() { return sourceSelected; } |
| 53 |
|
| 54 |
void setNearestPlanet(bool b); |
| 55 |
bool isNearestPlanet() { return nearestPlanet; } |
| 56 |
|
| 57 |
void moveResidentsTo(Uint32, Planet *, int); |
| 58 |
|
| 59 |
void setSelected( bool selected ); |
| 60 |
void setUniverse( Universe* universe ); |
| 61 |
bool getMoon() const { return isAMoon; } |
| 62 |
|
| 63 |
|
| 64 |
void setOwner(Player *); |
| 65 |
Player* getOwner() const { return owner; } |
| 66 |
|
| 67 |
}; |
| 68 |
|
| 69 |
class Planets : public std::list< Planet *> { |
| 70 |
public: |
| 71 |
Planets(); |
| 72 |
Planets( int numberOfPlanets, int numberOfMoons ); |
| 73 |
~Planets(); |
| 74 |
|
| 75 |
void addPlanets( int numberOfPlanets ); |
| 76 |
void addMoons( int numberOfMoons ); |
| 77 |
|
| 78 |
void render(Uint32) const; |
| 79 |
void renderOrbits( ) const; |
| 80 |
|
| 81 |
Planet* closestToCoordinate( const Coordinate& c ); |
| 82 |
Planet* closestToCoordinate( const Coordinate& c, double treshold ); |
| 83 |
|
| 84 |
void select( Selection selection ); |
| 85 |
void sourceSelect( Selection *selection, Player *owner ); |
| 86 |
|
| 87 |
void update(Uint32); |
| 88 |
|
| 89 |
void setUniverse( Universe* universe ); |
| 90 |
|
| 91 |
Planet* getRandomPlanet(); |
| 92 |
Planet* getRandomEnemyPlanet( Player* ); |
| 93 |
Planet* getRandomFriendlyPlanet( Player* ); |
| 94 |
Planet* getRandomNearbyPlanet( Planet* ); |
| 95 |
|
| 96 |
}; |
| 97 |
|
| 98 |
class CreateShipAction : public Action { |
| 99 |
private: |
| 100 |
Planet *planet; |
| 101 |
public: |
| 102 |
CreateShipAction(Planet *); |
| 103 |
void execute( const Uint32& time ); |
| 104 |
}; |
| 105 |
|
| 106 |
#endif |