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

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