KasizukiManSelectCtrl.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace Kasizuki
  5. {
  6. public class KasizukiManSelectCtrl : MonoBehaviour
  7. {
  8. public Action<int> OnClickManTypeButton { get; set; }
  9. public ManDataType nowSelectManType { get; set; }
  10. private void Awake()
  11. {
  12. uGUIListViewer component = this.m_WindowManList.GetComponent<uGUIListViewer>();
  13. this.m_ButtonSelectedColor = (this.m_ButtonDefaultColor = component.tempItem.GetComponent<UIWidget>().color);
  14. this.m_ButtonSelectedColor.a = 1f;
  15. this.SetUpManList();
  16. this.SetUpManProfile();
  17. this.SetUpManInfo();
  18. this.m_WindowManInfo.SetActive(false);
  19. }
  20. private void SetUpManList()
  21. {
  22. this.m_ManListCache = new ObjectCacheDic();
  23. List<ManData.Data> dataArray = ManData.GetAllDatas(true, true);
  24. uGUIListViewer component = this.m_WindowManList.GetComponent<uGUIListViewer>();
  25. component.Show<UIButton>(dataArray.Count, delegate(int index, UIButton button)
  26. {
  27. UILabel componentInChildren2 = button.GetComponentInChildren<UILabel>();
  28. componentInChildren2.text = dataArray[index].drawName;
  29. EventDelegate.Add(button.onClick, delegate
  30. {
  31. this.OnClickManListButton(dataArray[index].ID);
  32. });
  33. this.m_ManListCache.AddCache<UIButton>(dataArray[index].ID.ToString(), button);
  34. });
  35. UIGrid component2 = component.parentItemArea.GetComponent<UIGrid>();
  36. if (component2)
  37. {
  38. component2.Reposition();
  39. }
  40. UIScrollView componentInChildren = component.GetComponentInChildren<UIScrollView>();
  41. if (componentInChildren)
  42. {
  43. componentInChildren.UpdatePosition();
  44. }
  45. componentInChildren.ResetPosition();
  46. }
  47. private void SetUpManProfile()
  48. {
  49. this.m_ManProfileCache = new ObjectCacheDic();
  50. this.m_ManProfileCache.CacheChildObject<UILabel>(this.m_WindowManProfile, "Text Free Comment", "フリーコメント");
  51. this.m_ManProfileCache.CacheChildObject<UILabel>(this.m_WindowManProfile, "Favorite/Value", "好きなプレイ");
  52. }
  53. private void SetUpManInfo()
  54. {
  55. this.m_ManInfoCache = new ObjectCacheDic();
  56. this.m_ManInfoCache.CacheChildObject<UILabel>(this.m_WindowManInfo, "PlayCount/Value", "プレイ回数");
  57. List<ItemData.Data> allDatas = ItemData.GetAllDatas(true);
  58. uGUIListViewer component = this.m_WindowManInfo.GetComponent<uGUIListViewer>();
  59. component.Show<UISprite>(allDatas.Count, delegate(int index, UISprite sprite)
  60. {
  61. UILabel componentInChildren2 = sprite.GetComponentInChildren<UILabel>();
  62. componentInChildren2.text = "未実装";
  63. this.ChangeButtonColor(sprite.gameObject, false);
  64. });
  65. UITable component2 = component.parentItemArea.GetComponent<UITable>();
  66. if (component2)
  67. {
  68. component2.Reposition();
  69. }
  70. UIScrollView componentInChildren = component.GetComponentInChildren<UIScrollView>();
  71. if (componentInChildren)
  72. {
  73. componentInChildren.UpdatePosition();
  74. }
  75. componentInChildren.ResetPosition();
  76. }
  77. public void OnClickManListButton(int selectedManID)
  78. {
  79. UIButton cache = this.m_ManListCache.GetCache<UIButton>(selectedManID.ToString());
  80. uGUIListViewer component = this.m_WindowManList.GetComponent<uGUIListViewer>();
  81. this.ChangeButtonArrayColor(component.ItemArray, cache.gameObject);
  82. this.nowSelectManType = ManData.GetData(selectedManID).manType;
  83. this.UpdateManProfile(selectedManID);
  84. this.UpdateManInfo();
  85. if (this.OnClickManTypeButton != null)
  86. {
  87. this.OnClickManTypeButton(selectedManID);
  88. }
  89. }
  90. private void UpdateManProfile(int manID)
  91. {
  92. ManData.Data data = ManData.GetData(manID);
  93. UILabel cache = this.m_ManProfileCache.GetCache<UILabel>("フリーコメント");
  94. cache.text = data.profileText;
  95. cache = this.m_ManProfileCache.GetCache<UILabel>("好きなプレイ");
  96. cache.text = data.favoritePlayText;
  97. }
  98. private void UpdateManInfo()
  99. {
  100. UILabel cache = this.m_ManInfoCache.GetCache<UILabel>("プレイ回数");
  101. cache.text = "未実装";
  102. }
  103. private void ChangeButtonArrayColor(GameObject[] buttonArray, GameObject target)
  104. {
  105. foreach (GameObject gameObject in buttonArray)
  106. {
  107. this.ChangeButtonColor(gameObject, gameObject == target);
  108. }
  109. }
  110. private void ChangeButtonColor(GameObject buttonObj, bool isHighLightColor)
  111. {
  112. if (buttonObj == null)
  113. {
  114. return;
  115. }
  116. UIButton component = buttonObj.GetComponent<UIButton>();
  117. if (component)
  118. {
  119. component.defaultColor = ((!isHighLightColor) ? this.m_ButtonDefaultColor : this.m_ButtonSelectedColor);
  120. return;
  121. }
  122. UIWidget component2 = buttonObj.GetComponent<UIWidget>();
  123. if (component2)
  124. {
  125. component2.color = ((!isHighLightColor) ? this.m_ButtonDefaultColor : this.m_ButtonSelectedColor);
  126. return;
  127. }
  128. }
  129. [SerializeField]
  130. private GameObject m_WindowManList;
  131. [SerializeField]
  132. private GameObject m_WindowManProfile;
  133. [SerializeField]
  134. private GameObject m_WindowManInfo;
  135. private ObjectCacheDic m_ManListCache;
  136. private ObjectCacheDic m_ManProfileCache;
  137. private ObjectCacheDic m_ManInfoCache;
  138. private Color m_ButtonDefaultColor;
  139. private Color m_ButtonSelectedColor;
  140. }
  141. }