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

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