ClubRoomSelectCtrl.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using wf;
  5. namespace Kasizuki
  6. {
  7. public class ClubRoomSelectCtrl : NGUIWindow
  8. {
  9. private void Start()
  10. {
  11. }
  12. public void SetCallbackOnClick(Action<RoomData.Data> callback)
  13. {
  14. this.m_CallbackOnClick = callback;
  15. }
  16. public void SetData()
  17. {
  18. this.UpdateUI();
  19. }
  20. private void UpdateUI()
  21. {
  22. FacilityManager facilityMgr = GameMain.Instance.FacilityMgr;
  23. Facility[] facilityArray = facilityMgr.GetFacilityArray();
  24. List<RoomData.Data> enableFacilityArray = this.GetFilteringKasizukiFacilityArray(facilityArray);
  25. this.GetFilteringRoomData(ref enableFacilityArray, delegate(RoomData.Data room)
  26. {
  27. if (room.isExistUpwardRoom && enableFacilityArray.Contains(room.GetUpwardRoomData()))
  28. {
  29. return false;
  30. }
  31. if (room.strConditionsArraySystemFlag != null && !GameMain.Instance.KasizukiMgr.IsMeetConditions(room.strConditionsArraySystemFlag))
  32. {
  33. return false;
  34. }
  35. ManDataType nowManType = (ManDataType)GameMain.Instance.KasizukiMgr.GetNowManType();
  36. if (!room.enableManTypeDic[nowManType])
  37. {
  38. return false;
  39. }
  40. List<PlayData.Data> playDatas = room.GetPlayDatas();
  41. List<PlayData.Data> list = new List<PlayData.Data>();
  42. foreach (PlayData.Data data in playDatas)
  43. {
  44. if (data.enableManTypeDic[nowManType])
  45. {
  46. if (data.GetFilteringPlayDataMaidArray(nowManType).Count > 0)
  47. {
  48. list.Add(data);
  49. }
  50. }
  51. }
  52. return list.Count > 0;
  53. });
  54. this.listViewer.Show<Transform>(enableFacilityArray.Count, delegate(int index, Transform trans)
  55. {
  56. RoomData.Data data = enableFacilityArray[index];
  57. this.OnCreateItemList(index, trans, data);
  58. });
  59. UIGrid component = this.listViewer.parentItemArea.GetComponent<UIGrid>();
  60. component.Reposition();
  61. }
  62. private void OnCreateItemList(int index, Transform trans, RoomData.Data data)
  63. {
  64. int facilityTypeID = data.facilityTypeID;
  65. Sprite facilityThumbnail = FacilityDataTable.GetFacilityThumbnail(facilityTypeID, true);
  66. if (facilityThumbnail != null)
  67. {
  68. UITexture componentInChildren = trans.GetComponentInChildren<UITexture>();
  69. componentInChildren.mainTexture = facilityThumbnail.texture;
  70. }
  71. UILabel component = UTY.GetChildObject(trans.gameObject, "Label Name", false).GetComponent<UILabel>();
  72. component.text = data.drawName;
  73. Utility.SetLocalizeTerm(component, data.drawNameTerm, false);
  74. UILabel component2 = UTY.GetChildObject(trans.gameObject, "Comment/Value", false).GetComponent<UILabel>();
  75. component2.text = data.explanatoryText;
  76. Utility.SetLocalizeTerm(component2, data.explanatoryTextTerm, false);
  77. UIButton uiButton = trans.GetComponent<UIButton>();
  78. if (uiButton)
  79. {
  80. EventDelegate.Add(uiButton.onClick, delegate()
  81. {
  82. this.OnClickItem(uiButton, data);
  83. });
  84. }
  85. else
  86. {
  87. Debug.LogWarningFormat("項目には「{0}」コンポーネントがありません", new object[]
  88. {
  89. typeof(UIButton)
  90. });
  91. }
  92. }
  93. private void OnClickItem(UIButton item, RoomData.Data roomData)
  94. {
  95. foreach (GameObject f_goParent in this.listViewer.ItemArray)
  96. {
  97. UTY.GetChildObject(f_goParent, "mask", false).SetActive(true);
  98. }
  99. UTY.GetChildObject(item.gameObject, "mask", false).SetActive(false);
  100. if (this.m_CallbackOnClick != null)
  101. {
  102. this.m_CallbackOnClick(roomData);
  103. }
  104. }
  105. private List<RoomData.Data> GetFilteringKasizukiFacilityArray(Facility[] nowFacilityArray)
  106. {
  107. List<RoomData.Data> list = new List<RoomData.Data>();
  108. List<RoomData.Data> allDatas = RoomData.GetAllDatas(true);
  109. foreach (RoomData.Data data in allDatas)
  110. {
  111. if (GameMain.Instance.FacilityMgr.IsExistTypeFacility(data.facilityTypeID))
  112. {
  113. list.Add(data);
  114. }
  115. }
  116. return list;
  117. }
  118. private void GetFilteringRoomData(ref List<RoomData.Data> roomList, Func<RoomData.Data, bool> filteringFunc)
  119. {
  120. List<RoomData.Data> list = new List<RoomData.Data>(roomList);
  121. for (int i = 0; i < list.Count; i++)
  122. {
  123. RoomData.Data data = list[i];
  124. if (!filteringFunc(data))
  125. {
  126. roomList.Remove(data);
  127. }
  128. }
  129. }
  130. private RoomData.Data GetKasizukiRoomData(int facilityTypeID)
  131. {
  132. List<RoomData.Data> allDatas = RoomData.GetAllDatas(true);
  133. foreach (RoomData.Data data in allDatas)
  134. {
  135. if (data.facilityTypeID == facilityTypeID)
  136. {
  137. return data;
  138. }
  139. }
  140. return null;
  141. }
  142. private uGUIListViewer listViewer
  143. {
  144. get
  145. {
  146. if (!this.m_ListViewerRoom)
  147. {
  148. this.m_ListViewerRoom = base.GetComponent<uGUIListViewer>();
  149. }
  150. return this.m_ListViewerRoom;
  151. }
  152. }
  153. private uGUIListViewer m_ListViewerRoom;
  154. private Action<RoomData.Data> m_CallbackOnClick;
  155. }
  156. }