#ifndef GAMEENGINE_H
#define GAMEENGINE_H
#include <QObject>
#include <QDeclarativeItem>
#include <QMutex>
#include <QPluginLoader>
#include <QList>
#ifdef Q_OS_SYMBIAN
#include <hwrmvibra.h>
#endif
#if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5
#include <QSystemDeviceInfo>
QTM_USE_NAMESPACE
#endif
class CInvSounds;
class LevelPluginInterface;
class GameEngine : public QObject
{
Q_OBJECT
public:
GameEngine(QObject* parent);
~GameEngine();
void timerEvent(QTimerEvent *);
void setGameLevel(LevelPluginInterface* level);
void setPluginList(QList<QPluginLoader*> plugins);
void pauseGame();
public:
Q_INVOKABLE void enableEngineTimer(QVariant enable);
Q_INVOKABLE QVariant randInt(QVariant low, QVariant high);
Q_INVOKABLE void enableSounds(QVariant enable);
Q_INVOKABLE void playSound(QVariant index);
Q_INVOKABLE void playSounds(QVariant index, QVariant count);
Q_INVOKABLE void playInternalSound(QVariant index);
Q_INVOKABLE void playInternalSounds(QVariant index, QVariant count);
Q_INVOKABLE QVariant pluginList();
Q_INVOKABLE void findQmlObjects();
Q_INVOKABLE void clearQmlObjects();
Q_INVOKABLE void pauseLevel(QVariant doPause);
Q_INVOKABLE void gameStartSound();
Q_INVOKABLE QVariant isSymbian();
Q_INVOKABLE QVariant isMaemo();
Q_INVOKABLE QVariant isWindows();
Q_INVOKABLE void vibra();
Q_INVOKABLE void fastVibra();
Q_INVOKABLE void openLink(QVariant link);
private slots:
#if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5
void currentProfileChanged (QSystemDeviceInfo::Profile);
#endif
public:
void setGameQml(QObject* o);
private:
void findMissiles(QObject* rootObject);
void findEnemies(QObject* rootObject);
void setLevelQml(QObject* o) {m_levelQml = o;}
void setEnemiesGridQml(QObject* o);
void setMyShipQml(QObject* o);
void gameOver(bool youWin);
void selectVisibleEnemy(int& start, int& end);
private:
void doHitTest();
void doEnemyMissile();
private:
bool m_enableEnemyMissiles;
QMutex m_enemyListMutex;
QList<QDeclarativeItem*> m_enemyList;
QList<QDeclarativeItem*> m_missileList;
QList<QDeclarativeItem*> m_enemyMissileList;
QObject* m_levelQml;
QDeclarativeItem* m_enemiesGridGml;
QDeclarativeItem* m_myShipGml;
QDeclarativeItem* m_GameGml;
LevelPluginInterface* m_gameLevel;
CInvSounds* m_soundEngine;
QList<QPluginLoader*> m_pluginList;
int m_timerId;
int m_doEnemyMissile;
#if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5
QSystemDeviceInfo* m_systemDeviceInfo;
#endif
bool m_silent;
#ifdef Q_OS_SYMBIAN
CHWRMVibra* iVibrate;
#endif
};
#endif // GAMEENGINE_H