/*Copyright (C) 2010-2012 Duncan Deveaux

This file is part of Hikou no mizu.

Hikou no mizu is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Hikou no mizu is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Hikou no mizu.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef DEF_PLAYER_MOVES
#define DEF_PLAYER_MOVES

#define STATE_DEFAULT 0
#define STATE_MOVING 1
#define STATE_FALLING 2
#define STATE_KO 3

#define ACTION_DEFAULT 0
#define ACTION_PUNCH 1

#include <map>
#include "Animation/Animation.hpp"
#include "Attack.hpp"

#include "Engines/Resources/TextureManager.hpp"
#include "extlibs/TinyXML/tinyxml.h"

struct State
{
    State()
    {
        
    }
    
    Animation animation;
    std::map<unsigned int, Attack> attacks;
};

class PlayerMoves : public Drawable
{
    public:
        PlayerMoves();
        void draw();
        
        void update(float frameTime);
        
        //Action
        void punch();
        
        //State
        void setState(unsigned int state);
        void setState(unsigned int state, unsigned int targetState);
        
        unsigned int getAction() const;
        unsigned int getState() const;
        
        float getWidth();
        float getHeight();
        
        void load(const std::string &xmlPath, const std::string &animationsPath, TextureManager &textureManager, Player &player);
    
    private:
        void loadAnimation(Texture &texture, const TiXmlElement *xmlData, Animation &dst) const;
        
        const Animation &getAnimation();
        void updateOrigin();
        
        std::map<unsigned int, State> m_statesList;
        
        unsigned int m_state; //Current state
        unsigned int m_action; //Current action
        
        int m_targetState; //Target of a transition
};

#endif
