GardenSmartFoxManager.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using System;
  2. using System.Collections.Generic;
  3. using Sfs2X.Requests;
  4. using UnityEngine;
  5. public class CounterAction
  6. {
  7. public int Count;
  8. public int Counter;
  9. public Action Action;
  10. public CounterAction(Action action, int count = 1)
  11. {
  12. Count = count;
  13. Action = action;
  14. }
  15. public void Invoke()
  16. {
  17. if (Counter++ < Count)
  18. {
  19. Action.Invoke();
  20. }
  21. }
  22. public void Bind(ref Action parent)
  23. {
  24. parent += Invoke;
  25. }
  26. }
  27. public class CounterAction<T>
  28. {
  29. public int Count;
  30. public int Counter;
  31. public Action<T> Action;
  32. public CounterAction(Action<T> action, int count = 1)
  33. {
  34. Count = count;
  35. Action = action;
  36. }
  37. public void Invoke(T t)
  38. {
  39. if (Counter++ < Count)
  40. {
  41. Action.Invoke(t);
  42. }
  43. }
  44. public void Bind(ref Action<T> parent)
  45. {
  46. parent += Invoke;
  47. }
  48. }
  49. public class CounterAction<T1, T2>
  50. {
  51. public int Count;
  52. public int Counter;
  53. public Action<T1, T2> Action;
  54. public CounterAction(Action<T1, T2> action, int count = 1)
  55. {
  56. Count = count;
  57. Action = action;
  58. }
  59. public void Invoke(T1 t1, T2 t2)
  60. {
  61. if (Counter++ < Count)
  62. {
  63. Action.Invoke(t1, t2);
  64. }
  65. }
  66. public void Bind(ref Action<T1, T2> parent)
  67. {
  68. parent += Invoke;
  69. }
  70. }
  71. public class GardenSmartFoxManager : Regist
  72. {
  73. #region Variable
  74. public static GardenSmartFox GardenSmartFox;
  75. #endregion
  76. public override bool RegistImmed()
  77. {
  78. enabled = true;
  79. return base.RegistImmed();
  80. }
  81. public void Start()
  82. {
  83. GardenSmartFox = new GardenSmartFox(new Loggor(), new Connector());
  84. //GardenSmartFox.Connector.Connect();
  85. }
  86. public void OnDisable()
  87. {
  88. if (GardenSmartFox != null)
  89. GardenSmartFox.Connector.Disconnect();
  90. }
  91. public void Update()
  92. {
  93. GardenSmartFox.SmartFox.ProcessEvents();
  94. GardenSmartFox.SFSPlazaRoomManager.Update();
  95. GardenSmartFox.ProcessRequest();
  96. }
  97. }