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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. using Preparation.Utility;
  16. namespace Client
  17. {
  18. /// <summary>
  19. /// StatusBarOfSurvivor.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class StatusBarOfSurvivor : UserControl
  22. {
  23. public StatusBarOfSurvivor(Grid parent, int Row, int Column)
  24. {
  25. InitializeComponent();
  26. parent.Children.Add(this);
  27. Grid.SetColumn(this, Column);
  28. Grid.SetRow(this, Row);
  29. initialized = false;
  30. }
  31. public void SetFontSize(double fontsize)
  32. {
  33. serial.FontSize = scores.FontSize = status.FontSize = activeSkill0.FontSize = activeSkill1.FontSize = activeSkill2.FontSize = prop0.FontSize = prop1.FontSize = prop2.FontSize = fontsize;
  34. }
  35. private void SetStaticValue(MessageOfStudent obj)
  36. {
  37. switch (obj.StudentType) // coolTime参数未设定,
  38. {
  39. case StudentType.Athlete:
  40. serial.Text = "👥" + Convert.ToString(2) + "🧓" + Convert.ToString(obj.PlayerId) + "\nAthlete";
  41. break;
  42. case StudentType.Teacher:
  43. serial.Text = "👥" + Convert.ToString(2) + "🧓" + Convert.ToString(obj.PlayerId) + "\nTeacher";
  44. break;
  45. case StudentType.StraightAStudent:
  46. serial.Text = "👥" + Convert.ToString(2) + "🧓" + Convert.ToString(obj.PlayerId) + "\nStraightAStudent";
  47. break;
  48. case StudentType.Robot:
  49. serial.Text = "👥" + Convert.ToString(2) + "🧓" + Convert.ToString(obj.PlayerId) + "\nRobot";
  50. break;
  51. case StudentType.TechOtaku:
  52. serial.Text = "👥" + Convert.ToString(2) + "🧓" + Convert.ToString(obj.PlayerId) + "\nTechOtaku";
  53. break;
  54. case StudentType.NullStudentType:
  55. serial.Text = "👥" + Convert.ToString(2) + "🧓" + Convert.ToString(obj.PlayerId) + "\nNullStudentType";
  56. break;
  57. }
  58. activeSkill0.Text = "Skill0";
  59. activeSkill1.Text = "Skill1";
  60. activeSkill2.Text = "Skill2";
  61. initialized = true;
  62. }
  63. private void SetDynamicValue(MessageOfStudent obj, long i)
  64. {
  65. int life = obj.Determination, death = obj.Addiction;
  66. int perLife = (int)(100.0 * life / totalLife[i]), perDeath = (int)(100.0 * death / totalDeath[i]);
  67. switch (obj.PlayerState)
  68. {
  69. case PlayerState.Idle:
  70. status.Text = "♥: " + Convert.ToString(life) + "\nIdle, " + Convert.ToString(perLife) + "%";
  71. break;
  72. case PlayerState.Learning:
  73. status.Text = "♥: " + Convert.ToString(life) + "\nLearning, " + Convert.ToString(perLife) + "%";
  74. break;
  75. case PlayerState.Addicted:
  76. status.Text = "💀: " + Convert.ToString(death) + "\nAddicted, " + Convert.ToString(perDeath) + "%";
  77. break;
  78. case PlayerState.Graduated:
  79. status.Text = "♥" + "\nGraduated";
  80. break;
  81. case PlayerState.Quit:
  82. status.Text = "💀" + "\nQuit";
  83. break;
  84. case PlayerState.Treated:
  85. status.Text = "♥: " + Convert.ToString(life) + "\nTreated, " + Convert.ToString(perLife) + "%";
  86. break;
  87. case PlayerState.Rescued:
  88. status.Text = "💀: " + Convert.ToString(death) + "\nRescued, " + Convert.ToString(perDeath) + "%";
  89. break;
  90. case PlayerState.Stunned:
  91. status.Text = "♥: " + Convert.ToString(life) + "\nStunned, " + Convert.ToString(perLife) + "%";
  92. break;
  93. case PlayerState.Treating:
  94. status.Text = "♥: " + Convert.ToString(life) + "\nTreating, " + Convert.ToString(perLife) + "%";
  95. break;
  96. case PlayerState.Rescuing:
  97. status.Text = "♥: " + Convert.ToString(life) + "\nRescuing, " + Convert.ToString(perLife) + "%";
  98. break;
  99. case PlayerState.Swinging:
  100. status.Text = "♥: " + Convert.ToString(life) + "\nSwinging, " + Convert.ToString(perLife) + "%";
  101. break;
  102. case PlayerState.Attacking:
  103. status.Text = "♥: " + Convert.ToString(life) + "\nAttacking, " + Convert.ToString(perLife) + "%";
  104. break;
  105. case PlayerState.Locking:
  106. status.Text = "♥: " + Convert.ToString(life) + "\nLocking, " + Convert.ToString(perLife) + "%";
  107. break;
  108. case PlayerState.Rummaging:
  109. status.Text = "♥: " + Convert.ToString(life) + "\nRummaging, " + Convert.ToString(perLife) + "%";
  110. break;
  111. case PlayerState.Climbing:
  112. status.Text = "♥: " + Convert.ToString(life) + "\nClimbing, " + Convert.ToString(perLife) + "%";
  113. break;
  114. case PlayerState.OpeningAChest:
  115. status.Text = "♥: " + Convert.ToString(life) + "\nOpeningAChest, " + Convert.ToString(perLife) + "%";
  116. break;
  117. case PlayerState.UsingSpecialSkill:
  118. status.Text = "♥: " + Convert.ToString(life) + "\nUsingSpecialSkill, " + Convert.ToString(perLife) + "%";
  119. break;
  120. case PlayerState.OpeningAGate:
  121. status.Text = "♥: " + Convert.ToString(life) + "\nOpeningAGate, " + Convert.ToString(perLife) + "%";
  122. break;
  123. default:
  124. break;
  125. }
  126. scores.Text = "Scores: " + obj.Score;
  127. if (obj.TimeUntilSkillAvailable[0] >= 0)
  128. skillprogress0.Value = 100 - 100.0 * obj.TimeUntilSkillAvailable[0] / coolTime0[i];
  129. if (obj.TimeUntilSkillAvailable[1] >= 0)
  130. skillprogress1.Value = 100 - 100.0 * obj.TimeUntilSkillAvailable[1] / coolTime1[i];
  131. if (obj.TimeUntilSkillAvailable[2] >= 0)
  132. skillprogress2.Value = 100 - 100.0 * obj.TimeUntilSkillAvailable[2] / coolTime2[i];
  133. if (obj.PlayerState == PlayerState.Quit)
  134. {
  135. skillprogress0.Value = skillprogress1.Value = skillprogress2.Value = 0;
  136. skillprogress0.Background = skillprogress1.Background = skillprogress2.Background = Brushes.Gray;
  137. }
  138. else
  139. skillprogress0.Background = skillprogress1.Background = skillprogress2.Background = Brushes.White;
  140. int cnt = 0;
  141. foreach (var icon in obj.Prop)
  142. {
  143. switch (cnt)
  144. {
  145. case 0:
  146. switch (icon)
  147. {
  148. case Protobuf.PropType.Key3:
  149. prop0.Text = "🔑3";
  150. break;
  151. case Protobuf.PropType.Key5:
  152. prop0.Text = "🔑5";
  153. break;
  154. case Protobuf.PropType.Key6:
  155. prop0.Text = "🔑6";
  156. break;
  157. case Protobuf.PropType.AddSpeed:
  158. prop0.Text = "⛸";
  159. break;
  160. case Protobuf.PropType.AddLifeOrClairaudience:
  161. prop0.Text = "🏅";
  162. break;
  163. case Protobuf.PropType.AddHpOrAp:
  164. prop0.Text = "♥";
  165. break;
  166. case Protobuf.PropType.ShieldOrSpear:
  167. prop0.Text = "🛡";
  168. break;
  169. case Protobuf.PropType.RecoveryFromDizziness:
  170. prop0.Text = "🕶";
  171. break;
  172. default:
  173. prop0.Text = "";
  174. break;
  175. }
  176. cnt++;
  177. break;
  178. case 1:
  179. switch (icon)
  180. {
  181. case Protobuf.PropType.Key3:
  182. prop1.Text = "🔑3";
  183. break;
  184. case Protobuf.PropType.Key5:
  185. prop1.Text = "🔑5";
  186. break;
  187. case Protobuf.PropType.Key6:
  188. prop1.Text = "🔑6";
  189. break;
  190. case Protobuf.PropType.AddSpeed:
  191. prop1.Text = "⛸";
  192. break;
  193. case Protobuf.PropType.AddLifeOrClairaudience:
  194. prop1.Text = "🏅";
  195. break;
  196. case Protobuf.PropType.AddHpOrAp:
  197. prop1.Text = "♥";
  198. break;
  199. case Protobuf.PropType.ShieldOrSpear:
  200. prop1.Text = "🛡";
  201. break;
  202. case Protobuf.PropType.RecoveryFromDizziness:
  203. prop1.Text = "🕶";
  204. break;
  205. default:
  206. prop1.Text = "";
  207. break;
  208. }
  209. cnt++;
  210. break;
  211. case 2:
  212. switch (icon)
  213. {
  214. case Protobuf.PropType.Key3:
  215. prop2.Text = "🔑3";
  216. break;
  217. case Protobuf.PropType.Key5:
  218. prop2.Text = "🔑5";
  219. break;
  220. case Protobuf.PropType.Key6:
  221. prop2.Text = "🔑6";
  222. break;
  223. case Protobuf.PropType.AddSpeed:
  224. prop2.Text = "⛸";
  225. break;
  226. case Protobuf.PropType.AddLifeOrClairaudience:
  227. prop2.Text = "🏅";
  228. break;
  229. case Protobuf.PropType.AddHpOrAp:
  230. prop2.Text = "♥";
  231. break;
  232. case Protobuf.PropType.ShieldOrSpear:
  233. prop2.Text = "🛡";
  234. break;
  235. case Protobuf.PropType.RecoveryFromDizziness:
  236. prop2.Text = "🕶";
  237. break;
  238. default:
  239. prop2.Text = "";
  240. break;
  241. }
  242. cnt++;
  243. break;
  244. default:
  245. break;
  246. }
  247. }
  248. }
  249. public void SetValue(MessageOfStudent obj, long i)
  250. {
  251. if (!initialized)
  252. SetStaticValue(obj);
  253. SetDynamicValue(obj, i);
  254. }
  255. public void NewData(int[] life, int[] death, int[,] coolTime)
  256. {
  257. for (int i = 0; i < GameData.numOfStudent; ++i)
  258. {
  259. totalLife[i] = life[i];
  260. totalDeath[i] = death[i];
  261. coolTime0[i] = coolTime[0, i];
  262. coolTime1[i] = coolTime[1, i];
  263. coolTime2[i] = coolTime[2, i];
  264. }
  265. coolTime0[4] = coolTime[0, 4];
  266. coolTime1[4] = coolTime[1, 4];
  267. coolTime2[4] = coolTime[2, 4];
  268. }
  269. private int[] totalLife = new int[4] { 100, 100, 100, 100 }, totalDeath = new int[4] { 100, 100, 100, 100 };
  270. private int[] coolTime0 = new int[5] { 100, 100, 100, 100, 100 }, coolTime1 = new int[5] { 100, 100, 100, 100, 100 }, coolTime2 = new int[5] { 100, 100, 100, 100, 100 };
  271. private bool initialized;
  272. }
  273. }