KasizukiCharacterSelectCtrl.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. using System;
  2. using System.Collections.Generic;
  3. using MaidStatus;
  4. using UnityEngine;
  5. namespace Kasizuki
  6. {
  7. public class KasizukiCharacterSelectCtrl : NGUIWindow
  8. {
  9. private void Init()
  10. {
  11. if (this.m_IsInit)
  12. {
  13. return;
  14. }
  15. this.m_CharaMgr = GameMain.Instance.CharacterMgr;
  16. this.m_IsInit = true;
  17. }
  18. private void Start()
  19. {
  20. this.Init();
  21. }
  22. public void SetData()
  23. {
  24. this.Init();
  25. List<Maid> maidList;
  26. if (this.callbackGetMaidList == null)
  27. {
  28. maidList = this.GetMaidList();
  29. }
  30. else
  31. {
  32. maidList = this.callbackGetMaidList();
  33. }
  34. if (this.callbackCreateItem == null)
  35. {
  36. this.m_ListViewer.Show<Transform>(maidList.Count, delegate(int i, Transform trans)
  37. {
  38. this.CreateItem(maidList[i], i, trans);
  39. });
  40. }
  41. else
  42. {
  43. this.m_ListViewer.Show<Transform>(maidList.Count, delegate(int i, Transform trans)
  44. {
  45. this.callbackCreateItem(maidList[i], i, trans);
  46. });
  47. }
  48. UIGrid componentInParent = this.m_ListViewer.parentItemArea.GetComponentInParent<UIGrid>();
  49. if (componentInParent)
  50. {
  51. componentInParent.repositionNow = true;
  52. }
  53. UIScrollView componentInParent2 = this.m_ListViewer.parentItemArea.GetComponentInParent<UIScrollView>();
  54. if (componentInParent2)
  55. {
  56. componentInParent2.ResetPosition();
  57. }
  58. }
  59. private List<Maid> GetMaidList()
  60. {
  61. List<Maid> list = new List<Maid>();
  62. for (int i = 0; i < this.m_CharaMgr.GetStockMaidCount(); i++)
  63. {
  64. Maid stockMaid = this.m_CharaMgr.GetStockMaid(i);
  65. if (!(stockMaid == null))
  66. {
  67. if (stockMaid.status.heroineType != HeroineType.Transfer)
  68. {
  69. if (stockMaid.status.heroineType != HeroineType.Sub)
  70. {
  71. list.Add(stockMaid);
  72. }
  73. }
  74. }
  75. }
  76. return list;
  77. }
  78. private void CreateItem(Maid maid, int index, Transform item)
  79. {
  80. GameObject itemObj = item.gameObject;
  81. UIButton componentInChildren = item.GetComponentInChildren<UIButton>(item);
  82. EventDelegate.Add(componentInChildren.onClick, delegate
  83. {
  84. this.callbackSelectItem(maid);
  85. this.UpdateListColor(itemObj);
  86. });
  87. UI2DSprite component = UTY.GetChildObject(itemObj, "BG/ThumbnailFrame/Thumbnail", false).GetComponent<UI2DSprite>();
  88. UILabel component2 = UTY.GetChildObject(itemObj, "BG/FirstName", false).GetComponent<UILabel>();
  89. UILabel component3 = UTY.GetChildObject(itemObj, "BG/LastName", false).GetComponent<UILabel>();
  90. Texture2D thumIcon = maid.GetThumIcon();
  91. if (thumIcon != null)
  92. {
  93. Sprite sprite2D = Sprite.Create(thumIcon, new Rect(0f, 0f, (float)thumIcon.width, (float)thumIcon.height), default(Vector2));
  94. component.sprite2D = sprite2D;
  95. }
  96. else
  97. {
  98. component.sprite2D = null;
  99. }
  100. component2.text = maid.status.firstName;
  101. component3.text = maid.status.lastName;
  102. }
  103. private void UpdateListColor(GameObject target)
  104. {
  105. if (!this.m_IsInit)
  106. {
  107. return;
  108. }
  109. foreach (GameObject f_goParent in this.m_ListViewer.ItemArray)
  110. {
  111. GameObject childObject = UTY.GetChildObject(f_goParent, "BG/mask", true);
  112. if (childObject)
  113. {
  114. childObject.SetActive(true);
  115. }
  116. }
  117. if (target != null)
  118. {
  119. GameObject childObject = UTY.GetChildObject(target, "BG/mask", true);
  120. if (childObject)
  121. {
  122. childObject.SetActive(false);
  123. }
  124. }
  125. }
  126. public BigThumbnailKasizuki bigThumbnail
  127. {
  128. get
  129. {
  130. return this.m_BigThumbnail;
  131. }
  132. }
  133. public Func<List<Maid>> callbackGetMaidList { get; set; }
  134. public Action<Maid, int, Transform> callbackCreateItem { get; set; }
  135. public Action<Maid> callbackSelectItem { get; set; }
  136. public uGUIListViewer listViewer
  137. {
  138. get
  139. {
  140. return this.m_ListViewer;
  141. }
  142. }
  143. private bool m_IsInit;
  144. [SerializeField]
  145. private BigThumbnailKasizuki m_BigThumbnail;
  146. private CharacterMgr m_CharaMgr;
  147. [SerializeField]
  148. private uGUIListViewer m_ListViewer;
  149. }
  150. }