123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- namespace Kasizuki
- {
- public class ClubRoomSelectCtrl : NGUIWindow
- {
- private void Start()
- {
- }
- public void SetCallbackOnClick(Action<RoomData.Data> callback)
- {
- this.m_CallbackOnClick = callback;
- }
- public void SetData()
- {
- this.UpdateUI();
- }
- private void UpdateUI()
- {
- FacilityManager facilityMgr = GameMain.Instance.FacilityMgr;
- Facility[] facilityArray = facilityMgr.GetFacilityArray();
- List<RoomData.Data> 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<PlayData.Data> playDatas = room.GetPlayDatas();
- List<PlayData.Data> list = new List<PlayData.Data>();
- 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<Transform>(enableFacilityArray.Count, delegate(int index, Transform trans)
- {
- RoomData.Data data = enableFacilityArray[index];
- this.OnCreateItemList(index, trans, data);
- });
- UIGrid component = this.listViewer.parentItemArea.GetComponent<UIGrid>();
- 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<UITexture>();
- componentInChildren.mainTexture = facilityThumbnail.texture;
- }
- UILabel component = UTY.GetChildObject(trans.gameObject, "Label Name", false).GetComponent<UILabel>();
- component.text = data.drawName;
- UILabel component2 = UTY.GetChildObject(trans.gameObject, "Comment/Value", false).GetComponent<UILabel>();
- component2.text = data.explanatoryText;
- UIButton uiButton = trans.GetComponent<UIButton>();
- 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<RoomData.Data> GetFilteringKasizukiFacilityArray(Facility[] nowFacilityArray)
- {
- List<RoomData.Data> list = new List<RoomData.Data>();
- List<RoomData.Data> 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<RoomData.Data> roomList, Func<RoomData.Data, bool> filteringFunc)
- {
- List<RoomData.Data> list = new List<RoomData.Data>(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<RoomData.Data> 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<uGUIListViewer>();
- }
- return this.m_ListViewerRoom;
- }
- }
- private uGUIListViewer m_ListViewerRoom;
- private Action<RoomData.Data> m_CallbackOnClick;
- }
- }
|