using System; using System.Collections.Generic; using UnityEngine; namespace Kasizuki { public class ClubRoomSelectCtrl : NGUIWindow { private void Start() { } public void SetCallbackOnClick(Action callback) { this.m_CallbackOnClick = callback; } public void SetData() { this.UpdateUI(); } private void UpdateUI() { FacilityManager facilityMgr = GameMain.Instance.FacilityMgr; Facility[] facilityArray = facilityMgr.GetFacilityArray(); List enableFacilityArray = this.GetFilteringKasizukiFacilityArray(facilityArray); this.GetFilteringRoomData(ref enableFacilityArray, delegate(RoomData.Data room) { if (room.isExistUpwardRoom && enableFacilityArray.Contains(room.GetUpwardRoomData())) { return false; } if (room.strConditionsArraySystemFlag != null && !GameMain.Instance.KasizukiMgr.IsMeetConditions(room.strConditionsArraySystemFlag)) { return false; } ManDataType nowManType = (ManDataType)GameMain.Instance.KasizukiMgr.GetNowManType(); if (!room.enableManTypeDic[nowManType]) { return false; } List playDatas = room.GetPlayDatas(); List list = new List(); foreach (PlayData.Data data in playDatas) { if (data.enableManTypeDic[nowManType]) { if (data.GetFilteringPlayDataMaidArray(nowManType).Count > 0) { list.Add(data); } } } return list.Count > 0; }); this.listViewer.Show(enableFacilityArray.Count, delegate(int index, Transform trans) { RoomData.Data data = enableFacilityArray[index]; this.OnCreateItemList(index, trans, data); }); UIGrid component = this.listViewer.parentItemArea.GetComponent(); component.Reposition(); } private void OnCreateItemList(int index, Transform trans, RoomData.Data data) { int facilityTypeID = data.facilityTypeID; Sprite facilityThumbnail = FacilityDataTable.GetFacilityThumbnail(facilityTypeID, true); if (facilityThumbnail != null) { UITexture componentInChildren = trans.GetComponentInChildren(); componentInChildren.mainTexture = facilityThumbnail.texture; } UILabel component = UTY.GetChildObject(trans.gameObject, "Label Name", false).GetComponent(); component.text = data.drawName; UILabel component2 = UTY.GetChildObject(trans.gameObject, "Comment/Value", false).GetComponent(); component2.text = data.explanatoryText; UIButton uiButton = trans.GetComponent(); if (uiButton) { EventDelegate.Add(uiButton.onClick, delegate { this.OnClickItem(uiButton, data); }); } else { Debug.LogWarningFormat("項目には「{0}」コンポーネントがありません", new object[] { typeof(UIButton) }); } } private void OnClickItem(UIButton item, RoomData.Data roomData) { foreach (GameObject f_goParent in this.listViewer.ItemArray) { UTY.GetChildObject(f_goParent, "mask", false).SetActive(true); } UTY.GetChildObject(item.gameObject, "mask", false).SetActive(false); if (this.m_CallbackOnClick != null) { this.m_CallbackOnClick(roomData); } } private List GetFilteringKasizukiFacilityArray(Facility[] nowFacilityArray) { List list = new List(); List allDatas = RoomData.GetAllDatas(true); foreach (RoomData.Data data in allDatas) { if (GameMain.Instance.FacilityMgr.IsExistTypeFacility(data.facilityTypeID)) { list.Add(data); } } return list; } private void GetFilteringRoomData(ref List roomList, Func filteringFunc) { List list = new List(roomList); for (int i = 0; i < list.Count; i++) { RoomData.Data data = list[i]; if (!filteringFunc(data)) { roomList.Remove(data); } } } private RoomData.Data GetKasizukiRoomData(int facilityTypeID) { List allDatas = RoomData.GetAllDatas(true); foreach (RoomData.Data data in allDatas) { if (data.facilityTypeID == facilityTypeID) { return data; } } return null; } private uGUIListViewer listViewer { get { if (!this.m_ListViewerRoom) { this.m_ListViewerRoom = base.GetComponent(); } return this.m_ListViewerRoom; } } private uGUIListViewer m_ListViewerRoom; private Action m_CallbackOnClick; } }