Winning or losing the game
We have added a nice new feature to our RTS game, the objectives, and now we can configure the level objectives, track the player’s progress, and display the progress in the UI. However, there is still one thing left to implement here: the condition to win or lose the game with visual feedback to the player.
We are going to create a couple of new scripts with a new message type for the game over condition, a new component to listen to this message, and a new pop-up message that will display the game outcome to the player.
Let’s start by adding the new message type. Create a new script in the Scripts | MessageQueue | Messages | UI folder, name it GameOverMessage
, and replace the content with the following code block:
namespace Dragoncraft { public class GameOverMessage : IMessage { public bool PlayerWin; } }
The GameOverMessage
class has only the PlayerWin
property, which...