KasizukiManSelectCtrl.cs 5.6 KB

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