VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Classes | Public Slots | Signals | Public Member Functions | Static Public Member Functions | List of all members
Game Class Reference

The top-level Game object for VoltAir. More...

Inheritance diagram for Game:
QObject

Public Slots

void onLevelCompleted ()
 Respond to a level being completed. More...
 
void onSignedIntoCloudChanged (bool signedIntoCloud)
 Respond to a change to the state of GPGS cloud sign-in. More...
 
void onCloudDataLoaded (int statusCode, const QString &data)
 Respond to the GPGS cloud data being loaded. More...
 
QString onCloudDataConflict (const QString &localData, const QString &serverData)
 Respond to a conflict in the loading of GPGS cloud data. More...
 

Signals

void levelCompleted (bool gameIsOver, int oneStarThreshold, int twoStarThreshold, int threeStarThreshold, int fourStarThreshold, int playerScore)
 Emitted on level completed. More...
 
void playerScoreChanged (int playerId, int score)
 Emitted when a player's score changes. More...
 

Public Member Functions

void init ()
 Initialize the game. More...
 
bool isUiActive () const
 Returns if any of the UI screens are active. More...
 
LevelProgressionListgetLevelProgressionList () const
 Returns the unique LevelProgressionList for the game. More...
 
void tryLoadLevel ()
 Informs the engine to load the current level. More...
 
DebugMetricsMonitorgetDebugMetricsMonitor () const
 Returns the unique DebugMetricsMonitor for the game. More...
 
void updatePlayerScore (int playerId, int amountChanged)
 Updates score and completes level if appropriate. More...
 
Q_INVOKABLE UiInternalgetUi () const
 Returns the main UI element. More...
 
Q_INVOKABLE LevelProgressiongetCurrentLevelProgression () const
 Returns the current LevelProgression selected by the player. More...
 
Q_INVOKABLE LevelInfogetCurrentLevelInfo () const
 Returns the current LevelInfo selected by the player. More...
 
Q_INVOKABLE bool isEnvironmentUnlocked (const QString &progressionName, const QString &environmentName) const
 Returns whether or not the specified environment is unlocked in the specified progression. More...
 
Q_INVOKABLE bool isLevelUnlocked (const QString &progressionName, const QString &levelName) const
 Returns whether or not the specified level is unlocked in the specified progression. More...
 
Q_INVOKABLE int getNumStars (const QString &progressionName, const QString &levelName) const
 Returns the highest number of stars achieved on a level, as logged in the PlayerProfile. More...
 
Q_INVOKABLE int getLastPlayedEnvironmentIndex (const QString &progressionName) const
 Returns the index of the environment last played in the specified progression. More...
 
Q_INVOKABLE int getLastPlayedLevelIndexInEnvironment (const QString &progressionName, const QString &environmentName) const
 Returns the index of the last played level in a given environment. More...
 
Q_INVOKABLE void unlockAchievement (const QString &name, bool immediately=true)
 Unlocks a Google Play Games Services achievement. More...
 
Q_INVOKABLE void incrementAchievement (const QString &name, int numSteps, bool immediately=false)
 Increments a Google Play Games Services incremental achievement. More...
 
Q_INVOKABLE void setAchievementSteps (const QString &name, int minSteps, bool immediately=false)
 Sets a Google Play Games Services incremental achievement to have a minimum number of steps. More...
 
Q_INVOKABLE void revealAchievement (const QString &name, bool immediately=true)
 Reveals a Google Play Games Services achievement. More...
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
virtual const QMetaObjectmetaObject () const
 
QString objectName () const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const
 
bool blockSignals (bool block)
 
QThreadthread () const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QString &name, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QRegExp &regExp, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QRegularExpression &re, QFlags< Qt::FindChildOption > options) const
 
const QObjectList & children () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const
 
bool disconnect (const QObject *receiver, const char *method) const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const
 
bool inherits (const char *className) const
 
void deleteLater ()
 

Static Public Member Functions

static GamegetInstance ()
 Gets the singleton Game. More...
 
- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 

Additional Inherited Members

- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

The top-level Game object for VoltAir.

This singleton class is effectively the mainline of the game as well as the parent object for all game-related objects (e.g. PlayerProfile, LevelProgression).

Member Function Documentation

Q_INVOKABLE LevelInfo* Game::getCurrentLevelInfo ( ) const

Returns the current LevelInfo selected by the player.

Note
The returned value is always non-null if getCurrentLevelProgression is non-null. That is, selections of LevelInfo can be implicit based on the previous level played in a LevelProgression.
Q_INVOKABLE LevelProgression* Game::getCurrentLevelProgression ( ) const
inline

Returns the current LevelProgression selected by the player.

Note
The returned value can be non-null even if Engine::getLevel() is null.
DebugMetricsMonitor* Game::getDebugMetricsMonitor ( ) const
inline

Returns the unique DebugMetricsMonitor for the game.

static Game* Game::getInstance ( )
static

Gets the singleton Game.

Q_INVOKABLE int Game::getLastPlayedEnvironmentIndex ( const QString progressionName) const

Returns the index of the environment last played in the specified progression.

Parameters
progressionNameName of LevelProgression to query
Q_INVOKABLE int Game::getLastPlayedLevelIndexInEnvironment ( const QString progressionName,
const QString environmentName 
) const

Returns the index of the last played level in a given environment.

Parameters
progressionNameName of LevelProgression in which environmentName resides
environmentNameName of Environment to query
LevelProgressionList* Game::getLevelProgressionList ( ) const
inline

Returns the unique LevelProgressionList for the game.

Q_INVOKABLE int Game::getNumStars ( const QString progressionName,
const QString levelName 
) const

Returns the highest number of stars achieved on a level, as logged in the PlayerProfile.

Note
If progressionName is a multiplayer LevelProgression, this function will always return a invalid (i.e. negative) star score.
Parameters
progressionNameName of single player LevelProgression in which levelName resides
levelNameName of the LevelInfo whose number of stars is being queried
Q_INVOKABLE UiInternal* Game::getUi ( ) const
inline

Returns the main UI element.

Q_INVOKABLE void Game::incrementAchievement ( const QString name,
int  numSteps,
bool  immediately = false 
)

Increments a Google Play Games Services incremental achievement.

Note
This function only has an effect on an Android device.
Parameters
nameAndroid resource name used to locate the achievement id
numStepsNumber of steps to increment the achievement
immediatelyWhether or not to sync the achievement change with Google Play Games Services now
void Game::init ( )

Initialize the game.

This includes instantiating the UI, reading in the level progressions, player profiles and making signal/slot connections to the various submodules.

Q_INVOKABLE bool Game::isEnvironmentUnlocked ( const QString progressionName,
const QString environmentName 
) const

Returns whether or not the specified environment is unlocked in the specified progression.

Parameters
progressionNameName of LevelProgression in which environmentName resides
environmentNameName of Environment whose lock status to check
Q_INVOKABLE bool Game::isLevelUnlocked ( const QString progressionName,
const QString levelName 
) const

Returns whether or not the specified level is unlocked in the specified progression.

Parameters
progressionNameName of LevelProgression in which levelName resides
levelNameName of LevelInfo whose lock status to check
bool Game::isUiActive ( ) const
inline

Returns if any of the UI screens are active.

void Game::levelCompleted ( bool  gameIsOver,
int  oneStarThreshold,
int  twoStarThreshold,
int  threeStarThreshold,
int  fourStarThreshold,
int  playerScore 
)
signal

Emitted on level completed.

This is emitted upon completion of the call to onLevelCompleted().

Parameters
gameIsOverWhether this level completion resulted in the game being over
oneStarThresholdThreshold for a single star on the completed level
twoStarThresholdThreshold for a two stars on the completed level
threeStarThresholdThreshold for a three stars on the completed level
fourStarThresholdThreshold for a four stars on the completed level
playerScorePlayer's score on the completed level
QString Game::onCloudDataConflict ( const QString localData,
const QString serverData 
)
slot

Respond to a conflict in the loading of GPGS cloud data.

Parameters
localDataString encoded local save game data that is in conflict
serverDataString encoded cloud save game data that is in conflict
Returns
JSON representing the conflicting GPGS cloud data, when possible
void Game::onCloudDataLoaded ( int  statusCode,
const QString data 
)
slot

Respond to the GPGS cloud data being loaded.

Parameters
statusCodeStatus of load, zero implying success, non-zero is error
dataString encoded loaded save game data or a null string if loading error occurred
void Game::onLevelCompleted ( )
slot

Respond to a level being completed.

void Game::onSignedIntoCloudChanged ( bool  signedIntoCloud)
slot

Respond to a change to the state of GPGS cloud sign-in.

Parameters
signedIntoCloudtrue if notifying of sign-in success
void Game::playerScoreChanged ( int  playerId,
int  score 
)
signal

Emitted when a player's score changes.

Parameters
playerIdUnique ID of the player (0-3)
scorePlayer's new score
Q_INVOKABLE void Game::revealAchievement ( const QString name,
bool  immediately = true 
)

Reveals a Google Play Games Services achievement.

Note
This function only has an effect on an Android device.
Parameters
nameAndroid resource name used to locate the achievement id
immediatelyWhether or not to sync the achievement change with Google Play Games Services now
Q_INVOKABLE void Game::setAchievementSteps ( const QString name,
int  minSteps,
bool  immediately = false 
)

Sets a Google Play Games Services incremental achievement to have a minimum number of steps.

Note
This function only has an effect on an Android device.
Parameters
nameAndroid resource name used to locate the achievement id
minStepsLower bound for incremental progress
immediatelyWhether or not to sync the achievement change with Google Play Games Services now
void Game::tryLoadLevel ( )

Informs the engine to load the current level.

The call to the engine is only made if the PlayerProfile is loaded and it has a LevelProgression from which it can get the current level to load.

Q_INVOKABLE void Game::unlockAchievement ( const QString name,
bool  immediately = true 
)

Unlocks a Google Play Games Services achievement.

Note
This function only has an effect on an Android device.
Parameters
nameAndroid resource name used to locate the achievement id
immediatelyWhether or not to sync the achievement change with Google Play Games Services now
void Game::updatePlayerScore ( int  playerId,
int  amountChanged 
)

Updates score and completes level if appropriate.

Parameters
playerIdUnique ID [0, 3] of the player
amountChangedDelta of the score change