diff --git a/Game/Behaviours/PongBall.cs b/Game/Behaviours/BallBehaviour.cs similarity index 88% rename from Game/Behaviours/PongBall.cs rename to Game/Behaviours/BallBehaviour.cs index 736b214..cc62d2a 100644 --- a/Game/Behaviours/PongBall.cs +++ b/Game/Behaviours/BallBehaviour.cs @@ -6,7 +6,7 @@ using Syntriax.Engine.Physics2D.Abstract; namespace Pong.Behaviours; -public class PongBall : BehaviourOverride +public class BallBehaviour : BehaviourOverride { public Vector2D StartDirection { get; private set; } = Vector2D.Zero; public float Speed { get; set; } = 500f; @@ -14,12 +14,12 @@ public class PongBall : BehaviourOverride private IRigidBody2D rigidBody = null!; - public PongBall(Vector2D startDirection, float speed) + public BallBehaviour(Vector2D startDirection, float speed) { StartDirection = Vector2D.Normalize(startDirection); Speed = speed; } - public PongBall() { } + public BallBehaviour() { } protected override void OnFirstActiveFrame() { @@ -32,7 +32,7 @@ public class PongBall : BehaviourOverride rigidBody = foundRigidBody; - if (GameObject.GameManager.TryFindBehaviour(out PongManager? pongManager)) + if (GameObject.GameManager.TryFindBehaviour(out PongManagerBehaviour? pongManager)) { pongManager.OnReset += ResetBall; pongManager.OnScored += ResetBall; @@ -40,13 +40,13 @@ public class PongBall : BehaviourOverride } } - private void DisableBall(PongManager pongManager) + private void DisableBall(PongManagerBehaviour pongManager) { BehaviourController.GameObject.Transform.Position = Vector2D.Zero; rigidBody.Velocity = Vector2D.Zero; } - private void ResetBall(PongManager pongManager) + private void ResetBall(PongManagerBehaviour pongManager) { StateEnable.Enabled = true; BehaviourController.GameObject.Transform.Position = Vector2D.Zero; diff --git a/Game/Behaviours/MovementBoxBehaviour.cs b/Game/Behaviours/PaddleBehaviour.cs similarity index 93% rename from Game/Behaviours/MovementBoxBehaviour.cs rename to Game/Behaviours/PaddleBehaviour.cs index 86ae8e1..d944847 100644 --- a/Game/Behaviours/MovementBoxBehaviour.cs +++ b/Game/Behaviours/PaddleBehaviour.cs @@ -1,12 +1,13 @@ using System; -using Microsoft.Xna.Framework; + using Microsoft.Xna.Framework.Input; + using Syntriax.Engine.Core; using Syntriax.Engine.Input; namespace Pong.Behaviours; -public class MovementBoxBehaviour(Keys Up, Keys Down, float High, float Low, float Speed) : BehaviourOverride +public class PaddleBehaviour(Keys Up, Keys Down, float High, float Low, float Speed) : BehaviourOverride { private Keys Up { get; } = Up; private Keys Down { get; } = Down; diff --git a/Game/Behaviours/PongManager.cs b/Game/Behaviours/PongManagerBehaviour.cs similarity index 75% rename from Game/Behaviours/PongManager.cs rename to Game/Behaviours/PongManagerBehaviour.cs index 54b1cd4..dbdb3d7 100644 --- a/Game/Behaviours/PongManager.cs +++ b/Game/Behaviours/PongManagerBehaviour.cs @@ -6,11 +6,11 @@ using Syntriax.Engine.Core; namespace Pong.Behaviours; -public class PongManager : BehaviourOverride +public class PongManagerBehaviour : BehaviourOverride { - public Action? OnReset { get; set; } = null; - public Action? OnFinished { get; set; } = null; - public Action? OnScored { get; set; } = null; + public Action? OnReset { get; set; } = null; + public Action? OnFinished { get; set; } = null; + public Action? OnScored { get; set; } = null; public int ScoreLeft { get; private set; } = 0; public int ScoreRight { get; private set; } = 0; @@ -18,8 +18,8 @@ public class PongManager : BehaviourOverride public int WinScore { get; } = 5; - public PongManager() => WinScore = 5; - public PongManager(int winScore) => WinScore = winScore; + public PongManagerBehaviour() => WinScore = 5; + public PongManagerBehaviour(int winScore) => WinScore = winScore; protected override void OnFirstActiveFrame() { diff --git a/Game/Behaviours/PongTextBehaviour.cs b/Game/Behaviours/TextScoreBehaviour.cs similarity index 63% rename from Game/Behaviours/PongTextBehaviour.cs rename to Game/Behaviours/TextScoreBehaviour.cs index dc050d2..c896806 100644 --- a/Game/Behaviours/PongTextBehaviour.cs +++ b/Game/Behaviours/TextScoreBehaviour.cs @@ -3,14 +3,14 @@ using Syntriax.Engine.Core; namespace Pong.Behaviours; -public class PongTextBehaviour : TextBehaviour +public class TextScoreBehaviour : TextBehaviour { public bool IsLeft { get; } - private PongManager? pongManager = null; + private PongManagerBehaviour? pongManager = null; - public PongTextBehaviour(bool IsLeft) => this.IsLeft = IsLeft; - public PongTextBehaviour(bool IsLeft, SpriteFont font) : base(font) => this.IsLeft = IsLeft; + public TextScoreBehaviour(bool IsLeft) => this.IsLeft = IsLeft; + public TextScoreBehaviour(bool IsLeft, SpriteFont font) : base(font) => this.IsLeft = IsLeft; protected override void OnFirstActiveFrame() { @@ -23,7 +23,7 @@ public class PongTextBehaviour : TextBehaviour UpdateScores(pongManager); } - private void UpdateScores(PongManager pongManager) + private void UpdateScores(PongManagerBehaviour pongManager) { if (IsLeft) Text = pongManager.ScoreLeft.ToString(); diff --git a/Game/Behaviours/ScoreBoundary.cs b/Game/Behaviours/WallScoreBehaviour.cs similarity index 85% rename from Game/Behaviours/ScoreBoundary.cs rename to Game/Behaviours/WallScoreBehaviour.cs index dac1d30..b9c3c4b 100644 --- a/Game/Behaviours/ScoreBoundary.cs +++ b/Game/Behaviours/WallScoreBehaviour.cs @@ -4,7 +4,7 @@ using Syntriax.Engine.Physics2D.Abstract; namespace Pong.Behaviours; -public class ScoreBoundary(Action OnCollision) : BehaviourOverride +public class WallScoreBehaviour(Action OnCollision) : BehaviourOverride { private Action OnCollision { get; } = OnCollision; diff --git a/Game/GamePong.cs b/Game/GamePong.cs index 8ce1b4b..dac0c3f 100644 --- a/Game/GamePong.cs +++ b/Game/GamePong.cs @@ -26,7 +26,7 @@ public class GamePong : Game private BehaviourCacher displayableShapeCacher = null!; private MonoGameCameraBehaviour cameraBehaviour = null!; - private PongManager pongManager = null!; + private PongManagerBehaviour pongManager = null!; private float physicsTimer = 0f; @@ -71,7 +71,7 @@ public class GamePong : Game //////////////////////////////////////////////////////////////////////////////////// IGameObject gameObjectPongManager = gameManager.InstantiateGameObject().SetGameObject("Pong Game Manager"); - pongManager = gameObjectPongManager.BehaviourController.AddBehaviour(5); + pongManager = gameObjectPongManager.BehaviourController.AddBehaviour(5); //////////////////////////////////////////////////////////////////////////////////// @@ -79,7 +79,7 @@ public class GamePong : Game gameObjectBall.Transform.SetTransform(position: new Vector2D(0, 0f), scale: new Vector2D(10f, 10f)); gameObjectBall.BehaviourController.AddBehaviour(new Circle(Vector2D.Zero, 1f)); - gameObjectBall.BehaviourController.AddBehaviour(); + gameObjectBall.BehaviourController.AddBehaviour(); gameObjectBall.BehaviourController.AddBehaviour(); //////////////////////////////////////////////////////////////////////////////////// @@ -87,13 +87,13 @@ public class GamePong : Game IGameObject gameObjectLeftPaddle = gameManager.InstantiateGameObject().SetGameObject("Left Paddle"); gameObjectLeftPaddle.Transform.SetTransform(position: new Vector2D(-468f, 0f), scale: new Vector2D(15f, 60f)); - gameObjectLeftPaddle.BehaviourController.AddBehaviour(Keys.W, Keys.S, 228f, -228f, 400f); + gameObjectLeftPaddle.BehaviourController.AddBehaviour(Keys.W, Keys.S, 228f, -228f, 400f); gameObjectLeftPaddle.BehaviourController.AddBehaviour(Shape.Box); gameObjectLeftPaddle.BehaviourController.AddBehaviour().IsStatic = true; IGameObject gameObjectRightPaddle = gameManager.InstantiateGameObject().SetGameObject("Right Paddle"); gameObjectRightPaddle.Transform.SetTransform(position: new Vector2D(468f, 0f), scale: new Vector2D(15f, 60f)); - gameObjectRightPaddle.BehaviourController.AddBehaviour(Keys.Up, Keys.Down, 228f, -228f, 400f); + gameObjectRightPaddle.BehaviourController.AddBehaviour(Keys.Up, Keys.Down, 228f, -228f, 400f); gameObjectRightPaddle.BehaviourController.AddBehaviour(Shape.Box); gameObjectRightPaddle.BehaviourController.AddBehaviour().IsStatic = true; @@ -111,13 +111,13 @@ public class GamePong : Game IGameObject gameObjectWallRight = gameManager.InstantiateGameObject().SetGameObject("Wall Right"); gameObjectWallRight.Transform.SetTransform(position: new Vector2D(532f, 0f), scale: new Vector2D(20f, 328f)); - gameObjectWallRight.BehaviourController.AddBehaviour((Action)pongManager.ScoreToLeft); + gameObjectWallRight.BehaviourController.AddBehaviour((Action)pongManager.ScoreToLeft); gameObjectWallRight.BehaviourController.AddBehaviour(Shape.Box); gameObjectWallRight.BehaviourController.AddBehaviour().IsStatic = true; IGameObject gameObjectWallLeft = gameManager.InstantiateGameObject().SetGameObject("Wall Left"); gameObjectWallLeft.Transform.SetTransform(position: new Vector2D(-532f, 0f), scale: new Vector2D(20f, 328f)); - gameObjectWallLeft.BehaviourController.AddBehaviour((Action)pongManager.ScoreToRight); + gameObjectWallLeft.BehaviourController.AddBehaviour((Action)pongManager.ScoreToRight); gameObjectWallLeft.BehaviourController.AddBehaviour(Shape.Box); gameObjectWallLeft.BehaviourController.AddBehaviour().IsStatic = true; @@ -125,11 +125,11 @@ public class GamePong : Game IGameObject gameObjectLeftScoreText = gameManager.InstantiateGameObject().SetGameObject("Score Left"); gameObjectLeftScoreText.Transform.SetTransform(position: new Vector2D(-250f, 250f), scale: Vector2D.One * .25f); - gameObjectLeftScoreText.BehaviourController.AddBehaviour(true, spriteFont); + gameObjectLeftScoreText.BehaviourController.AddBehaviour(true, spriteFont); IGameObject gameObjectRightScoreText = gameManager.InstantiateGameObject().SetGameObject("Score Right"); gameObjectRightScoreText.Transform.SetTransform(position: new Vector2D(250f, 250f), scale: Vector2D.One * .25f); - gameObjectRightScoreText.BehaviourController.AddBehaviour(false, spriteFont); + gameObjectRightScoreText.BehaviourController.AddBehaviour(false, spriteFont); } protected override void Update(GameTime gameTime)