/// <summary> /// Changes end game status and triggers events. /// </summary> public void OnEndGame(object sender, EndGameArgs endGameArgs) { bool status = endGameArgs.Status; int score = endGameArgs.Score; //true -> win //false -> loss if (status) { this.Status = WinStatus; this.Message = WinMessage; } else { this.Status = LossStatus; this.Message = LossMessage; } this.Score = score; }
/// <summary> /// Changes ball position according to velocity values. /// </summary> /// <param name="targetBlocksCollection">Needed for calculating score should game end.</param> public void MoveBall(TargetBlocksCollection targetBlocksCollection) { this.X += CurrentVelocityX; if (this.X + this.Width >= this.ScreenWidth || this.X <= 0) { ChangeDirectionX(); } this.Y += CurrentVelocityY; if (this.Y <= 0) { ChangeDirectionY(); } if (this.Y + this.Width >= ScreenHeight) { EndGameArgs endGameArgs = new EndGameArgs(false, targetBlocksCollection.DestroyedBlocks); this.EndGame(this, endGameArgs); } }