ProfileMgr.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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 || this.sceneEdit.modeType == SceneEdit.ModeType.ScoutChara);
  29. this.m_enabledPersonalityInput = (this.sceneEdit.modeType == SceneEdit.ModeType.OriginalChara || this.sceneEdit.modeType == SceneEdit.ModeType.ScoutChara);
  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 OnChangeNickName()
  150. {
  151. string value = UIInput.current.value;
  152. this.m_profileCtrl.SetNickName(value);
  153. }
  154. public void OnChangeAge()
  155. {
  156. string value = UIInput.current.value;
  157. this.m_profileCtrl.SetAge(value);
  158. }
  159. public void OnSubmitAge()
  160. {
  161. this.m_profileCtrl.SubmitAge();
  162. }
  163. public void OnChangeFreeComment()
  164. {
  165. string value = UIInput.current.value;
  166. this.m_profileCtrl.SetFreeCommnet(value);
  167. }
  168. public void CloseSubWindowIfOpen()
  169. {
  170. if (ProfileMgr.currentActiveBtn == ProfileMgr.UpperButtonType.Character || ProfileMgr.currentActiveBtn == ProfileMgr.UpperButtonType.Propensity)
  171. {
  172. this.m_profileCtrl.SetActiveViewerAndButton(ProfileMgr.UpperButtonType.None);
  173. return;
  174. }
  175. }
  176. public void LoadMaidParamData()
  177. {
  178. this.m_profileCtrl.LoadMaidParamData();
  179. }
  180. public void UpdateProfileData(bool updateYotogiSkill)
  181. {
  182. this.m_profileCtrl.UpdateProfileData(updateYotogiSkill);
  183. }
  184. private string DelNewlineOfSentenceEnd(string str)
  185. {
  186. return Regex.Replace(str, "[\\r\\n]+$", string.Empty);
  187. }
  188. private void MakeSubWindowData()
  189. {
  190. this.m_dicCharacter = new Dictionary<string, ProfileCtrl.ProfileLabelUnit>();
  191. HashSet<string> hashSet = new HashSet<string>();
  192. hashSet.Add("過去の秘密");
  193. hashSet.Add("過去の過ち");
  194. hashSet.Add("疲労");
  195. foreach (int num in this.m_maidStatus.features.GetKeyArray())
  196. {
  197. ProfileCtrl.ProfileLabelUnit profileLabelUnit = new ProfileCtrl.ProfileLabelUnit();
  198. profileLabelUnit.m_parameter = this.m_maidStatus.features.Get(num).drawName;
  199. profileLabelUnit.m_id = num.ToString();
  200. string uniqueName = this.m_maidStatus.features.Get(num).uniqueName;
  201. if (hashSet.Contains(uniqueName))
  202. {
  203. profileLabelUnit.m_id = (num * 1000).ToString();
  204. }
  205. this.m_dicCharacter.Add(profileLabelUnit.m_id, profileLabelUnit);
  206. }
  207. this.m_dicPropensity = new Dictionary<string, ProfileCtrl.ProfileLabelUnit>();
  208. foreach (int key in this.m_maidStatus.propensitys.GetKeyArray())
  209. {
  210. ProfileCtrl.ProfileLabelUnit profileLabelUnit2 = new ProfileCtrl.ProfileLabelUnit();
  211. profileLabelUnit2.m_parameter = this.m_maidStatus.propensitys.Get(key).drawName;
  212. profileLabelUnit2.m_id = key.ToString();
  213. this.m_dicPropensity.Add(profileLabelUnit2.m_id, profileLabelUnit2);
  214. }
  215. this.m_dicMaidSkill = new Dictionary<string, ProfileCtrl.ProfileLabelUnit>();
  216. this.m_dicYotogiSkill = new Dictionary<string, ProfileCtrl.ProfileYotogiSkillUnit>();
  217. }
  218. private T Random<T>()
  219. {
  220. System.Random random = new System.Random();
  221. return (from T c in Enum.GetValues(typeof(T))
  222. orderby random.Next()
  223. select c).FirstOrDefault<T>();
  224. }
  225. [SerializeField]
  226. private SceneEdit sceneEdit;
  227. public Dictionary<string, ProfileCtrl.ProfileLabelUnit> m_dicMaidSkill;
  228. public Dictionary<string, ProfileCtrl.ProfileLabelUnit> m_dicCharacter;
  229. public Dictionary<string, ProfileCtrl.ProfileYotogiSkillUnit> m_dicYotogiSkill;
  230. public Dictionary<string, ProfileCtrl.ProfileLabelUnit> m_dicPropensity;
  231. public ProfileCtrl.ProfileAttribute m_profileAttribute;
  232. public Dictionary<string, int> m_dicDividedPoint;
  233. public static ProfileMgr.UpperButtonType currentActiveBtn = ProfileMgr.UpperButtonType.None;
  234. private bool m_bInited;
  235. private GameObject m_goProfilePanel;
  236. private ProfileCtrl m_profileCtrl;
  237. private ProfileMgr.CommentTab m_currentTab;
  238. private string m_currentPersonal;
  239. private string m_currentSexualExperience;
  240. public enum CommentTab
  241. {
  242. ProfileTab,
  243. FreeTab
  244. }
  245. private enum PopUpList
  246. {
  247. None = -1,
  248. Personal,
  249. SexualExperience
  250. }
  251. public enum UpperButtonType
  252. {
  253. None = -1,
  254. MaidSkill,
  255. YotogiSkill,
  256. Character,
  257. Propensity
  258. }
  259. }