LeveItem.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /****************************************************************************
  2. * 2024.6 LXD
  3. ****************************************************************************/
  4. using System;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. using UnityEngine.UI;
  8. using QFramework;
  9. namespace QFramework
  10. {
  11. public partial class LeveItem : UIElement
  12. {
  13. /// <summary>
  14. /// Index值
  15. /// </summary>
  16. [HideInInspector]
  17. public int m_index;
  18. /// <summary>
  19. /// 设置时间
  20. /// </summary>
  21. [HideInInspector]
  22. public string m_Time;
  23. /// <summary>
  24. /// 关卡名称
  25. /// </summary>
  26. [HideInInspector]
  27. public string m_LevelName;
  28. #region UI状态
  29. /// <summary>
  30. /// 选择状态
  31. /// </summary>
  32. [HideInInspector]
  33. public bool m_SelectState;
  34. /// <summary>
  35. /// 时间图标的选中/取消颜色
  36. /// </summary>
  37. [Header("时间图标的选中状态")]
  38. public Color m_SelectTimeIconColor;
  39. [Header("时间图标的取消状态")]
  40. public Color m_NormalTimeIconColor;
  41. /// <summary>
  42. /// 时间字体的选中/取消颜色
  43. /// </summary>
  44. [Header("时间字体的选中状态")]
  45. public Color m_SelectTimeColor;
  46. [Header("时间字体的选中状态")]
  47. public Color m_NormalTimeColor;
  48. /// <summary>
  49. /// 关卡名称字体的选中/取消颜色
  50. /// </summary>
  51. [Header("关卡名称字体的选中状态")]
  52. public Color m_SelectConentColor;
  53. [Header("关卡名称字体的取消状态")]
  54. public Color m_NormalConentColor;
  55. #endregion
  56. /// <summary>
  57. /// 子集第一个元素
  58. /// </summary>
  59. public OperationStepDataInfo m_OperationStepDataInfo;
  60. void Start()
  61. {
  62. ClickBtn.onClick.AddListener(OnClickBtnClick);
  63. TimeInputField.onEndEdit.AddListener(OnTimeInputFildEndEditor);
  64. }
  65. /// <summary>
  66. /// 初始化
  67. /// </summary>
  68. /// <param name="index">indexz</param>
  69. /// <param name="conent"></param>
  70. /// <param name="childId"></param>
  71. public void InitData(int index, OperationStepDataInfo operationStepDataInfo)
  72. {
  73. m_OperationStepDataInfo = operationStepDataInfo;
  74. IdText.text = (index + 1).ToString();
  75. m_index = index;
  76. m_LevelName = operationStepDataInfo.parentStepName;
  77. LeveConentText.text = m_LevelName;
  78. m_Time = m_LevelName;
  79. }
  80. public void OnClickBtnClick()
  81. {
  82. SetSelectState(!m_SelectState);
  83. UIKit.GetPanel<ChallengeConfigurationPanel>().SetSelectState(m_index, m_SelectState);
  84. }
  85. public void SetSelectState(bool state)
  86. {
  87. SelectStateIcon.gameObject.SetActive(state);
  88. if (state)
  89. {
  90. TimeLogo.color = m_SelectTimeIconColor;
  91. LeveConentText.color = m_SelectConentColor;
  92. Placeholder.color = m_SelectTimeColor;
  93. Text.color = m_SelectTimeColor;
  94. }
  95. else
  96. {
  97. TimeLogo.color = m_NormalTimeIconColor;
  98. LeveConentText.color = m_NormalConentColor;
  99. Text.color = m_NormalTimeColor;
  100. Placeholder.color= m_NormalConentColor;
  101. }
  102. m_SelectState = state;
  103. }
  104. public void SetSelectedData(ChallengeConfiguration challengeConfiguration)
  105. {
  106. SetSelectState(true);
  107. TimeInputField.text = challengeConfiguration.LeveTime;
  108. }
  109. private void OnTimeInputFildEndEditor(string conent)
  110. {
  111. m_Time = conent;
  112. UIKit.GetPanel<ChallengeConfigurationPanel>().RefreshTotalTime();
  113. }
  114. }
  115. }