BodyStatusMgr.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using System;
  2. using System.Collections.Generic;
  3. using MaidStatus;
  4. using SceneEditWindow;
  5. using UnityEngine;
  6. using wf;
  7. public class BodyStatusMgr : BaseMgr<BodyStatusMgr>
  8. {
  9. private void Start()
  10. {
  11. this.Init();
  12. }
  13. private void OnDestroy()
  14. {
  15. foreach (KeyValuePair<string, Texture2D> keyValuePair in this.texDic)
  16. {
  17. UnityEngine.Object.DestroyImmediate(keyValuePair.Value);
  18. }
  19. this.texDic.Clear();
  20. }
  21. private void Init()
  22. {
  23. this.m_goPanel = base.GetComponentInParent<UIRoot>().transform.Find("BodyStatusPanel").gameObject;
  24. this.m_BodyPanel = UTY.GetChildObject(this.m_goPanel, "Panel1", false);
  25. this.m_MotionPanel = UTY.GetChildObject(this.m_goPanel, "Panel2", false);
  26. EventDelegate.Add(UTY.GetChildObject(this.m_MotionPanel, "Close", false).GetComponent<UIButton>().onClick, new EventDelegate.Callback(this.CloseMotionPanel));
  27. EventDelegate.Add(this.CreateItemObject(UTY.GetChildObject(this.m_MotionPanel, "Grid", false), "com3d2_poseicon0001.tex").onClick, new EventDelegate.Callback(this.PlayMotionYure1));
  28. EventDelegate.Add(this.CreateItemObject(UTY.GetChildObject(this.m_MotionPanel, "Grid", false), "com3d2_poseicon0002.tex").onClick, new EventDelegate.Callback(this.PlayMotionYure2));
  29. EventDelegate.Add(this.CreateItemObject(UTY.GetChildObject(this.m_MotionPanel, "Grid", false), "cm3d2_poseicon01.tex").onClick, new EventDelegate.Callback(this.PlayMotionNormal));
  30. UTY.GetChildObject(this.m_MotionPanel, "Grid", false).GetComponent<UIGrid>().Reposition();
  31. this.m_ctrl = base.GetCtrl<BodyStatusCtrl>();
  32. this.m_ctrl.Init(this, this.m_BodyPanel);
  33. this.ClosePanel();
  34. }
  35. public void OpenPanel(bool muneYurePanel)
  36. {
  37. this.UpdateBodyStatus();
  38. this.m_goPanel.SetActive(true);
  39. this.m_BodyPanel.SetActive(true);
  40. if (muneYurePanel)
  41. {
  42. this.m_MotionPanel.SetActive(true);
  43. }
  44. }
  45. public void UpdateBodyStatus()
  46. {
  47. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
  48. BodyStatusCtrl.Status data = this.LoadData(maid);
  49. this.m_ctrl.SetData(data);
  50. }
  51. private BodyStatusCtrl.Status LoadData(Maid maid)
  52. {
  53. Status status = maid.status;
  54. status.UpdateBodyParam();
  55. return new BodyStatusCtrl.Status
  56. {
  57. height = status.body.height,
  58. weight = status.body.weight,
  59. bust = status.body.bust,
  60. cup = status.body.cup,
  61. waist = status.body.waist,
  62. hip = status.body.hip
  63. };
  64. }
  65. public void PlayMotionNormal()
  66. {
  67. WindowManager component = base.GetComponentInParent<UIRoot>().transform.Find("Window").gameObject.GetComponent<WindowManager>();
  68. PoseIconWindow component2 = component.GetWindow("ポーズ").GetComponent<PoseIconWindow>();
  69. bool visibleAutoCam = SceneEdit.Instance.viewReset.GetVisibleAutoCam();
  70. SceneEdit.Instance.viewReset.SetVisibleAutoCam(false);
  71. component2.Exec(this.normalPoseId);
  72. SceneEdit.Instance.viewReset.SetVisibleAutoCam(visibleAutoCam);
  73. }
  74. public void PlayMotionYure1()
  75. {
  76. WindowManager component = base.GetComponentInParent<UIRoot>().transform.Find("Window").gameObject.GetComponent<WindowManager>();
  77. PoseIconWindow component2 = component.GetWindow("ポーズ").GetComponent<PoseIconWindow>();
  78. bool visibleAutoCam = SceneEdit.Instance.viewReset.GetVisibleAutoCam();
  79. SceneEdit.Instance.viewReset.SetVisibleAutoCam(false);
  80. component2.Exec(this.yure1PoseId);
  81. SceneEdit.Instance.viewReset.SetVisibleAutoCam(visibleAutoCam);
  82. }
  83. public void PlayMotionYure2()
  84. {
  85. WindowManager component = base.GetComponentInParent<UIRoot>().transform.Find("Window").gameObject.GetComponent<WindowManager>();
  86. PoseIconWindow component2 = component.GetWindow("ポーズ").GetComponent<PoseIconWindow>();
  87. bool visibleAutoCam = SceneEdit.Instance.viewReset.GetVisibleAutoCam();
  88. SceneEdit.Instance.viewReset.SetVisibleAutoCam(false);
  89. component2.Exec(this.yure2PoseId);
  90. SceneEdit.Instance.viewReset.SetVisibleAutoCam(visibleAutoCam);
  91. }
  92. public void CloseBodyPanel()
  93. {
  94. this.m_BodyPanel.SetActive(false);
  95. }
  96. public void CloseMotionPanel()
  97. {
  98. this.m_MotionPanel.SetActive(false);
  99. }
  100. public void ClosePanel()
  101. {
  102. this.m_BodyPanel.SetActive(false);
  103. this.m_MotionPanel.SetActive(false);
  104. this.m_goPanel.SetActive(false);
  105. }
  106. protected UIWFTabButton CreateItemObject(GameObject parent, string iconTexName)
  107. {
  108. GameObject gameObject = Utility.CreatePrefab(parent, "SceneEdit/WindowParts/PoseIconItem", true);
  109. if (!this.texDic.ContainsKey(iconTexName))
  110. {
  111. this.texDic.Add(iconTexName, ImportCM.CreateTexture(iconTexName));
  112. }
  113. UITexture component = gameObject.GetComponent<UITexture>();
  114. component.mainTexture = this.texDic[iconTexName];
  115. return gameObject.GetComponent<UIWFTabButton>();
  116. }
  117. [SerializeField]
  118. private int normalPoseId = 100;
  119. [SerializeField]
  120. private int yure1PoseId = 1000;
  121. [SerializeField]
  122. private int yure2PoseId = 1010;
  123. private BodyStatusCtrl m_ctrl;
  124. private GameObject m_BodyPanel;
  125. private GameObject m_MotionPanel;
  126. private Dictionary<string, Texture2D> texDic = new Dictionary<string, Texture2D>();
  127. }