Files
OldThink/Content.Client/Arcade/UI/BlockGameBoundUserInterface.cs

77 lines
2.8 KiB
C#
Raw Normal View History

2021-06-09 22:19:39 +02:00
using Content.Shared.Arcade;
using Robust.Client.GameObjects;
2023-06-15 04:25:25 -07:00
namespace Content.Client.Arcade.UI;
public sealed class BlockGameBoundUserInterface : BoundUserInterface
{
2023-06-15 04:25:25 -07:00
private BlockGameMenu? _menu;
2023-07-08 09:02:17 -07:00
public BlockGameBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
2023-06-15 04:25:25 -07:00
{
}
2023-06-15 04:25:25 -07:00
protected override void Open()
{
base.Open();
2023-06-15 04:25:25 -07:00
_menu = new BlockGameMenu(this);
_menu.OnClose += Close;
_menu.OpenCentered();
}
2023-06-15 04:25:25 -07:00
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
{
switch (message)
{
2023-06-15 04:25:25 -07:00
case BlockGameMessages.BlockGameVisualUpdateMessage updateMessage:
switch (updateMessage.GameVisualType)
{
case BlockGameMessages.BlockGameVisualType.GameField:
_menu?.UpdateBlocks(updateMessage.Blocks);
break;
case BlockGameMessages.BlockGameVisualType.HoldBlock:
_menu?.UpdateHeldBlock(updateMessage.Blocks);
break;
case BlockGameMessages.BlockGameVisualType.NextBlock:
_menu?.UpdateNextBlock(updateMessage.Blocks);
break;
}
break;
case BlockGameMessages.BlockGameScoreUpdateMessage scoreUpdate:
_menu?.UpdatePoints(scoreUpdate.Points);
break;
case BlockGameMessages.BlockGameUserStatusMessage userMessage:
_menu?.SetUsability(userMessage.IsPlayer);
break;
case BlockGameMessages.BlockGameSetScreenMessage statusMessage:
if (statusMessage.IsStarted) _menu?.SetStarted();
_menu?.SetScreen(statusMessage.Screen);
if (statusMessage is BlockGameMessages.BlockGameGameOverScreenMessage gameOverScreenMessage)
_menu?.SetGameoverInfo(gameOverScreenMessage.FinalScore, gameOverScreenMessage.LocalPlacement, gameOverScreenMessage.GlobalPlacement);
break;
case BlockGameMessages.BlockGameHighScoreUpdateMessage highScoreUpdateMessage:
_menu?.UpdateHighscores(highScoreUpdateMessage.LocalHighscores,
highScoreUpdateMessage.GlobalHighscores);
break;
case BlockGameMessages.BlockGameLevelUpdateMessage levelUpdateMessage:
_menu?.UpdateLevel(levelUpdateMessage.Level);
break;
}
2023-06-15 04:25:25 -07:00
}
2023-06-15 04:25:25 -07:00
public void SendAction(BlockGamePlayerAction action)
{
SendMessage(new BlockGameMessages.BlockGamePlayerActionMessage(action));
}
2023-06-15 04:25:25 -07:00
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
2023-06-15 04:25:25 -07:00
_menu?.Dispose();
}
}