DivineSenceInfoPanel.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Excel2Json;
  5. using Fort23.Core;
  6. using Fort23.UTool;
  7. using UnityEngine;
  8. using Utility;
  9. namespace Fort23.Mono
  10. {
  11. [UIBinding(prefab = "DivineSenceInfoPanel")]
  12. public partial class DivineSenceInfoPanel : UIPanel
  13. {
  14. private Action<int> callback;
  15. private int useCount = 0;
  16. private void Init()
  17. {
  18. }
  19. protected override void AddEvent()
  20. {
  21. }
  22. protected override void DelEvent()
  23. {
  24. }
  25. public override void AddButtonEvent()
  26. {
  27. Btn_Ok.onClick.AddListener(() =>
  28. {
  29. callback?.Invoke(useCount);
  30. UIManager.Instance.HideUIUIPanel(this);
  31. });
  32. Btn_Back.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
  33. Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
  34. Slider_Count.onValueChanged.AddListener((c) =>
  35. {
  36. useCount = (int)c;
  37. Text_Count.text = $"神识探索:{c}次";
  38. });
  39. }
  40. public void CustomInit(Action<int> callback)
  41. {
  42. DivineSenseConfig divineSenseConfig = ConfigComponent.Instance.Get<DivineSenseConfig>(AccountFileInfo.Instance.playerData.divineSenseLevel);
  43. HeroPowerUpConfig heroPowerUpConfig = PlayerManager.Instance.myHero.powerUpConfig;
  44. Text_Level.text = $"神识等级:{AccountFileInfo.Instance.playerData.divineSenseLevel}级";
  45. Text_Exp.text = $"{AccountFileInfo.Instance.playerData.divineSenseexp}/{divineSenseConfig.exp}";
  46. Slider_Exp.maxValue = divineSenseConfig.exp;
  47. Slider_Exp.value = divineSenseConfig.exp;
  48. int count = AccountFileInfo.Instance.playerData.divineSensePoint / PlayerManager.Instance.gameConstantConfig.DetectEventCount;
  49. int maxCount = heroPowerUpConfig.ShenshiMax / PlayerManager.Instance.gameConstantConfig.DetectEventCount;
  50. maxCount = maxCount > 10 ? 10 : maxCount;
  51. count = count + EventSystemManager.Instance.GetShenShiCount() > maxCount ? maxCount - EventSystemManager.Instance.GetShenShiCount() : count;
  52. Slider_Count.maxValue = count;
  53. Slider_Count.minValue = 1;
  54. List<float> probabilities = UtilTools.CalculateProbabilities(divineSenseConfig.QualityBonusChance.ToList());
  55. for (var i = 0; i < Text_qs.Count; i++)
  56. {
  57. Text_qs[i].text = $"{probabilities[i] * 100:F2}%";
  58. }
  59. // for (int i = 0; i < probabilities.Count; i++)
  60. // {
  61. // Debug.Log($"选项 {i + 1} 的概率: {probabilities[i]:F4} ({probabilities[i] * 100:F2}%)");
  62. // }
  63. this.callback = callback;
  64. }
  65. public async static CTask OpenPanel(Action<int> callback)
  66. {
  67. DivineSenceInfoPanel divineSenceInfoPanel = await UIManager.Instance.LoadAndOpenPanel<DivineSenceInfoPanel>(null, UILayer.Top);
  68. divineSenceInfoPanel.CustomInit(callback);
  69. }
  70. }
  71. }