Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 2, 2018, 10:47:00 PM (6 years ago)
Author:
stadlero
Message:

Troop count is visible in the HUD

Location:
code/branches/wagnis_HS18/src/modules/wagnis
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc

    r12133 r12134  
    1 
    2 
    3 
    41
    52
     
    6461                        if (checkMove(SET_TROOPS_INITIAL)){
    6562                            this->target_province->owner_ID = this->Player_ID;
    66                             this->target_province->troops += 1;
    67                             orxout()<<"Province "<<this->target_province->ID<<" owned by Player "<<this->target_province->owner_ID<<" troops: "<<this->target_province->troops<<endl;
     63                            this->target_province->setTroops(this->target_province->getTroops()+1);
     64                            orxout()<<"Province "<<this->target_province->ID<<" owned by Player "<<this->target_province->owner_ID<<" troops: "<<this->target_province->getTroops()<<endl;
    6865                            master->playerFinishedStageCallback(this);
    6966                        }else{
     
    7774                    {
    7875                        if (checkMove(SET_TROOPS)){
    79                             this->target_province->troops += 1;
    80                             orxout()<<"Province "<<this->target_province->ID<<" owned by Player "<<this->target_province->owner_ID<<" troops: "<<this->target_province->troops<<endl;
     76                            this->target_province->setTroops(this->target_province->getTroops()+1);
     77                            orxout()<<"Province "<<this->target_province->ID<<" owned by Player "<<this->target_province->owner_ID<<" troops: "<<this->target_province->getTroops()<<endl;
    8178                        }
    8279                           
     
    8784                        if (checkMove(ATTACK))
    8885                        {
    89                             while ((this->origin_province->troops > 1) && (this->target_province->troops > 0)) //still troops available
     86                            while ((this->origin_province->getTroops() > 1) && (this->target_province->getTroops() > 0)) //still troops available
    9087                            {
    91                                 while ((this->origin_province->troops >= 4) && (this->target_province->troops >= 2))
     88                                while ((this->origin_province->getTroops() >= 4) && (this->target_province->getTroops() >= 2))
    9289                                {
    9390                                    //normal fight, 3 attackers, 2 defenders
    9491                                }
    9592
    96                                 if ((this->origin_province->troops == 3) && (this->target_province->troops >= 2))
     93                                if ((this->origin_province->getTroops() == 3) && (this->target_province->getTroops() >= 2))
    9794                                {
    9895                                    //2 attackers, 2 defenders
    9996                                }
    10097
    101                                 if((this->origin_province->troops == 2) && (this->target_province->troops >= 2))
     98                                if((this->origin_province->getTroops() == 2) && (this->target_province->getTroops() >= 2))
    10299                                {
    103100                                    //1 attacker, 2 defenders
     
    107104                            }
    108105
    109                             if (this->target_province->troops == 0) //attacker won
     106                            if (this->target_province->getTroops() == 0) //attacker won
    110107                            {
    111108                                this->target_province->owner_ID = this->Player_ID;
    112                                 this->target_province->troops = (this->origin_province->troops - 1);
    113                                 this->origin_province->troops = 1;
     109                                this->target_province->setTroops(this->origin_province->getTroops() - 1);
     110                                this->origin_province->setTroops(1);
    114111                            }
    115112                        }
     
    121118                        if (checkMove(MOVE))
    122119                        {
    123                             this->target_province->troops += ((this->origin_province->troops) - 1);
    124                             this->origin_province->troops = 1;
     120                            this->target_province->setTroops(this->origin_province->getTroops()-1);
     121                            this->origin_province->setTroops(1);
    125122                        }
    126123                        break;
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h

    r12130 r12134  
    3939
    4040
    41         //void (Wagnis::*finishedStageCallback) (WagnisPlayer*);
    4241        Wagnis* master;
    4342        GameStage gameStage;
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc

    r12133 r12134  
    22
    33#include "WagnisProvince.h"
    4 #include "core/CoreIncludes.h"
    5 #include "BulletDynamics/Dynamics/btRigidBody.h"
    6 #include "worldentities/StaticEntity.h"
    7 #include <vector>
    84
    95#define WAGNIS_PROVINCE_MAX_HEALTH 1000000.0f
     
    2420        this->owner_ID = -1;
    2521        this->troops = 0;
     22        this->setRadarName(std::to_string(0));
    2623        this->ID = -1;
    2724        this->continent = -1;
    2825        this->neighbors = std::vector<WagnisProvince*>();
    29         this->markerBillboard = nullptr;
    3026       
    3127        this->initialHealth_ = WAGNIS_PROVINCE_MAX_HEALTH;
     
    4238        SUPER(WagnisProvince, XMLPort, xmlelement, mode);
    4339
    44         XMLPortObject(WagnisProvince, Billboard, "MarkerBillboard", addMarkerBillboard, getMarkerBillboard, xmlelement, mode);
    4540        XMLPortParam(WagnisProvince, "ID", setID, getID, xmlelement, mode);
    4641        XMLPortParam(WagnisProvince, "continent", setContinent, getContinent, xmlelement, mode);
    47     }
    48 
    49     void WagnisProvince::addMarkerBillboard(Billboard* billi){
    50         this->markerBillboard = billi;
    51         attach(billi);
    52     }
    53     Billboard* WagnisProvince::getMarkerBillboard(unsigned int i) const{
    54         if(i != 0) return nullptr;
    55         return this->markerBillboard;
    5642    }
    5743
     
    6854    void WagnisProvince::setTroops(int troops){
    6955        this->troops = troops;
     56        this->setRadarName(std::to_string(troops));
     57        //TEST
     58        if(troops == 5){
     59            Ogre::ColourValue cv = colour({255,255,255}, 100.0f);
     60            this->setRadarObjectColour(cv);
     61        }
     62       
    7063    }
    7164    //set ID
     
    10295        neighbors.push_back(prov);
    10396    }
    104 
    105     void WagnisProvince::setBillbardVisibility(bool b){
    106         //TODO set visibility of billboard
    107     }
    10897}
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.h

    r12114 r12134  
    1111#include "core/XMLPort.h"
    1212#include "worldentities/pawns/Pawn.h"
    13 #include "graphics/Billboard.h"
     13#include "tools/OgreBulletUtils.h"
    1414#include <vector>
     15#include <OgreColourValue.h>
     16#include "tools/ToolsPrereqs.h"
    1517
    1618
     
    2527
    2628        virtual void XMLPort(Element&,XMLPort::Mode);
    27         void addMarkerBillboard(Billboard*);
    28         Billboard* getMarkerBillboard(unsigned int) const;
    2929
    3030        void setOwner_ID(int);
     
    3939
    4040        void addNeighbor(WagnisProvince*);
    41         void setBillbardVisibility(bool);
    4241
    4342
    4443        std::vector<WagnisProvince*> neighbors;
    4544        int owner_ID;
    46         int troops;
    4745        int ID;
    4846        int continent;
    49        
    50         Billboard* markerBillboard;
     47
     48        private:
     49        int troops;
     50
    5151    };
    5252}
Note: See TracChangeset for help on using the changeset viewer.