The Goal: Create a game mechanic or mini-game in under a week that involves the State Design Pattern in the code's implementation.
1. Briefly, what was the game feature you chose to create?
This game feature is part of a mini pet simulator game where the player can both pet and feed their virtual pet.
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 click the feed button to feed their virtual pet, or click their pet to actually pet them. To put this in the sentence format: “As a player, I want to feed and pet my virtual pet so I can make sure the pet’s hunger bar doesn’t get too low and my number of pets goes up.”
3. What is the internal state or process you are trying to control with the State design pattern?
The State design pattern controls the different states of the virtual pet, switching between idle, excited, and hungry.
4. What triggers changes between the states?
The pet starts out in its idle state, which can turn to excited if the player pets them (and they aren’t hungry) and can turn to hungry if the hunger bar gets low enough. When hungry, the pet can return to idle when fed. When excited, the pet can return to idle after eating or when their hunger bar gets semi-low (not low enough to be hungry but too low to be considered well fed.)
5. What were the benefits of using the State Pattern to make your game feature?
This was probably the easiest way I’ve implemented AI like this, and would have been very useful when designing monsters for other games in the past. It was also very organized compared to other methods I’ve tried to do the same thing.
6. Did you find any drawbacks to using the State Pattern? If so, what were they?
I ran into a bug pretty early on in development that came from not being able to assign a GameObject by tag if the game object starts off not active. I eventually found a way around this, but the combination of the scripts not being added until they’re used and not being able to assign GameObjects unless they’re already active led to a rather annoying bug.
7. How is the goal of the game feature communicated to the player in your unity project?
The goal of the game feature is communicated through the ‘How to Play’ section that can be accessed through the ‘How to Play’ button that also shows the controls.
8. How are the controls required to use the game feature you created communicated to the player in your unity project?
The controls are seen through the same panel that the game feature’s goal is stated, in the ‘How to Play’ section.
9. How does the game communicate to the players whether or not they have successfully used the game feature?
There is a hunger bar that shows the current hunger of your pet, which goes up when you feed your pet. The pet also has heart particle effects that show whenever you pet them and they count for your ‘pet.’