PrivateModeMgr.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. namespace PrivateMaidMode
  6. {
  7. public class PrivateModeMgr
  8. {
  9. public static PrivateModeMgr Instance
  10. {
  11. get
  12. {
  13. return PrivateModeMgr.m_Instance;
  14. }
  15. }
  16. public Maid PrivateMaid
  17. {
  18. get
  19. {
  20. return (this.m_privateMaid == null) ? null : this.m_privateMaid.Maid;
  21. }
  22. }
  23. public DataBase.BG SelectBG
  24. {
  25. get
  26. {
  27. return (this.m_privateMaid == null) ? null : this.m_privateMaid.BG;
  28. }
  29. }
  30. public DataBase.BG.Location SelectLocation
  31. {
  32. get
  33. {
  34. return (this.m_privateMaid == null) ? null : this.m_privateMaid.Location;
  35. }
  36. }
  37. private void CreateListData()
  38. {
  39. uGUICharacterSelectManager.PrivateMaidList(this.maidList);
  40. List<DataBase.BG> list = new List<DataBase.BG>();
  41. using (List<DataBase.Data>.Enumerator enumerator = DataBase.GetAllDatas(true).GetEnumerator())
  42. {
  43. while (enumerator.MoveNext())
  44. {
  45. DataBase.Data data = enumerator.Current;
  46. if (!list.Exists((DataBase.BG bgElm) => bgElm.uniqueName == data.bgData.uniqueName))
  47. {
  48. list.Add(data.bgData);
  49. }
  50. }
  51. }
  52. this.enabledBGList = new List<DataBase.BG>();
  53. foreach (DataBase.BG bg in list)
  54. {
  55. if (bg.enabled)
  56. {
  57. this.enabledBGList.Add(bg);
  58. }
  59. }
  60. }
  61. public bool LoadPrivateMaid(bool isNoon)
  62. {
  63. this.CreateListData();
  64. if (this.SelectBG == null)
  65. {
  66. return false;
  67. }
  68. if (isNoon)
  69. {
  70. this.ChangeRandom();
  71. }
  72. if (!this.maidList.Contains(this.PrivateMaid))
  73. {
  74. this.SetPrivateMaid(null);
  75. }
  76. if (!this.enabledBGList.Contains(this.SelectBG))
  77. {
  78. this.SetPrivateBG(this.enabledBGList[0]);
  79. this.SetPrivateLocation(this.enabledBGList[0].locations[0]);
  80. }
  81. if (this.PrivateMaid != null)
  82. {
  83. GameMain.Instance.CharacterMgr.SetActiveMaid(this.PrivateMaid, 0);
  84. this.PrivateMaid.Visible = true;
  85. this.PrivateMaid.AllProcProp();
  86. this.SelectBG.Apply(isNoon);
  87. this.LoadLocation();
  88. return true;
  89. }
  90. return false;
  91. }
  92. public void ChangeRandom()
  93. {
  94. if (this.isRandomMaid)
  95. {
  96. if (this.maidList != null)
  97. {
  98. int index = UnityEngine.Random.Range(0, this.maidList.Count);
  99. this.SetPrivateMaid(this.maidList[index]);
  100. }
  101. else
  102. {
  103. this.SetPrivateMaid(null);
  104. }
  105. }
  106. if (this.isRandomBG)
  107. {
  108. int index2 = UnityEngine.Random.Range(0, this.enabledBGList.Count);
  109. this.SetPrivateBG(this.enabledBGList[index2]);
  110. }
  111. if (this.isRandomLocation && this.SelectBG.locations != null)
  112. {
  113. int num = UnityEngine.Random.Range(0, this.SelectBG.locations.Length);
  114. this.SetPrivateLocation(this.SelectBG.locations[num]);
  115. }
  116. }
  117. public void LoadLocation()
  118. {
  119. if (this.SelectLocation != null)
  120. {
  121. string currentFileName = GameMain.Instance.ScriptMgr.adv_kag.kag.GetCurrentFileName();
  122. GameMain.Instance.ScriptMgr.is_motion_blend = false;
  123. this.SelectLocation.LoadScript();
  124. GameMain.Instance.ScriptMgr.is_motion_blend = true;
  125. }
  126. }
  127. public void SetPrivateMaid(Maid maid)
  128. {
  129. this.m_privateMaid.SetPrivateMaid(maid);
  130. }
  131. public void SetPrivateBG(DataBase.BG bg)
  132. {
  133. this.m_privateMaid.SetPrivateBG(bg);
  134. }
  135. public void SetPrivateLocation(DataBase.BG.Location location)
  136. {
  137. this.m_privateMaid.SetPrivateLocation(location);
  138. }
  139. public void Serialize(BinaryWriter bw)
  140. {
  141. bw.Write("COM3D2_PRIVATE");
  142. bw.Write(0);
  143. this.m_privateMaid.Serialize(bw);
  144. bw.Write(this.isRandomMaid);
  145. bw.Write(this.isRandomBG);
  146. bw.Write(this.isRandomLocation);
  147. }
  148. public void Deserialize(BinaryReader br, int save_version)
  149. {
  150. string a = br.ReadString();
  151. NDebug.Assert(a == "COM3D2_PRIVATE", "セーブデータ\nプライベートメイドモード設定のヘッダーが正しくありません");
  152. int num = br.ReadInt32();
  153. this.m_privateMaid.Deserialize(br);
  154. this.isRandomMaid = br.ReadBoolean();
  155. this.isRandomBG = br.ReadBoolean();
  156. this.isRandomLocation = br.ReadBoolean();
  157. }
  158. private static PrivateModeMgr m_Instance = new PrivateModeMgr();
  159. private const string m_SaveHeader = "COM3D2_PRIVATE";
  160. private const int SaveDataVersion = 0;
  161. private PrivateMaid m_privateMaid = new PrivateMaid();
  162. public bool isRandomMaid;
  163. public bool isRandomBG;
  164. public bool isRandomLocation;
  165. private List<Maid> maidList = new List<Maid>();
  166. private List<DataBase.BG> enabledBGList = new List<DataBase.BG>();
  167. }
  168. }