#pragma once

//#include <Windows.h>
#include "Global.h"
#include "GameSettings.h"
#include "GameWindow.h"
#include "Sprite.h"
#include "InputData.h"
#include "Camera.h"
#include "vector.h"
//#include "DxWrapper.h"
//#include <math.h>
//#include "Missile.h"
//#include "PatternMovement.h"
//#include "PlayerCraft.h"
//#include <string>

#include <conio.h>

#include <aiScene.h>   // root structure of the imported data
#include <aiMesh.h>    // example: mesh data structures. you'll propably need other includes, too
#include <aiPostProcess.h>

using namespace std;


class Explosion;
class Camera;
class PlayerCraft;
class EnemyCraft;
class Missile;
class DxWrapper;
class PatternMovement;
class Projectile;
class GameObject3D;

class TimePilot
{

private:

    aiScene* m_pScene;

    GAMEWINDOW m_GameWindow;
    HINSTANCE m_hInstance;
    DxWrapper* m_Dxw;
    SPRITE m_Graphics;
    INPUTDATA m_InputData;    
    PlayerCraft* m_Player;
	PlayerCraft* m_Player2;		// PNX: just for debugging (see GameSettings::ASSIMP_COMPARE_ASSETS)

    aiVector3D m_avSunLightDirection;
    SPRITE m_BackGroundSprites[BACKGROUND_ROWS][BACKGROUND_COLS];
    float m_BackGroundOffsetX;
    float m_BackGroundOffsetY;
    LARGE_INTEGER m_perfFrequency;      // // gibt die Genauigkeit des performance timers an (in Counts pro Sekunde). Wird gebraucht um den gameLoop-Timer zu berechnen

    AssimpRendererD3d::Camera m_Camera;

    std::vector<Projectile*> m_VecProjectiles; 
    std::vector<EnemyCraft*> m_VecEnemies;
    std::vector<Explosion*> m_VecExplosions;
    
    Missile* m_pMissile;

    bool m_Fire1Hold, m_Fire2Hold;

    //debug output strings
    string strDebug1;

    bool m_graphicsDeviceWasLost;

    enum MovementType
    {
        MOV_LINEOFSIGHTCHASING,
        MOV_LINEOFSIGHTINTERCEPTING,
        MOV_PATTERN
    };

    void Initialize();
    void InitGame();
    void InitProjectile(const GameObject3D& shootingObj);
    void MainLoop();
    void Logic(float deltaMs);
    void Cycle(float deltaMs);
    void Render();
    void RenderBackground();

    void SpawnNewEnemy(float x, float y, float z, MovementType movementType);
    void InitExplosionAt(const CPos &position);

public:
    TimePilot(GAMEWINDOW gw, HINSTANCE hInstance);
    ~TimePilot(void);

    void LoadGraphics();
};
