NPCEditMain.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using System;
  2. using System.Collections.Generic;
  3. using com.workman.cm3d2.scene.dailyEtc;
  4. using UnityEngine;
  5. namespace SceneNPCEdit
  6. {
  7. public class NPCEditMain : WfScreenChildren
  8. {
  9. public override void Awake()
  10. {
  11. base.Awake();
  12. this.mainUIFade = base.root_obj.GetComponent<WfFadeBehaviour>();
  13. NDebug.AssertNull(this.mainUIFade);
  14. this.parent_grid_ = UTY.GetChildObject(base.root_obj, "ButtonParent/Tower/Grid", false).GetComponent<UIGrid>();
  15. this.button_dic_.Add("エディット", UTY.GetChildObject(this.parent_grid_.gameObject, "エディット", false).GetComponent<UIButton>());
  16. this.button_dic_.Add("リセット", UTY.GetChildObject(this.parent_grid_.gameObject, "リセット", false).GetComponent<UIButton>());
  17. this.button_dic_.Add("Cancel", UTY.GetChildObject(base.root_obj, "ButtonParent/Cancel", false).GetComponent<UIButton>());
  18. foreach (KeyValuePair<string, UIButton> keyValuePair in this.button_dic_)
  19. {
  20. EventDelegate.Add(keyValuePair.Value.onClick, new EventDelegate.Callback(this.OnClickButton));
  21. }
  22. }
  23. protected override void OnCall()
  24. {
  25. base.SetCallInFadeWaitFrame(2);
  26. GameMain.Instance.MainLight.Reset();
  27. GameMain.Instance.CharacterMgr.ResetCharaPosAll();
  28. GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
  29. GameMain.Instance.SoundMgr.VoiceStopAll();
  30. GameMain.Instance.CharacterMgr.DeactivateCharaAll();
  31. GameMain.Instance.CharacterMgr.DeactivateMaid(0);
  32. if (this.charaMgr.status.isDaytime)
  33. {
  34. GameMain.Instance.SoundMgr.PlayBGM(DailyAPI.dayBgm, 0.5f, true);
  35. GameMain.Instance.BgMgr.ChangeBg(DailyAPI.dayBg);
  36. }
  37. else
  38. {
  39. GameMain.Instance.SoundMgr.PlayBGM(DailyAPI.nightBgm, 0.5f, true);
  40. GameMain.Instance.BgMgr.ChangeBg(DailyAPI.nightBg);
  41. }
  42. this.parent_grid_.repositionNow = true;
  43. this.select_maid_ = null;
  44. for (int i = 0; i < this.charaMgr.GetStockMaidCount(); i++)
  45. {
  46. if (this.charaMgr.GetStockMaid(i).status.leader)
  47. {
  48. this.cur_maid_leader_ = this.charaMgr.GetStockMaid(i);
  49. break;
  50. }
  51. }
  52. for (int j = 0; j < this.charaMgr.GetMaidCount(); j++)
  53. {
  54. if (this.charaMgr.GetMaid(j) != null)
  55. {
  56. this.charaMgr.GetMaid(j).Visible = false;
  57. }
  58. }
  59. }
  60. public void SetScreenManager(NPCEdit maid_management, string edit_label, string new_edit_label, string transfer_label)
  61. {
  62. this.screenManager = maid_management;
  63. this.edit_label_ = edit_label;
  64. this.new_edit_label_ = new_edit_label;
  65. this.transfer_label_ = transfer_label;
  66. }
  67. private void OnSelectChara(Maid select_maid)
  68. {
  69. this.select_maid_ = select_maid;
  70. }
  71. private void OnClickButton()
  72. {
  73. if (!PluginData.IsEnabled("GP001"))
  74. {
  75. return;
  76. }
  77. string a = string.Empty;
  78. foreach (KeyValuePair<string, UIButton> keyValuePair in this.button_dic_)
  79. {
  80. if (keyValuePair.Value == UIButton.current)
  81. {
  82. a = keyValuePair.Key;
  83. break;
  84. }
  85. }
  86. if (a == "エディット" && this.npcEditCharaSelect.selectNPC != null)
  87. {
  88. if (string.IsNullOrEmpty(this.edit_label_))
  89. {
  90. return;
  91. }
  92. Maid maid = this.charaMgr.ActivateNpc(0);
  93. this.npcEditCharaSelect.selectNPC.npcData.Apply(maid, false);
  94. NPCCharaSelect.editTargetNPCData = this.npcEditCharaSelect.selectNPC;
  95. this.screenManager.move_screen.SetNextLabel(this.edit_label_);
  96. this.Finish();
  97. }
  98. if (a == "リセット" && this.npcEditCharaSelect.selectNPC != null)
  99. {
  100. SaveData.RemovePreset(this.npcEditCharaSelect.selectNPC.id);
  101. this.npcEditCharaSelect.UpdateSelectData();
  102. }
  103. else if (a == "Cancel")
  104. {
  105. this.Finish();
  106. }
  107. }
  108. protected override void OnFinish()
  109. {
  110. if ((this.screenManager.move_screen.next_label == this.edit_label_ || this.screenManager.move_screen.next_label == this.new_edit_label_ || this.screenManager.move_screen.next_label == this.transfer_label_) && this.charaMgr.GetMaid(0) != null)
  111. {
  112. this.charaMgr.GetMaid(0).Visible = true;
  113. }
  114. if (!string.IsNullOrEmpty(this.screenManager.move_screen.next_label))
  115. {
  116. this.screenManager.CallScreen("Move");
  117. }
  118. }
  119. private CharacterMgr charaMgr
  120. {
  121. get
  122. {
  123. return GameMain.Instance.CharacterMgr;
  124. }
  125. }
  126. [SerializeField]
  127. private NPCCharaSelect npcEditCharaSelect;
  128. private WfFadeBehaviour mainUIFade;
  129. private NPCEdit screenManager;
  130. private Maid cur_maid_leader_;
  131. private Maid select_maid_;
  132. private UIGrid parent_grid_;
  133. private Dictionary<string, UIButton> button_dic_ = new Dictionary<string, UIButton>();
  134. private string edit_label_;
  135. private string new_edit_label_;
  136. private string transfer_label_;
  137. }
  138. }