/// <summary> /// Decrements the accumulating number value. /// </summary> /// <param name='dataMap'> /// Data map. /// </param> void DecrementValue(AGSGameDataMap dataMap) { // Increments the accumulating number value based on its type. AGSSyncableAccumulatingNumber accumulatingNumber = dataMap.GetAccumulatingNumber(SyncableVariableName()); switch (type) { case AvailableAccumulatingNumberType.Double: accumulatingNumber.Decrement(doubleIncrementValue); break; case AvailableAccumulatingNumberType.Int: accumulatingNumber.Decrement(intIncrementValue); break; case AvailableAccumulatingNumberType.Long: accumulatingNumber.Decrement(longIncrementValue); break; case AvailableAccumulatingNumberType.String: accumulatingNumber.Decrement(stringIncrementValue); break; } // after the decrement is complete, update the value locally. RetrieveAccumulatingNumberValue(dataMap); }
/// <summary> /// Retrieves the accumulating number value from Whispersync. /// </summary> /// <param name='dataMap'> /// Data map. /// </param> void RetrieveAccumulatingNumberValue(AGSGameDataMap dataMap) { // Retrieve the accumulating number value from Whispersync, based on its type. AGSSyncableAccumulatingNumber accumulatingNumber = dataMap.GetAccumulatingNumber(SyncableVariableName()); switch (type) { case AvailableAccumulatingNumberType.Double: valueAsDouble = accumulatingNumber.AsDouble(); break; case AvailableAccumulatingNumberType.Int: valueAsInt = accumulatingNumber.AsInt(); break; case AvailableAccumulatingNumberType.Long: valueAsLong = accumulatingNumber.AsLong(); break; case AvailableAccumulatingNumberType.String: valueAsString = accumulatingNumber.AsString(); break; } }
// Use this for initialization void Start() { didScore15 = false; didScore30 = false; didScore50 = false; didScore75 = false; didScore100 = false; guiSkin.button.fontSize = Mathf.Max (Screen.width, Screen.height) / 25; AGSClient.ServiceReadyEvent += serviceReadyHandler; AGSClient.ServiceNotReadyEvent += serviceNotReadyHandler; bool usesLeaderboards = true; bool usesAchievements = true; bool usesWhispersync = true; AGSClient.Init (usesLeaderboards, usesAchievements, usesWhispersync); isServiceReady = AGSClient.IsServiceReady(); // Hook up feedback functions AGSLeaderboardsClient.SubmitScoreSucceededEvent += submitScoreSucceeded; AGSLeaderboardsClient.SubmitScoreFailedEvent += submitScoreFailed; AGSAchievementsClient.UpdateAchievementSucceededEvent += updateAchievementSucceeded; AGSAchievementsClient.UpdateAchievementFailedEvent += updateAchievementFailed; // Whispersync dataMap = AGSWhispersyncClient.GetGameData(); if(dataMap != null){ gamesPlayed = dataMap.GetAccumulatingNumber("gamesPlayed"); } }
/// <summary> /// Retrieves the accumulating number value from Whispersync. /// </summary> /// <param name='dataMap'> /// Data map. /// </param> void RetrieveAccumulatingNumberValue(AGSGameDataMap dataMap) { // Retrieve the accumulating number value from Whispersync, based on its type. AGSSyncableAccumulatingNumber accumulatingNumber = dataMap.GetAccumulatingNumber(SyncableVariableName()); switch(type) { case AvailableAccumulatingNumberType.Double: valueAsDouble = accumulatingNumber.AsDouble(); break; case AvailableAccumulatingNumberType.Int: valueAsInt = accumulatingNumber.AsInt(); break; case AvailableAccumulatingNumberType.Long: valueAsLong = accumulatingNumber.AsLong(); break; case AvailableAccumulatingNumberType.String: valueAsString = accumulatingNumber.AsString(); break; } }
/// <summary> /// Increments the accumulating number value. /// </summary> /// <param name='dataMap'> /// Data map. /// </param> void IncrementValue(AGSGameDataMap dataMap) { // Increments the accumulating number value based on its type. AGSSyncableAccumulatingNumber accumulatingNumber = dataMap.GetAccumulatingNumber(SyncableVariableName()); switch(type) { case AvailableAccumulatingNumberType.Double: accumulatingNumber.Increment(doubleIncrementValue); break; case AvailableAccumulatingNumberType.Int: accumulatingNumber.Increment(intIncrementValue); break; case AvailableAccumulatingNumberType.Long: accumulatingNumber.Increment(longIncrementValue); break; case AvailableAccumulatingNumberType.String: accumulatingNumber.Increment(stringIncrementValue); break; } // after the increment is complete, update the value locally. RetrieveAccumulatingNumberValue(dataMap); }