123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- 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<Maid> maidList;
- if (this.callbackGetMaidList == null)
- {
- maidList = this.GetMaidList();
- }
- else
- {
- maidList = this.callbackGetMaidList();
- }
- if (this.callbackCreateItem == null)
- {
- this.m_ListViewer.Show<Transform>(maidList.Count, delegate(int i, Transform trans)
- {
- this.CreateItem(maidList[i], i, trans);
- });
- }
- else
- {
- this.m_ListViewer.Show<Transform>(maidList.Count, delegate(int i, Transform trans)
- {
- this.callbackCreateItem(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();
- }
- }
- private List<Maid> GetMaidList()
- {
- List<Maid> list = new List<Maid>();
- 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<UIButton>(item);
- EventDelegate.Add(componentInChildren.onClick, delegate()
- {
- 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 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<List<Maid>> callbackGetMaidList { get; set; }
- public Action<Maid, int, Transform> callbackCreateItem { get; set; }
- public Action<Maid> 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;
- }
- }
|