protected override void Dispose(bool disposing) { if (disposing) { Ball?.Dispose(); PlayerPaddle?.Dispose(); AiPaddle?.Dispose(); ServeBallHandler?.Dispose(); } }
/// <summary> /// ROUND EVENTS /// </summary> public void StateChanged(IMachineStateComponent <RoundState> component, RoundState previous) { if (_round.State.Equals(RoundState.WaitingForBallServe)) { Paddle servingPaddle = Components.OfType <Paddle>().Where((x) => x.Team == _round.ServingTeam).Single(); ServeBallHandler.AssignRequiredEntities(Ball, servingPaddle); } else if (previous.Equals(RoundState.WaitingForBallServe)) { ServeBallHandler.FreeRequiredEntities(); } }
public OngoingMatchScreen(Game game) : base(game) { Translucent = false; Components.Add(Ball = new Ball(game)); Components.Add(AiPaddle = new Paddle(game, Team.Red)); Components.Add(PlayerPaddle = new Paddle(game, Team.Blue)); Components.Add(ScoreDisplay = new ScoreDisplay(game)); Components.Add(FirstServerFinder = new FirstServerFinder(Game, Ball)); Components.Add(ServeBallHandler = new ServeBallHandler(Game)); Components.Add(CollisionTester = new CollisionTester(game, Ball, new List <Paddle>() { AiPaddle, PlayerPaddle })); }