| 1 | |
|---|
| 2 | |
|---|
| 3 | #include "WagnisProvince.h" |
|---|
| 4 | |
|---|
| 5 | #define WAGNIS_PROVINCE_MAX_HEALTH 1000000.0f |
|---|
| 6 | |
|---|
| 7 | /**TODO |
|---|
| 8 | * |
|---|
| 9 | * |
|---|
| 10 | * |
|---|
| 11 | **/ |
|---|
| 12 | |
|---|
| 13 | namespace orxonox |
|---|
| 14 | { |
|---|
| 15 | RegisterClass(WagnisProvince); |
|---|
| 16 | |
|---|
| 17 | //Constructor |
|---|
| 18 | WagnisProvince::WagnisProvince(Context* context) : Pawn(context){ |
|---|
| 19 | RegisterObject(WagnisProvince); |
|---|
| 20 | this->owner_ID = -1; |
|---|
| 21 | this->troops = 0; |
|---|
| 22 | this->setRadarName(""); |
|---|
| 23 | this->setRadarObjectColour(colour({128,128,128}, 100.0f)); |
|---|
| 24 | this->ID = -1; |
|---|
| 25 | this->continent = 0; |
|---|
| 26 | this->neighbors = std::vector<WagnisProvince*>(); |
|---|
| 27 | |
|---|
| 28 | this->initialHealth_ = WAGNIS_PROVINCE_MAX_HEALTH; |
|---|
| 29 | this->maxHealth_ = WAGNIS_PROVINCE_MAX_HEALTH; |
|---|
| 30 | this->health_ = WAGNIS_PROVINCE_MAX_HEALTH; |
|---|
| 31 | } |
|---|
| 32 | //Destructor |
|---|
| 33 | WagnisProvince::~WagnisProvince(){ |
|---|
| 34 | |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | //XML Port |
|---|
| 38 | void WagnisProvince::XMLPort(Element& xmlelement,XMLPort::Mode mode){ |
|---|
| 39 | SUPER(WagnisProvince, XMLPort, xmlelement, mode); |
|---|
| 40 | |
|---|
| 41 | XMLPortParam(WagnisProvince, "ID", setID, getID, xmlelement, mode); |
|---|
| 42 | XMLPortParam(WagnisProvince, "continent", setContinent, getContinent, xmlelement, mode); |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | //SET() |
|---|
| 49 | |
|---|
| 50 | //set owner_ID |
|---|
| 51 | void WagnisProvince::setOwner_ID(int owner){ |
|---|
| 52 | this->owner_ID = owner; |
|---|
| 53 | switch(owner){ |
|---|
| 54 | case 1: this->setRadarObjectColour( colour({255,0,0}, 100.0f) ); |
|---|
| 55 | break; |
|---|
| 56 | case 2: this->setRadarObjectColour( colour({0,255,0}, 100.0f) ); |
|---|
| 57 | break; |
|---|
| 58 | case 3: this->setRadarObjectColour( colour({255,255,0}, 100.0f) ); |
|---|
| 59 | break; |
|---|
| 60 | case 4: this->setRadarObjectColour( colour({0,0,255}, 100.0f) ); |
|---|
| 61 | break; |
|---|
| 62 | case 5: this->setRadarObjectColour( colour({255,0,255}, 100.0f) ); |
|---|
| 63 | break; |
|---|
| 64 | case 6: this->setRadarObjectColour( colour({0,255,255}, 100.0f) ); |
|---|
| 65 | break; |
|---|
| 66 | case 7: this->setRadarObjectColour( colour({128,128,0}, 100.0f) ); |
|---|
| 67 | break; |
|---|
| 68 | case 8: this->setRadarObjectColour( colour({153,255,204}, 100.0f) ); |
|---|
| 69 | break; |
|---|
| 70 | case 9: this->setRadarObjectColour( colour({102,51,0}, 100.0f) ); |
|---|
| 71 | break; |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | } |
|---|
| 75 | //highlight a province |
|---|
| 76 | void WagnisProvince::highlight(){ |
|---|
| 77 | this->setRadarObjectColour( colour({255,255,255}, 100.0f) ); |
|---|
| 78 | } |
|---|
| 79 | //dehighlight a province |
|---|
| 80 | void WagnisProvince::dehighlight(){ |
|---|
| 81 | this->setOwner_ID( this->getOwner_ID() ); |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | //set troops |
|---|
| 88 | void WagnisProvince::setTroops(int troops){ |
|---|
| 89 | this->troops = troops; |
|---|
| 90 | this->setRadarName(std::to_string(troops)); |
|---|
| 91 | } |
|---|
| 92 | //set ID |
|---|
| 93 | void WagnisProvince::setID(int id){ |
|---|
| 94 | this->ID = id; |
|---|
| 95 | } |
|---|
| 96 | //set Continent |
|---|
| 97 | void WagnisProvince::setContinent(int cont){ |
|---|
| 98 | this->continent = cont; |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | //GET() |
|---|
| 103 | |
|---|
| 104 | //get owner_ID |
|---|
| 105 | int WagnisProvince::getOwner_ID() const{ |
|---|
| 106 | return this->owner_ID; |
|---|
| 107 | } |
|---|
| 108 | //get troops |
|---|
| 109 | int WagnisProvince::getTroops() const{ |
|---|
| 110 | return this->troops; |
|---|
| 111 | } |
|---|
| 112 | //get ID |
|---|
| 113 | int WagnisProvince::getID() const{ |
|---|
| 114 | return this->ID; |
|---|
| 115 | } |
|---|
| 116 | //get continent |
|---|
| 117 | int WagnisProvince::getContinent() const{ |
|---|
| 118 | return this-> continent; |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | //Adds a connection to neighbors. |
|---|
| 122 | void WagnisProvince::addNeighbor(WagnisProvince* prov){ |
|---|
| 123 | neighbors.push_back(prov); |
|---|
| 124 | } |
|---|
| 125 | } |
|---|