NPCCharaSelect.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System;
  2. using UnityEngine;
  3. using wf;
  4. namespace SceneNPCEdit
  5. {
  6. public class NPCCharaSelect : MonoBehaviour
  7. {
  8. public EditCharacterDatabase.Data selectNPC { get; private set; }
  9. private UIProgressBar scrollBar
  10. {
  11. get
  12. {
  13. return this.scrollView.verticalScrollBar;
  14. }
  15. }
  16. private void Awake()
  17. {
  18. NDebug.AssertNull(this.MaidPlateParentGrid != null);
  19. this.plateTabPanel = this.MaidPlateParentGrid.gameObject.GetComponent<UIWFTabPanel>();
  20. this.scrollView = UTY.GetChildObject(base.gameObject, "Contents", false).GetComponent<UIScrollView>();
  21. this.Create();
  22. }
  23. public void Create()
  24. {
  25. foreach (EditCharacterDatabase.Data data in EditCharacterDatabase.GetAllDatas(true))
  26. {
  27. GameObject gameObject = Utility.CreatePrefab(this.MaidPlateParentGrid.gameObject, "CharacterSelect/Prefab/MaidPlateSimple", true);
  28. gameObject.name = data.id.ToString();
  29. NPCEditPlate npceditPlate = gameObject.AddComponent<NPCEditPlate>();
  30. npceditPlate.onSelectEvent = new Action<NPCEditPlate>(this.OnSelectPlate);
  31. npceditPlate.lastName = data.npcData.lastName;
  32. npceditPlate.firstName = data.npcData.firstName;
  33. Texture2D thumbnail = (!SaveData.Contains(data.id)) ? data.GetThumbnail() : SaveData.GetPreset(data.id).texThum;
  34. npceditPlate.thumbnail = thumbnail;
  35. }
  36. this.plateTabPanel.UpdateChildren();
  37. Utility.ResetNGUI(this.MaidPlateParentGrid);
  38. Utility.ResetNGUI(this.scrollView);
  39. if (this.MaidPlateParentGrid.GetChildList().Count != 0)
  40. {
  41. if (NPCCharaSelect.editTargetNPCData != null)
  42. {
  43. for (int i = 0; i < this.MaidPlateParentGrid.transform.childCount; i++)
  44. {
  45. int num = int.Parse(this.MaidPlateParentGrid.GetChild(i).name);
  46. if (num == NPCCharaSelect.editTargetNPCData.id)
  47. {
  48. UIWFTabButton component = UTY.GetChildObject(this.MaidPlateParentGrid.GetChild(i).gameObject, "Button", false).GetComponent<UIWFTabButton>();
  49. if (component != null)
  50. {
  51. this.plateTabPanel.Select(component);
  52. }
  53. break;
  54. }
  55. }
  56. }
  57. else
  58. {
  59. UIWFTabButton component2 = UTY.GetChildObject(this.MaidPlateParentGrid.GetChild(0).gameObject, "Button", false).GetComponent<UIWFTabButton>();
  60. if (component2 != null)
  61. {
  62. this.plateTabPanel.Select(component2);
  63. }
  64. }
  65. }
  66. NPCCharaSelect.editTargetNPCData = null;
  67. }
  68. public void UpdateSelectData()
  69. {
  70. for (int i = 0; i < this.MaidPlateParentGrid.transform.childCount; i++)
  71. {
  72. int num = int.Parse(this.MaidPlateParentGrid.GetChild(i).name);
  73. if (num == this.selectNPC.id)
  74. {
  75. NPCEditPlate component = this.MaidPlateParentGrid.GetChild(i).GetComponent<NPCEditPlate>();
  76. Texture2D thumbnail = (!SaveData.Contains(num)) ? this.selectNPC.GetThumbnail() : SaveData.GetPreset(num).texThum;
  77. component.thumbnail = thumbnail;
  78. this.statusPanel.Apply(component, this.selectNPC.additionalInformationText);
  79. }
  80. }
  81. }
  82. public void OnSelectPlate(NPCEditPlate selectPlate)
  83. {
  84. this.selectNPC = EditCharacterDatabase.GetData(int.Parse(selectPlate.name));
  85. this.statusPanel.Apply(selectPlate, this.selectNPC.additionalInformationText);
  86. }
  87. public static EditCharacterDatabase.Data editTargetNPCData;
  88. [SerializeField]
  89. private UIGrid MaidPlateParentGrid;
  90. [SerializeField]
  91. private NPCEditStatus statusPanel;
  92. private UIWFTabPanel plateTabPanel;
  93. private UIScrollView scrollView;
  94. }
  95. }