ECS Arcade Machines (#16791)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -20,16 +21,16 @@ namespace Content.Client.Arcade
|
||||
{
|
||||
public sealed class BlockGameMenu : DefaultWindow
|
||||
{
|
||||
private static readonly Color OverlayBackgroundColor = new(74,74,81,180);
|
||||
private static readonly Color OverlayShadowColor = new(0,0,0,83);
|
||||
private static readonly Color OverlayBackgroundColor = new(74, 74, 81, 180);
|
||||
private static readonly Color OverlayShadowColor = new(0, 0, 0, 83);
|
||||
|
||||
private static readonly Vector2 BlockSize = new(15,15);
|
||||
private static readonly Vector2 BlockSize = new(15, 15);
|
||||
|
||||
private readonly BlockGameBoundUserInterface _owner;
|
||||
|
||||
private readonly PanelContainer _mainPanel;
|
||||
|
||||
private BoxContainer _gameRootContainer;
|
||||
private readonly BoxContainer _gameRootContainer;
|
||||
private GridContainer _gameGrid = default!;
|
||||
private GridContainer _nextBlockGrid = default!;
|
||||
private GridContainer _holdBlockGrid = default!;
|
||||
@@ -82,7 +83,7 @@ namespace Content.Client.Arcade
|
||||
_gameRootContainer.AddChild(_levelLabel);
|
||||
_gameRootContainer.AddChild(new Control
|
||||
{
|
||||
MinSize = new Vector2(1,5)
|
||||
MinSize = new Vector2(1, 5)
|
||||
});
|
||||
|
||||
_pointsLabel = new Label
|
||||
@@ -93,7 +94,7 @@ namespace Content.Client.Arcade
|
||||
_gameRootContainer.AddChild(_pointsLabel);
|
||||
_gameRootContainer.AddChild(new Control
|
||||
{
|
||||
MinSize = new Vector2(1,10)
|
||||
MinSize = new Vector2(1, 10)
|
||||
});
|
||||
|
||||
var gameBox = new BoxContainer
|
||||
@@ -103,12 +104,12 @@ namespace Content.Client.Arcade
|
||||
gameBox.AddChild(SetupHoldBox(backgroundTexture));
|
||||
gameBox.AddChild(new Control
|
||||
{
|
||||
MinSize = new Vector2(10,1)
|
||||
MinSize = new Vector2(10, 1)
|
||||
});
|
||||
gameBox.AddChild(SetupGameGrid(backgroundTexture));
|
||||
gameBox.AddChild(new Control
|
||||
{
|
||||
MinSize = new Vector2(10,1)
|
||||
MinSize = new Vector2(10, 1)
|
||||
});
|
||||
gameBox.AddChild(SetupNextBox(backgroundTexture));
|
||||
|
||||
@@ -116,7 +117,7 @@ namespace Content.Client.Arcade
|
||||
|
||||
_gameRootContainer.AddChild(new Control
|
||||
{
|
||||
MinSize = new Vector2(1,10)
|
||||
MinSize = new Vector2(1, 10)
|
||||
});
|
||||
|
||||
_pauseButton = new Button
|
||||
@@ -176,7 +177,7 @@ namespace Content.Client.Arcade
|
||||
_owner.SendAction(BlockGamePlayerAction.NewGame);
|
||||
};
|
||||
pauseMenuContainer.AddChild(_newGameButton);
|
||||
pauseMenuContainer.AddChild(new Control{MinSize = new Vector2(1,10)});
|
||||
pauseMenuContainer.AddChild(new Control { MinSize = new Vector2(1, 10) });
|
||||
|
||||
_scoreBoardButton = new Button
|
||||
{
|
||||
@@ -185,7 +186,7 @@ namespace Content.Client.Arcade
|
||||
};
|
||||
_scoreBoardButton.OnPressed += (e) => _owner.SendAction(BlockGamePlayerAction.ShowHighscores);
|
||||
pauseMenuContainer.AddChild(_scoreBoardButton);
|
||||
_unpauseButtonMargin = new Control {MinSize = new Vector2(1, 10), Visible = false};
|
||||
_unpauseButtonMargin = new Control { MinSize = new Vector2(1, 10), Visible = false };
|
||||
pauseMenuContainer.AddChild(_unpauseButtonMargin);
|
||||
|
||||
_unpauseButton = new Button
|
||||
@@ -239,13 +240,13 @@ namespace Content.Client.Arcade
|
||||
VerticalAlignment = VAlignment.Center
|
||||
};
|
||||
|
||||
gameOverMenuContainer.AddChild(new Label{Text = Loc.GetString("blockgame-menu-msg-game-over"),Align = Label.AlignMode.Center});
|
||||
gameOverMenuContainer.AddChild(new Control{MinSize = new Vector2(1,10)});
|
||||
gameOverMenuContainer.AddChild(new Label { Text = Loc.GetString("blockgame-menu-msg-game-over"), Align = Label.AlignMode.Center });
|
||||
gameOverMenuContainer.AddChild(new Control { MinSize = new Vector2(1, 10) });
|
||||
|
||||
|
||||
_finalScoreLabel = new Label{Align = Label.AlignMode.Center};
|
||||
_finalScoreLabel = new Label { Align = Label.AlignMode.Center };
|
||||
gameOverMenuContainer.AddChild(_finalScoreLabel);
|
||||
gameOverMenuContainer.AddChild(new Control{MinSize = new Vector2(1,10)});
|
||||
gameOverMenuContainer.AddChild(new Control { MinSize = new Vector2(1, 10) });
|
||||
|
||||
_finalNewGameButton = new Button
|
||||
{
|
||||
@@ -275,7 +276,7 @@ namespace Content.Client.Arcade
|
||||
HorizontalAlignment = HAlignment.Center
|
||||
};
|
||||
|
||||
var c = new Color(OverlayBackgroundColor.R,OverlayBackgroundColor.G,OverlayBackgroundColor.B,220);
|
||||
var c = new Color(OverlayBackgroundColor.R, OverlayBackgroundColor.G, OverlayBackgroundColor.B, 220);
|
||||
var innerBack = new StyleBoxTexture
|
||||
{
|
||||
Texture = backgroundTexture,
|
||||
@@ -298,8 +299,8 @@ namespace Content.Client.Arcade
|
||||
VerticalAlignment = VAlignment.Center
|
||||
};
|
||||
|
||||
menuContainer.AddChild(new Label{Text = Loc.GetString("blockgame-menu-label-highscores")});
|
||||
menuContainer.AddChild(new Control{MinSize = new Vector2(1,10)});
|
||||
menuContainer.AddChild(new Label { Text = Loc.GetString("blockgame-menu-label-highscores") });
|
||||
menuContainer.AddChild(new Control { MinSize = new Vector2(1, 10) });
|
||||
|
||||
var highScoreBox = new BoxContainer
|
||||
{
|
||||
@@ -311,14 +312,14 @@ namespace Content.Client.Arcade
|
||||
Align = Label.AlignMode.Center
|
||||
};
|
||||
highScoreBox.AddChild(_localHighscoresLabel);
|
||||
highScoreBox.AddChild(new Control{MinSize = new Vector2(40,1)});
|
||||
highScoreBox.AddChild(new Control { MinSize = new Vector2(40, 1) });
|
||||
_globalHighscoresLabel = new Label
|
||||
{
|
||||
Align = Label.AlignMode.Center
|
||||
};
|
||||
highScoreBox.AddChild(_globalHighscoresLabel);
|
||||
menuContainer.AddChild(highScoreBox);
|
||||
menuContainer.AddChild(new Control{MinSize = new Vector2(1,10)});
|
||||
menuContainer.AddChild(new Control { MinSize = new Vector2(1, 10) });
|
||||
_highscoreBackButton = new Button
|
||||
{
|
||||
Text = Loc.GetString("blockgame-menu-button-back"),
|
||||
@@ -359,7 +360,7 @@ namespace Content.Client.Arcade
|
||||
HSeparationOverride = 1,
|
||||
VSeparationOverride = 1
|
||||
};
|
||||
UpdateBlocks(new BlockGameBlock[0]);
|
||||
UpdateBlocks(Array.Empty<BlockGameBlock>());
|
||||
|
||||
var back = new StyleBoxTexture
|
||||
{
|
||||
@@ -376,7 +377,7 @@ namespace Content.Client.Arcade
|
||||
};
|
||||
var backgroundPanel = new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat{BackgroundColor = Color.FromHex("#86868d")}
|
||||
PanelOverride = new StyleBoxFlat { BackgroundColor = Color.FromHex("#86868d") }
|
||||
};
|
||||
backgroundPanel.AddChild(_gameGrid);
|
||||
gamePanel.AddChild(backgroundPanel);
|
||||
@@ -416,7 +417,7 @@ namespace Content.Client.Arcade
|
||||
nextBlockPanel.AddChild(nextCenterContainer);
|
||||
grid.AddChild(nextBlockPanel);
|
||||
|
||||
grid.AddChild(new Label{Text = Loc.GetString("blockgame-menu-label-next"), Align = Label.AlignMode.Center});
|
||||
grid.AddChild(new Label { Text = Loc.GetString("blockgame-menu-label-next"), Align = Label.AlignMode.Center });
|
||||
|
||||
return grid;
|
||||
}
|
||||
@@ -454,15 +455,17 @@ namespace Content.Client.Arcade
|
||||
holdBlockPanel.AddChild(holdCenterContainer);
|
||||
grid.AddChild(holdBlockPanel);
|
||||
|
||||
grid.AddChild(new Label{Text = Loc.GetString("blockgame-menu-label-hold"), Align = Label.AlignMode.Center});
|
||||
grid.AddChild(new Label { Text = Loc.GetString("blockgame-menu-label-hold"), Align = Label.AlignMode.Center });
|
||||
|
||||
return grid;
|
||||
}
|
||||
|
||||
protected override void KeyboardFocusExited()
|
||||
{
|
||||
if (!IsOpen) return;
|
||||
if(_gameOver) return;
|
||||
if (!IsOpen)
|
||||
return;
|
||||
if (_gameOver)
|
||||
return;
|
||||
TryPause();
|
||||
}
|
||||
|
||||
@@ -480,7 +483,8 @@ namespace Content.Client.Arcade
|
||||
|
||||
public void SetScreen(BlockGameMessages.BlockGameScreen screen)
|
||||
{
|
||||
if (_gameOver) return;
|
||||
if (_gameOver)
|
||||
return;
|
||||
|
||||
switch (screen)
|
||||
{
|
||||
@@ -512,9 +516,12 @@ namespace Content.Client.Arcade
|
||||
|
||||
private void CloseMenus()
|
||||
{
|
||||
if(_mainPanel.Children.Contains(_menuRootContainer)) _mainPanel.RemoveChild(_menuRootContainer);
|
||||
if(_mainPanel.Children.Contains(_gameOverRootContainer)) _mainPanel.RemoveChild(_gameOverRootContainer);
|
||||
if(_mainPanel.Children.Contains(_highscoresRootContainer)) _mainPanel.RemoveChild(_highscoresRootContainer);
|
||||
if (_mainPanel.Children.Contains(_menuRootContainer))
|
||||
_mainPanel.RemoveChild(_menuRootContainer);
|
||||
if (_mainPanel.Children.Contains(_gameOverRootContainer))
|
||||
_mainPanel.RemoveChild(_gameOverRootContainer);
|
||||
if (_mainPanel.Children.Contains(_highscoresRootContainer))
|
||||
_mainPanel.RemoveChild(_highscoresRootContainer);
|
||||
}
|
||||
|
||||
public void SetGameoverInfo(int amount, int? localPlacement, int? globalPlacement)
|
||||
@@ -563,72 +570,56 @@ namespace Content.Client.Arcade
|
||||
{
|
||||
base.KeyBindDown(args);
|
||||
|
||||
if(!_isPlayer || args.Handled) return;
|
||||
if (!_isPlayer || args.Handled)
|
||||
return;
|
||||
|
||||
if (args.Function == ContentKeyFunctions.ArcadeLeft)
|
||||
{
|
||||
else if (args.Function == ContentKeyFunctions.ArcadeLeft)
|
||||
_owner.SendAction(BlockGamePlayerAction.StartLeft);
|
||||
}
|
||||
else if (args.Function == ContentKeyFunctions.ArcadeRight)
|
||||
{
|
||||
_owner.SendAction(BlockGamePlayerAction.StartRight);
|
||||
}
|
||||
else if (args.Function == ContentKeyFunctions.ArcadeUp)
|
||||
{
|
||||
_owner.SendAction(BlockGamePlayerAction.Rotate);
|
||||
}
|
||||
else if (args.Function == ContentKeyFunctions.Arcade3)
|
||||
{
|
||||
_owner.SendAction(BlockGamePlayerAction.CounterRotate);
|
||||
}
|
||||
else if (args.Function == ContentKeyFunctions.ArcadeDown)
|
||||
{
|
||||
_owner.SendAction(BlockGamePlayerAction.SoftdropStart);
|
||||
}
|
||||
else if (args.Function == ContentKeyFunctions.Arcade2)
|
||||
{
|
||||
_owner.SendAction(BlockGamePlayerAction.Hold);
|
||||
}
|
||||
else if (args.Function == ContentKeyFunctions.Arcade1)
|
||||
{
|
||||
_owner.SendAction(BlockGamePlayerAction.Harddrop);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void KeyBindUp(GUIBoundKeyEventArgs args)
|
||||
{
|
||||
base.KeyBindUp(args);
|
||||
|
||||
if(!_isPlayer || args.Handled) return;
|
||||
if (!_isPlayer || args.Handled)
|
||||
return;
|
||||
|
||||
if (args.Function == ContentKeyFunctions.ArcadeLeft)
|
||||
{
|
||||
else if (args.Function == ContentKeyFunctions.ArcadeLeft)
|
||||
_owner.SendAction(BlockGamePlayerAction.EndLeft);
|
||||
}
|
||||
else if (args.Function == ContentKeyFunctions.ArcadeRight)
|
||||
{
|
||||
_owner.SendAction(BlockGamePlayerAction.EndRight);
|
||||
}else if (args.Function == ContentKeyFunctions.ArcadeDown)
|
||||
{
|
||||
else if (args.Function == ContentKeyFunctions.ArcadeDown)
|
||||
_owner.SendAction(BlockGamePlayerAction.SoftdropEnd);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateNextBlock(BlockGameBlock[] blocks)
|
||||
{
|
||||
_nextBlockGrid.RemoveAllChildren();
|
||||
if (blocks.Length == 0) return;
|
||||
if (blocks.Length == 0)
|
||||
return;
|
||||
var columnCount = blocks.Max(b => b.Position.X) + 1;
|
||||
var rowCount = blocks.Max(b => b.Position.Y) + 1;
|
||||
_nextBlockGrid.Columns = columnCount;
|
||||
for (int y = 0; y < rowCount; y++)
|
||||
for (var y = 0; y < rowCount; y++)
|
||||
{
|
||||
for (int x = 0; x < columnCount; x++)
|
||||
for (var x = 0; x < columnCount; x++)
|
||||
{
|
||||
var c = GetColorForPosition(blocks, x, y);
|
||||
_nextBlockGrid.AddChild(new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat {BackgroundColor = c},
|
||||
PanelOverride = new StyleBoxFlat { BackgroundColor = c },
|
||||
MinSize = BlockSize,
|
||||
RectDrawClipMargin = 0
|
||||
});
|
||||
@@ -639,18 +630,19 @@ namespace Content.Client.Arcade
|
||||
public void UpdateHeldBlock(BlockGameBlock[] blocks)
|
||||
{
|
||||
_holdBlockGrid.RemoveAllChildren();
|
||||
if (blocks.Length == 0) return;
|
||||
if (blocks.Length == 0)
|
||||
return;
|
||||
var columnCount = blocks.Max(b => b.Position.X) + 1;
|
||||
var rowCount = blocks.Max(b => b.Position.Y) + 1;
|
||||
_holdBlockGrid.Columns = columnCount;
|
||||
for (int y = 0; y < rowCount; y++)
|
||||
for (var y = 0; y < rowCount; y++)
|
||||
{
|
||||
for (int x = 0; x < columnCount; x++)
|
||||
for (var x = 0; x < columnCount; x++)
|
||||
{
|
||||
var c = GetColorForPosition(blocks, x, y);
|
||||
_holdBlockGrid.AddChild(new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat {BackgroundColor = c},
|
||||
PanelOverride = new StyleBoxFlat { BackgroundColor = c },
|
||||
MinSize = BlockSize,
|
||||
RectDrawClipMargin = 0
|
||||
});
|
||||
@@ -661,14 +653,14 @@ namespace Content.Client.Arcade
|
||||
public void UpdateBlocks(BlockGameBlock[] blocks)
|
||||
{
|
||||
_gameGrid.RemoveAllChildren();
|
||||
for (int y = 0; y < 20; y++)
|
||||
for (var y = 0; y < 20; y++)
|
||||
{
|
||||
for (int x = 0; x < 10; x++)
|
||||
for (var x = 0; x < 10; x++)
|
||||
{
|
||||
var c = GetColorForPosition(blocks, x, y);
|
||||
_gameGrid.AddChild(new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat {BackgroundColor = c},
|
||||
PanelOverride = new StyleBoxFlat { BackgroundColor = c },
|
||||
MinSize = BlockSize,
|
||||
RectDrawClipMargin = 0
|
||||
});
|
||||
@@ -676,9 +668,9 @@ namespace Content.Client.Arcade
|
||||
}
|
||||
}
|
||||
|
||||
private Color GetColorForPosition(BlockGameBlock[] blocks, int x, int y)
|
||||
private static Color GetColorForPosition(BlockGameBlock[] blocks, int x, int y)
|
||||
{
|
||||
Color c = Color.Transparent;
|
||||
var c = Color.Transparent;
|
||||
var matchingBlock = blocks.FirstOrNull(b => b.Position.X == x && b.Position.Y == y);
|
||||
if (matchingBlock.HasValue)
|
||||
{
|
||||
|
||||
@@ -24,40 +24,46 @@ namespace Content.Client.Arcade
|
||||
Title = Loc.GetString("spacevillain-menu-title");
|
||||
Owner = owner;
|
||||
|
||||
var grid = new GridContainer {Columns = 1};
|
||||
var grid = new GridContainer { Columns = 1 };
|
||||
|
||||
var infoGrid = new GridContainer {Columns = 3};
|
||||
infoGrid.AddChild(new Label{ Text = Loc.GetString("spacevillain-menu-label-player"), Align = Label.AlignMode.Center });
|
||||
infoGrid.AddChild(new Label{ Text = "|", Align = Label.AlignMode.Center });
|
||||
_enemyNameLabel = new Label{ Align = Label.AlignMode.Center};
|
||||
var infoGrid = new GridContainer { Columns = 3 };
|
||||
infoGrid.AddChild(new Label { Text = Loc.GetString("spacevillain-menu-label-player"), Align = Label.AlignMode.Center });
|
||||
infoGrid.AddChild(new Label { Text = "|", Align = Label.AlignMode.Center });
|
||||
_enemyNameLabel = new Label { Align = Label.AlignMode.Center };
|
||||
infoGrid.AddChild(_enemyNameLabel);
|
||||
|
||||
_playerInfoLabel = new Label {Align = Label.AlignMode.Center};
|
||||
_playerInfoLabel = new Label { Align = Label.AlignMode.Center };
|
||||
infoGrid.AddChild(_playerInfoLabel);
|
||||
infoGrid.AddChild(new Label{ Text = "|", Align = Label.AlignMode.Center });
|
||||
_enemyInfoLabel = new Label {Align = Label.AlignMode.Center};
|
||||
infoGrid.AddChild(new Label { Text = "|", Align = Label.AlignMode.Center });
|
||||
_enemyInfoLabel = new Label { Align = Label.AlignMode.Center };
|
||||
infoGrid.AddChild(_enemyInfoLabel);
|
||||
var centerContainer = new CenterContainer();
|
||||
centerContainer.AddChild(infoGrid);
|
||||
grid.AddChild(centerContainer);
|
||||
|
||||
_playerActionLabel = new Label {Align = Label.AlignMode.Center};
|
||||
_playerActionLabel = new Label { Align = Label.AlignMode.Center };
|
||||
grid.AddChild(_playerActionLabel);
|
||||
|
||||
_enemyActionLabel = new Label {Align = Label.AlignMode.Center};
|
||||
_enemyActionLabel = new Label { Align = Label.AlignMode.Center };
|
||||
grid.AddChild(_enemyActionLabel);
|
||||
|
||||
var buttonGrid = new GridContainer {Columns = 3};
|
||||
var buttonGrid = new GridContainer { Columns = 3 };
|
||||
_gameButtons[0] = new ActionButton(Owner, SharedSpaceVillainArcadeComponent.PlayerAction.Attack)
|
||||
{Text = Loc.GetString("spacevillain-menu-button-attack")};
|
||||
{
|
||||
Text = Loc.GetString("spacevillain-menu-button-attack")
|
||||
};
|
||||
buttonGrid.AddChild(_gameButtons[0]);
|
||||
|
||||
_gameButtons[1] = new ActionButton(Owner, SharedSpaceVillainArcadeComponent.PlayerAction.Heal)
|
||||
{Text = Loc.GetString("spacevillain-menu-button-heal")};
|
||||
{
|
||||
Text = Loc.GetString("spacevillain-menu-button-heal")
|
||||
};
|
||||
buttonGrid.AddChild(_gameButtons[1]);
|
||||
|
||||
_gameButtons[2] = new ActionButton(Owner, SharedSpaceVillainArcadeComponent.PlayerAction.Recharge)
|
||||
{Text = Loc.GetString("spacevillain-menu-button-recharge")};
|
||||
{
|
||||
Text = Loc.GetString("spacevillain-menu-button-recharge")
|
||||
};
|
||||
buttonGrid.AddChild(_gameButtons[2]);
|
||||
|
||||
centerContainer = new CenterContainer();
|
||||
@@ -65,7 +71,9 @@ namespace Content.Client.Arcade
|
||||
grid.AddChild(centerContainer);
|
||||
|
||||
var newGame = new ActionButton(Owner, SharedSpaceVillainArcadeComponent.PlayerAction.NewGame)
|
||||
{Text = Loc.GetString("spacevillain-menu-button-new-game")};
|
||||
{
|
||||
Text = Loc.GetString("spacevillain-menu-button-new-game")
|
||||
};
|
||||
grid.AddChild(newGame);
|
||||
|
||||
Contents.AddChild(grid);
|
||||
@@ -84,7 +92,8 @@ namespace Content.Client.Arcade
|
||||
|
||||
public void UpdateInfo(SharedSpaceVillainArcadeComponent.SpaceVillainArcadeDataUpdateMessage message)
|
||||
{
|
||||
if(message is SharedSpaceVillainArcadeComponent.SpaceVillainArcadeMetaDataUpdateMessage metaMessage) UpdateMetadata(metaMessage);
|
||||
if (message is SharedSpaceVillainArcadeComponent.SpaceVillainArcadeMetaDataUpdateMessage metaMessage)
|
||||
UpdateMetadata(metaMessage);
|
||||
|
||||
_playerInfoLabel.Text = $"HP: {message.PlayerHP} MP: {message.PlayerMP}";
|
||||
_enemyInfoLabel.Text = $"HP: {message.EnemyHP} MP: {message.EnemyMP}";
|
||||
@@ -97,7 +106,7 @@ namespace Content.Client.Arcade
|
||||
private readonly SpaceVillainArcadeBoundUserInterface _owner;
|
||||
private readonly SharedSpaceVillainArcadeComponent.PlayerAction _playerAction;
|
||||
|
||||
public ActionButton(SpaceVillainArcadeBoundUserInterface owner,SharedSpaceVillainArcadeComponent.PlayerAction playerAction)
|
||||
public ActionButton(SpaceVillainArcadeBoundUserInterface owner, SharedSpaceVillainArcadeComponent.PlayerAction playerAction)
|
||||
{
|
||||
_owner = owner;
|
||||
_playerAction = playerAction;
|
||||
|
||||
@@ -1,78 +1,76 @@
|
||||
using Content.Shared.Arcade;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Arcade.UI
|
||||
namespace Content.Client.Arcade.UI;
|
||||
|
||||
public sealed class BlockGameBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
public sealed class BlockGameBoundUserInterface : BoundUserInterface
|
||||
private BlockGameMenu? _menu;
|
||||
|
||||
public BlockGameBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
private BlockGameMenu? _menu;
|
||||
}
|
||||
|
||||
public BlockGameBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
|
||||
_menu = new BlockGameMenu(this);
|
||||
_menu.OnClose += Close;
|
||||
_menu.OpenCentered();
|
||||
}
|
||||
|
||||
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
|
||||
_menu = new BlockGameMenu(this);
|
||||
_menu.OnClose += Close;
|
||||
_menu.OpenCentered();
|
||||
}
|
||||
|
||||
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public void SendAction(BlockGamePlayerAction action)
|
||||
{
|
||||
SendMessage(new BlockGameMessages.BlockGamePlayerActionMessage(action));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing)
|
||||
return;
|
||||
|
||||
_menu?.Dispose();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public void SendAction(BlockGamePlayerAction action)
|
||||
{
|
||||
SendMessage(new BlockGameMessages.BlockGamePlayerActionMessage(action));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing)
|
||||
return;
|
||||
|
||||
_menu?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,51 +3,45 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using static Content.Shared.Arcade.SharedSpaceVillainArcadeComponent;
|
||||
|
||||
namespace Content.Client.Arcade.UI
|
||||
namespace Content.Client.Arcade.UI;
|
||||
|
||||
public sealed class SpaceVillainArcadeBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
public sealed class SpaceVillainArcadeBoundUserInterface : BoundUserInterface
|
||||
[ViewVariables] private SpaceVillainArcadeMenu? _menu;
|
||||
|
||||
//public SharedSpaceVillainArcadeComponent SpaceVillainArcade;
|
||||
|
||||
public SpaceVillainArcadeBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
[ViewVariables] private SpaceVillainArcadeMenu? _menu;
|
||||
SendAction(PlayerAction.RequestData);
|
||||
}
|
||||
|
||||
//public SharedSpaceVillainArcadeComponent SpaceVillainArcade;
|
||||
public void SendAction(PlayerAction action)
|
||||
{
|
||||
SendMessage(new SpaceVillainArcadePlayerActionMessage(action));
|
||||
}
|
||||
|
||||
public SpaceVillainArcadeBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
SendAction(PlayerAction.RequestData);
|
||||
}
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
|
||||
public void SendAction(PlayerAction action)
|
||||
{
|
||||
SendMessage(new SpaceVillainArcadePlayerActionMessage(action));
|
||||
}
|
||||
_menu = new SpaceVillainArcadeMenu(this);
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
_menu.OnClose += Close;
|
||||
_menu.OpenCentered();
|
||||
}
|
||||
|
||||
/*if(!Owner.Owner.TryGetComponent(out SharedSpaceVillainArcadeComponent spaceVillainArcade))
|
||||
{
|
||||
return;
|
||||
}
|
||||
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
|
||||
{
|
||||
if (message is SpaceVillainArcadeDataUpdateMessage msg)
|
||||
_menu?.UpdateInfo(msg);
|
||||
}
|
||||
|
||||
SpaceVillainArcade = spaceVillainArcade;*/
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
_menu = new SpaceVillainArcadeMenu(this);
|
||||
|
||||
_menu.OnClose += Close;
|
||||
_menu.OpenCentered();
|
||||
}
|
||||
|
||||
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
|
||||
{
|
||||
if (message is SpaceVillainArcadeDataUpdateMessage msg) _menu?.UpdateInfo(msg);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (disposing) _menu?.Dispose();
|
||||
}
|
||||
if (disposing)
|
||||
_menu?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user