#ifndef LEVELMANAGER_H_INCLUDED
#define LEVELMANAGER_H_INCLUDED

#include "Engine.h"

typedef enum {OBJECT_WALL = 0, OBJECT_EMPTY = 1, OBJECT_DEST=2, OBJECT_PLAYER=3, OBJECT_BOX=4} GAME_TYPE_OBJECT;

//-----------------------------------------

class cLevel
{
    private:
    protected:
    public:

    cLevel()
    {
        for(int indx1 = 0; indx1 < 20; indx1++)
            for(int indx2 = 0; indx2 < 20; indx2++)
            {
                m_Level[indx1][indx2] = OBJECT_EMPTY;
                m_CrateArray[indx1][indx2] = OBJECT_EMPTY;
            }

        m_LevelName = "";
        m_LevelNumber = 0;
        m_PlayerStartPosX = m_PlayerStartPosY = 0;
    }

    GAME_TYPE_OBJECT m_Level[20][20];
    GAME_TYPE_OBJECT m_CrateArray[20][20];
    int m_PlayerStartPosX;
    int m_PlayerStartPosY;
    int m_LevelNumber;
    std::string m_LevelName;
};

//-----------------------------------------

class cLevelManager : public cRenderObject
{
    private:
    protected:
        SDL_Surface *m_LevelTiles;
        SDL_Surface *m_CrateTile;

        cSprite *m_Player;
        int m_PlayerPosX;
        int m_PlayerPosY;

        int m_TileSize;
        void createLevels();

    public:

        std::vector<cLevel*> m_Levels;

        cLevel m_CurrentLevel;

        cLevelManager(std::string Name, int TileSize);
        void update(SDL_Surface *Screen);
        bool updateKey(SDLKey Key);
        bool setPlayerPos(int x, int y);
        bool doMove(SDLKey Key);
        void selectLevel(unsigned int Level);
        bool checkForWin();
};

#endif // LEVELMANAGER_H_INCLUDED
