123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- 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<DataBase.BG> list = new List<DataBase.BG>();
- using (List<DataBase.Data>.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<DataBase.BG>();
- 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.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<Maid> maidList = new List<Maid>();
- private List<DataBase.BG> enabledBGList = new List<DataBase.BG>();
- }
- }
|