TreasureChestProbabilityListItemCtrl.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using XGame.Framework.UI;
  7. namespace FL.FGUI
  8. {
  9. public class ProbabilityParam
  10. {
  11. public int quality;
  12. public int curValue;
  13. public int nextValue;
  14. public bool bMaxLv;
  15. }
  16. /// <summary>
  17. /// UI逻辑处理类
  18. /// </summary>
  19. /// <typeparam name=""></typeparam>
  20. public partial class TreasureChestProbabilityListItemCtrl : UIController<TreasureChestProbabilityListItemVM>
  21. {
  22. protected override void OnEnable(object intent)
  23. {
  24. AddUIListenres();
  25. }
  26. protected override void OnDisable()
  27. {
  28. RemoveUIListenres();
  29. }
  30. #region UI事件
  31. private void AddUIListenres()
  32. {
  33. }
  34. private void RemoveUIListenres()
  35. {
  36. }
  37. #endregion
  38. public void OnRefresh(int index, ProbabilityParam param)
  39. {
  40. VM.QualityCtrl.selectedIndex = index;
  41. VM.CurProbabilityLabel.text = GetProbability(param.curValue);
  42. VM.MaxLvCtrl.selectedIndex = param.bMaxLv ? 1 : 0;
  43. if (!param.bMaxLv)
  44. {
  45. VM.NextProbabilityLabel.text = GetProbability(param.nextValue);
  46. }
  47. }
  48. /// <summary>
  49. /// 十万分比
  50. /// </summary>
  51. /// <param name="val"></param>
  52. /// <returns></returns>
  53. private string GetProbability(int val)
  54. {
  55. return $"{(val * 0.00001f).ToString("F4")}%";
  56. }
  57. }
  58. }