123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Runtime.CompilerServices;
- using PlayerStatus;
- using UnityEngine;
- using wf;
- public class CharacterSelectManager : MonoBehaviour
- {
- public static void DefaultMaidList(List<Maid> draw_list)
- {
- CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
- for (int i = 0; i < characterMgr.GetStockMaidCount(); i++)
- {
- draw_list.Add(characterMgr.GetStockMaid(i));
- }
- }
- public static int SortMaidStandardNoSchedule(Maid maid_a, Maid maid_b)
- {
- if (maid_a.status.leader && !maid_b.status.leader)
- {
- return -1;
- }
- if (!maid_a.status.leader && maid_b.status.leader)
- {
- return 1;
- }
- Status status = GameMain.Instance.CharacterMgr.status;
- if (maid_a.status.creationTimeNum < maid_b.status.creationTimeNum)
- {
- return -1;
- }
- if (maid_a.status.creationTimeNum != maid_b.status.creationTimeNum)
- {
- return 1;
- }
- return string.Compare(maid_b.status.guid, maid_a.status.guid);
- }
- public static int SortMaidStandard(Maid maid_a, Maid maid_b)
- {
- if (maid_a.status.leader && !maid_b.status.leader)
- {
- return -1;
- }
- if (!maid_a.status.leader && maid_b.status.leader)
- {
- return 1;
- }
- Status status = GameMain.Instance.CharacterMgr.status;
- int scheduleMaidSetting = status.GetScheduleMaidSetting(maid_a);
- int scheduleMaidSetting2 = status.GetScheduleMaidSetting(maid_b);
- if (scheduleMaidSetting != -1 && scheduleMaidSetting2 == -1)
- {
- return -1;
- }
- if (scheduleMaidSetting == -1 && scheduleMaidSetting2 != -1)
- {
- return 1;
- }
- if (scheduleMaidSetting < scheduleMaidSetting2)
- {
- return -1;
- }
- if (scheduleMaidSetting > scheduleMaidSetting2)
- {
- return 1;
- }
- if (maid_a.status.creationTimeNum < maid_b.status.creationTimeNum)
- {
- return -1;
- }
- if (maid_a.status.creationTimeNum != maid_b.status.creationTimeNum)
- {
- return 1;
- }
- return string.Compare(maid_b.status.guid, maid_a.status.guid);
- }
- public static int SortMaidStandard(Transform a, Transform b)
- {
- Maid maid = a.gameObject.GetComponent<MaidPlate>().maid;
- Maid maid2 = b.gameObject.GetComponent<MaidPlate>().maid;
- return CharacterSelectManager.SortMaidStandard(maid, maid2);
- }
- public static int SortMaidRanking(Maid maid_a, Maid maid_b)
- {
- if (maid_a.status.popularRank != 0 && maid_b.status.popularRank == 0)
- {
- return -1;
- }
- if (maid_a.status.popularRank == 0 && maid_b.status.popularRank != 0)
- {
- return 1;
- }
- if (maid_a.status.popularRank < maid_b.status.popularRank)
- {
- return -1;
- }
- if (maid_a.status.popularRank != maid_b.status.popularRank)
- {
- return 1;
- }
- return CharacterSelectManager.SortMaidStandard(maid_a, maid_b);
- }
- public static int SortMaidRanking(Transform a, Transform b)
- {
- Maid maid = a.gameObject.GetComponent<MaidPlate>().maid;
- Maid maid2 = b.gameObject.GetComponent<MaidPlate>().maid;
- return CharacterSelectManager.SortMaidRanking(maid, maid2);
- }
- public void Awake()
- {
- NDebug.AssertNull(this.MaidPlateParentGrid != null);
- this.switch_panel_ = this.MaidPlateParentGrid.gameObject.GetComponent<UIWFSwitchPanel>();
- this.tab_panel_ = this.MaidPlateParentGrid.gameObject.GetComponent<UIWFTabPanel>();
- this.scroll_view_ = UTY.GetChildObject(base.gameObject, "Contents", false).GetComponent<UIScrollView>();
- this.scroll_bar_ = UTY.GetChildObject(base.gameObject, "Scroll Bar", false).GetComponent<UIScrollBar>();
- Transform transform = base.gameObject.transform.Find("BigThumbnail");
- if (transform != null)
- {
- this.big_thumbnail_ = transform.gameObject.GetComponent<BigThumbnail>();
- }
- this.SetSortType(CharacterSelectManager.SortType.Normal);
- }
- public void Create(CharacterSelectManager.Type type, int slect_max = 3, bool select_no_draw = true)
- {
- this.thumbnail_load_ = true;
- this.select_no_draw_ = select_no_draw;
- Stopwatch stopwatch = new Stopwatch();
- stopwatch.Start();
- if (this.big_thumbnail_ != null)
- {
- this.big_thumbnail_.Visible = true;
- }
- this.type_ = type;
- if (this.callback_maid_list_ == null)
- {
- if (CharacterSelectManager.<>f__mg$cache0 == null)
- {
- CharacterSelectManager.<>f__mg$cache0 = new CharacterSelectManager.CallBackMaidList(CharacterSelectManager.DefaultMaidList);
- }
- this.callback_maid_list_ = CharacterSelectManager.<>f__mg$cache0;
- }
- Transform transform = this.MaidPlateParentGrid.transform;
- for (int i = 0; i < transform.childCount; i++)
- {
- UnityEngine.Object.Destroy(transform.GetChild(i).gameObject);
- }
- transform.DetachChildren();
- List<Maid> list = new List<Maid>();
- this.callback_maid_list_(list);
- this.maid_list_count_ = list.Count;
- this.select_list_ = null;
- for (int j = 0; j < list.Count; j++)
- {
- GameObject gameObject = Utility.CreatePrefab(this.MaidPlateParentGrid.gameObject, "CharacterSelect/Prefab/MaidPlateSimple", true);
- gameObject.GetComponent<MaidPlate>().SetMaidData(list[j]);
- UIWFSelectButton component = UTY.GetChildObject(gameObject, "Button", false).GetComponent<UIWFSelectButton>();
- UIWFTabButton component2 = UTY.GetChildObject(gameObject, "Button", false).GetComponent<UIWFTabButton>();
- if (type == CharacterSelectManager.Type.Select)
- {
- UnityEngine.Object.Destroy(component);
- component2.enabled = true;
- EventDelegate.Add(component2.onSelect, new EventDelegate.Callback(this.OnSelect));
- }
- else if (type == CharacterSelectManager.Type.Multiple)
- {
- UnityEngine.Object.Destroy(component2);
- component.enabled = true;
- EventDelegate.Add(component.onSelect, new EventDelegate.Callback(this.OnSelect));
- }
- else if (type == CharacterSelectManager.Type.Click)
- {
- UnityEngine.Object.Destroy(component);
- component2.enabled = true;
- EventDelegate.Add(component2.onClick, new EventDelegate.Callback(this.OnClick));
- }
- }
- if (type == CharacterSelectManager.Type.Select)
- {
- UnityEngine.Object.Destroy(this.switch_panel_);
- this.switch_panel_ = null;
- if (this.tab_panel_ == null)
- {
- this.tab_panel_ = this.MaidPlateParentGrid.gameObject.AddComponent<UIWFTabPanel>();
- }
- this.tab_panel_.enabled = true;
- this.tab_panel_.UpdateChildren();
- }
- else if (type == CharacterSelectManager.Type.Multiple)
- {
- UnityEngine.Object.Destroy(this.tab_panel_);
- this.tab_panel_ = null;
- if (this.switch_panel_ == null)
- {
- this.switch_panel_ = this.MaidPlateParentGrid.gameObject.AddComponent<UIWFSwitchPanel>();
- }
- this.switch_panel_.SetNumberOfSelected(slect_max);
- this.switch_panel_.enabled = true;
- this.select_list_ = new MaidPlate[slect_max];
- this.switch_panel_.UpdateChildren();
- }
- this.Reposition();
- this.scroll_view_.ResetPosition();
- if (this.type_ == CharacterSelectManager.Type.Select && this.MaidPlateParentGrid.GetChildList().Count != 0)
- {
- UIWFTabButton component3 = UTY.GetChildObject(this.MaidPlateParentGrid.GetChild(0).gameObject, "Button", false).GetComponent<UIWFTabButton>();
- this.tab_panel_.Select(component3);
- }
- stopwatch.Stop();
- }
- public void SetSortType(CharacterSelectManager.SortType type)
- {
- if (type == CharacterSelectManager.SortType.Normal)
- {
- UIGrid maidPlateParentGrid = this.MaidPlateParentGrid;
- if (CharacterSelectManager.<>f__mg$cache1 == null)
- {
- CharacterSelectManager.<>f__mg$cache1 = new Comparison<Transform>(CharacterSelectManager.SortMaidStandard);
- }
- maidPlateParentGrid.onCustomSort = CharacterSelectManager.<>f__mg$cache1;
- }
- else
- {
- UIGrid maidPlateParentGrid2 = this.MaidPlateParentGrid;
- if (CharacterSelectManager.<>f__mg$cache2 == null)
- {
- CharacterSelectManager.<>f__mg$cache2 = new Comparison<Transform>(CharacterSelectManager.SortMaidRanking);
- }
- maidPlateParentGrid2.onCustomSort = CharacterSelectManager.<>f__mg$cache2;
- }
- this.Reposition();
- }
- public void SelectMaid(Maid maid)
- {
- if (this.type_ != CharacterSelectManager.Type.Select || maid == null)
- {
- return;
- }
- List<Transform> childList = this.MaidPlateParentGrid.GetChildList();
- for (int i = 0; i < childList.Count; i++)
- {
- if (childList[i].gameObject.GetComponent<MaidPlate>().maid == maid)
- {
- UIWFTabButton component = UTY.GetChildObject(childList[i].gameObject, "Button", false).GetComponent<UIWFTabButton>();
- this.tab_panel_.Select(component);
- return;
- }
- }
- }
- public void SelectAllMaid()
- {
- if (this.type_ != CharacterSelectManager.Type.Multiple || this.select_list_ == null || this.select_no_draw_)
- {
- return;
- }
- this.thumbnail_load_ = false;
- CharacterSelectManager.CallBackOnMultiSelect callBackOnMultiSelect = this.callback_on_multi_select_;
- this.callback_on_multi_select_ = null;
- this.switch_panel_.SelectAll();
- this.callback_on_multi_select_ = callBackOnMultiSelect;
- if (this.callback_on_multi_select_ != null)
- {
- Maid[] array = new Maid[this.select_list_.Length];
- for (int i = 0; i < this.select_list_.Length; i++)
- {
- if (this.select_list_[i] != null)
- {
- array[i] = this.select_list_[i].maid;
- }
- }
- this.callback_on_multi_select_(array);
- }
- this.thumbnail_load_ = true;
- }
- public void SelectAllReleaseMaid()
- {
- if (this.type_ != CharacterSelectManager.Type.Multiple || this.select_list_ == null || this.select_no_draw_)
- {
- return;
- }
- this.thumbnail_load_ = false;
- CharacterSelectManager.CallBackOnMultiSelect callBackOnMultiSelect = this.callback_on_multi_select_;
- this.callback_on_multi_select_ = null;
- this.switch_panel_.SelectAllRelease();
- this.callback_on_multi_select_ = callBackOnMultiSelect;
- if (this.callback_on_multi_select_ != null)
- {
- Maid[] array = new Maid[this.select_list_.Length];
- for (int i = 0; i < this.select_list_.Length; i++)
- {
- if (this.select_list_[i] != null)
- {
- array[i] = this.select_list_[i].maid;
- }
- }
- this.callback_on_multi_select_(array);
- }
- this.thumbnail_load_ = true;
- }
- public void SetSelectStateMaid(Maid maid, bool isSelect)
- {
- Transform transform = this.MaidPlateParentGrid.transform;
- for (int i = 0; i < transform.childCount; i++)
- {
- MaidPlate component = transform.GetChild(i).GetComponent<MaidPlate>();
- if (component.maid == maid)
- {
- UIWFSelectButton component2 = UTY.GetChildObject(component.gameObject, "Button", false).GetComponent<UIWFSelectButton>();
- if (component2.isSelected != isSelect)
- {
- this.switch_panel_.Select(component2);
- }
- return;
- }
- }
- }
- public void UpdateMaidPlate(Maid maid)
- {
- Transform transform = this.MaidPlateParentGrid.transform;
- for (int i = 0; i < transform.childCount; i++)
- {
- MaidPlate component = transform.GetChild(i).GetComponent<MaidPlate>();
- if (component.maid == maid)
- {
- component.SetMaidData(maid);
- return;
- }
- }
- transform = this.NoDrawArea.transform;
- for (int j = 0; j < transform.childCount; j++)
- {
- MaidPlate component2 = transform.GetChild(j).GetComponent<MaidPlate>();
- if (component2.maid == maid)
- {
- component2.SetMaidData(maid);
- return;
- }
- }
- }
- public void RemoveMaidPlate(Maid maid)
- {
- List<Transform> childList = this.MaidPlateParentGrid.GetChildList();
- MaidPlate maidPlate = null;
- MaidPlate maidPlate2 = null;
- bool flag = false;
- for (int i = 0; i < childList.Count; i++)
- {
- maidPlate = childList[i].gameObject.GetComponent<MaidPlate>();
- if (maidPlate.maid == maid)
- {
- if (i + 1 < childList.Count)
- {
- maidPlate2 = childList[i + 1].gameObject.GetComponent<MaidPlate>();
- }
- flag = true;
- break;
- }
- maidPlate2 = maidPlate;
- }
- if (!flag)
- {
- NDebug.Assert("error.", false);
- return;
- }
- if (this.type_ == CharacterSelectManager.Type.Select && maidPlate2 != null && maidPlate2.maid != maid)
- {
- UIWFTabButton component = UTY.GetChildObject(maidPlate2.gameObject, "Button", false).GetComponent<UIWFTabButton>();
- this.tab_panel_.Select(component);
- }
- this.MoveNoDrawArea(maid);
- maidPlate.SetMaidData(null);
- this.Reposition();
- }
- public bool MoveNoDrawArea(Maid maid)
- {
- MaidPlate maidPlate = null;
- Transform transform = this.MaidPlateParentGrid.transform;
- for (int i = 0; i < transform.childCount; i++)
- {
- MaidPlate component = transform.GetChild(i).GetComponent<MaidPlate>();
- if (component.maid == maid)
- {
- maidPlate = component;
- break;
- }
- }
- if (maidPlate == null)
- {
- return false;
- }
- maidPlate.gameObject.transform.SetParent(this.NoDrawArea.transform, false);
- this.Reposition();
- return true;
- }
- public bool MoveGridArea(Maid maid)
- {
- MaidPlate maidPlate = null;
- Transform transform = this.NoDrawArea.transform;
- for (int i = 0; i < transform.childCount; i++)
- {
- MaidPlate component = transform.GetChild(i).GetComponent<MaidPlate>();
- if (component.maid == maid)
- {
- maidPlate = component;
- break;
- }
- }
- if (maidPlate == null)
- {
- return false;
- }
- maidPlate.gameObject.transform.SetParent(this.MaidPlateParentGrid.transform, false);
- this.Reposition();
- return true;
- }
- public void SetRightVisible(bool is_visible)
- {
- Transform transform = this.MaidPlateParentGrid.transform;
- UISprite component = UTY.GetChildObject(base.gameObject, "BG", false).GetComponent<UISprite>();
- Transform transform2 = UTY.GetChildObject(base.gameObject, "Scroll Bar", false).transform;
- UIWidget component2 = UTY.GetChildObject(base.gameObject, "DragMat", false).GetComponent<UIWidget>();
- this.right_visible_ = is_visible;
- if (is_visible)
- {
- for (int i = 0; i < transform.childCount; i++)
- {
- MaidPlate component3 = transform.GetChild(i).gameObject.GetComponent<MaidPlate>();
- component3.SetRightPlateVisible(true);
- }
- component.transform.localPosition = new Vector3(145f, 0f, 0f);
- component.width = 792;
- transform2.localPosition = new Vector3(354f, 0f, 0f);
- component2.transform.localPosition = new Vector3(140f, 0f, 0f);
- component2.width = 784;
- component2.ResizeCollider();
- }
- else
- {
- for (int j = 0; j < transform.childCount; j++)
- {
- MaidPlate component4 = transform.GetChild(j).gameObject.GetComponent<MaidPlate>();
- component4.SetRightPlateVisible(false);
- }
- component.transform.localPosition = Vector3.zero;
- component.width = 502;
- transform2.localPosition = new Vector3(64f, 0f, 0f);
- component2.transform.localPosition = new Vector3(-5f, 0f, 0f);
- component2.width = 492;
- component2.ResizeCollider();
- }
- }
- public void SetCallBackMaidList(CharacterSelectManager.CallBackMaidList callback)
- {
- this.callback_maid_list_ = callback;
- }
- public void SetCallBackOnClick(CharacterSelectManager.CallBackOnClick callback)
- {
- this.callback_on_click_ = callback;
- }
- public void SetCallBackOnMultiSelect(CharacterSelectManager.CallBackOnMultiSelect callback)
- {
- this.callback_on_multi_select_ = callback;
- }
- public void SetCallBackCallBackOnSelect(CharacterSelectManager.CallBackOnSelect callback)
- {
- this.callback_on_select_ = callback;
- }
- public void Reposition()
- {
- this.MaidPlateParentGrid.Reposition();
- this.scroll_view_.UpdatePosition();
- }
- public bool IsRightVisible()
- {
- return this.right_visible_;
- }
- public UIScrollView scroll_view
- {
- get
- {
- return this.scroll_view_;
- }
- }
- public UIScrollBar scroll_bar
- {
- get
- {
- return this.scroll_bar_;
- }
- }
- public BigThumbnail big_thumbnail
- {
- get
- {
- return this.big_thumbnail_;
- }
- }
- public int maid_list_count
- {
- get
- {
- return this.maid_list_count_;
- }
- }
- private void OnSelect()
- {
- GameObject gameObject = UIButton.current.transform.parent.gameObject;
- MaidPlate component = gameObject.GetComponent<MaidPlate>();
- bool selected = UIWFSelectButton.selected;
- if (this.type_ == CharacterSelectManager.Type.Select)
- {
- if (selected && this.callback_on_select_ != null)
- {
- if (this.big_thumbnail_ != null && this.thumbnail_load_)
- {
- this.big_thumbnail_.SetMaid(component.maid);
- }
- this.callback_on_select_(component.maid);
- }
- }
- else if (this.type_ == CharacterSelectManager.Type.Multiple)
- {
- if (selected)
- {
- for (int i = 0; i < this.select_list_.Length; i++)
- {
- if (this.select_list_[i] == null)
- {
- if (this.big_thumbnail_ != null && this.thumbnail_load_)
- {
- this.big_thumbnail_.SetMaid(component.maid);
- }
- this.select_list_[i] = component;
- if (this.select_no_draw_)
- {
- this.select_list_[i].SetSelectNoVisible(i + 1, true);
- }
- break;
- }
- }
- }
- else
- {
- for (int j = 0; j < this.select_list_.Length; j++)
- {
- if (this.select_list_[j] == component)
- {
- if (this.big_thumbnail_ != null && this.thumbnail_load_)
- {
- this.big_thumbnail_.SetMaid(component.maid);
- }
- if (this.select_no_draw_)
- {
- this.select_list_[j].SetSelectNoVisible(j + 1, false);
- }
- this.select_list_[j] = null;
- break;
- }
- }
- }
- if (this.callback_on_multi_select_ != null)
- {
- Maid[] array = new Maid[this.select_list_.Length];
- for (int k = 0; k < this.select_list_.Length; k++)
- {
- if (this.select_list_[k] != null)
- {
- array[k] = this.select_list_[k].maid;
- }
- }
- this.callback_on_multi_select_(array);
- }
- }
- }
- private void OnClick()
- {
- MaidPlate component = UIButton.current.transform.parent.GetComponent<MaidPlate>();
- if (this.callback_on_click_ != null)
- {
- this.callback_on_click_(component.maid);
- }
- }
- public int select_max
- {
- get
- {
- return (this.select_list_ != null) ? this.select_list_.Length : 0;
- }
- }
- public UIGrid MaidPlateParentGrid;
- public GameObject NoDrawArea;
- private CharacterSelectManager.CallBackMaidList callback_maid_list_;
- private CharacterSelectManager.CallBackOnClick callback_on_click_;
- private CharacterSelectManager.CallBackOnMultiSelect callback_on_multi_select_;
- private CharacterSelectManager.CallBackOnSelect callback_on_select_;
- private BigThumbnail big_thumbnail_;
- private UIScrollView scroll_view_;
- private UIScrollBar scroll_bar_;
- private UIWFSwitchPanel switch_panel_;
- private UIWFTabPanel tab_panel_;
- private CharacterSelectManager.Type type_;
- private MaidPlate[] select_list_;
- private bool right_visible_;
- private bool select_no_draw_;
- private int maid_list_count_;
- private bool thumbnail_load_;
- [CompilerGenerated]
- private static CharacterSelectManager.CallBackMaidList <>f__mg$cache0;
- [CompilerGenerated]
- private static Comparison<Transform> <>f__mg$cache1;
- [CompilerGenerated]
- private static Comparison<Transform> <>f__mg$cache2;
- public enum Type
- {
- Click,
- Select,
- Multiple
- }
- public enum SortType
- {
- Normal,
- Ranking
- }
- public delegate void CallBackMaidList(List<Maid> draw_list);
- public delegate void CallBackOnClick(Maid select_maid);
- public delegate void CallBackOnSelect(Maid select_maid);
- public delegate void CallBackOnMultiSelect(Maid[] select_maid);
- }
|