ProfileMgr.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. if (SceneEdit.storageModeType == SceneEdit.ModeType.OriginalChara || SceneEdit.storageModeType == SceneEdit.ModeType.MainChara || SceneEdit.storageModeType == SceneEdit.ModeType.ScoutChara)
  31. {
  32. this.m_enabledInput = true;
  33. }
  34. if (SceneEdit.storageModeType == SceneEdit.ModeType.OriginalChara || SceneEdit.storageModeType == SceneEdit.ModeType.ScoutChara)
  35. {
  36. this.m_enabledPersonalityInput = true;
  37. }
  38. this.m_profileCtrl.Init(this.m_goProfilePanel, this.m_maidStatus);
  39. this.m_profileCtrl.SetActiveViewerAndButton(ProfileMgr.UpperButtonType.None);
  40. this.m_dicDividedPoint = this.InitDicDividedPoint();
  41. if (SceneEdit.storageFlg)
  42. {
  43. this.m_dicDividedPoint = this.CRCUpdataDicDividedPoint(SceneEdit.StorageDicDividedPoint);
  44. }
  45. this.m_goProfilePanel.SetActive(false);
  46. this.m_bInited = true;
  47. }
  48. private Dictionary<string, int> CRCUpdataDicDividedPoint(Dictionary<string, int> storageDicDividedPoint)
  49. {
  50. this.m_dicDividedPoint = new Dictionary<string, int>();
  51. foreach (KeyValuePair<string, int> keyValuePair in storageDicDividedPoint)
  52. {
  53. this.m_dicDividedPoint.Add(keyValuePair.Key, keyValuePair.Value);
  54. }
  55. return this.m_dicDividedPoint;
  56. }
  57. private Dictionary<string, int> InitDicDividedPoint()
  58. {
  59. this.m_dicDividedPoint = new Dictionary<string, int>();
  60. this.m_dicDividedPoint.Add("Lovely", 0);
  61. this.m_dicDividedPoint.Add("Elegance", 0);
  62. this.m_dicDividedPoint.Add("Charm", 0);
  63. this.m_dicDividedPoint.Add("Hentai", 0);
  64. this.m_dicDividedPoint.Add("MValue", 0);
  65. this.m_dicDividedPoint.Add("Inran", 0);
  66. this.m_dicDividedPoint.Add("Housi", 0);
  67. this.m_dicDividedPoint.Add("Cooking", 0);
  68. this.m_dicDividedPoint.Add("Dance", 0);
  69. this.m_dicDividedPoint.Add("Vocal", 0);
  70. return this.m_dicDividedPoint;
  71. }
  72. public void OpenProfilePanel()
  73. {
  74. if (BaseMgr<PresetButtonMgr>.Instance != null)
  75. {
  76. BaseMgr<PresetButtonMgr>.Instance.CloseItemPresetsViewer();
  77. }
  78. this.LoadMaidParamData();
  79. this.m_goProfilePanel.SetActive(true);
  80. }
  81. public void CloseProfilePanel()
  82. {
  83. this.m_goProfilePanel.SetActive(false);
  84. }
  85. public void ClickUpperButton()
  86. {
  87. this.MakeSubWindowData();
  88. string name = UIButton.current.name;
  89. ProfileMgr.UpperButtonType upperButtonType = (ProfileMgr.UpperButtonType)Enum.Parse(typeof(ProfileMgr.UpperButtonType), name);
  90. if (upperButtonType == ProfileMgr.currentActiveBtn)
  91. {
  92. this.m_profileCtrl.SetActiveViewerAndButton(ProfileMgr.UpperButtonType.None);
  93. return;
  94. }
  95. if (upperButtonType != ProfileMgr.UpperButtonType.Character)
  96. {
  97. if (upperButtonType != ProfileMgr.UpperButtonType.Propensity)
  98. {
  99. Debug.LogError(string.Format("不適切なボタンが押されました。 ボタン名={0}", name));
  100. }
  101. else
  102. {
  103. this.m_profileCtrl.CreatePropensityViewer(this.m_dicPropensity);
  104. }
  105. }
  106. else
  107. {
  108. this.m_profileCtrl.CreateCharacterViewer(this.m_dicCharacter);
  109. }
  110. }
  111. public void ChangeCommentTab()
  112. {
  113. string name = UIButton.current.name;
  114. if (name == this.m_currentTab.ToString())
  115. {
  116. return;
  117. }
  118. if (name == ProfileMgr.CommentTab.ProfileTab.ToString() || name == ProfileMgr.CommentTab.FreeTab.ToString())
  119. {
  120. this.m_profileCtrl.ChangeCommentTab(name);
  121. this.m_currentTab = (ProfileMgr.CommentTab)Enum.Parse(typeof(ProfileMgr.CommentTab), name);
  122. }
  123. else
  124. {
  125. Debug.LogError(string.Format("不適切なタブが選択されました。タブ名={0}", name));
  126. }
  127. }
  128. public void OnValueChangePopupList(string popupListName)
  129. {
  130. if (!this.m_bInited || string.IsNullOrEmpty(popupListName))
  131. {
  132. return;
  133. }
  134. string text = this.DelNewlineOfSentenceEnd(UIPopupList.current.value);
  135. if (popupListName == ProfileMgr.PopUpList.Personal.ToString())
  136. {
  137. if (text != this.m_currentPersonal)
  138. {
  139. this.m_profileCtrl.SetPersonal(text);
  140. this.m_currentPersonal = text;
  141. this.CloseSubWindowIfOpen();
  142. this.LoadMaidParamData();
  143. }
  144. }
  145. else if (popupListName == ProfileMgr.PopUpList.SexualExperience.ToString())
  146. {
  147. if (text != this.m_currentSexualExperience)
  148. {
  149. this.m_profileCtrl.SetSexualExperience(text);
  150. this.m_currentSexualExperience = text;
  151. this.CloseSubWindowIfOpen();
  152. this.LoadMaidParamData();
  153. }
  154. }
  155. else
  156. {
  157. Debug.LogError("不適切なポップアップリストが選択されました");
  158. }
  159. }
  160. public void OnChangeLastName()
  161. {
  162. string value = UIInput.current.value;
  163. this.m_profileCtrl.SetLastName(value);
  164. }
  165. public void OnChangeFirstName()
  166. {
  167. string value = UIInput.current.value;
  168. this.m_profileCtrl.SetFirstName(value);
  169. }
  170. public void OnChangeNickName()
  171. {
  172. string value = UIInput.current.value;
  173. this.m_profileCtrl.SetNickName(value);
  174. }
  175. public void OnChangeAge()
  176. {
  177. string value = UIInput.current.value;
  178. this.m_profileCtrl.SetAge(value);
  179. }
  180. public void OnSubmitAge()
  181. {
  182. this.m_profileCtrl.SubmitAge();
  183. }
  184. public void OnChangeFreeComment()
  185. {
  186. string value = UIInput.current.value;
  187. this.m_profileCtrl.SetFreeCommnet(value);
  188. }
  189. public void CloseSubWindowIfOpen()
  190. {
  191. if (ProfileMgr.currentActiveBtn == ProfileMgr.UpperButtonType.Character || ProfileMgr.currentActiveBtn == ProfileMgr.UpperButtonType.Propensity)
  192. {
  193. this.m_profileCtrl.SetActiveViewerAndButton(ProfileMgr.UpperButtonType.None);
  194. return;
  195. }
  196. }
  197. public void LoadMaidParamData()
  198. {
  199. this.m_profileCtrl.LoadMaidParamData();
  200. }
  201. public void UpdateProfileData(bool updateYotogiSkill)
  202. {
  203. this.m_profileCtrl.UpdateProfileData(updateYotogiSkill);
  204. }
  205. private string DelNewlineOfSentenceEnd(string str)
  206. {
  207. return Regex.Replace(str, "[\\r\\n]+$", string.Empty);
  208. }
  209. private void MakeSubWindowData()
  210. {
  211. this.m_dicCharacter = new Dictionary<string, ProfileCtrl.ProfileLabelUnit>();
  212. HashSet<string> hashSet = new HashSet<string>();
  213. hashSet.Add("過去の秘密");
  214. hashSet.Add("過去の過ち");
  215. hashSet.Add("疲労");
  216. foreach (int num in this.m_maidStatus.features.GetKeyArray())
  217. {
  218. ProfileCtrl.ProfileLabelUnit profileLabelUnit = new ProfileCtrl.ProfileLabelUnit();
  219. profileLabelUnit.m_parameter = this.m_maidStatus.features.Get(num).drawName;
  220. profileLabelUnit.m_id = num.ToString();
  221. string uniqueName = this.m_maidStatus.features.Get(num).uniqueName;
  222. if (hashSet.Contains(uniqueName))
  223. {
  224. profileLabelUnit.m_id = (num * 1000).ToString();
  225. }
  226. this.m_dicCharacter.Add(profileLabelUnit.m_id, profileLabelUnit);
  227. }
  228. this.m_dicPropensity = new Dictionary<string, ProfileCtrl.ProfileLabelUnit>();
  229. foreach (int key in this.m_maidStatus.propensitys.GetKeyArray())
  230. {
  231. ProfileCtrl.ProfileLabelUnit profileLabelUnit2 = new ProfileCtrl.ProfileLabelUnit();
  232. profileLabelUnit2.m_parameter = this.m_maidStatus.propensitys.Get(key).drawName;
  233. profileLabelUnit2.m_id = key.ToString();
  234. this.m_dicPropensity.Add(profileLabelUnit2.m_id, profileLabelUnit2);
  235. }
  236. this.m_dicMaidSkill = new Dictionary<string, ProfileCtrl.ProfileLabelUnit>();
  237. this.m_dicYotogiSkill = new Dictionary<string, ProfileCtrl.ProfileYotogiSkillUnit>();
  238. }
  239. private T Random<T>()
  240. {
  241. System.Random random = new System.Random();
  242. return (from T c in Enum.GetValues(typeof(T))
  243. orderby random.Next()
  244. select c).FirstOrDefault<T>();
  245. }
  246. [SerializeField]
  247. private SceneEdit sceneEdit;
  248. public Dictionary<string, ProfileCtrl.ProfileLabelUnit> m_dicMaidSkill;
  249. public Dictionary<string, ProfileCtrl.ProfileLabelUnit> m_dicCharacter;
  250. public Dictionary<string, ProfileCtrl.ProfileYotogiSkillUnit> m_dicYotogiSkill;
  251. public Dictionary<string, ProfileCtrl.ProfileLabelUnit> m_dicPropensity;
  252. public ProfileCtrl.ProfileAttribute m_profileAttribute;
  253. public Dictionary<string, int> m_dicDividedPoint;
  254. public static ProfileMgr.UpperButtonType currentActiveBtn = ProfileMgr.UpperButtonType.None;
  255. private bool m_bInited;
  256. private GameObject m_goProfilePanel;
  257. private ProfileCtrl m_profileCtrl;
  258. private ProfileMgr.CommentTab m_currentTab;
  259. private string m_currentPersonal;
  260. private string m_currentSexualExperience;
  261. public enum CommentTab
  262. {
  263. ProfileTab,
  264. FreeTab
  265. }
  266. private enum PopUpList
  267. {
  268. None = -1,
  269. Personal,
  270. SexualExperience
  271. }
  272. public enum UpperButtonType
  273. {
  274. None = -1,
  275. MaidSkill,
  276. YotogiSkill,
  277. Character,
  278. Propensity
  279. }
  280. }