12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Excel2Json;
- using Fort23.Core;
- using Fort23.UTool;
- using UnityEngine;
- using Utility;
- namespace Fort23.Mono
- {
- [UIBinding(prefab = "DivineSenceInfoPanel")]
- public partial class DivineSenceInfoPanel : UIPanel
- {
- private Action<int> callback;
- private int useCount = 0;
- private void Init()
- {
- }
- protected override void AddEvent()
- {
- }
- protected override void DelEvent()
- {
- }
- public override void AddButtonEvent()
- {
- Btn_Ok.onClick.AddListener(() =>
- {
- callback?.Invoke(useCount);
- UIManager.Instance.HideUIUIPanel(this);
- });
- Btn_Back.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
- Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
- Slider_Count.onValueChanged.AddListener((c) =>
- {
- useCount = (int)c;
- Text_Count.text = $"神识探索:{c}次";
- });
- }
- public void CustomInit(Action<int> callback)
- {
- DivineSenseConfig divineSenseConfig = ConfigComponent.Instance.Get<DivineSenseConfig>(AccountFileInfo.Instance.playerData.divineSenseLevel);
- HeroPowerUpConfig heroPowerUpConfig = PlayerManager.Instance.myHero.powerUpConfig;
- Text_Level.text = $"神识等级:{AccountFileInfo.Instance.playerData.divineSenseLevel}级";
- Text_Exp.text = $"{AccountFileInfo.Instance.playerData.divineSenseexp}/{divineSenseConfig.exp}";
- Slider_Exp.maxValue = divineSenseConfig.exp;
- Slider_Exp.value = divineSenseConfig.exp;
- int count = AccountFileInfo.Instance.playerData.divineSensePoint / PlayerManager.Instance.gameConstantConfig.DetectEventCount;
- int maxCount = heroPowerUpConfig.ShenshiMax / PlayerManager.Instance.gameConstantConfig.DetectEventCount;
- maxCount = maxCount > 10 ? 10 : maxCount;
- count = count + EventSystemManager.Instance.GetShenShiCount() > maxCount ? maxCount - EventSystemManager.Instance.GetShenShiCount() : count;
- Slider_Count.maxValue = count;
- Slider_Count.minValue = 1;
- List<float> probabilities = UtilTools.CalculateProbabilities(divineSenseConfig.QualityBonusChance.ToList());
- for (var i = 0; i < Text_qs.Count; i++)
- {
- Text_qs[i].text = $"{probabilities[i] * 100:F2}%";
- }
- // for (int i = 0; i < probabilities.Count; i++)
- // {
- // Debug.Log($"选项 {i + 1} 的概率: {probabilities[i]:F4} ({probabilities[i] * 100:F2}%)");
- // }
- this.callback = callback;
- }
- public async static CTask OpenPanel(Action<int> callback)
- {
- DivineSenceInfoPanel divineSenceInfoPanel = await UIManager.Instance.LoadAndOpenPanel<DivineSenceInfoPanel>(null, UILayer.Top);
- divineSenceInfoPanel.CustomInit(callback);
- }
- }
- }
|