Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc @ 12159

Last change on this file since 12159 was 12159, checked in by kunzro, 5 years ago

highlight and dehighlight function added for province and WagnisHUD info adjusts colour

File size: 3.3 KB
Line 
1
2
3#include "WagnisProvince.h"
4
5#define WAGNIS_PROVINCE_MAX_HEALTH 1000000.0f
6
7/**TODO
8 *
9 *
10 *
11 **/
12
13namespace 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(std::to_string(0));
23        this->setRadarObjectColour(colour({128,128,128}, 100.0f));
24        this->ID = -1;
25        this->continent = -1;
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({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
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    //set troops
84    void WagnisProvince::setTroops(int troops){
85        this->troops = troops;
86        this->setRadarName(std::to_string(troops));
87    }
88    //set ID
89    void WagnisProvince::setID(int id){
90        this->ID = id;
91    }
92    //set Continent
93    void WagnisProvince::setContinent(int cont){
94        this->continent = cont;
95    }
96
97
98    //GET()
99
100    //get owner_ID
101    int WagnisProvince::getOwner_ID() const{
102        return this->owner_ID;
103    }
104    //get troops
105    int WagnisProvince::getTroops() const{
106        return this->troops;
107    }
108    //get ID
109    int WagnisProvince::getID() const{
110        return this->ID;
111    }
112    //get continent
113    int WagnisProvince::getContinent() const{
114        return this-> continent;
115    }
116
117    //Adds a connection to neighbors.
118    void WagnisProvince::addNeighbor(WagnisProvince* prov){
119        neighbors.push_back(prov);
120    }
121}
Note: See TracBrowser for help on using the repository browser.