#pragma once
#include "unit.h"
#include "main.h"
#include "cWalker.h"
#include "pathMaster.h"
#include "player.h"
class army;
class armyUnit;
class unit;
class cRegion{
public:
polygon2D shape;
army a;
};
class gameMap{
public:
bool startSave;
char name[20];
char tile[MAP_SIZE][MAP_SIZE];
int2 startPos[MAX_PLAYERS];
int2 size;
cRegion region[REGION_MAX];
bool endSave;
gameMap(){
}
bool withinMap(int x,int y){if(x>=0 && x<MAP_SIZE && y>=0 && y<MAP_SIZE) return true; return false; };
};
class gameObject{
public:
int type;
int subType,team;
float2 pos;
float life,rot;
float2 target;
bool ranged;
std::list<gameObject*>::iterator curIt;
};
class world
{
public:
hgeSprite * lightSprite;
HTARGET lightTexture;
HTEXTURE mapTexture;
int attackSoundMass[30];
int hitSoundMass[30];
float2 pan;
int2 sector;
bool editorOn;
float noUnitDelay;
pathMaster pathSolver;
std::list<gameObject *> objectList;
std::list<army> armyList;
std::list<unit> unitList;
unit * selectedUnit;
army * theNewArmy;
gameMap map;
HTEXTURE minimapTexture;
hgeSprite * minimap;
char roadBit[MAP_SIZE][MAP_SIZE];
char tileVariation[MAP_SIZE][MAP_SIZE];
float moveCost[10][30];
// battle stuff
char battleTerrain[BATTLE_X][BATTLE_Y];
char battleTerrainCurrent[BATTLE_X][BATTLE_Y];
army * bArmy1;
army * bArmy2;
bool battleOn;
float aiWait;
bool battleTurnLeft;
//_________________________________________________________________________________
bool startSave;
float timeMatch,timeCurrentRound;
int nextArmyId,nextTownId;
int turnNumber;
float gameTime;
bool showUnitRange;
int infoClass,infoType;
char townBaseIncome[10];
int gameScreen;
//settings
bool explorationOn;
int difficulty,baseIncome;
int startingPoints;
int gameMode;
bool mapLoaded;
int popupArmyID;
int regionID;
bool endSave;
//_________________________________________________________________________________
char goodsName[10][20];
char incomeName[10][20];
char regionRatingName[20][20];
char unitClassName[10][20];
void loadTextData();
void loadFileData();
void controlPan();
void controlGame();
void setupWorld();
void drawWorld();
void drawPanel();
void doWorldTurn();
void selectArmyFromMap();
void createArmy(int team,int2 pos,int type,int level=0);
void deleteArmy(army * u);
void drawSystemInfo();
//battle functions
void setupBattle(army * a1, army * a2);
void doBattle();
void reset(){
regionID = 0;
battleOn = false;
popupArmyID=-1;
gameScreen=0;
mapLoaded=false;
infoClass=0;
infoType=0;
startingPoints=20;
difficulty=2;
baseIncome=0;
selectedUnit=0;
editorOn=false;
explorationOn=true;
pan.x=0;
pan.y=0;
sprintf(goodsName[0],"Funds");
sprintf(goodsName[1],"Rare earth");
sprintf(goodsName[2],"Tech");
sprintf(goodsName[3],"Power");
sprintf(goodsName[4],"NOT_USED_GOODS");
sprintf(goodsName[5],"NOT_USED_GOODS");
sprintf(goodsName[6],"NOT_USED_GOODS");
sprintf(goodsName[7],"NOT_USED_GOODS");
sprintf(goodsName[8],"NOT_USED_GOODS");
sprintf(goodsName[9],"NOT_USED_GOODS");
sprintf(incomeName[0],"Taxes");
sprintf(incomeName[1],"Trade");
sprintf(incomeName[2],"Mining");
sprintf(incomeName[3],"Agriculture");
sprintf(incomeName[4], "Drilling");
sprintf(incomeName[6], "Rare earth");
sprintf(incomeName[7], "Tech");
for (int i = 0; i < 20; i++)
regionRatingName[0] = 0;
sprintf(regionRatingName[1], "Growth");
sprintf(regionRatingName[2], "Mining");
sprintf(regionRatingName[3], "Agriculture");
sprintf(regionRatingName[4], "Drilling");
sprintf(regionRatingName[6], "Rare earth");
sprintf(regionRatingName[10], "Solar");
sprintf(regionRatingName[11], "Biomass");
sprintf(regionRatingName[12], "Hydro");
sprintf(regionRatingName[13], "Geothermal");
sprintf(unitClassName[0], "Soft");
sprintf(unitClassName[4], "Mixed");
sprintf(unitClassName[1], "Hard");
sprintf(unitClassName[2], "Rotor");
sprintf(unitClassName[3], "Plane");
};
world(){
reset();
};
~world(void);
void editMap();
bool loadMap(char * name);
void saveMap(char * name);
void setVisible(int2 pos,int range);
void explore(int2 pos,int range);
void updateMinimap(int2 pos,bool careAboutExplored=true);
void drawMinimap(int2 pos,bool simple,int size);
void effectMinimap( int type );
void resetMap(int clearType=0);
bool withinMap( int x,int y );
void findNextUnit(int type=0);
void setPan( float2 pos );
void createObject( int type,int team,float2 pos,int data,float rot=0,float2 target=float2(-1,-1),bool ranged=false);
std::list<gameObject *>::iterator deleteObject(gameObject * o);
void updateObjects();
void drawCost( int x,int y,short cost[10],int time=0,char * name=0,int nameGap=0,int workers=0,int background=0);
void setMap( int x,int y,int type ,bool updateMini=true);
void drawInfo();
int getBuildingIcon(int bType);
void drawSingleCost( int x,int y,float cost,int costType,char * name=0,int nameGap=0,int decimals=0,DWORD color=white, float secondValue=-1000,char * helpTextOverride=0, int endingStyle=0, bool forcePlus=false);
int2 findFreeTile( int2 pos, int moveClass );
void calcControl( int teamID, bool draw );
void doArmyTurn(army * a);
void setRoadBit( int x,int y );
int10 getTerrainIncome( int x,int y,bool support=false, bool drawTiles=false );
bool buildPosOk( int x,int y,bool support );
void toggleInfo( int classIn, int typeIn );
void setMapTiles(int2 singleTile=int2(-1,-1));
void toggleGamescreen( int type);
void drawGamescreen();
float getSoundVol(int2 absPos,int team=0);
void gainGoods(int team, int2 absPos,int type, int mass, int playSound=-1);
int2 getBattlePos(float x, float y, bool leftSide);
int getSeason();
void newGame();
army * getArmyFromId(int id);
void doGame();
int drawProgressBoxes(int x, int y, char * name, char * helpText, int value, int maxValue, int nameGap=90);
void drawArmyUnit(int x, int y, armyUnit * u, int uType = 0);
bool drawBuilding(int2 pos, int bType = 0, int damage = 0, char * helpText=0);
void analyzeMap();
void setPathSolver(bool battle);
void drawBattle();
bool withinMapCombat(int x, int y);
bool enemyAdjacent(int2 pos, int team);
unit * getUnit(int2 pos);
};