GardenSmartFoxManager.cs 2.2 KB

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