gameengine.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. #ifndef GAMEENGINE_H
  5. #define GAMEENGINE_H
  6. #include <QObject>
  7. #include <QDeclarativeItem>
  8. #include <QMutex>
  9. #include <QPluginLoader>
  10. #include <QList>
  11. #ifdef Q_OS_SYMBIAN
  12. #include <hwrmvibra.h>
  13. #endif
  14. // QtMobility
  15. #if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5
  16. #include <QSystemDeviceInfo>
  17. QTM_USE_NAMESPACE
  18. #endif
  19. class CInvSounds;
  20. class LevelPluginInterface;
  21. class GameEngine : public QObject
  22. {
  23. Q_OBJECT
  24. public:
  25. GameEngine(QObject* parent);
  26. ~GameEngine();
  27. void timerEvent(QTimerEvent *);
  28. void setGameLevel(LevelPluginInterface* level);
  29. void setPluginList(QList<QPluginLoader*> plugins);
  30. void pauseGame();
  31. public:
  32. Q_INVOKABLE void enableEngineTimer(QVariant enable);
  33. Q_INVOKABLE QVariant randInt(QVariant low, QVariant high);
  34. Q_INVOKABLE void enableSounds(QVariant enable);
  35. Q_INVOKABLE void playSound(QVariant index);
  36. Q_INVOKABLE void playSounds(QVariant index, QVariant count);
  37. Q_INVOKABLE void playInternalSound(QVariant index);
  38. Q_INVOKABLE void playInternalSounds(QVariant index, QVariant count);
  39. Q_INVOKABLE QVariant pluginList();
  40. Q_INVOKABLE void findQmlObjects();
  41. Q_INVOKABLE void clearQmlObjects();
  42. Q_INVOKABLE void pauseLevel(QVariant doPause);
  43. Q_INVOKABLE void gameStartSound();
  44. Q_INVOKABLE QVariant isSymbian();
  45. Q_INVOKABLE QVariant isMaemo();
  46. Q_INVOKABLE QVariant isWindows();
  47. Q_INVOKABLE void vibra();
  48. Q_INVOKABLE void fastVibra();
  49. Q_INVOKABLE void openLink(QVariant link);
  50. private slots:
  51. #if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5
  52. void currentProfileChanged (QSystemDeviceInfo::Profile);
  53. #endif
  54. public:
  55. void setGameQml(QObject* o);
  56. private:
  57. void findMissiles(QObject* rootObject);
  58. void findEnemies(QObject* rootObject);
  59. void setLevelQml(QObject* o) {m_levelQml = o;}
  60. void setEnemiesGridQml(QObject* o);
  61. void setMyShipQml(QObject* o);
  62. void gameOver(bool youWin);
  63. void selectVisibleEnemy(int& start, int& end);
  64. private:
  65. void doHitTest();
  66. void doEnemyMissile();
  67. private:
  68. bool m_enableEnemyMissiles;
  69. QMutex m_enemyListMutex;
  70. QList<QDeclarativeItem*> m_enemyList;
  71. QList<QDeclarativeItem*> m_missileList;
  72. QList<QDeclarativeItem*> m_enemyMissileList;
  73. QObject* m_levelQml;
  74. QDeclarativeItem* m_enemiesGridGml;
  75. QDeclarativeItem* m_myShipGml;
  76. QDeclarativeItem* m_GameGml;
  77. LevelPluginInterface* m_gameLevel;
  78. CInvSounds* m_soundEngine;
  79. QList<QPluginLoader*> m_pluginList;
  80. int m_timerId;
  81. int m_doEnemyMissile;
  82. #if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5
  83. QSystemDeviceInfo* m_systemDeviceInfo;
  84. #endif
  85. bool m_silent;
  86. #ifdef Q_OS_SYMBIAN
  87. CHWRMVibra* iVibrate;
  88. #endif
  89. };
  90. #endif // GAMEENGINE_H