ProgressBarShowModle.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using UnityEngine.UIElements;
  4. namespace xy002Editor.CombatEditor
  5. {
  6. public class ProgressBarShowModle
  7. {
  8. public VisualElement root;
  9. private Dictionary<string, HeroValueReport> valueReprot = new Dictionary<string, HeroValueReport>();
  10. public CombaReportEnditorManager manager;
  11. public ProgressBarShowModle(VisualElement root, CombaReportEnditorManager manager)
  12. {
  13. this.root = root;
  14. this.manager = manager;
  15. }
  16. public void CrendHarmValue(string vname, float currValue, float maxValue)
  17. {
  18. if (valueReprot.TryGetValue(vname, out HeroValueReport heroValueReport))
  19. {
  20. heroValueReport.progressBar.title = currValue.ToString();
  21. heroValueReport.progressBar.lowValue = currValue;
  22. heroValueReport.progressBar.highValue = maxValue;
  23. }
  24. else
  25. {
  26. heroValueReport = new HeroValueReport();
  27. VisualElement herovaluegrid = manager.Copy<VisualElement>("value_data_entity_style");
  28. root.Add(herovaluegrid);
  29. Label testv = manager.Copy<Label>("valuename");
  30. testv.text = vname;
  31. testv.style.unityFontStyleAndWeight = FontStyle.Bold;
  32. testv.style.color = Color.magenta;
  33. herovaluegrid.Add(testv);
  34. ProgressBar progressBar = manager.Copy<ProgressBar>("valuebar");
  35. progressBar.title = currValue.ToString();
  36. progressBar.lowValue = currValue;
  37. progressBar.highValue = maxValue;
  38. herovaluegrid.Add(progressBar);
  39. heroValueReport.progressBar = progressBar;
  40. valueReprot.Add(vname, heroValueReport);
  41. }
  42. }
  43. }
  44. }