[12114] | 1 | |
---|
| 2 | |
---|
[12049] | 3 | #include "WagnisProvince.h" |
---|
| 4 | |
---|
[12119] | 5 | #define WAGNIS_PROVINCE_MAX_HEALTH 1000000.0f |
---|
[12107] | 6 | |
---|
| 7 | /**TODO |
---|
| 8 | * |
---|
| 9 | * |
---|
| 10 | * |
---|
| 11 | **/ |
---|
| 12 | |
---|
[12049] | 13 | namespace orxonox |
---|
| 14 | { |
---|
| 15 | RegisterClass(WagnisProvince); |
---|
| 16 | |
---|
| 17 | //Constructor |
---|
[12107] | 18 | WagnisProvince::WagnisProvince(Context* context) : Pawn(context){ |
---|
[12049] | 19 | RegisterObject(WagnisProvince); |
---|
[12133] | 20 | this->owner_ID = -1; |
---|
[12049] | 21 | this->troops = 0; |
---|
[12160] | 22 | this->setRadarName(""); |
---|
[12136] | 23 | this->setRadarObjectColour(colour({128,128,128}, 100.0f)); |
---|
[12049] | 24 | this->ID = -1; |
---|
| 25 | this->continent = -1; |
---|
[12050] | 26 | this->neighbors = std::vector<WagnisProvince*>(); |
---|
[12132] | 27 | |
---|
| 28 | this->initialHealth_ = WAGNIS_PROVINCE_MAX_HEALTH; |
---|
[12107] | 29 | this->maxHealth_ = WAGNIS_PROVINCE_MAX_HEALTH; |
---|
[12119] | 30 | this->health_ = WAGNIS_PROVINCE_MAX_HEALTH; |
---|
[12049] | 31 | } |
---|
| 32 | //Destructor |
---|
| 33 | WagnisProvince::~WagnisProvince(){ |
---|
| 34 | |
---|
| 35 | } |
---|
| 36 | |
---|
[12051] | 37 | //XML Port |
---|
| 38 | void WagnisProvince::XMLPort(Element& xmlelement,XMLPort::Mode mode){ |
---|
[12067] | 39 | SUPER(WagnisProvince, XMLPort, xmlelement, mode); |
---|
| 40 | |
---|
[12051] | 41 | XMLPortParam(WagnisProvince, "ID", setID, getID, xmlelement, mode); |
---|
| 42 | XMLPortParam(WagnisProvince, "continent", setContinent, getContinent, xmlelement, mode); |
---|
| 43 | } |
---|
[12049] | 44 | |
---|
| 45 | |
---|
| 46 | |
---|
[12051] | 47 | |
---|
[12049] | 48 | //SET() |
---|
| 49 | |
---|
| 50 | //set owner_ID |
---|
| 51 | void WagnisProvince::setOwner_ID(int owner){ |
---|
| 52 | this->owner_ID = owner; |
---|
[12136] | 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; |
---|
[12150] | 58 | case 3: this->setRadarObjectColour( colour({255,255,0}, 100.0f) ); |
---|
[12136] | 59 | break; |
---|
[12150] | 60 | case 4: this->setRadarObjectColour( colour({0,0,255}, 100.0f) ); |
---|
[12136] | 61 | break; |
---|
| 62 | case 5: this->setRadarObjectColour( colour({255,0,255}, 100.0f) ); |
---|
| 63 | break; |
---|
| 64 | case 6: this->setRadarObjectColour( colour({128,128,0}, 40.0f) ); |
---|
| 65 | break; |
---|
| 66 | case 7: this->setRadarObjectColour( colour({0,255,255}, 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 | |
---|
[12049] | 74 | } |
---|
[12159] | 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 | } |
---|
[12160] | 83 | |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | |
---|
[12049] | 87 | //set troops |
---|
| 88 | void WagnisProvince::setTroops(int troops){ |
---|
| 89 | this->troops = troops; |
---|
[12134] | 90 | this->setRadarName(std::to_string(troops)); |
---|
[12049] | 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 |
---|
[12051] | 105 | int WagnisProvince::getOwner_ID() const{ |
---|
[12049] | 106 | return this->owner_ID; |
---|
| 107 | } |
---|
| 108 | //get troops |
---|
[12051] | 109 | int WagnisProvince::getTroops() const{ |
---|
[12049] | 110 | return this->troops; |
---|
| 111 | } |
---|
| 112 | //get ID |
---|
[12051] | 113 | int WagnisProvince::getID() const{ |
---|
[12049] | 114 | return this->ID; |
---|
| 115 | } |
---|
| 116 | //get continent |
---|
[12051] | 117 | int WagnisProvince::getContinent() const{ |
---|
[12049] | 118 | return this-> continent; |
---|
| 119 | } |
---|
| 120 | |
---|
[12072] | 121 | //Adds a connection to neighbors. |
---|
[12049] | 122 | void WagnisProvince::addNeighbor(WagnisProvince* prov){ |
---|
| 123 | neighbors.push_back(prov); |
---|
| 124 | } |
---|
| 125 | } |
---|