The Goal: Create a game mechanic or mini-game in under a week that involves the Decorator Design Pattern in the code's implementation.
1. Briefly, what was the game feature you chose to create?
The game feature gives the player a blank slate of a pizza and buttons that they can push for different toppings they can add to it so they can fulfill orders given by customers.
2. What is the player able to do with the game feature you chose to create? What goal are they able to achieve with it and for what purpose? To put this another way, complete this sentence: As a player, I want to ____<goal>____ so I can ____<reason>____. (This is a user story: https://en.wikipedia.org/wiki/User_story.)
The player is able to make different pizzas to make customers happy. To put it in the proper format, “As a player, I want to make the correct pizza so I can make customers happy and increase my score.”
3. What does the player do in the game that creates an object of a type that can be decorated?
A pizza is created automatically when the game starts up, but after that every pizza (which is the object that can be decorated) is created upon either throwing a pizza out or giving the current pizza to a customer.
4. What does the player do that adds a decorator to that object (with the decorator design pattern) while the game is running?
Pressing a button to add a topping (cheese, sauce, sausage, etc) adds a decorator to the pizza, the class name being “Toppings.”
5. What does the decorator do to change the object it decorates? For example, the Starbuzz Coffee condiments added to the beverage price, and adding a profession added to the character’s damage.
The decorator turns its respective boolean to true, while preserving the status of the other booleans. Adding a topping also adds to the score value, so the more toppings the pizza has the more points you earn upon giving the correct pizza to the correct customer.
6. What were the benefits of using the Decorator Pattern to make your game feature?
Once it was implemented, it made keeping track of the different booleans easier than having everything in just one script. It was easier to have multiple “toppings” that all would add to the score and help the game keep track of what sprites needed to be activated than having everything being changed from one place.
7. Did you find any drawbacks to using the Decorator Pattern? If so, what were they?
Yes. Specifically in Unity, the weird way that Unity treats MonoBehaviour made it take more than a few tries to get everything to work the way I wanted it to, with AddComponent() acting strange and eventually leading to me having to scrap all my code and use SerializeFields. With that being implemented, I noticed that my UML diagram looks slightly different than the example, which worries me slightly but the code was heavily inspired by the 3rd example code so I’m hoping that I implemented everything properly.
8. How is the goal of the game feature communicated to the player in your unity project? (If it’s not being communicated, be sure to fix that so you can answer this question.)
The goal of the game is stated in the “How to Play” section of the screen. Specifically in the “Make the pizzas correctly to earn points!” line.
9. How are the controls required to use the game feature you created communicated to the player in your unity project? (If they’re not being communicated, be sure to do so.)
The controls are similarly communicated to the play through a small “How to Play” text section on the screen. Everything is activated by clicking buttons, so the controls mostly just explain what clicking certain elements does.
10. How does the game communicate to players whether or not they have successfully used the game feature? (Again, if it’s not communicated, fix that in your Unity project before you answer this question.)
When giving a pizza to a customer, the score increases and their sprite changes to a happy face if you give the correct pizza, while the score stays the same and their sprite changes to a mad face if you get the pizza wrong.