You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

StatusBarOfSurvivor.xaml.cs 4.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Shapes;
  14. using Protobuf;
  15. namespace Client
  16. {
  17. /// <summary>
  18. /// StatusBarOfSurvivor.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class StatusBarOfSurvivor : UserControl
  21. {
  22. public StatusBarOfSurvivor(Grid parent, int Row, int Column)
  23. {
  24. InitializeComponent();
  25. parent.Children.Add(this);
  26. Grid.SetColumn(this, Column);
  27. Grid.SetRow(this, Row);
  28. initialized = false;
  29. }
  30. public void SetFontSize(double fontsize)
  31. {
  32. serial.FontSize = scores.FontSize = star.FontSize = status.FontSize = prop.FontSize = fontsize;
  33. }
  34. private void SetStaticValue(MessageOfStudent obj)
  35. {
  36. switch (obj.StudentType) // 参数未设定
  37. {
  38. case StudentType._1:
  39. coolTime = 10000;
  40. serial.Text = "👥" + Convert.ToString(2) + "🧓" + Convert.ToString(obj.PlayerId) + "\nSkill:StudentType1";
  41. break;
  42. case StudentType._2:
  43. coolTime = 20000;
  44. serial.Text = "👥" + Convert.ToString(2) + "🧓" + Convert.ToString(obj.PlayerId) + "\nSkill:StudentType2";
  45. break;
  46. case StudentType._3:
  47. coolTime = 30000;
  48. serial.Text = "👥" + Convert.ToString(2) + "🧓" + Convert.ToString(obj.PlayerId) + "\nSkill:StudentType3";
  49. break;
  50. case StudentType._4:
  51. coolTime = 40000;
  52. serial.Text = "👥" + Convert.ToString(2) + "🧓" + Convert.ToString(obj.PlayerId) + "\nSkill:StudentType4";
  53. break;
  54. case StudentType.NullStudentType:
  55. coolTime = 10000;
  56. serial.Text = "👥" + Convert.ToString(2) + "🧓" + Convert.ToString(obj.PlayerId) + "\nSkill:NullStudentType";
  57. break;
  58. }
  59. initialized = true;
  60. }
  61. private void SetDynamicValue(MessageOfStudent obj)
  62. {
  63. skillprogress.Value = 100 - obj.TimeUntilSkillAvailable[0] / coolTime * 100;
  64. if (obj.State == PlayerState.Quit)
  65. {
  66. skillprogress.Value = 0;
  67. skillprogress.Background = Brushes.Gray;
  68. }
  69. else
  70. skillprogress.Background = Brushes.White;
  71. Func<MessageOfStudent, int> life =
  72. (obj) =>
  73. {
  74. if (obj.State == PlayerState.Quit || obj.State == PlayerState.Addicted)
  75. return 0;
  76. else
  77. return obj.Determination;
  78. };
  79. // star.Text = "⭐:";准备放剩余被挂次数
  80. status.Text = "🔧:" + Convert.ToString(0) + "\n🏃:" + Convert.ToString(obj.Speed) + "\n♥:" + Convert.ToString(life(obj)) + "\n🛡:" + Convert.ToString(0);
  81. scores.Text = "Scores:" +obj.Score;
  82. foreach (var icon in obj.Prop)
  83. {
  84. switch (icon)
  85. {
  86. case PropType.Ptype1:
  87. prop.Text = "🔧";
  88. break;
  89. case PropType.Ptype2:
  90. prop.Text = "🛡";
  91. break;
  92. case PropType.Ptype3:
  93. prop.Text = "♥";
  94. break;
  95. case PropType.Ptype4:
  96. prop.Text = "⛸";
  97. break;
  98. default:
  99. prop.Text = " ";
  100. break;
  101. }
  102. }
  103. }
  104. public void SetValue(MessageOfStudent obj)
  105. {
  106. if (!initialized)
  107. SetStaticValue(obj);
  108. SetDynamicValue(obj);
  109. }
  110. private int coolTime;
  111. private bool initialized;
  112. }
  113. }