ProfileMgr.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5. using MaidStatus;
  6. using UnityEngine;
  7. public class ProfileMgr : BaseMgr<ProfileMgr>
  8. {
  9. public bool m_enabledInput { get; private set; }
  10. public bool m_enabledPersonalityInput { get; private set; }
  11. public Status m_maidStatus { get; set; }
  12. private void Start()
  13. {
  14. this.Init();
  15. }
  16. private void Init()
  17. {
  18. UIRoot componentInParent = base.GetComponentInParent<UIRoot>();
  19. this.m_goProfilePanel = componentInParent.transform.Find("ProfilePanel").gameObject;
  20. if (this.m_goProfilePanel == null)
  21. {
  22. Debug.LogError(string.Format("{0}が見つかりませんでした", "ProfilePanel"));
  23. return;
  24. }
  25. this.m_profileCtrl = this.m_goProfilePanel.GetComponent<ProfileCtrl>();
  26. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
  27. this.m_maidStatus = maid.status;
  28. this.m_enabledInput = (this.sceneEdit.modeType == SceneEdit.ModeType.OriginalChara || this.sceneEdit.modeType == SceneEdit.ModeType.MainChara);
  29. this.m_enabledPersonalityInput = (this.sceneEdit.modeType == SceneEdit.ModeType.OriginalChara);
  30. this.m_profileCtrl.Init(this.m_goProfilePanel, this.m_maidStatus);
  31. this.m_profileCtrl.SetActiveViewerAndButton(ProfileMgr.UpperButtonType.None);
  32. this.m_dicDividedPoint = this.InitDicDividedPoint();
  33. this.m_goProfilePanel.SetActive(false);
  34. this.m_bInited = true;
  35. }
  36. private Dictionary<string, int> InitDicDividedPoint()
  37. {
  38. this.m_dicDividedPoint = new Dictionary<string, int>();
  39. this.m_dicDividedPoint.Add("Lovely", 0);
  40. this.m_dicDividedPoint.Add("Elegance", 0);
  41. this.m_dicDividedPoint.Add("Charm", 0);
  42. this.m_dicDividedPoint.Add("Hentai", 0);
  43. this.m_dicDividedPoint.Add("MValue", 0);
  44. this.m_dicDividedPoint.Add("Inran", 0);
  45. this.m_dicDividedPoint.Add("Housi", 0);
  46. this.m_dicDividedPoint.Add("Cooking", 0);
  47. this.m_dicDividedPoint.Add("Dance", 0);
  48. this.m_dicDividedPoint.Add("Vocal", 0);
  49. return this.m_dicDividedPoint;
  50. }
  51. public void OpenProfilePanel()
  52. {
  53. if (BaseMgr<PresetButtonMgr>.Instance != null)
  54. {
  55. BaseMgr<PresetButtonMgr>.Instance.CloseItemPresetsViewer();
  56. }
  57. this.LoadMaidParamData();
  58. this.m_goProfilePanel.SetActive(true);
  59. }
  60. public void CloseProfilePanel()
  61. {
  62. this.m_goProfilePanel.SetActive(false);
  63. }
  64. public void ClickUpperButton()
  65. {
  66. this.MakeSubWindowData();
  67. string name = UIButton.current.name;
  68. ProfileMgr.UpperButtonType upperButtonType = (ProfileMgr.UpperButtonType)Enum.Parse(typeof(ProfileMgr.UpperButtonType), name);
  69. if (upperButtonType == ProfileMgr.currentActiveBtn)
  70. {
  71. this.m_profileCtrl.SetActiveViewerAndButton(ProfileMgr.UpperButtonType.None);
  72. return;
  73. }
  74. if (upperButtonType != ProfileMgr.UpperButtonType.Character)
  75. {
  76. if (upperButtonType != ProfileMgr.UpperButtonType.Propensity)
  77. {
  78. Debug.LogError(string.Format("不適切なボタンが押されました。 ボタン名={0}", name));
  79. }
  80. else
  81. {
  82. this.m_profileCtrl.CreatePropensityViewer(this.m_dicPropensity);
  83. }
  84. }
  85. else
  86. {
  87. this.m_profileCtrl.CreateCharacterViewer(this.m_dicCharacter);
  88. }
  89. }
  90. public void ChangeCommentTab()
  91. {
  92. string name = UIButton.current.name;
  93. if (name == this.m_currentTab.ToString())
  94. {
  95. return;
  96. }
  97. if (name == ProfileMgr.CommentTab.ProfileTab.ToString() || name == ProfileMgr.CommentTab.FreeTab.ToString())
  98. {
  99. this.m_profileCtrl.ChangeCommentTab(name);
  100. this.m_currentTab = (ProfileMgr.CommentTab)Enum.Parse(typeof(ProfileMgr.CommentTab), name);
  101. }
  102. else
  103. {
  104. Debug.LogError(string.Format("不適切なタブが選択されました。タブ名={0}", name));
  105. }
  106. }
  107. public void OnValueChangePopupList(string popupListName)
  108. {
  109. if (!this.m_bInited || string.IsNullOrEmpty(popupListName))
  110. {
  111. return;
  112. }
  113. string text = this.DelNewlineOfSentenceEnd(UIPopupList.current.value);
  114. if (popupListName == ProfileMgr.PopUpList.Personal.ToString())
  115. {
  116. if (text != this.m_currentPersonal)
  117. {
  118. this.m_profileCtrl.SetPersonal(text);
  119. this.m_currentPersonal = text;
  120. this.CloseSubWindowIfOpen();
  121. this.LoadMaidParamData();
  122. }
  123. }
  124. else if (popupListName == ProfileMgr.PopUpList.SexualExperience.ToString())
  125. {
  126. if (text != this.m_currentSexualExperience)
  127. {
  128. this.m_profileCtrl.SetSexualExperience(text);
  129. this.m_currentSexualExperience = text;
  130. this.CloseSubWindowIfOpen();
  131. this.LoadMaidParamData();
  132. }
  133. }
  134. else
  135. {
  136. Debug.LogError("不適切なポップアップリストが選択されました");
  137. }
  138. }
  139. public void OnChangeLastName()
  140. {
  141. string value = UIInput.current.value;
  142. this.m_profileCtrl.SetLastName(value);
  143. }
  144. public void OnChangeFirstName()
  145. {
  146. string value = UIInput.current.value;
  147. this.m_profileCtrl.SetFirstName(value);
  148. }
  149. public void OnChangeFreeComment()
  150. {
  151. string value = UIInput.current.value;
  152. this.m_profileCtrl.SetFreeCommnet(value);
  153. }
  154. public void CloseSubWindowIfOpen()
  155. {
  156. if (ProfileMgr.currentActiveBtn == ProfileMgr.UpperButtonType.Character || ProfileMgr.currentActiveBtn == ProfileMgr.UpperButtonType.Propensity)
  157. {
  158. this.m_profileCtrl.SetActiveViewerAndButton(ProfileMgr.UpperButtonType.None);
  159. return;
  160. }
  161. }
  162. public void LoadMaidParamData()
  163. {
  164. this.m_profileCtrl.LoadMaidParamData();
  165. }
  166. public void UpdateProfileData(bool updateYotogiSkill)
  167. {
  168. this.m_profileCtrl.UpdateProfileData(updateYotogiSkill);
  169. }
  170. private string DelNewlineOfSentenceEnd(string str)
  171. {
  172. return Regex.Replace(str, "[\\r\\n]+$", string.Empty);
  173. }
  174. private void MakeSubWindowData()
  175. {
  176. this.m_dicCharacter = new Dictionary<string, ProfileCtrl.ProfileLabelUnit>();
  177. HashSet<string> hashSet = new HashSet<string>();
  178. hashSet.Add("過去の秘密");
  179. hashSet.Add("過去の過ち");
  180. hashSet.Add("疲労");
  181. foreach (int num in this.m_maidStatus.features.GetKeyArray())
  182. {
  183. ProfileCtrl.ProfileLabelUnit profileLabelUnit = new ProfileCtrl.ProfileLabelUnit();
  184. profileLabelUnit.m_parameter = this.m_maidStatus.features.Get(num).drawName;
  185. profileLabelUnit.m_id = num.ToString();
  186. string uniqueName = this.m_maidStatus.features.Get(num).uniqueName;
  187. if (hashSet.Contains(uniqueName))
  188. {
  189. profileLabelUnit.m_id = (num * 1000).ToString();
  190. }
  191. this.m_dicCharacter.Add(profileLabelUnit.m_id, profileLabelUnit);
  192. }
  193. this.m_dicPropensity = new Dictionary<string, ProfileCtrl.ProfileLabelUnit>();
  194. foreach (int key in this.m_maidStatus.propensitys.GetKeyArray())
  195. {
  196. ProfileCtrl.ProfileLabelUnit profileLabelUnit2 = new ProfileCtrl.ProfileLabelUnit();
  197. profileLabelUnit2.m_parameter = this.m_maidStatus.propensitys.Get(key).drawName;
  198. profileLabelUnit2.m_id = key.ToString();
  199. this.m_dicPropensity.Add(profileLabelUnit2.m_id, profileLabelUnit2);
  200. }
  201. this.m_dicMaidSkill = new Dictionary<string, ProfileCtrl.ProfileLabelUnit>();
  202. this.m_dicYotogiSkill = new Dictionary<string, ProfileCtrl.ProfileYotogiSkillUnit>();
  203. }
  204. private T Random<T>()
  205. {
  206. System.Random random = new System.Random();
  207. return (from T c in Enum.GetValues(typeof(T))
  208. orderby random.Next()
  209. select c).FirstOrDefault<T>();
  210. }
  211. [SerializeField]
  212. private SceneEdit sceneEdit;
  213. public Dictionary<string, ProfileCtrl.ProfileLabelUnit> m_dicMaidSkill;
  214. public Dictionary<string, ProfileCtrl.ProfileLabelUnit> m_dicCharacter;
  215. public Dictionary<string, ProfileCtrl.ProfileYotogiSkillUnit> m_dicYotogiSkill;
  216. public Dictionary<string, ProfileCtrl.ProfileLabelUnit> m_dicPropensity;
  217. public ProfileCtrl.ProfileAttribute m_profileAttribute;
  218. public Dictionary<string, int> m_dicDividedPoint;
  219. public static ProfileMgr.UpperButtonType currentActiveBtn = ProfileMgr.UpperButtonType.None;
  220. private bool m_bInited;
  221. private GameObject m_goProfilePanel;
  222. private ProfileCtrl m_profileCtrl;
  223. private ProfileMgr.CommentTab m_currentTab;
  224. private string m_currentPersonal;
  225. private string m_currentSexualExperience;
  226. public enum CommentTab
  227. {
  228. ProfileTab,
  229. FreeTab
  230. }
  231. private enum PopUpList
  232. {
  233. None = -1,
  234. Personal,
  235. SexualExperience
  236. }
  237. public enum UpperButtonType
  238. {
  239. None = -1,
  240. MaidSkill,
  241. YotogiSkill,
  242. Character,
  243. Propensity
  244. }
  245. }