KasizukiCharacterSelectCtrl.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. NamePair charaName = maid.status.charaName;
  101. component3.text = charaName.name1;
  102. component2.text = charaName.name2;
  103. }
  104. private void UpdateListColor(GameObject target)
  105. {
  106. if (!this.m_IsInit)
  107. {
  108. return;
  109. }
  110. foreach (GameObject f_goParent in this.m_ListViewer.ItemArray)
  111. {
  112. GameObject childObject = UTY.GetChildObject(f_goParent, "BG/mask", true);
  113. if (childObject)
  114. {
  115. childObject.SetActive(true);
  116. }
  117. }
  118. if (target != null)
  119. {
  120. GameObject childObject = UTY.GetChildObject(target, "BG/mask", true);
  121. if (childObject)
  122. {
  123. childObject.SetActive(false);
  124. }
  125. }
  126. }
  127. public BigThumbnailKasizuki bigThumbnail
  128. {
  129. get
  130. {
  131. return this.m_BigThumbnail;
  132. }
  133. }
  134. public Func<List<Maid>> callbackGetMaidList { get; set; }
  135. public Action<Maid, int, Transform> callbackCreateItem { get; set; }
  136. public Action<Maid> callbackSelectItem { get; set; }
  137. public uGUIListViewer listViewer
  138. {
  139. get
  140. {
  141. return this.m_ListViewer;
  142. }
  143. }
  144. private bool m_IsInit;
  145. [SerializeField]
  146. private BigThumbnailKasizuki m_BigThumbnail;
  147. private CharacterMgr m_CharaMgr;
  148. [SerializeField]
  149. private uGUIListViewer m_ListViewer;
  150. }
  151. }