123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- 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<ScoutMaidData> maidList = this.callbackGetScoutMaidList();
- this.m_ListViewer.Show<Transform>(maidList.Count, delegate(int i, Transform trans)
- {
- this.CreateItem(maidList[i], i, trans);
- });
- UIGrid componentInParent = this.m_ListViewer.parentItemArea.GetComponentInParent<UIGrid>();
- if (componentInParent)
- {
- componentInParent.repositionNow = true;
- }
- UIScrollView componentInParent2 = this.m_ListViewer.parentItemArea.GetComponentInParent<UIScrollView>();
- 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<UIButton>();
- if (componentInChildren != null && componentInChildren.onClick != null)
- {
- EventDelegate.Execute(componentInChildren.onClick);
- }
- }
- UIGrid componentInParent = this.m_ListViewer.parentItemArea.GetComponentInParent<UIGrid>();
- 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<UIButton>(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<UI2DSprite>();
- UILabel component2 = UTY.GetChildObject(itemObj, "BG/FirstName", false).GetComponent<UILabel>();
- UILabel component3 = UTY.GetChildObject(itemObj, "BG/LastName", false).GetComponent<UILabel>();
- 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<List<ScoutMaidData>> callbackGetScoutMaidList;
- public Action<ScoutMaidData> callbackSelectItem;
- private Dictionary<ScoutMaidData, GameObject> itemDictionary = new Dictionary<ScoutMaidData, GameObject>();
- private bool m_IsInit;
- [SerializeField]
- private BigThumbnail m_BigThumbnail;
- [SerializeField]
- private uGUIListViewer m_ListViewer;
- }
- }
|