refactor: Text Behaviour Font Constructor

This commit is contained in:
2024-01-30 20:56:43 +03:00
parent 80ee5d760a
commit bc7925dbab
3 changed files with 13 additions and 8 deletions

View File

@@ -1,13 +1,17 @@
using Microsoft.Xna.Framework.Graphics;
using Syntriax.Engine.Core;
namespace Pong.Behaviours;
public class PongTextBehaviour(bool IsLeft) : TextBehaviour
public class PongTextBehaviour : TextBehaviour
{
public bool IsLeft { get; } = IsLeft;
public bool IsLeft { get; }
private PongManager? pongManager = null;
public PongTextBehaviour(bool IsLeft) => this.IsLeft = IsLeft;
public PongTextBehaviour(bool IsLeft, SpriteFont font) : base(font) => this.IsLeft = IsLeft;
protected override void OnFirstActiveFrame()
{
if (!GameObject.GameManager.TryFindBehaviour(out pongManager))
@@ -15,6 +19,8 @@ public class PongTextBehaviour(bool IsLeft) : TextBehaviour
pongManager.OnScored += UpdateScores;
pongManager.OnReset += UpdateScores;
UpdateScores(pongManager);
}
private void UpdateScores(PongManager pongManager)

View File

@@ -8,6 +8,9 @@ namespace Pong.Behaviours;
public class TextBehaviour : BehaviourOverride, IDisplayable
{
public TextBehaviour() { }
public TextBehaviour(SpriteFont font) => Font = font;
public SpriteFont? Font { get; set; } = null;
public int Size { get; set; } = 16;
public string Text { get; set; } = string.Empty;