UIComponent.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using System;
  2. using Fort23.Core;
  3. using Fort23.UTool;
  4. using UnityEngine;
  5. namespace Fort23.Mono
  6. {
  7. public class UIComponent : UIBase, IGObjectPoolInterface
  8. {
  9. private bool _isActivePool;
  10. public virtual async void Show()
  11. {
  12. await base.Show();
  13. }
  14. public virtual void Close()
  15. {
  16. }
  17. public string poolObjName { get; set; }
  18. public bool isUse { get; set; }
  19. public bool isDestroy { get; }
  20. public AssetHandle AssetHandle { get; set; }
  21. public TimerEntity DestroyTimer { get; set; }
  22. public GameObject own
  23. {
  24. get { return _own; }
  25. }
  26. private GameObject _own;
  27. public virtual void ResetData()
  28. {
  29. }
  30. /// <summary>
  31. /// 池子激活的时候
  32. /// </summary>
  33. public virtual void ActiveObj()
  34. {
  35. _isActivePool = true;
  36. if (own != null)
  37. {
  38. own.SetActive(true);
  39. }
  40. }
  41. /// <summary>
  42. /// 对方放回池子的时候
  43. /// </summary>
  44. public virtual void DormancyObj()
  45. {
  46. own.SetActive(false);
  47. if (!_isActivePool)
  48. {
  49. return;
  50. }
  51. DelEvent();
  52. }
  53. public void SetPosition(Vector3 pos)
  54. {
  55. #if !COMBAT_SERVER
  56. _own.transform.position = pos;
  57. #endif
  58. }
  59. public void SetScale(Vector3 scale)
  60. {
  61. #if !COMBAT_SERVER
  62. _own.transform.localScale = scale;
  63. #endif
  64. }
  65. public void SetRotation(Vector3 rotation)
  66. {
  67. #if !COMBAT_SERVER
  68. _own.transform.eulerAngles = rotation;
  69. #endif
  70. }
  71. public Vector3 GetPosition()
  72. {
  73. throw new System.NotImplementedException();
  74. }
  75. public Vector3 GetScale()
  76. {
  77. throw new System.NotImplementedException();
  78. }
  79. public Vector3 GettRotation()
  80. {
  81. throw new System.NotImplementedException();
  82. }
  83. public void SetActive(bool isActive)
  84. {
  85. #if !COMBAT_SERVER
  86. _own.SetActive(isActive);
  87. #endif
  88. }
  89. public async CTask DelayHide()
  90. {
  91. }
  92. /// <summary>
  93. /// 对象被销毁的时候
  94. /// </summary>
  95. public virtual void DestroyObj()
  96. {
  97. if (!_isActivePool)
  98. {
  99. return;
  100. }
  101. DelEvent();
  102. }
  103. public virtual void Preset()
  104. {
  105. }
  106. public virtual void AddEvent()
  107. {
  108. }
  109. public virtual void DelEvent()
  110. {
  111. }
  112. public void SetGameObject(GameObject gameObject)
  113. {
  114. _own = gameObject;
  115. }
  116. }
  117. }