public static string playerName = ""; // Muratet : overrided in SendStatements system // ------------------------------------------------------------------------ // Sample Gameplay GBLxAPI Triggers // ------------------------------------------------------------------------ /* * Here is where you will put functions to be called whenever you want to send a GBLxAPI statement. */ public static void SendStatement(string verb, string activityType, string activityName, Dictionary <string, string> activityExtensions = null) { ActivityDefinitionBuilder.IOptional definitionBuilder = GBLXAPI.ActivityDefinition .WithType(activityType) .WithName(activityName); if (activityExtensions != null) { //set extensions ExtensionsBuilder extensions = GBLXAPI.Extensions; foreach (KeyValuePair <string, string> entry in activityExtensions) { extensions = extensions.WithStandard(entry.Key, entry.Value); } definitionBuilder.WithExtensions(extensions.Build()); } GBLXAPI.Statement .WithActor(GBLXAPI.Agent .WithAccount(userUUID, "https://www.lip6.fr/mocah/") .WithName(playerName) .Build()) .WithVerb(verb) .WithTargetActivity(GBLXAPI.Activity .WithID("https://www.lip6.fr/mocah/invalidURI/" + activityType + "/" + activityName) .WithDefinition(definitionBuilder.Build()) .Build()) .Enqueue(); }
public static void SendStatementWithResult(string verb, string activityType, string activityName, Dictionary <string, string> activityExtensions = null, Dictionary <string, string> resultExtensions = null, bool?completed = null, bool?success = null, string response = null, int?score = null, float duration = 0) { ActivityDefinitionBuilder.IOptional definitionBuilder = GBLXAPI.ActivityDefinition .WithType(activityType) .WithName(activityName); if (activityExtensions != null) { //set extensions ExtensionsBuilder extensions = GBLXAPI.Extensions; foreach (KeyValuePair <string, string> entry in activityExtensions) { extensions = extensions.WithStandard(entry.Key, entry.Value); } definitionBuilder.WithExtensions(extensions.Build()); } ResultBuilder resultBuilder = GBLXAPI.Result; if (completed != null) { resultBuilder = resultBuilder.WithCompletion(completed == true); } if (success != null) { resultBuilder = resultBuilder.WithSuccess(success == true); } if (score != null) { resultBuilder = resultBuilder.WithScore(score); } if (response != null) { resultBuilder = resultBuilder.WithResponse(response); } if (resultExtensions != null) { //set extensions ExtensionsBuilder extensions = GBLXAPI.Extensions; foreach (KeyValuePair <string, string> entry in resultExtensions) { extensions = extensions.WithStandard(entry.Key, entry.Value); } resultBuilder.WithExtensions(extensions.Build()); } GBLXAPI.Statement .WithActor(GBLXAPI.Agent .WithAccount(userUUID, "https://www.lip6.fr/mocah/") .WithName(playerName) .Build()) .WithVerb(verb) .WithTargetActivity(GBLXAPI.Activity .WithID("https://www.lip6.fr/mocah/invalidURI/" + activityType + "/" + activityName) .WithDefinition(definitionBuilder.Build()) .Build()) .WithResult(resultBuilder) .Enqueue(); }