//
//  DungeonGame.h
//  GlobalGameJam15
//
//  Created by Cesar Parent on 23/01/2015.
//  Copyright (c) 2015 Cesar Parent. All rights reserved.
//

#ifndef __GlobalGameJam15__DungeonGame__
#define __GlobalGameJam15__DungeonGame__

#include <PixelKit/PixelKit.h>
#include <vector>

using namespace PixelKit;

typedef enum
{
	kAITurn,
	kPlayerTurn
} Turns;

class Entity;
class MapLayer;
class PauseMenu;
class FailMenu;
class SuccessScreen;

class DungeonGame :
	public Scene,
	public ControlDelegate
{
public:
	DungeonGame(Game& game);
	virtual ~DungeonGame();
	
	virtual void finishedIntro();
	
	virtual void update(int timeInterval) override;
	
	virtual void nextTurn();
	virtual void takeTurn();
	
	virtual bool enemyOnTile(int x, int y);
	
	virtual void decreaseEnemyMoves()
	{
		_enemyMoves--;
		_enemyMoves = (_enemyMoves < 0) ? 0 : _enemyMoves;
	}
	
	virtual void didCollide(Collision collision);
	
#pragma mark delegates
	
	virtual void didEnterStack();
	virtual void didLeaveStack();
	
	virtual void controllerDidConnect(int controllerID){};
	virtual void controllerDidDisconnect(int controllerID){};
	virtual void controllerButtonPressBegan(int controller, SDL_GameControllerButton button);
	virtual void controllerButtonPressEnded(int controller, SDL_GameControllerButton event){};
	virtual void controllerAxisMoved(int controller, SDL_GameControllerAxis axis, Sint16 value){};
	virtual void keyboardPressBegan(SDL_Scancode key);
	virtual void keyboardPressEnded(SDL_Scancode key){};
	
private:
	
	Entity* _chest;
	Entity* _player;
	MapLayer* _gameLayer;
	PauseMenu* _pauseMenu;
	FailMenu* _failMenu;
	SuccessScreen* _successMenu;
	std::vector<Entity*> _enemies;
	
	Turns _currentTurn;
	int _enemyMoves;
	
	void _spawnEnemies();
	void _spawnPlayer();
	void _spawnChest();
	
};

#endif /* defined(__GlobalGameJam15__DungeonGame__) */
