Fish Factory Scripts - vr4vet/Blue-Sector GitHub Wiki
All of the project scripts are monobehaviour, including our GameManager. Here are some important information about some of the scripts. For more details about these scripts and other scripts in the project, see comments in code.
GameManager
The GameManager keeps track of the player's progress and the state of the simulation throughout the Fish Factory. Some important things to note:
- The GameManager is a Singleton, meaning that only one instance of the GameManager can exist at any given time.
- The GameManager should be present in every scene, and should not be destroyed when loading a new scene to ensure persistence of the player's progress.
- The GameManager is connected to the AudioManager object in every scene to play sound effects. The AudioManager prefab should therefore be present in every scene.
- The GameManager will dynamically find the AudioManager object in the scene, as well as the game objects for the player's hands, to ensure that the player's gloves are set correctly.
FactoryFishSpawner
The FactoryFishSpawner is used to spawn the fish prefab in varying sizes and with varying textures. Some important things to note:
- "Toggle fish variation" should be toggled in the Bleeding Station. This will spawn fish with variation in size and state.
- Percentages for different fish states "alive", "bad" and "stunned" are kept as percentages from 0 to 100. The script first checks alive chances, then unedible (bad fish) chances, and the remaining percent is stunned. Eg. if alive percent is set to 100 - then all fish will be spawned as alive.
- "Toggle fish tier" should be toggled on in the QA station, but only for the spawners spawning fish for the sorting machine. The "tier 1", "tier 2" and "tier 3" percentages works the same way as the "alive", "bad" and "stunned" percentages.
- "Toggle fish gutting chance" should only be toggled for the spawners spawning fish for the gutting station. The "successful gutting", "incomplete gutting" and "bad gutting" percentages works the same way as the "alive", "bad" and "stunned" percentages.
- Big variations in size does not work well with the FishFactorySalmon prefab, as the armature objects do not resize properly.
FactoryFishState
The FactoryFishState
is used to make and assign states to the fish as well as containing methods to change the states when needed and a function to move fish that are alive. Some important things to note:
- The script is attached to the
FishFactorySalmon
and theFishFactoryBadFish
as a component. - The function
CutFishGills
is used in the bleeding station to check if the user has cut the fish gills on a fish with the correct state and will give feedback and change the state accordingly.
FishSortingButton
The FishSortingButton
script is used on the buttons on the sorting machine prefab in order to change the active tier the fish gets put into. Some important things to note:
"_currentTier"
is used for ensuring only one active fish tier at a time.- The list
"_sortedFish"
is used by the scriptFishSortingTrigger.cs
to allow a fish to be sorted only once. - The
SetTier
method is used to set the_currentTier
FishSortingTrigger
The FishSortingTrigger
script is used with the sorting machine prefab to check if the fish has been sorted correctly, and to open the correct door to let the fish slide down onto the conveyor. Some important things to note:
- The
_door
variable is a serialize field that maps a trigger to the door it opens. - The
_tierManager
variable is a serialize field that maps the QA machine's currently set tier state.
CutFish
This script holds boilerplate code for linking gill and body related scripts to knife and fish state. This keeps our code DRY. It also has a method called cutEvent
which can handle both gill- and body cuts.
CutFishBody
The script CutFishBody
call the method "cutEvent"
if the knife collides with the trigger box the script is a component of. This will be registered as a wrong cut. It inherits the method from CutFish
CutFishGill
The script CutFishGill
call the method "cutEvent"
if the knife collides with the trigger box the script is a component of. This will be registered as a correct cut. CutFish
StunFish
The script StunFish
is used on the StunMachine
prefab to stun fish that are alive.
DiscardBadFish
The DiscardBadFish
script is used to allow the player to discard fish that has gone bad or are dead. Some important things to note:
- The
DiscardBadFish
script is placed as a component on an invisible trigger box inside the discard tub model. - The variable
"_destroyFishTreshold"
allows the discard box to accumulate a set number of fish instead of deleting them instantly. This threshold can be adjusted in the editor.
KnifeState
The KnifeState
script determines if the knife should chip and changes the blade model to a chipped blade. Some important things to note:
- The
"_durabilityCount"
is set to 5 as default but can be changed in the editor or can be assigned a random value.