summaryrefslogtreecommitdiff
path: root/UnitOld.h
diff options
context:
space:
mode:
authorXaviDCR92 <xavi.dcr@gmail.com>2018-07-09 19:26:13 +0200
committerXaviDCR92 <xavi.dcr@gmail.com>2018-07-09 19:26:13 +0200
commitf0b654b9bf3bc2a93c1f89d4cc3edcf77b948555 (patch)
tree91b7404dca0b6eb136cb7f9b144435419144b777 /UnitOld.h
parentd85464781580796bbcc744ae732e56d1920e3b0f (diff)
downloadpocketempires-f0b654b9bf3bc2a93c1f89d4cc3edcf77b948555.tar.gz
Game has been restructured in favor of OOP
Diffstat (limited to 'UnitOld.h')
-rw-r--r--UnitOld.h123
1 files changed, 123 insertions, 0 deletions
diff --git a/UnitOld.h b/UnitOld.h
new file mode 100644
index 0000000..d8a59e0
--- /dev/null
+++ b/UnitOld.h
@@ -0,0 +1,123 @@
+#ifndef UNIT_H__
+#define UNIT_H__
+
+/* **************************************
+ * Includes *
+ * **************************************/
+
+#include "Global_Inc.h"
+#include "Camera.h"
+#include "Player.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* cplusplus. */
+
+/* **************************************
+ * Defines *
+ * **************************************/
+
+ /* **************************************
+ * Structs and enums *
+ * **************************************/
+
+typedef enum t_unitdirection
+{
+ DIRECTION_LEFT = 0,
+ DIRECTION_RIGHT,
+ DIRECTION_UP,
+ DIRECTION_DOWN
+}UNIT_DIRECTION;
+
+typedef enum t_unitid
+{
+ /* Walking units. */
+ PEASANT,
+ SOLDIER,
+
+ MAX_UNIT_ID,
+
+ /* Buildings. */
+ BARRACKS,
+ TOWER,
+ TOWN_CENTER,
+
+ MAX_BUILDING_ID,
+
+ MAX_UNITS_BUILDINGS,
+
+ FIRST_UNIT_ID = PEASANT,
+ 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;
+ void (*pAction)(TYPE_UNIT*);
+}TYPE_UNIT_ACTION;
+
+typedef enum t_availableactions
+{
+ ACTION_BUILD_BARRACKS,
+ 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);
+
+/* Unit information. */
+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 UnitDrawShadow(TYPE_UNIT *ptrUnit, TYPE_CAMERA *ptrCamera);
+
+/* Movement. */
+void UnitMoveTo(TYPE_UNIT *ptrUnit, uint16_t x, uint16_t y);
+
+/* Collision cheking. */
+bool UnitCheckCollisionAgainstOtherUnits(TYPE_COLLISION_BLOCK* cb, TYPE_UNIT *ptrUnitArray, TYPE_UNIT* ptrCurrentUnit);
+
+/* Selection index. */
+const char* UnitGetActionString(UNIT_ACTION action);
+
+#ifdef __cplusplus
+}
+#endif /* cplusplus. */
+
+#endif /* UNIT_H__. */