102 lines
2.8 KiB
C++
102 lines
2.8 KiB
C++
#ifndef __PLAYER_HEADER__
|
|
#define __PLAYER_HEADER__
|
|
|
|
/* **************************************
|
|
* Includes *
|
|
* **************************************/
|
|
|
|
#include "Global_Inc.h"
|
|
#include "Camera.h"
|
|
#include "Unit.h"
|
|
|
|
/* **************************************
|
|
* Defines *
|
|
* **************************************/
|
|
|
|
#define PLAYER_NAME_LENGTH 16
|
|
#define PLAYER_MAX_UNITS_BUILDINGS 32
|
|
|
|
/* **************************************
|
|
* Structs and enums *
|
|
* **************************************/
|
|
|
|
typedef struct t_Resource
|
|
{
|
|
uint8_t Wood;
|
|
uint8_t Gold;
|
|
uint8_t Food;
|
|
}TYPE_RESOURCES;
|
|
|
|
/* **************************************
|
|
* Class definition *
|
|
* **************************************/
|
|
|
|
#ifdef __cplusplus
|
|
|
|
class Player
|
|
{
|
|
public:
|
|
Player();
|
|
~Player();
|
|
void Init(void);
|
|
void Handler(void);
|
|
void DrawHandler(void);
|
|
char* getName(void) {return name;}
|
|
void setHuman(bool value) { human = value; }
|
|
bool isHuman(void) {return human;}
|
|
bool createUnit(TYPE_UNIT_ID id, TYPE_COLLISION_BLOCK cb);
|
|
uint8_t getPopulation(void) {return (unit_i + 1);}
|
|
void ShowResources(void);
|
|
|
|
private:
|
|
// Player definition
|
|
bool human;
|
|
char name[PLAYER_NAME_LENGTH];
|
|
TYPE_RESOURCES Resources;
|
|
|
|
// Unit handling
|
|
TYPE_UNIT units[PLAYER_MAX_UNITS_BUILDINGS];
|
|
uint8_t unit_i;
|
|
|
|
// Camera handling
|
|
TYPE_CAMERA Camera;
|
|
|
|
// Map rendering
|
|
void RenderMap(void);
|
|
|
|
// Button pressed/released events
|
|
void ButtonLeftReleased(void);
|
|
void ButtonRightReleased(void);
|
|
void ButtonAPressed(void);
|
|
void ButtonAReleased(void);
|
|
void ButtonBPressed(void);
|
|
void ButtonBReleased(void);
|
|
|
|
bool checkNewBuildingPosition(TYPE_COLLISION_BLOCK * cb);
|
|
void UnitBuildingSelection(void);
|
|
void showHealth(uint8_t hp);
|
|
void ButtonHandler(void);
|
|
void ActionsMenu(void);
|
|
TYPE_COLLISION_BLOCK GetCursorPos(void);
|
|
|
|
// Unit selection
|
|
bool anyUnitSelected;
|
|
int8_t selectedUnitCandidate;
|
|
uint8_t unselectUnits_counter;
|
|
|
|
// Actions selection
|
|
bool showActionsMenu;
|
|
uint8_t showActionsMenu_counter;
|
|
uint8_t showActionsMenu_index;
|
|
uint8_t showActionsMenu_counterLevel1;
|
|
void IncreaseShowActionsMenuIndex();
|
|
|
|
// Action callbacks
|
|
void ActionCreateUnit(TYPE_UNIT* ptrUnit, TYPE_UNIT_ID unit);
|
|
void ActionCreateBuilding(TYPE_UNIT* ptrUnit, TYPE_UNIT_ID bldg);
|
|
};
|
|
|
|
#endif // __cplusplus
|
|
|
|
#endif //PLAYER_HEADER__
|