refactor: removed noise from class names
This commit is contained in:
34
Shared/Behaviours/ScoreLabel.cs
Normal file
34
Shared/Behaviours/ScoreLabel.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
using Syntriax.Engine.Core;
|
||||
using Syntriax.Engine.Integration.MonoGame;
|
||||
|
||||
namespace Pong.Behaviours;
|
||||
|
||||
public class ScoreLabel(bool IsLeft) : Label, IFirstFrameUpdate
|
||||
{
|
||||
public readonly bool IsLeft = IsLeft;
|
||||
|
||||
private PongManager pongManager = null!;
|
||||
|
||||
public void FirstActiveFrame()
|
||||
{
|
||||
MonoGameWindow monoGameWindow = Universe.FindRequiredBehaviour<MonoGameWindowContainer>().Window;
|
||||
Font = monoGameWindow.Content.Load<SpriteFont>("UbuntuMono");
|
||||
|
||||
pongManager = Universe.FindRequiredBehaviour<PongManager>();
|
||||
|
||||
pongManager.OnScoreUpdated += UpdateScores;
|
||||
pongManager.OnReset += UpdateScores;
|
||||
|
||||
UpdateScores(pongManager);
|
||||
}
|
||||
|
||||
private void UpdateScores(PongManager pongManager)
|
||||
{
|
||||
if (IsLeft)
|
||||
Text = pongManager.ScoreLeft.ToString();
|
||||
else
|
||||
Text = pongManager.ScoreRight.ToString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user