diff options
| author | XaviDCR92 <xavi.dcr@gmail.com> | 2017-11-05 05:38:31 +0100 |
|---|---|---|
| committer | XaviDCR92 <xavi.dcr@gmail.com> | 2017-11-05 05:38:31 +0100 |
| commit | 8fba2176bc34aa7e507f0b9d983427bb5e522e17 (patch) | |
| tree | d5e1c7d5560f30581fc5a1957121fc0a198b62f7 /Unit.h | |
| parent | 2cf2d608af862e812e7fd3ac580f869141a96fa7 (diff) | |
| download | pocketempires-8fba2176bc34aa7e507f0b9d983427bb5e522e17.tar.gz | |
* Modified shadows for Town centre.
* Bugfixes in unit movement and collision detection. Now it should work fine.
* Added include guards to all *.i files.
* Other minor changes
Diffstat (limited to 'Unit.h')
| -rw-r--r-- | Unit.h | 64 |
1 files changed, 35 insertions, 29 deletions
@@ -7,6 +7,7 @@ #include "Global_Inc.h" #include "Camera.h" +#include "Player.h" #ifdef __cplusplus extern "C" @@ -29,29 +30,11 @@ typedef enum t_unitdirection DIRECTION_DOWN }UNIT_DIRECTION; -typedef struct t_Unit -{ - uint16_t x; - uint16_t y; - uint16_t target_x; - uint16_t target_y; - uint8_t hp; - uint8_t id; - UNIT_DIRECTION dir; - bool mirror; // True = down or left; true = up or right - bool building; - bool walking; - bool alive; - bool selected; - bool selecting_attack; - bool attacking; - uint8_t walk_counter; -}TYPE_UNIT; - typedef enum t_unitid { // Walking units - PEASANT = 0, + PEASANT, + SOLDIER, MAX_UNIT_ID, @@ -68,6 +51,25 @@ typedef enum t_unitid FIRST_BUILDING_ID = BARRACKS }TYPE_UNIT_ID; +typedef struct t_Unit +{ + uint16_t x; + uint16_t y; + uint16_t target_x; + uint16_t target_y; + uint8_t hp; + TYPE_UNIT_ID id; + UNIT_DIRECTION dir; + bool mirror; // True = down or left; true = up or right + bool building; + bool walking; + bool alive; + bool selected; + bool selecting_attack; + bool attacking; + uint8_t walk_counter; +}TYPE_UNIT; + typedef struct { const char* str; @@ -79,32 +81,36 @@ typedef enum t_availableactions ACTION_BUILD_BARRACKS, ACTION_ATTACK, ACTION_CREATE_PEASANT, + ACTION_CREATE_SOLDIER, + ACTION_BUILD_TOWER_CENTER, MAX_ACTIONS }UNIT_ACTION; typedef struct t_Camera TYPE_CAMERA; +typedef struct t_Resource TYPE_RESOURCES; /* ************************************** * Global prototypes * * **************************************/ // Initialization and handling -void UnitInit(void); -void UnitHandler(TYPE_UNIT* unitArray, size_t sz); +void UnitInit(void); +void UnitHandler(TYPE_UNIT* unitArray, size_t sz); // Unit information -uint8_t UnitGetHpFromID(uint8_t id); -uint8_t UnitGetWidthFromID(uint8_t id); -uint8_t UnitGetHeightFromID(uint8_t id); -uint8_t UnitGetAvailableActions(TYPE_UNIT* ptrUnit); +uint8_t UnitGetHpFromID(TYPE_UNIT_ID id); +uint8_t UnitGetWidthFromID(TYPE_UNIT_ID id); +uint8_t UnitGetHeightFromID(TYPE_UNIT_ID id); +uint8_t UnitGetAvailableActions(TYPE_UNIT* ptrUnit); +TYPE_RESOURCES UnitNeededResourcesFromID(TYPE_UNIT_ID id); // Rendering -void UnitDraw(TYPE_UNIT* ptrUnit, TYPE_CAMERA* ptrCamera, bool bHighlighted); +void UnitDraw(TYPE_UNIT* ptrUnit, TYPE_CAMERA* ptrCamera, bool bHighlighted); -void UnitMoveTo(TYPE_UNIT* ptrUnit, uint16_t x, uint16_t y); +void UnitMoveTo(TYPE_UNIT* ptrUnit, uint16_t x, uint16_t y); // Selection index -const char* UnitGetActionString(UNIT_ACTION action); +const char* UnitGetActionString(UNIT_ACTION action); #ifdef __cplusplus } |
