#include "../game.h" #include "selectable.h" #include "button.h" #include "../definitions.h" #include "raylib.h" #include "stdio.h" #include "../MapObject/building.h" #include "../Sprite/sprite.h" #include "../Entity/entity.h" #include "../Input/inputHandler.h" void OnClickButton(Game *game, Button *button){ printf("\n\n\n\n\n\n Unsupported Button ID %d \n\n\n\n\n\n", button->id); return; } void OnClickContinueButton(Game *game, Button *button){ game->screen = SCREEN_GAME; } void OnClickExitButton(Game *game, Button *button){ game->screen = SCREEN_EXIT; } void OnClickStartButton(Game *game, Button *button){ game->screen = SCREEN_GAME; } // Hier sollte eine Bedingung stehen die nur in einem Frame true sein kann // Oder das selectable wird abgewählt indem seine ID auf default zurückgesetzt wird // Sonst kann das hier jeden Frame passieren. ID wird nicht automatisch zurückgesetzt void OnSelectedSelectable(Game *game, Selectable *selectable){ printf("\n\n\n\n\n\n WARNING: Unsupported SELECTABLE ID %d \n\n\n\n\n\n", selectable->id); return; } void OnSelectedSpawnBuilding(Game *game, Selectable *selectable){ if(IsMouseButtonDown(MOUSE_BUTTON_LEFT) && game->mouseOnUI == 0){ Building *newObject = BuildingInit(game, BU_HOUSE, game->inputHandler->cursorWorldPos.x, game->inputHandler->cursorWorldPos.y); BuildingListInsert(game->buildings, newObject); selectable->state = SELECTABLE_STATE_DEFAULT; } } void OnSelectedSpawnWorker(Game *game, Selectable *selectable){ if(IsMouseButtonDown(MOUSE_BUTTON_LEFT) && game->mouseOnUI == 0){ Entity *lumberjack = EntityInit(game, PR_BUILDER, game->inputHandler->cursorWorldPos.x, game->inputHandler->cursorWorldPos.y); EntityListInsert(game->entities, lumberjack); selectable->state = SELECTABLE_STATE_DEFAULT; } }