ClubRoomSelectCtrl.cs 4.5 KB

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