PresetMgr.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PresetMgr : BaseMgr<PresetMgr>
  5. {
  6. private void Start()
  7. {
  8. this.Init();
  9. }
  10. private void Init()
  11. {
  12. UIRoot componentInParent = base.GetComponentInParent<UIRoot>();
  13. NDebug.Assert(componentInParent != null, "UI Rootがみつかりません。");
  14. this.m_goPresetPanel = componentInParent.transform.Find("PresetPanel").gameObject;
  15. if (this.m_goPresetPanel == null)
  16. {
  17. NDebug.Assert(string.Format("{0}が見つかりませんでした", "PresetPanel"), false);
  18. return;
  19. }
  20. this.m_presetCtrl = this.m_goPresetPanel.GetComponent<PresetCtrl>();
  21. NDebug.Assert(this.m_presetCtrl != null, "PresetCtrlコンポーネントがみつかりません。");
  22. GameMain instance = GameMain.Instance;
  23. NDebug.Assert(instance != null, "GameMainがありません。");
  24. Maid maid = instance.CharacterMgr.GetMaid(0);
  25. NDebug.Assert(maid != null, "メイド0が居ません。");
  26. this.m_presetCtrl.Init(this.m_goPresetPanel, maid);
  27. this.m_goPresetPanel.SetActive(false);
  28. }
  29. public void OpenPresetPanel()
  30. {
  31. this.m_presetCtrl.InitFilterButtonActive(PresetMgr.m_currentActiveFilterBtnName);
  32. PresetMgr.m_currentActiveFilterBtnName = PresetMgr.Filter.NotFilter;
  33. this.listPre = GameMain.Instance.CharacterMgr.PresetListLoad();
  34. Resources.UnloadUnusedAssets();
  35. this.m_goPresetPanel.SetActive(true);
  36. this.m_presetCtrl.CreatePresetList(this.listPre);
  37. }
  38. public void UpdatePresetList()
  39. {
  40. List<CharacterMgr.Preset> listPreset = GameMain.Instance.CharacterMgr.PresetListLoad();
  41. Resources.UnloadUnusedAssets();
  42. this.m_presetCtrl.CreatePresetList(listPreset);
  43. }
  44. public void ClosePresetPanel()
  45. {
  46. this.m_presetCtrl.InitFilterButtonActive(PresetMgr.m_currentActiveFilterBtnName);
  47. this.m_goPresetPanel.SetActive(false);
  48. Resources.UnloadUnusedAssets();
  49. }
  50. public void ClickPreset()
  51. {
  52. if (GameMain.Instance.CharacterMgr.GetMaid(0).IsBusy)
  53. {
  54. return;
  55. }
  56. string name = UIButton.current.name;
  57. if (UICamera.currentTouchID == -1)
  58. {
  59. this.currentPreset = name;
  60. this.m_presetCtrl.PresetSet();
  61. }
  62. if (UICamera.currentTouchID == -2)
  63. {
  64. this.m_presetCtrl.DeletePreset(name);
  65. }
  66. }
  67. public void ClickFilterPreset()
  68. {
  69. string name = UIButton.current.name;
  70. if (!Enum.IsDefined(typeof(PresetMgr.Filter), name))
  71. {
  72. Debug.LogError(string.Format("不適切なボタンがクリックされました。クリックされたボタン名={0}", name));
  73. return;
  74. }
  75. PresetMgr.Filter filter = (PresetMgr.Filter)Enum.Parse(typeof(PresetMgr.Filter), name);
  76. if (filter != PresetMgr.m_currentActiveFilterBtnName)
  77. {
  78. this.ClickFilterPresetByEnum(filter);
  79. }
  80. }
  81. public void ClickFilterPresetByEnum(PresetMgr.Filter clickBtnName)
  82. {
  83. this.m_presetCtrl.FilterPreset(clickBtnName, PresetMgr.m_currentActiveFilterBtnName);
  84. PresetMgr.m_currentActiveFilterBtnName = clickBtnName;
  85. }
  86. public void UpdateFilterPreset(PresetMgr.Filter btnName)
  87. {
  88. this.m_presetCtrl.FilterPreset(btnName, PresetMgr.Filter.None, false);
  89. }
  90. public float GetScrollBarValue()
  91. {
  92. return this.m_presetCtrl.GetScrollBarValue();
  93. }
  94. public void SetScrollBar(float scrollBarValue)
  95. {
  96. this.m_presetCtrl.SetScrollBar(scrollBarValue);
  97. }
  98. private GameObject m_goPresetPanel;
  99. private PresetCtrl m_presetCtrl;
  100. private const int LeftClick = -1;
  101. private const int RightClick = -2;
  102. private string currentPreset;
  103. public static PresetMgr.Filter m_currentActiveFilterBtnName = PresetMgr.Filter.None;
  104. private List<CharacterMgr.Preset> listPre;
  105. public enum Filter
  106. {
  107. None = -1,
  108. NotFilter,
  109. All,
  110. Wear,
  111. Body
  112. }
  113. }