123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Runtime.CompilerServices;
- using MaidStatus;
- using MaidStatus.Old;
- using UnityEngine;
- [RequireComponent(typeof(UIPanel))]
- public class MaidTransferMain : WfFadeBehaviour
- {
- public void Awake()
- {
- this.statusMgr.Init();
- this.statusMgr.statusCtrl.gameObject.SetActive(true);
- this.loadBlackBG.SetActive(false);
- this.maidList = new List<Maid>(this.maidStorageObject.GetComponents<Maid>());
- this.charaSelectMgr.SetCallBackCallBackOnSelect(new CharacterSelectManager.CallBackOnSelect(this.OnSelectChara));
- this.deserializeCount = -1;
- this.initCount = 0;
- this.initCoroutine = this.InitializeMaid();
- base.StartCoroutine(this.initCoroutine);
- }
- private IEnumerator InitializeMaid()
- {
- this.initCount = 0;
- while (0 <= this.initCount)
- {
- this.maidList[this.initCount].InitializeStatus();
- this.initCount++;
- if (this.maidList.Count <= this.initCount)
- {
- this.initCount = -1;
- }
- yield return null;
- }
- yield break;
- }
- public void Call(string loadSaveFilePath)
- {
- if (this.initCount != -1)
- {
- base.StopCoroutine(this.initCoroutine);
- while (0 <= this.initCount)
- {
- this.maidList[this.initCount].InitializeStatus();
- this.initCount++;
- if (this.maidList.Count <= this.initCount)
- {
- this.initCount = -1;
- }
- }
- }
- if (this.deserializeCount != -1)
- {
- return;
- }
- this.loadSaveFilePath = loadSaveFilePath;
- OldDataConverter oldDataConverter = new OldDataConverter();
- this.oldDataList = oldDataConverter.OpenFile(loadSaveFilePath);
- base.StartCoroutine(this.InitializeDeserialize());
- }
- private IEnumerator InitializeDeserialize()
- {
- UICamera.InputEnable = false;
- this.deserializeCount = 0;
- GameMain.Instance.LoadIcon.NextLoadIcontImmediatelyDisplay();
- GameMain.Instance.LoadIcon.force_draw_new = true;
- GameMain.Instance.LoadIcon.SetForceDraw(true);
- GameMain.Instance.LoadIcon.is_center_draw = true;
- this.loadBlackBG.SetActive(true);
- foreach (OldDataConverter.MaidData oldData in this.oldDataList)
- {
- Texture2D iconTex = new Texture2D(1, 1, TextureFormat.ARGB32, false);
- iconTex.LoadImage(oldData.ReadThumbnailByte());
- this.maidList[this.deserializeCount].status.Deserialize(oldData.statusReader, false);
- this.maidList[this.deserializeCount].status.leader = oldData.statusReader.leader;
- if (this.maidList[this.deserializeCount].GetThumIcon() != null)
- {
- UnityEngine.Object.DestroyImmediate(this.maidList[this.deserializeCount].GetThumIcon());
- }
- this.maidList[this.deserializeCount].SetThumIcon(iconTex);
- this.deserializeCount++;
- yield return null;
- }
- this.loadBlackBG.SetActive(false);
- GameMain.Instance.LoadIcon.is_center_draw = false;
- GameMain.Instance.LoadIcon.force_draw_new = false;
- GameMain.Instance.LoadIcon.SetForceDraw(false);
- this.deserializeCount = -1;
- this.transferPossibleMaidList = this.GetEnabledMaid();
- if (this.transferPossibleMaidList.Count == 0)
- {
- UICamera.InputEnable = true;
- GameMain.Instance.SysDlg.Show("移籍可能なメイドがいませんでした", SystemDialog.TYPE.OK, null, null);
- yield break;
- }
- List<Maid> list = this.transferPossibleMaidList;
- if (MaidTransferMain.<>f__mg$cache0 == null)
- {
- MaidTransferMain.<>f__mg$cache0 = new Comparison<Maid>(CharacterSelectManager.SortMaidStandardNoSchedule);
- }
- list.Sort(MaidTransferMain.<>f__mg$cache0);
- this.charaSelectMgr.SetCallBackMaidList(delegate(List<Maid> draw_list)
- {
- draw_list.Clear();
- foreach (Maid item in this.$this.transferPossibleMaidList)
- {
- draw_list.Add(item);
- }
- });
- this.charaSelectMgr.Create(CharacterSelectManager.Type.Select, 3, true);
- this.charaSelectMgr.big_thumbnail.Visible = false;
- this.charaSelectMgr.gameObject.SetActive(true);
- WfFadeJob.Create(this, this.loadUi, this.fadeTime, iTween.EaseType.easeOutSine);
- yield break;
- }
- public void Close()
- {
- WfFadeJob.Create(this.loadUi, this, this.fadeTime, iTween.EaseType.easeOutSine);
- }
- public void OnDestroy()
- {
- foreach (Maid maid in this.maidList)
- {
- if (!(maid == null))
- {
- if (maid.GetThumIcon() != null)
- {
- UnityEngine.Object.DestroyImmediate(maid.GetThumIcon());
- }
- }
- }
- }
- public void OnSelectChara(Maid select_maid)
- {
- if (select_maid == null)
- {
- return;
- }
- this.statusMgr.UpdateMaidStatus(select_maid);
- this.selectedMaid = select_maid;
- }
- public void ExecTransfer()
- {
- if (this.selectedMaid == null || string.IsNullOrEmpty(this.loadSaveFilePath))
- {
- return;
- }
- OldDataConverter.MaidData maidData = null;
- foreach (OldDataConverter.MaidData maidData2 in this.oldDataList)
- {
- if (this.selectedMaid.status.guid == maidData2.statusReader.guid)
- {
- maidData = maidData2;
- break;
- }
- }
- if (maidData != null)
- {
- this.maidManagementMain.Transfer(this.loadSaveFilePath, maidData);
- }
- }
- public List<Maid> GetEnabledMaid()
- {
- List<Maid> list = new List<Maid>();
- Dictionary<MaidStatus.Old.Personal, bool> dictionary = new Dictionary<MaidStatus.Old.Personal, bool>();
- dictionary.Add(MaidStatus.Old.Personal.Pure, MaidStatus.Personal.IsEnabled("Pure"));
- dictionary.Add(MaidStatus.Old.Personal.Pride, MaidStatus.Personal.IsEnabled("Pride"));
- dictionary.Add(MaidStatus.Old.Personal.Cool, MaidStatus.Personal.IsEnabled("Cool"));
- dictionary.Add(MaidStatus.Old.Personal.Yandere, MaidStatus.Personal.IsEnabled("Yandere"));
- dictionary.Add(MaidStatus.Old.Personal.Anesan, MaidStatus.Personal.IsEnabled("Anesan"));
- dictionary.Add(MaidStatus.Old.Personal.Genki, MaidStatus.Personal.IsEnabled("Genki"));
- dictionary.Add(MaidStatus.Old.Personal.Sadist, MaidStatus.Personal.IsEnabled("Sadist"));
- HashSet<string> hashSet = new HashSet<string>();
- CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
- for (int i = 0; i < characterMgr.GetStockMaidCount(); i++)
- {
- Maid stockMaid = characterMgr.GetStockMaid(i);
- if (stockMaid != null && !hashSet.Contains(stockMaid.status.guid))
- {
- hashSet.Add(stockMaid.status.guid);
- }
- }
- for (int j = 0; j < this.oldDataList.Count; j++)
- {
- StatusReader statusReader = this.oldDataList[j].statusReader;
- if (!statusReader.isRentalMaid && dictionary[statusReader.personal])
- {
- if (!hashSet.Contains(statusReader.guid))
- {
- list.Add(this.maidList[j]);
- }
- }
- }
- return list;
- }
- public override void OnUpdateFadeIn(float val)
- {
- this.alpha = val;
- }
- public override void OnUpdateFadeOut(float val)
- {
- this.alpha = val;
- }
- public virtual float alpha
- {
- set
- {
- if (this.targetPanels != null && 0 < this.targetPanels.Length)
- {
- foreach (UIPanel uipanel in this.targetPanels)
- {
- if (uipanel != null)
- {
- uipanel.alpha = value;
- }
- }
- }
- }
- }
- [SerializeField]
- public GameObject maidStorageObject;
- [SerializeField]
- public float fadeTime;
- [SerializeField]
- private WfFadeBehaviour loadUi;
- [SerializeField]
- private GameObject loadBlackBG;
- [SerializeField]
- private MaidManagementMain maidManagementMain;
- [SerializeField]
- private CharacterSelectManager charaSelectMgr;
- [SerializeField]
- private CharaSelectStatusMgr statusMgr;
- [SerializeField]
- public UIPanel[] targetPanels;
- public string loadSaveFilePath;
- private List<Maid> maidList = new List<Maid>();
- private List<OldDataConverter.MaidData> oldDataList;
- private List<Maid> transferPossibleMaidList = new List<Maid>();
- private Maid selectedMaid;
- private IEnumerator initCoroutine;
- private int initCount;
- private int deserializeCount;
- [CompilerGenerated]
- private static Comparison<Maid> <>f__mg$cache0;
- }
|