1
0

BlockGameMessages.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. using Robust.Shared.Serialization;
  2. namespace Content.Shared.Arcade
  3. {
  4. public static class BlockGameMessages
  5. {
  6. [Serializable, NetSerializable]
  7. public sealed class BlockGamePlayerActionMessage : BoundUserInterfaceMessage
  8. {
  9. public readonly BlockGamePlayerAction PlayerAction;
  10. public BlockGamePlayerActionMessage(BlockGamePlayerAction playerAction)
  11. {
  12. PlayerAction = playerAction;
  13. }
  14. }
  15. [Serializable, NetSerializable]
  16. public sealed class BlockGameVisualUpdateMessage : BoundUserInterfaceMessage
  17. {
  18. public readonly BlockGameVisualType GameVisualType;
  19. public readonly BlockGameBlock[] Blocks;
  20. public BlockGameVisualUpdateMessage(BlockGameBlock[] blocks, BlockGameVisualType gameVisualType)
  21. {
  22. Blocks = blocks;
  23. GameVisualType = gameVisualType;
  24. }
  25. }
  26. public enum BlockGameVisualType
  27. {
  28. GameField,
  29. HoldBlock,
  30. NextBlock
  31. }
  32. [Serializable, NetSerializable]
  33. public sealed class BlockGameScoreUpdateMessage : BoundUserInterfaceMessage
  34. {
  35. public readonly int Points;
  36. public BlockGameScoreUpdateMessage(int points)
  37. {
  38. Points = points;
  39. }
  40. }
  41. [Serializable, NetSerializable]
  42. public sealed class BlockGameUserStatusMessage : BoundUserInterfaceMessage
  43. {
  44. public readonly bool IsPlayer;
  45. public BlockGameUserStatusMessage(bool isPlayer)
  46. {
  47. IsPlayer = isPlayer;
  48. }
  49. }
  50. [Serializable, NetSerializable, Virtual]
  51. public class BlockGameSetScreenMessage : BoundUserInterfaceMessage
  52. {
  53. public readonly BlockGameScreen Screen;
  54. public readonly bool IsStarted;
  55. public BlockGameSetScreenMessage(BlockGameScreen screen, bool isStarted = true)
  56. {
  57. Screen = screen;
  58. IsStarted = isStarted;
  59. }
  60. }
  61. [Serializable, NetSerializable]
  62. public sealed class BlockGameGameOverScreenMessage : BlockGameSetScreenMessage
  63. {
  64. public readonly int FinalScore;
  65. public readonly int? LocalPlacement;
  66. public readonly int? GlobalPlacement;
  67. public BlockGameGameOverScreenMessage(int finalScore, int? localPlacement, int? globalPlacement) : base(BlockGameScreen.Gameover)
  68. {
  69. FinalScore = finalScore;
  70. LocalPlacement = localPlacement;
  71. GlobalPlacement = globalPlacement;
  72. }
  73. }
  74. [Serializable, NetSerializable]
  75. public enum BlockGameScreen
  76. {
  77. Game,
  78. Pause,
  79. Gameover,
  80. Highscores
  81. }
  82. [Serializable, NetSerializable]
  83. public sealed class BlockGameHighScoreUpdateMessage : BoundUserInterfaceMessage
  84. {
  85. public List<HighScoreEntry> LocalHighscores;
  86. public List<HighScoreEntry> GlobalHighscores;
  87. public BlockGameHighScoreUpdateMessage(List<HighScoreEntry> localHighscores, List<HighScoreEntry> globalHighscores)
  88. {
  89. LocalHighscores = localHighscores;
  90. GlobalHighscores = globalHighscores;
  91. }
  92. }
  93. [Serializable, NetSerializable]
  94. public sealed class HighScoreEntry : IComparable
  95. {
  96. public string Name;
  97. public int Score;
  98. public HighScoreEntry(string name, int score)
  99. {
  100. Name = name;
  101. Score = score;
  102. }
  103. public int CompareTo(object? obj)
  104. {
  105. if (obj is not HighScoreEntry entry) return 0;
  106. return Score.CompareTo(entry.Score);
  107. }
  108. }
  109. [Serializable, NetSerializable]
  110. public sealed class BlockGameLevelUpdateMessage : BoundUserInterfaceMessage
  111. {
  112. public readonly int Level;
  113. public BlockGameLevelUpdateMessage(int level)
  114. {
  115. Level = level;
  116. }
  117. }
  118. }
  119. }