您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

56 行
1.6 KiB

  1. using System;
  2. using System.Collections;
  3. using CIG.Translation;
  4. using SUISS.Cloud;
  5. using SUISS.Core;
  6. public class SparkSocCreatePopupState : PopupBaseState
  7. {
  8. public void TryCreate(string username, string password)
  9. {
  10. if (this.IsValidInput(username, password))
  11. {
  12. base.StartCoroutine(this.DoCreate(username, password));
  13. }
  14. }
  15. public bool IsValidInput(string username, string password)
  16. {
  17. return SingletonMonobehaviour<CIGSparkSocServices>.Instance.IsValidUsernameAndPassword(username, password);
  18. }
  19. public void SetLoggedInCallback(Action loggedInCallback)
  20. {
  21. this._loggedInCallback = loggedInCallback;
  22. }
  23. private IEnumerator DoCreate(string username, string password)
  24. {
  25. CIGSparkSocServices sparkSocServices = SingletonMonobehaviour<CIGSparkSocServices>.Instance;
  26. ((SparkSocCreatePopupView)this.View).SparkSocIsBusy(true);
  27. CloudRequest<PlayernameErrors?> create = sparkSocServices.CreateSparkSocPlayer(username, password);
  28. yield return create;
  29. ((SparkSocCreatePopupView)this.View).SparkSocIsBusy(false);
  30. if (create.Error != null)
  31. {
  32. this.ShowErrorPopup(sparkSocServices.LocalizedServerErrorCode(create.Error.Value));
  33. }
  34. else
  35. {
  36. base.ClosePopup();
  37. if (this._loggedInCallback != null)
  38. {
  39. this._loggedInCallback();
  40. }
  41. }
  42. yield break;
  43. }
  44. private void ShowErrorPopup(ILocalizedString text)
  45. {
  46. this._fsm.SwitchState<GenericPopupState>().UpdateInfo(null, Localization.Key("oops_something_went_wrong"), text, Localization.Key("ok"), null, null, null, null, true);
  47. }
  48. private Action _loggedInCallback;
  49. }