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 8.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 = status.FontSize = activeSkill0.FontSize = activeSkill1.FontSize = activeSkill2.FontSize = prop0.FontSize = prop1.FontSize = prop2.FontSize = prop3.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) + "\n职业:StudentType1";
  41. break;
  42. case StudentType._2:
  43. coolTime = 20000;
  44. serial.Text = "👥" + Convert.ToString(2) + "🧓" + Convert.ToString(obj.PlayerId) + "\n职业:StudentType2";
  45. break;
  46. case StudentType._3:
  47. coolTime = 30000;
  48. serial.Text = "👥" + Convert.ToString(2) + "🧓" + Convert.ToString(obj.PlayerId) + "\n职业:StudentType3";
  49. break;
  50. case StudentType._4:
  51. coolTime = 40000;
  52. serial.Text = "👥" + Convert.ToString(2) + "🧓" + Convert.ToString(obj.PlayerId) + "\n职业:StudentType4";
  53. break;
  54. case StudentType.NullStudentType:
  55. coolTime = 10000;
  56. serial.Text = "👥" + Convert.ToString(2) + "🧓" + Convert.ToString(obj.PlayerId) + "\n职业:NullStudentType";
  57. break;
  58. }
  59. initialized = true;
  60. }
  61. private void SetDynamicValue(MessageOfStudent obj)
  62. {
  63. int life;
  64. switch(obj.PlayerState)
  65. {
  66. case PlayerState.Idle:
  67. life = obj.Determination;
  68. status.Text = "♥:" + Convert.ToString(life);
  69. break;
  70. case PlayerState.Addicted:
  71. life = obj.Addiction;
  72. status.Text = "💀:" + Convert.ToString(life);
  73. break;
  74. case PlayerState.Graduated:
  75. status.Text = "Graduated";
  76. break;
  77. case PlayerState.Quit:
  78. status.Text = "Quit";
  79. break;
  80. default:
  81. break;
  82. }//不完全
  83. scores.Text = "Scores:" + obj.Score;
  84. skillprogress0.Value = 100 - obj.TimeUntilSkillAvailable[0] / coolTime * 100;
  85. skillprogress1.Value = 100 - obj.TimeUntilSkillAvailable[1] / coolTime * 100;
  86. skillprogress2.Value = 100 - obj.TimeUntilSkillAvailable[2] / coolTime * 100;
  87. if (obj.State == PlayerState.Quit)
  88. {
  89. skillprogress0.Value = skillprogress1.Value = skillprogress2.Value = 0;
  90. skillprogress0.Background = skillprogress1.Background= skillprogress2.Background=Brushes.Gray;
  91. }
  92. else
  93. skillprogress0.Background = skillprogress1.Background= skillprogress2.Background=Brushes.White;
  94. int cnt = 0;
  95. foreach (var icon in obj.Prop)
  96. {
  97. switch(cnt)
  98. {
  99. case 0:
  100. switch (icon)
  101. {
  102. case PropType.Ptype1:
  103. prop0.Text = "🔧";
  104. break;
  105. case PropType.Ptype2:
  106. prop0.Text = "🛡";
  107. break;
  108. case PropType.Ptype3:
  109. prop0.Text = "♥";
  110. break;
  111. case PropType.Ptype4:
  112. prop0.Text = "⛸";
  113. break;
  114. default:
  115. prop0.Text = " ";
  116. break;
  117. }
  118. cnt++;
  119. break;
  120. case 1:
  121. switch (icon)
  122. {
  123. case PropType.Ptype1:
  124. prop1.Text = "🔧";
  125. break;
  126. case PropType.Ptype2:
  127. prop1.Text = "🛡";
  128. break;
  129. case PropType.Ptype3:
  130. prop1.Text = "♥";
  131. break;
  132. case PropType.Ptype4:
  133. prop1.Text = "⛸";
  134. break;
  135. default:
  136. prop1.Text = " ";
  137. break;
  138. }
  139. cnt++;
  140. break;
  141. case 2:
  142. switch (icon)
  143. {
  144. case PropType.Ptype1:
  145. prop2.Text = "🔧";
  146. break;
  147. case PropType.Ptype2:
  148. prop2.Text = "🛡";
  149. break;
  150. case PropType.Ptype3:
  151. prop2.Text = "♥";
  152. break;
  153. case PropType.Ptype4:
  154. prop2.Text = "⛸";
  155. break;
  156. default:
  157. prop2.Text = " ";
  158. break;
  159. }
  160. cnt++;
  161. break;
  162. case 3:
  163. switch (icon)
  164. {
  165. case PropType.Ptype1:
  166. prop3.Text = "🔧";
  167. break;
  168. case PropType.Ptype2:
  169. prop3.Text = "🛡";
  170. break;
  171. case PropType.Ptype3:
  172. prop3.Text = "♥";
  173. break;
  174. case PropType.Ptype4:
  175. prop3.Text = "⛸";
  176. break;
  177. default:
  178. prop3.Text = " ";
  179. break;
  180. }
  181. cnt++;
  182. break;
  183. default:
  184. break;
  185. }
  186. }
  187. }
  188. public void SetValue(MessageOfStudent obj)
  189. {
  190. if (!initialized)
  191. SetStaticValue(obj);
  192. SetDynamicValue(obj);
  193. }
  194. private int coolTime;
  195. private bool initialized;
  196. }
  197. }