PostScoreService.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using UnityEngine;
  3. using System.Collections;
  4. using SimpleJSON;
  5. namespace Newgrounds.Services {
  6. public class PostScoreService:BasicService {
  7. // Data
  8. private string scoreBoardName;
  9. private int numericScore;
  10. private string tag;
  11. // ================================================================================================================
  12. // CONSTRUCTOR ----------------------------------------------------------------------------------------------------
  13. public PostScoreService(ServiceCallback __callback = null) : base(__callback) {
  14. }
  15. // ================================================================================================================
  16. // PUBLIC INTERFACE -----------------------------------------------------------------------------------------------
  17. public void setData(string __scoreBoardName, int __numericScore, string __tag = null) {
  18. scoreBoardName = __scoreBoardName;
  19. numericScore = __numericScore;
  20. tag = __tag;
  21. }
  22. // ================================================================================================================
  23. // EXTENDED INTERFACE ---------------------------------------------------------------------------------------------
  24. protected override void setDefaultData() {
  25. // Extend
  26. commandId = "postScore";
  27. isSecure = true;
  28. }
  29. protected override void addCustomFields(Hashtable __hash) {
  30. __hash.Add("board", scoreBoardName);
  31. __hash.Add("value", numericScore);
  32. if (tag != null) __hash.Add("tag", tag);
  33. }
  34. protected override void parseSuccessResult(JSONNode __result) {
  35. // Extend
  36. // ==> {"command_id":"postScore","board":-4970,"tag":"","value":100,"success":1}
  37. }
  38. }
  39. }