B08_TaskListItem.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class B08_TaskListItem : MonoBehaviour
  6. {
  7. public Text typeText;
  8. public Text titleText;
  9. public Text stateText;
  10. public Text dateText;
  11. public Text ctrlText;
  12. public GameObject more;
  13. public Button moreButton;
  14. public bool moreMessage = false;
  15. public RectTransform rect;
  16. public GameObject pointItemPrefab;
  17. public List<B08_TaskPointItem> PointItems = new List<B08_TaskPointItem>();
  18. public Transform itemContent;
  19. public B08_TaskInfoData InfoData;
  20. public GCYWLayer gcywLayer;
  21. public void Init()
  22. {
  23. rect = this.GetComponent<RectTransform>();
  24. typeText = this.transform.Find("typeText").GetComponent<Text>();
  25. titleText = this.transform.Find("titleText").GetComponent<Text>();
  26. stateText = this.transform.Find("stateText").GetComponent<Text>();
  27. dateText = this.transform.Find("dateText").GetComponent<Text>();
  28. ctrlText = this.transform.Find("ctrlText").GetComponent<Text>();
  29. more = this.transform.Find("more").gameObject;
  30. more.SetActive(false);
  31. moreButton = ctrlText.GetComponent<Button>();
  32. moreButton.onClick.AddListener(ChangeMoreMessage);
  33. moreMessage = false;
  34. ctrlText.text = "<color=#00EFFF>详情</color>";
  35. rect.sizeDelta = new Vector2(360,38);
  36. more.SetActive(false);
  37. }
  38. public void ChangeMoreMessage()
  39. {
  40. if (moreMessage)
  41. {
  42. ctrlText.text = "<color=#00EFFF>详情</color>";
  43. rect.sizeDelta = new Vector2(360,38);
  44. more.SetActive(false);
  45. }
  46. else
  47. {
  48. ctrlText.text = "<color=#00FF3F>收起</color>";
  49. rect.sizeDelta = new Vector2(360,354);
  50. more.SetActive(true);
  51. gcywLayer.SetTaskImgPanelData(InfoData.task_items);
  52. }
  53. moreMessage = !moreMessage;
  54. }
  55. public void SetData(GCYWLayer baseLayer,B08_TaskInfoData data,int typeIndex)
  56. {
  57. gcywLayer = baseLayer;
  58. InfoData = data;
  59. string typeStr = "";
  60. switch (typeIndex)
  61. {
  62. case 0:
  63. typeStr = "电气";
  64. break;
  65. case 1:
  66. typeStr = "闸站";
  67. break;
  68. case 2:
  69. typeStr = "堤防";
  70. break;
  71. case 3:
  72. typeStr = "交叉建筑";
  73. break;
  74. case 4:
  75. typeStr = "定期专项";
  76. break;
  77. }
  78. typeText.text = typeStr;
  79. titleText.text = data.type;
  80. stateText.text = data.status;
  81. dateText.text = data.start_time;
  82. for (int i = 0; i < PointItems.Count; i++)
  83. {
  84. Destroy(PointItems[i].gameObject);
  85. }
  86. PointItems.Clear();
  87. for (int i = 0; i < data.task_items.Length; i++)
  88. {
  89. B08_TaskPointItem tempItem = Instantiate(pointItemPrefab,itemContent).GetComponent<B08_TaskPointItem>();
  90. tempItem.SetData(baseLayer,data.task_items[i],i,data.start_time);
  91. var button = tempItem.GetComponent<ExtendedButton_PointItem>();
  92. button.index = i;
  93. button.onPointerEnter += baseLayer.SetTaskPointIconHeightLight;
  94. PointItems.Add(tempItem);
  95. }
  96. }
  97. }