using System; using System.Collections.Generic; using Kasizuki; using UnityEngine; namespace scoutmode { public class ScoutCharacterSelectCtrl : NGUIWindow { public ScoutMaidData selectedMaidData { get; private set; } private void Init() { if (this.m_IsInit) { return; } this.m_IsInit = true; } private void Start() { this.Init(); } public void SetData() { this.Init(); List maidList = this.callbackGetScoutMaidList(); this.m_ListViewer.Show(maidList.Count, delegate(int i, Transform trans) { this.CreateItem(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(); } } public void DeleteItem(ScoutMaidData maid) { if (!this.itemDictionary.ContainsKey(maid)) { return; } GameObject gameObject = null; GameObject[] itemArray = this.m_ListViewer.ItemArray; for (int i = 0; i < itemArray.Length; i++) { GameObject x = itemArray[i]; if (!(x != this.itemDictionary[maid])) { if (i + 1 < itemArray.Length) { gameObject = itemArray[i + 1]; } else if (i - 1 >= 0) { gameObject = itemArray[i - 1]; } break; } } this.m_ListViewer.RemoveItem(this.itemDictionary[maid]); this.selectedMaidData = null; if (gameObject != null) { UIButton componentInChildren = gameObject.GetComponentInChildren(); if (componentInChildren != null && componentInChildren.onClick != null) { EventDelegate.Execute(componentInChildren.onClick); } } UIGrid componentInParent = this.m_ListViewer.parentItemArea.GetComponentInParent(); if (componentInParent) { componentInParent.Reposition(); } } private void CreateItem(ScoutMaidData maid, int index, Transform item) { GameObject itemObj = item.gameObject; this.itemDictionary[maid] = itemObj; UIButton componentInChildren = item.GetComponentInChildren(item); EventDelegate.Add(componentInChildren.onClick, delegate() { this.selectedMaidData = maid; if (this.callbackSelectItem != null) { 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 texture2D = null; byte[] iconImageBinary = maid.iconImageBinary; if (iconImageBinary != null) { texture2D = new Texture2D(1, 1, TextureFormat.ARGB32, false); texture2D.LoadImage(iconImageBinary); } if (texture2D != null) { Sprite sprite2D = Sprite.Create(texture2D, new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height), default(Vector2)); component.sprite2D = sprite2D; } else { component.sprite2D = null; } if (maid.status != null) { component3.text = maid.status.name1; component2.text = maid.status.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 BigThumbnail bigThumbnail { get { return this.m_BigThumbnail; } } public uGUIListViewer listViewer { get { return this.m_ListViewer; } } public Func> callbackGetScoutMaidList; public Action callbackSelectItem; private Dictionary itemDictionary = new Dictionary(); private bool m_IsInit; [SerializeField] private BigThumbnail m_BigThumbnail; [SerializeField] private uGUIListViewer m_ListViewer; } }