The Goal: Create a game mechanic or mini-game in under a week that involves the Composite Design Pattern
in the code's implementation.
1. Briefly, what was the game feature you chose to create?
This game feature is a basic inventory system where you can collect different fruits or baskets of fruit that area all worth different amounts of points.
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>____.
The player is able to walk around and collect the different fruits or baskets of fruit in order to get a higher score and see the numbers go up in their inventory. To put this in the sentence format: “As a player, I want to collect the different fruits so I can see my score go up.”
3. What are the composite and leaf objects in your Unity Project implementing a game feature?
The composite object is the fruit basket and I suppose technically also the inventory itself, though that is being used as the overarching client. The leaf objects are the individual fruits that you can pick up independent of the fruit basket collectables.
4. In the starting UML class diagram above, there is an operation() method that is shared by the Leaf and Composite objects. Your code needs to iterate through and call this method you create on all of the leaf and composite items.
1. What is one method your code calls on all of your leaf and composite items?
CalculatePointValue()
2. What visible effect does this method have on objects in the game? (Keep in mind that just displaying text is not sufficient.)
When you collect a new fruit or collection of fruits, the game updates both your total score and the number of a certain fruit or basket that you have collected in your inventory.
3. What triggers this method in the game?
Collecting an item after it spawns in the game world.
5. What were the benefits of using the Composite Pattern to make your game feature?
It was useful for having “bags” of other items and being able to pick all the items up at once. I can picture this being very useful in something like an Animal Crossing clone with bags of bells or even collections of multiple presents under one wrapping.
6. Did you find any drawbacks to using the Composite Pattern? If so, what were they?
I was slightly confused on how to implement the general inventory, if that was supposed to be a client or if it was to extend the InventoryItem class. I ended up working everything out, but I feel like this pattern would be more useful as a general guideline but not as a rigid structure.
7. 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 communicated on the screen in the top left hand corner.
8. 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 game’s controls are communicated on the screen in the top right hand corner.
9. 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.)
The game gives positive feedback whenever you collect a fruit item by the numbers going up in both the inventory and the general score.