PresetButtonMgr.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PresetButtonMgr : BaseMgr<PresetButtonMgr>
  5. {
  6. private void Start()
  7. {
  8. UIRoot componentInParent = base.GetComponentInParent<UIRoot>();
  9. this.m_goPresetButtonPanel = componentInParent.transform.Find("PresetButtonPanel").gameObject;
  10. if (this.m_goPresetButtonPanel == null)
  11. {
  12. Debug.LogError(string.Format("{0}が見つかりませんでした", "PresetButtonPanel"));
  13. return;
  14. }
  15. this.m_presetButtonCtrl = this.m_goPresetButtonPanel.GetComponent<PresetButtonCtrl>();
  16. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
  17. this.m_presetButtonCtrl.Init(this.m_goPresetButtonPanel, maid);
  18. this.m_goItemPresetsViewer = UTY.GetChildObject(this.m_goPresetButtonPanel, "ItemPresetsViewer", false);
  19. this.m_sceneEdit = GameObject.Find("__SceneEdit__").GetComponent<SceneEdit>();
  20. this.m_goProfilePanel = componentInParent.transform.Find("ProfilePanel").gameObject;
  21. this.m_goPresetButtonPanel.SetActive(true);
  22. }
  23. public void OpenPresetButtonPanel()
  24. {
  25. this.m_goPresetButtonPanel.SetActive(true);
  26. }
  27. public void ClosePresetButtonPanel()
  28. {
  29. this.m_goPresetButtonPanel.SetActive(false);
  30. }
  31. public void OnButtonClickWithType(string type)
  32. {
  33. string name = UIButton.current.name;
  34. if (type == "PresetButtons" && name == this.m_currentActivePresetBtnName)
  35. {
  36. this.CloseItemPresetsViewer();
  37. this.m_currentActivePresetBtnName = null;
  38. this.m_currentActiveItemPresetBtnName = null;
  39. }
  40. else if (type == "PresetButtons" && name != this.m_currentActivePresetBtnName)
  41. {
  42. if (name != "View" && this.IsDisplayingProfilePanel() && BaseMgr<ProfileMgr>.Instance != null)
  43. {
  44. BaseMgr<ProfileMgr>.instance.CloseProfilePanel();
  45. this.m_sceneEdit.CategoryUnSelect();
  46. this.m_sceneEdit.SetCameraOffset(SceneEdit.CAM_OFFS.CENTER);
  47. }
  48. this.m_presetButtonCtrl.CreateItemPresetsViewer("PresetButtons", name, this.m_currentActivePresetBtnName);
  49. this.m_currentActivePresetBtnName = name;
  50. this.m_currentActiveItemPresetBtnName = null;
  51. if (name == "View")
  52. {
  53. this.m_sceneEdit.ToView();
  54. Debug.Log("Call sceneEdit.ToView()");
  55. this.m_currentActivePresetBtnName = null;
  56. this.m_currentActiveItemPresetBtnName = null;
  57. }
  58. }
  59. else if (type == "ItemPresetsViewer" && name != this.m_currentActiveItemPresetBtnName)
  60. {
  61. this.InitItemPresetBtn(type, name, this.m_currentActiveItemPresetBtnName);
  62. }
  63. }
  64. private void InitItemPresetBtn(string type, string clickBtnName, string currentActiveItemPresetBtnName)
  65. {
  66. this.m_presetButtonCtrl.AdjustItemPresets(type, clickBtnName, currentActiveItemPresetBtnName);
  67. this.m_currentActiveItemPresetBtnName = clickBtnName;
  68. }
  69. public void CloseItemPresetsViewer()
  70. {
  71. this.m_presetButtonCtrl.CreateItemPresetsViewer("PresetButtons", "View", this.m_currentActivePresetBtnName);
  72. this.m_presetButtonCtrl.SetActiveBtn("View", false);
  73. this.m_currentActivePresetBtnName = null;
  74. }
  75. private bool IsDisplayingProfilePanel()
  76. {
  77. return this.m_goProfilePanel.activeSelf;
  78. }
  79. public void UpdateClothesByName(string name)
  80. {
  81. this.m_presetButtonCtrl.ClickClothesByButtonName(name);
  82. }
  83. private GameObject m_goPresetButtonPanel;
  84. private GameObject m_goItemPresetsViewer;
  85. private GameObject m_goProfilePanel;
  86. private SceneEdit m_sceneEdit;
  87. private PresetButtonCtrl m_presetButtonCtrl;
  88. private string m_currentActivePresetBtnName;
  89. private string m_currentActiveItemPresetBtnName;
  90. private Dictionary<string, PresetButtonCtrl.ItemPreset> m_dicItem;
  91. public enum ItemTypes
  92. {
  93. Pose,
  94. Clothes,
  95. PriSave,
  96. Voice,
  97. BG
  98. }
  99. }