TAB UNITY SDK VERSION 8.11
 All Classes Namespaces Functions Variables Properties Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Properties | List of all members
TABUnitySDK.PhoenixController Class Reference

Manages the connection between the game and the F4F framework (code named Phoenix) and the F4F game lifecycle. More...

+ Inheritance diagram for TABUnitySDK.PhoenixController:

Public Member Functions

delegate void OnStateInitialized ()
 Delegate for OnStateInitialized.
 
delegate void OnStateSetUnityAsReady ()
 Delegate for OnSetUnityAsReady.
 
delegate void OnStateSendAlive ()
 Delegate for OnStateSendAlive.
 
void SetUnityAsReady ()
 Call this method to tell the F4F framework that the Unity application has launched successfully. If this method is not called within 10 seconds after game launch, the F4F framework will shut down the Unity game process and display an error message to the user. More...
 
void ResetIdleTime ()
 Resets the idle timer back to 0.0f. The idle timer makes sure to shut down a game if no user interaction has happened for more than 120 seconds. More...
 
float GetIdleTime ()
 Retrieves the current idle time. See ResetIdleTime() documentation for more information about the idle timer. More...
 
bool SendLongAliveUpdate ()
 Sends a long alive message to the F4F framework. A long alive message is worth about 5 seconds. If you have an operation which last longer than the 3 seconds from the SendAliveUpdate, you can call the SendLongAliveUpdate() manually before the operation starts. More...
 
bool SendAliveUpdate ()
 Sends a standard short alive message to Phoenix. Is usually called automatically by the PhoenixController every 2 seconds. If you have an operation which last longer than the 2 seconds, you can call it manually. A standard short alive message is worth about 3 seconds. More...
 
int GetCurrentCredits ()
 Retrieves the current credit balance on the machine. More...
 
bool UseContinue ()
 Tries to activate a "Continue" for the player/s. The credit balance needs to be covering the continue costs. More...
 
int GetContinuePrice ()
 Retrieves the current credit cost for a "Continue". See the UseContinue() method for more information about this feature. More...
 
int GetMaxContinueCount ()
 Retrieves the max continue count for the game. A value of -1 equals to unlimited continues. All positive values represent the maximal count a continue for one player can be used. More...
 
void DoPlayerJoin (int playerTableId)
 Add a player at an previously unused place to the game. Only added players will have the ability to enter high scores. Before calling this function make sure that any player can be added to the game with CanPlayerJoin. More...
 
bool CanPlayerJoin ()
 This function is used to determine, if another player can be added to the game. The credit account is checked with this function, too to make sure that sufficient credits are available. Use this function before calling DoPlayerJoin to be sure that a player can be added. More...
 
int GetJoinPrice ()
 Retrieves the current credit cost for a "Join". See the DoPlayerJoin() method for more information about this feature. More...
 
void SetScore (int playerIndex, int score)
 Writes a score entry to the F4F framework. The scores are then managed by the F4F framework independently from the game itself (e.g. by generating highscores, or by publishing the scores to the TAB ChampionsNet(TM) global highscore database). You should call this method for every player at the end of the game. More...
 
List< bool > LoadPlayerPositionsFromPhoenix ()
 Loads a list of all player positions from the F4F framework. Each player position is set to either true (there is a player) or false (there is no player). The list count is based on the number of maximum allowed players for this game. More...
 
List< int > LoadPlayerMobileIdFromPhoenix ()
 This is a method used for mobile device integration. If you want to get more information about F4F mobile device integration, please visit the mobile integration section within this Mobile device Integration documentation. More...
 
bool IsMultiTouchSystem ()
 This method can be used to determine if a multi touch Fun4Four device is connected to the current system. More...
 
void SendMessageToMobilePlayer (int mobileId, string message)
 This is a method used for mobile device integration. If you want to get more information about F4F mobile device integration, please visit the mobile integration section within this Mobile device Integration documentation. More...
 
string GetLanguageISOCode ()
 Retrieve the currently set F4F language. More...
 
string GetText (string tag)
 Get a translated text for a given tag. The tags must be specified in one of the localization .resx files. The resource files are just containing key - value pairs. The key-names have to be same for all language files. If the current selected language is not available, the default language file (English) will be chosen. More...
 

Static Public Member Functions

static void InvokeLater (Action task)
 Internal use. Do not use directly. More...
 

Static Public Attributes

static OnStateInitialized onStateInitialized = null
 
static OnStateSetUnityAsReady onStateSetUnityAsReady = null
 
static OnStateSendAlive onStateSendAlive = null
 

Properties

static PhoenixController Instance [get]
 The global Phoenix controller instance. The PhoenixController class is a singleton class, which you can retrieve through the static member Instance. More...
 

Detailed Description

Manages the connection between the game and the F4F framework (code named Phoenix) and the F4F game lifecycle.

Covered functional areas:

Member Function Documentation

bool TABUnitySDK.PhoenixController.CanPlayerJoin ( )

This function is used to determine, if another player can be added to the game. The credit account is checked with this function, too to make sure that sufficient credits are available. Use this function before calling DoPlayerJoin to be sure that a player can be added.

Returns
True if another player can join the game.
void TABUnitySDK.PhoenixController.DoPlayerJoin ( int  playerTableId)

Add a player at an previously unused place to the game. Only added players will have the ability to enter high scores. Before calling this function make sure that any player can be added to the game with CanPlayerJoin.

Parameters
playerTableIdThe index for the place where the player wants to join. (See layouts)
int TABUnitySDK.PhoenixController.GetContinuePrice ( )

Retrieves the current credit cost for a "Continue". See the UseContinue() method for more information about this feature.

Returns
The current continue credit cost. Returns -1 if the F4F framework is not available.
void Start()
{
...
m_continueCostsText = GameObject.Find("ContinueCosts").guiText;
m_continueCosts = PhoenixController.Instance.GetContinuePrice();
}
void OnGUI()
{
m_continueCostsText.guiText.text = "Continue costs: " + m_continueCosts;
}
int TABUnitySDK.PhoenixController.GetCurrentCredits ( )

Retrieves the current credit balance on the machine.

Returns
The current credit value. Returns -1 if the method failed or if the F4F framework is not available.
void Start()
{
...
m_currentCreditsText = GameObject.Find("CurrentCredits").guiText;
m_currentCredits = PhoenixController.Instance.GetCurrentCredits();
}
void OnGUI()
{
m_currentCreditsText.guiText.text = "Current Credits: " + m_currentCredits;
}
float TABUnitySDK.PhoenixController.GetIdleTime ( )

Retrieves the current idle time. See ResetIdleTime() documentation for more information about the idle timer.

Returns
The current idle time in seconds.
// in GameManager class
public static void GetIdleTime()
{
PhoenixController.Instance.GetIdleTime();
}
// in function doSomething
public static void doSomething()
{
if (GameSceneManager.GetIdleTime() > maxIdleTime)
{
...
}
}
int TABUnitySDK.PhoenixController.GetJoinPrice ( )

Retrieves the current credit cost for a "Join". See the DoPlayerJoin() method for more information about this feature.

Returns
The current join credit cost. Returns -1 if the F4F framework is not available.
string TABUnitySDK.PhoenixController.GetLanguageISOCode ( )

Retrieve the currently set F4F language.

Returns
The currently set language as a three-letter ISO code (ISO 639-2/B). Returns string.Empty if the F4F framework is not available.
void OnGUI()
{
switch (m_languageIso)
{
case "eng":
{
m_currentCreditsText.guiText.text = "Current Credits: " + m_currentCredits;
m_continueCostsText.guiText.text = "Continue costs: " + m_continueCosts;
break;
}
case "ger":
{
m_currentCreditsText.guiText.text = "Verbleibende Credits: " + m_currentCredits;
m_continueCostsText.guiText.text = "Continue Kosten: " + m_continueCosts;
break;
}
}
}
int TABUnitySDK.PhoenixController.GetMaxContinueCount ( )

Retrieves the max continue count for the game. A value of -1 equals to unlimited continues. All positive values represent the maximal count a continue for one player can be used.

Returns
-1 if unlimited continues are allowed; positive values for the corresponding continues per player allowed
string TABUnitySDK.PhoenixController.GetText ( string  tag)

Get a translated text for a given tag. The tags must be specified in one of the localization .resx files. The resource files are just containing key - value pairs. The key-names have to be same for all language files. If the current selected language is not available, the default language file (English) will be chosen.

Parameters
tagOne of the tags specified in the resource files
Returns
The string which is stored to the given tag in the right language.
void Start()
{
...
m_ValCredits = PhoenixController.Instance.GetText ("NZ.Game.UnitySDKDemo.Credits") + m_currentCredits;
m_ValContinue = PhoenixController.Instance.GetText ("NZ.Game.UnitySDKDemo.Continue") + m_currentCredits;
}
void OnGUI()
{
m_currentCreditsText.guiText.text = m_ValCredits;
m_continueCostsText.guiText.text = m_ValContinue;
}
static void TABUnitySDK.PhoenixController.InvokeLater ( Action  task)
static

Internal use. Do not use directly.

Parameters
taskInternal use. Do not use directly.
bool TABUnitySDK.PhoenixController.IsMultiTouchSystem ( )

This method can be used to determine if a multi touch Fun4Four device is connected to the current system.

Returns
True if the system is a multi touch Fun4Four device.
void Start()
{
...
bool isMultiTouchSystem = PhoenixController.Instance.IsMultiTouchSystem();
}
List<int> TABUnitySDK.PhoenixController.LoadPlayerMobileIdFromPhoenix ( )

This is a method used for mobile device integration. If you want to get more information about F4F mobile device integration, please visit the mobile integration section within this Mobile device Integration documentation.

List<bool> TABUnitySDK.PhoenixController.LoadPlayerPositionsFromPhoenix ( )

Loads a list of all player positions from the F4F framework. Each player position is set to either true (there is a player) or false (there is no player). The list count is based on the number of maximum allowed players for this game.

Returns
Returns the player position list. The list will be empty if the F4F framework is not available.
private static List<bool> m_playerList = new List<bool>();
private void LoadPlayerListFromPhoenix()
{
m_playerList = PhoenixController.Instance.LoadPlayerPositionsFromPhoenix();
}
// returns the list of players
public static List<bool> getPlayers()
{
return m_playerList;
}
void TABUnitySDK.PhoenixController.ResetIdleTime ( )

Resets the idle timer back to 0.0f. The idle timer makes sure to shut down a game if no user interaction has happened for more than 120 seconds.

Once the idle timer triggers, the whole Unity process hosting the game will be shut down by the F4F framework. It is recommended to reset the idle timer on every input made by a player.

// in GameSceneMangerClass
public static void ResetIdleTime()
{
PhoenixController.Instance.ResetIdleTime();
}
// in class where input is handled
private void HandleStateChangedPress(object sender, TouchScript.Events.GestureStateChangeEventArgs e)
{
isClicked = true;
spriteRenderer.color = Color.red;
GameSceneManager.ResetIdleTime();
}
bool TABUnitySDK.PhoenixController.SendAliveUpdate ( )

Sends a standard short alive message to Phoenix. Is usually called automatically by the PhoenixController every 2 seconds. If you have an operation which last longer than the 2 seconds, you can call it manually. A standard short alive message is worth about 3 seconds.

Returns
Returns whether the F4F framework is available or not.
public void IntensiveProcess()
{
// if you have to do something cpu intensive for example,
// you can send the AliveUpdate to the Phoenix manually
PhoenixController.Instance.SendAliveUpdate();
foreach (var prime in Primes)
{
...
}
}
bool TABUnitySDK.PhoenixController.SendLongAliveUpdate ( )

Sends a long alive message to the F4F framework. A long alive message is worth about 5 seconds. If you have an operation which last longer than the 3 seconds from the SendAliveUpdate, you can call the SendLongAliveUpdate() manually before the operation starts.

Returns
Returns whether the F4F framework is available or not.
public void VeryIntensiveProcess()
{
// if you have to do something very cpu intensive for example,
// you can send the AliveUpdate to the Phoenix manually
PhoenixController.Instance.SendLongAliveUpdate();
foreach (var prime in AllPrimes)
{
...
}
}
void TABUnitySDK.PhoenixController.SendMessageToMobilePlayer ( int  mobileId,
string  message 
)

This is a method used for mobile device integration. If you want to get more information about F4F mobile device integration, please visit the mobile integration section within this Mobile device Integration documentation.

Parameters
mobileId
message
void TABUnitySDK.PhoenixController.SetScore ( int  playerIndex,
int  score 
)

Writes a score entry to the F4F framework. The scores are then managed by the F4F framework independently from the game itself (e.g. by generating highscores, or by publishing the scores to the TAB ChampionsNet(TM) global highscore database). You should call this method for every player at the end of the game.

Parameters
playerIndexThe index value for the player. The index is 0 (zero) based.
scoreThe score for the player. If a time highscore is used, convert the time in a int value representing the needed time in milliseconds.
private void endGame()
{
for (int i = 0; i < m_playerList.Count; i++)
{
if (m_playerList [i])
{
PlayerPrefs.SetInt("HighscoreP" + (i + 1), scoreHolder.getPlayerScore(i + 1));
PhoenixController.Instance.SetScore(i, scoreHolder.getPlayerScore(i + 1));
} else
PlayerPrefs.SetInt("HighscoreP" + (i + 1), 0);
}
Application.LoadLevel("Score");
}
void TABUnitySDK.PhoenixController.SetUnityAsReady ( )

Call this method to tell the F4F framework that the Unity application has launched successfully. If this method is not called within 10 seconds after game launch, the F4F framework will shut down the Unity game process and display an error message to the user.

void Start()
{
LoadPlayerListFromPhoenix();
EnableMobileCommunications();
PhoenixController.Instance.SetUnityAsReady();
}
bool TABUnitySDK.PhoenixController.UseContinue ( )

Tries to activate a "Continue" for the player/s. The credit balance needs to be covering the continue costs.

A "Continue" is the option to continue the game after all of the player's lives have been lost or after the game time ran out, rather than ending the game and restarting it from the very beginning. There may or may not be a penalty for doing this, such as losing a certain number of points or being unable to access bonus stages.

The F4F framework makes sure that there are enough credits in the F4F to cover the continue costs, and then reduces the F4F credit balance accordingly. The method returns false if the continue is not possible (because there are not enough credits available, or because the F4F framework is not available).

Returns
True if the "Continue" was performed successfully. Returns false otherwise.
void Start()
{
...
m_continueAllowed = PhoenixController.Instance.UseContinue();
}
void OnGUI() {
if (GUI.Button (m_btnRect, "Continue"))
{
if (m_continueAllowed)
Application.LoadLevel("Game");
} else
m_lblText = "Not enough credits";
GUI.Label(m_lblRect, m_lblText);
}

Member Data Documentation

OnStateInitialized TABUnitySDK.PhoenixController.onStateInitialized = null
static

Called once when the F4F framework setup finishes. Once when the scene is loaded.


To add a function to a static delegate:
-> PhoenixController.onStateInitialized += MethodToAddToDelegate;
To remove the function from a static delegate:
-> PhoenixController.onStateInitialized -= MethodToRemoveFromDelegate;

OnStateSendAlive TABUnitySDK.PhoenixController.onStateSendAlive = null
static

Is called when an alive signal is sent to the F4F framework. This happens every 2 seconds.


To add a function to a static delegate:
-> PhoenixController.onStateSendAlive += MethodToAddToDelegate;
To remove the function from a static delegate:
-> PhoenixController.onStateSendAlive -= MethodToRemoveFromDelegate;

OnStateSetUnityAsReady TABUnitySDK.PhoenixController.onStateSetUnityAsReady = null
static

Is called once when the method SetUnityAsReady() is called.


To add a function to a static delegate:
-> PhoenixController.onStateSetUnityAsReady += MethodToAddToDelegate;
To remove the function from a static delegate:
-> PhoenixController.onStateSetUnityAsReady -= MethodToRemoveFromDelegate;

Property Documentation

PhoenixController TABUnitySDK.PhoenixController.Instance
staticget

The global Phoenix controller instance. The PhoenixController class is a singleton class, which you can retrieve through the static member Instance.

void Start()
{
...
m_continueAllowed = PhoenixController.Instance.UseContinue();
}
void OnGUI()
{
if (GUI.Button(m_btnRect, "Continue"))
{
if (m_continueAllowed)
Application.LoadLevel("Game");
} else
m_lblText = "Not enough credits";
GUI.Label(m_lblRect, m_lblText);
}