using System; using System.Collections.Generic; using System.IO; using UnityEngine; namespace PrivateMaidMode { public class PrivateModeMgr { public static PrivateModeMgr Instance { get { return PrivateModeMgr.m_Instance; } } public Maid PrivateMaid { get { return (this.m_privateMaid == null) ? null : this.m_privateMaid.Maid; } } public DataBase.BG SelectBG { get { return (this.m_privateMaid == null) ? null : this.m_privateMaid.BG; } } public DataBase.BG.Location SelectLocation { get { return (this.m_privateMaid == null) ? null : this.m_privateMaid.Location; } } private void CreateListData() { uGUICharacterSelectManager.PrivateMaidList(this.maidList); List list = new List(); using (List.Enumerator enumerator = DataBase.GetAllDatas(true).GetEnumerator()) { while (enumerator.MoveNext()) { DataBase.Data data = enumerator.Current; if (!list.Exists((DataBase.BG bgElm) => bgElm.uniqueName == data.bgData.uniqueName)) { list.Add(data.bgData); } } } this.enabledBGList = new List(); foreach (DataBase.BG bg in list) { if (bg.enabled) { this.enabledBGList.Add(bg); } } } public bool LoadPrivateMaid(bool isNoon) { this.CreateListData(); if (this.SelectBG == null) { return false; } if (isNoon) { this.ChangeRandom(); } if (!this.maidList.Contains(this.PrivateMaid) || (this.PrivateMaid != null && this.PrivateMaid.IsCrcBody)) { this.SetPrivateMaid(null); } if (!this.enabledBGList.Contains(this.SelectBG)) { this.SetPrivateBG(this.enabledBGList[0]); this.SetPrivateLocation(this.enabledBGList[0].locations[0]); } if (this.PrivateMaid != null) { GameMain.Instance.CharacterMgr.SetActiveMaid(this.PrivateMaid, 0); this.PrivateMaid.Visible = true; this.PrivateMaid.AllProcProp(); this.SelectBG.Apply(isNoon); this.LoadLocation(); return true; } return false; } public void ChangeRandom() { if (this.isRandomMaid) { if (this.maidList != null) { int index = UnityEngine.Random.Range(0, this.maidList.Count); this.SetPrivateMaid(this.maidList[index]); } else { this.SetPrivateMaid(null); } } if (this.isRandomBG) { int index2 = UnityEngine.Random.Range(0, this.enabledBGList.Count); this.SetPrivateBG(this.enabledBGList[index2]); } if (this.isRandomLocation && this.SelectBG.locations != null) { int num = UnityEngine.Random.Range(0, this.SelectBG.locations.Length); this.SetPrivateLocation(this.SelectBG.locations[num]); } } public void LoadLocation() { if (this.SelectLocation != null) { string currentFileName = GameMain.Instance.ScriptMgr.adv_kag.kag.GetCurrentFileName(); GameMain.Instance.ScriptMgr.is_motion_blend = false; this.SelectLocation.LoadScript(); GameMain.Instance.ScriptMgr.is_motion_blend = true; } } public void SetPrivateMaid(Maid maid) { this.m_privateMaid.SetPrivateMaid(maid); } public void SetPrivateBG(DataBase.BG bg) { this.m_privateMaid.SetPrivateBG(bg); } public void SetPrivateLocation(DataBase.BG.Location location) { this.m_privateMaid.SetPrivateLocation(location); } public void Serialize(BinaryWriter bw) { bw.Write("COM3D2_PRIVATE"); bw.Write(0); this.m_privateMaid.Serialize(bw); bw.Write(this.isRandomMaid); bw.Write(this.isRandomBG); bw.Write(this.isRandomLocation); } public void Deserialize(BinaryReader br, int save_version) { string a = br.ReadString(); NDebug.Assert(a == "COM3D2_PRIVATE", "セーブデータ\nプライベートメイドモード設定のヘッダーが正しくありません"); int num = br.ReadInt32(); this.m_privateMaid.Deserialize(br); this.isRandomMaid = br.ReadBoolean(); this.isRandomBG = br.ReadBoolean(); this.isRandomLocation = br.ReadBoolean(); } private static PrivateModeMgr m_Instance = new PrivateModeMgr(); private const string m_SaveHeader = "COM3D2_PRIVATE"; private const int SaveDataVersion = 0; private PrivateMaid m_privateMaid = new PrivateMaid(); public bool isRandomMaid; public bool isRandomBG; public bool isRandomLocation; private List maidList = new List(); private List enabledBGList = new List(); } }