using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using MaidStatus; using UnityEngine; public class ProfileMgr : BaseMgr { public bool m_enabledInput { get; private set; } public bool m_enabledPersonalityInput { get; private set; } public Status m_maidStatus { get; set; } private void Start() { this.Init(); } private void Init() { UIRoot componentInParent = base.GetComponentInParent(); this.m_goProfilePanel = componentInParent.transform.Find("ProfilePanel").gameObject; if (this.m_goProfilePanel == null) { Debug.LogError(string.Format("{0}が見つかりませんでした", "ProfilePanel")); return; } this.m_profileCtrl = this.m_goProfilePanel.GetComponent(); Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0); this.m_maidStatus = maid.status; this.m_enabledInput = (this.sceneEdit.modeType == SceneEdit.ModeType.OriginalChara || this.sceneEdit.modeType == SceneEdit.ModeType.MainChara); this.m_enabledPersonalityInput = (this.sceneEdit.modeType == SceneEdit.ModeType.OriginalChara); this.m_profileCtrl.Init(this.m_goProfilePanel, this.m_maidStatus); this.m_profileCtrl.SetActiveViewerAndButton(ProfileMgr.UpperButtonType.None); this.m_dicDividedPoint = this.InitDicDividedPoint(); this.m_goProfilePanel.SetActive(false); this.m_bInited = true; } private Dictionary InitDicDividedPoint() { this.m_dicDividedPoint = new Dictionary(); this.m_dicDividedPoint.Add("Lovely", 0); this.m_dicDividedPoint.Add("Elegance", 0); this.m_dicDividedPoint.Add("Charm", 0); this.m_dicDividedPoint.Add("Hentai", 0); this.m_dicDividedPoint.Add("MValue", 0); this.m_dicDividedPoint.Add("Inran", 0); this.m_dicDividedPoint.Add("Housi", 0); this.m_dicDividedPoint.Add("Cooking", 0); this.m_dicDividedPoint.Add("Dance", 0); this.m_dicDividedPoint.Add("Vocal", 0); return this.m_dicDividedPoint; } public void OpenProfilePanel() { if (BaseMgr.Instance != null) { BaseMgr.Instance.CloseItemPresetsViewer(); } this.LoadMaidParamData(); this.m_goProfilePanel.SetActive(true); } public void CloseProfilePanel() { this.m_goProfilePanel.SetActive(false); } public void ClickUpperButton() { this.MakeSubWindowData(); string name = UIButton.current.name; ProfileMgr.UpperButtonType upperButtonType = (ProfileMgr.UpperButtonType)Enum.Parse(typeof(ProfileMgr.UpperButtonType), name); if (upperButtonType == ProfileMgr.currentActiveBtn) { this.m_profileCtrl.SetActiveViewerAndButton(ProfileMgr.UpperButtonType.None); return; } if (upperButtonType != ProfileMgr.UpperButtonType.Character) { if (upperButtonType != ProfileMgr.UpperButtonType.Propensity) { Debug.LogError(string.Format("不適切なボタンが押されました。 ボタン名={0}", name)); } else { this.m_profileCtrl.CreatePropensityViewer(this.m_dicPropensity); } } else { this.m_profileCtrl.CreateCharacterViewer(this.m_dicCharacter); } } public void ChangeCommentTab() { string name = UIButton.current.name; if (name == this.m_currentTab.ToString()) { return; } if (name == ProfileMgr.CommentTab.ProfileTab.ToString() || name == ProfileMgr.CommentTab.FreeTab.ToString()) { this.m_profileCtrl.ChangeCommentTab(name); this.m_currentTab = (ProfileMgr.CommentTab)Enum.Parse(typeof(ProfileMgr.CommentTab), name); } else { Debug.LogError(string.Format("不適切なタブが選択されました。タブ名={0}", name)); } } public void OnValueChangePopupList(string popupListName) { if (!this.m_bInited || string.IsNullOrEmpty(popupListName)) { return; } string text = this.DelNewlineOfSentenceEnd(UIPopupList.current.value); if (popupListName == ProfileMgr.PopUpList.Personal.ToString()) { if (text != this.m_currentPersonal) { this.m_profileCtrl.SetPersonal(text); this.m_currentPersonal = text; this.CloseSubWindowIfOpen(); this.LoadMaidParamData(); } } else if (popupListName == ProfileMgr.PopUpList.SexualExperience.ToString()) { if (text != this.m_currentSexualExperience) { this.m_profileCtrl.SetSexualExperience(text); this.m_currentSexualExperience = text; this.CloseSubWindowIfOpen(); this.LoadMaidParamData(); } } else { Debug.LogError("不適切なポップアップリストが選択されました"); } } public void OnChangeLastName() { string value = UIInput.current.value; this.m_profileCtrl.SetLastName(value); } public void OnChangeFirstName() { string value = UIInput.current.value; this.m_profileCtrl.SetFirstName(value); } public void OnChangeNickName() { string value = UIInput.current.value; this.m_profileCtrl.SetNickName(value); } public void OnChangeAge() { string value = UIInput.current.value; this.m_profileCtrl.SetAge(value); } public void OnSubmitAge() { this.m_profileCtrl.SubmitAge(); } public void OnChangeFreeComment() { string value = UIInput.current.value; this.m_profileCtrl.SetFreeCommnet(value); } public void CloseSubWindowIfOpen() { if (ProfileMgr.currentActiveBtn == ProfileMgr.UpperButtonType.Character || ProfileMgr.currentActiveBtn == ProfileMgr.UpperButtonType.Propensity) { this.m_profileCtrl.SetActiveViewerAndButton(ProfileMgr.UpperButtonType.None); return; } } public void LoadMaidParamData() { this.m_profileCtrl.LoadMaidParamData(); } public void UpdateProfileData(bool updateYotogiSkill) { this.m_profileCtrl.UpdateProfileData(updateYotogiSkill); } private string DelNewlineOfSentenceEnd(string str) { return Regex.Replace(str, "[\\r\\n]+$", string.Empty); } private void MakeSubWindowData() { this.m_dicCharacter = new Dictionary(); HashSet hashSet = new HashSet(); hashSet.Add("過去の秘密"); hashSet.Add("過去の過ち"); hashSet.Add("疲労"); foreach (int num in this.m_maidStatus.features.GetKeyArray()) { ProfileCtrl.ProfileLabelUnit profileLabelUnit = new ProfileCtrl.ProfileLabelUnit(); profileLabelUnit.m_parameter = this.m_maidStatus.features.Get(num).drawName; profileLabelUnit.m_id = num.ToString(); string uniqueName = this.m_maidStatus.features.Get(num).uniqueName; if (hashSet.Contains(uniqueName)) { profileLabelUnit.m_id = (num * 1000).ToString(); } this.m_dicCharacter.Add(profileLabelUnit.m_id, profileLabelUnit); } this.m_dicPropensity = new Dictionary(); foreach (int key in this.m_maidStatus.propensitys.GetKeyArray()) { ProfileCtrl.ProfileLabelUnit profileLabelUnit2 = new ProfileCtrl.ProfileLabelUnit(); profileLabelUnit2.m_parameter = this.m_maidStatus.propensitys.Get(key).drawName; profileLabelUnit2.m_id = key.ToString(); this.m_dicPropensity.Add(profileLabelUnit2.m_id, profileLabelUnit2); } this.m_dicMaidSkill = new Dictionary(); this.m_dicYotogiSkill = new Dictionary(); } private T Random() { System.Random random = new System.Random(); return (from T c in Enum.GetValues(typeof(T)) orderby random.Next() select c).FirstOrDefault(); } [SerializeField] private SceneEdit sceneEdit; public Dictionary m_dicMaidSkill; public Dictionary m_dicCharacter; public Dictionary m_dicYotogiSkill; public Dictionary m_dicPropensity; public ProfileCtrl.ProfileAttribute m_profileAttribute; public Dictionary m_dicDividedPoint; public static ProfileMgr.UpperButtonType currentActiveBtn = ProfileMgr.UpperButtonType.None; private bool m_bInited; private GameObject m_goProfilePanel; private ProfileCtrl m_profileCtrl; private ProfileMgr.CommentTab m_currentTab; private string m_currentPersonal; private string m_currentSexualExperience; public enum CommentTab { ProfileTab, FreeTab } private enum PopUpList { None = -1, Personal, SexualExperience } public enum UpperButtonType { None = -1, MaidSkill, YotogiSkill, Character, Propensity } }