KasizukiManSelectCtrl.cs 5.3 KB

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