Gameplay

Game play process consists of two phases:

Game preparation.

Communication with SDK during this phase is done via EAZGamePreparationManager, in order to receive callbacks from Manager set EAZGamePreparationDelegate as soon as possible ( ideally at Application’s start ).

Sequence:

  1. When user will choose the game he would like to play, EAZGamePreparationManager will callback with startLoadingGameResources(for gameId: String) indicating that Application must load resources for game specified by gameId parameter.

  2. After all resources will be loaded/prepared, Application must call gameDidLoad() function - informing the EAZGamePreparationManager that it is all set and ready to go further along the process.

  3. Then GamePreparationManager will make final callback with provideGameController(startGameInfo: EAZGameStartInfo?) -> UIViewController. In this callback Application must create, setup and return a Game Controller that will be presented on the main Window by SDK. The startGameInfo EAZGameStartInfo parameter contains all valuable information for the game: gameDuration, levels, gameSoundOn, language, gameTimeoutGap.

Here the Preparation phase is finished and we proceed to Actual Gameplay.

Actual Gameplay

Communication with SDK during this phase is done via EAZGamePlayManager, in order to receive callbacks from Manager set EAZGamePlayDelegate as soon as Game Scene will be created.

Sequence:

  1. Start. In order to start playing Application have to call didStartPlaying() function when the Game Scene will become visible. In iOS UIViewController lifecycle the most accurate place to do this is the func viewWillAppear(_ animated: Bool). All games must have a timer, that will indicate remaining time for playing. This timer also should be instantiated and launched with didStartPlaying() call. After timer will run out, Application must end game play with last acquired (final) score of the Player - finishPlayingWith(finalScore: Int). Duration value for timer is provided in the Game preparation phase inside EAZGameStartInfo. Also it contains:

    • levels - string that represents the sequence of game play for all users.
    • gameSoundOn - indicating sound setting.
    • lang - language ISO 639-1 code. E.g. “en”.
    • gameTimeoutGap - time gap in seconds. Determines margin for game to be timed out by the platform. Final time out value will be = duration + timeOutGap.
  2. Scoring. After Start, Application will have ability to send score:

    • sendScore(_ score: Int) - sends User’s current score to the Platform.

    as well as receive opponent’s score in case of Live game (callback):

    • didReceiveOpponentsScore(_ score: Int) - informs about opponent’s score. In case of tournament ( multiple opponents), it will send the highest score among all the opponents.
  3. End game play. Game can end in two ways:

    • Player leaves game with help of “Leave button” that will trigger action leaveGame() of the EAZGamePlayManager. In general it will inform Platform that user decided to leave the game, but depending on Game type it may have different scenarios in matching players:
      • Live game - informs Platform that user decided to leave the game. It will automatically match user with state LOST
      • Delayed game - there are few possible cases for “Leave” in delayed games:
        • if player is the one, who finishes the delayed game, it will inform platform that user decided to leave. Platform will automatically match user with state LOST
        • if player is not the one, who finishes the game by leaving it, his “Leave” result is saved, and final game results will be set later, when all opponents are found or game is finished by timeout.
        • In case if all the other users in this certain delayed game also left, and user finishes it by Leaving a game as well, platform will automatically match all users with the DRAW state.
      • Contest - informs platform that user finishes playing contest game and his last score is set as a final result in certain contest.
    • When timer will run out Application must call finishPlayingWith(finalScore: Int) with Player’s final score.

    as result SDK will send callback:

    • didEndGame() - informs about end of game play, and that Game Controller will be removed from the main window. After this callback score sending won’t be handled by the SDK.

    or if there will be a need to wait for opponent to finish playing in the Live game, SDK will fire firstly:

    • waitingForOpponent() - in this case Game Scene will remain on the screen until Opponent will finish and Game’s job is to inform Player about this event (e.g. on EazeGames Platform we show a toast message bar with text “Waiting for opponent”). Please note, that score sending won’t be handled by the SDK after this callback.

    and secondly will fire didEndGame() when opponent will finish playing.

pic.1 - Game Play Diagram

  • Interface that handles game preparation process.

    See more

    Declaration

    Swift

    @objc
    public protocol EAZGamePreparationManager
  • Game Preparation Manager Delegate.

    See more

    Declaration

    Swift

    @objc
    public protocol EAZGamePreparationDelegate : AnyObject
  • Interface that handles game play process.

    See more

    Declaration

    Swift

    @objc
    public protocol EAZGamePlayManager
  • Game Play Manager Delegate

    See more

    Declaration

    Swift

    @objc
    public protocol EAZGamePlayDelegate : AnyObject
  • Model that contains necessary information regarding Game that is about to start.

    See more

    Declaration

    Swift

    @objcMembers
    public class EAZGameStartInfo : NSObject, Codable