using System; using System.Collections.Generic; using MaidStatus; using UnityEngine; namespace Kasizuki { public class KasizukiCharacterSelectCtrl : NGUIWindow { private void Init() { if (this.m_IsInit) { return; } this.m_CharaMgr = GameMain.Instance.CharacterMgr; this.m_IsInit = true; } private void Start() { this.Init(); } public void SetData() { this.Init(); List maidList; if (this.callbackGetMaidList == null) { maidList = this.GetMaidList(); } else { maidList = this.callbackGetMaidList(); } if (this.callbackCreateItem == null) { this.m_ListViewer.Show(maidList.Count, delegate(int i, Transform trans) { this.CreateItem(maidList[i], i, trans); }); } else { this.m_ListViewer.Show(maidList.Count, delegate(int i, Transform trans) { this.callbackCreateItem(maidList[i], i, trans); }); } UIGrid componentInParent = this.m_ListViewer.parentItemArea.GetComponentInParent(); if (componentInParent) { componentInParent.repositionNow = true; } UIScrollView componentInParent2 = this.m_ListViewer.parentItemArea.GetComponentInParent(); if (componentInParent2) { componentInParent2.ResetPosition(); } } private List GetMaidList() { List list = new List(); for (int i = 0; i < this.m_CharaMgr.GetStockMaidCount(); i++) { Maid stockMaid = this.m_CharaMgr.GetStockMaid(i); if (!(stockMaid == null)) { if (stockMaid.status.heroineType != HeroineType.Transfer) { if (stockMaid.status.heroineType != HeroineType.Sub) { list.Add(stockMaid); } } } } return list; } private void CreateItem(Maid maid, int index, Transform item) { GameObject itemObj = item.gameObject; UIButton componentInChildren = item.GetComponentInChildren(item); EventDelegate.Add(componentInChildren.onClick, delegate() { this.callbackSelectItem(maid); this.UpdateListColor(itemObj); }); UI2DSprite component = UTY.GetChildObject(itemObj, "BG/ThumbnailFrame/Thumbnail", false).GetComponent(); UILabel component2 = UTY.GetChildObject(itemObj, "BG/FirstName", false).GetComponent(); UILabel component3 = UTY.GetChildObject(itemObj, "BG/LastName", false).GetComponent(); Texture2D thumIcon = maid.GetThumIcon(); if (thumIcon != null) { Sprite sprite2D = Sprite.Create(thumIcon, new Rect(0f, 0f, (float)thumIcon.width, (float)thumIcon.height), default(Vector2)); component.sprite2D = sprite2D; } else { component.sprite2D = null; } NamePair charaName = maid.status.charaName; component3.text = charaName.name1; component2.text = charaName.name2; } private void UpdateListColor(GameObject target) { if (!this.m_IsInit) { return; } foreach (GameObject f_goParent in this.m_ListViewer.ItemArray) { GameObject childObject = UTY.GetChildObject(f_goParent, "BG/mask", true); if (childObject) { childObject.SetActive(true); } } if (target != null) { GameObject childObject = UTY.GetChildObject(target, "BG/mask", true); if (childObject) { childObject.SetActive(false); } } } public BigThumbnailKasizuki bigThumbnail { get { return this.m_BigThumbnail; } } public Func> callbackGetMaidList { get; set; } public Action callbackCreateItem { get; set; } public Action callbackSelectItem { get; set; } public uGUIListViewer listViewer { get { return this.m_ListViewer; } } private bool m_IsInit; [SerializeField] private BigThumbnailKasizuki m_BigThumbnail; private CharacterMgr m_CharaMgr; [SerializeField] private uGUIListViewer m_ListViewer; } }