Skip to content

Commit

Permalink
Fixed bug that caused API calls time outs due to multiple calls on up…
Browse files Browse the repository at this point in the history
…date method
  • Loading branch information
germanviscuso committed Apr 2, 2014
1 parent afaf568 commit 22a409d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
9 changes: 3 additions & 6 deletions Assets/Readme.txt
Expand Up @@ -50,9 +50,9 @@ to initialize Kii when building for a specific platform you'll have to
use c). If you're bulding for Android make sure the Stripping level in
your project settings is set to "Disabled" and that the Internet setting
is set to "Require" (not "Auto").
5) If you want to use analytics (and saw an analytics related exception)
5) If you want to use analytics (and saw an analytics related debug message)
in the game please follow these instructions:
In PlayerHealth.cs the analytics rule id is 147, but the ID must match
In GameConfig.cs the analytics rule id is 0, but the ID must match
the analytic rule you should create on developer.kii.com this way:
- Go to developer.kii.com, go to your app's console
- Click on Analytics on the left side bar, then lick on "Create a new rule"
Expand All @@ -61,11 +61,8 @@ the analytic rule you should create on developer.kii.com this way:
- In the type combo select "float"
- In the dimensions fields enter "time", "time" and "float"
- Click on Save and activate the rule
- Once active copy the ID assigned to the rule and replace the 147 below
- Once active copy the ID assigned to the rule and replace the 0 below
with that
- If you experience a big delay the first time you die please wait for several
minutes until the game continues or disable SendDeathEvent() until it's fixed
(we're looking into this bug)

Want more info?
---------------
Expand Down
3 changes: 2 additions & 1 deletion Assets/Scripts/GameConfig.cs
Expand Up @@ -11,7 +11,8 @@

public class GameConfig
{
public static bool ENABLE_ANALYTICS = false;
public static bool ENABLE_ANALYTICS = true; // See Assets/Readme.txt for instructions on how to use analytics
public static int ANALYTICS_RULE_ID = 0; // See Assets/Readme.txt for instructions on how to replace this ID and use analytics
}


7 changes: 5 additions & 2 deletions Assets/Scripts/PlayerHealth.cs
Expand Up @@ -18,7 +18,6 @@ public class PlayerHealth : MonoBehaviour
private PlayerControl playerControl; // Reference to the PlayerControl script.
private Animator anim; // Reference to the Animator on the player


void Awake ()
{
// Setting up references.
Expand Down Expand Up @@ -160,6 +159,10 @@ void SendDeathEvent ()

void FetchAvgDeathTime ()
{
if(GameConfig.ANALYTICS_RULE_ID == 0){
Debug.Log("See Assets/Readme.txt for instructions on how to replace the rule ID and use analytics");
return;
}
Action<string> callback = delegate(string s) {
AnalyticsCallback (s);};
StartCoroutine (FetchAnalyticsBlocking (callback));
Expand Down Expand Up @@ -189,7 +192,7 @@ IEnumerator FetchAnalyticsBlocking (Action<string> callback)
// Once active copy the ID assigned to the rule and replace the 147 below with that
// If you experience a big delay the first time you die please wait for several minutes until the game
// continues (we're looking into this bug)
GroupedResult result = KiiAnalytics.GetResult("147", condition);
GroupedResult result = KiiAnalytics.GetResult(GameConfig.ANALYTICS_RULE_ID.ToString(), condition);
IList<GroupedSnapShot> snapshots = result.SnapShots;
Debug.Log("Cycling through analytics snapshots");
foreach (GroupedSnapShot snapshot in snapshots)
Expand Down
6 changes: 4 additions & 2 deletions Assets/Scripts/Score.cs
Expand Up @@ -6,7 +6,7 @@
public class Score : MonoBehaviour
{
public int score = 0; // The player's score.
public static int highscore = 0;
public static int highscore = -1;
public static float avgDeath = 0;

private PlayerControl playerControl; // Reference to the player control script.
Expand All @@ -25,8 +25,10 @@ void Update ()
// Set the score and user text.
if (KiiUser.CurrentUser != null)
{
if(highscore == 0)
if(highscore < 0) {
highscore = 0;
LoadHighScore ();
}
string username = KiiUser.CurrentUser.Username;
if(GameConfig.ENABLE_ANALYTICS)
guiText.text = "Score: " + score + " Highscore: " + highscore + "\nUser: " + username + " Avg death: " + avgDeath.ToString("n2") + " s";
Expand Down

0 comments on commit 22a409d

Please sign in to comment.