Sababich Tutorial
Technical Documentation - Sababich Game
Complete documentation of all classes and functions in the game, organized by folders with links to relevant code lines.
Folder Structure
Assets/Scripts/ ├── Enemies/ # Customer logic and orders ├── Manager/ # Core game managers ├── Player/ # Player actions and frying └── Util/ # Utilities and UI
Enemies Folder
MoveToCounter.cs
Description: Handles customer movement toward the counter in a linear way. Uses Vector2.MoveTowards to move the customer gradually toward the target.
Functions:
Update()- Key function: Updates customer position every frame by calculating the distance to target and moving the object at constant speed times elapsed time (speed * Time.deltaTime). If target is not set, exits early without updating position to prevent errors.
CheckOrder.cs
Description: Validates the customer's order against selected ingredients. Manages the correct ingredient list and compares it to the player's current selection.
Functions:
OnMouseDown()- Key function: Triggered when clicking on customer, checks if selected ingredient list matches the correct order usingIsSelectionMatching(). If order is correct, clears the ingredient list and notifies CustomerMoodTimer that customer was served successfully, and updates TutorialManager. If wrong, prints error message with entered order and correct order for debugging.
CustomerMoodTimer.cs
Description: Manages customer mood changes over time and their exit process. Customer goes through different mood states at set intervals until they leave or get served. - Not in Tutorial.
Manager Folder
ClickManager.cs
Description: Manages all clicks in game by converting mouse positions to world coordinates. Detects objects with Item component and triggers their corresponding function.
Functions:
Update()- Key function: Checks every frame if there's a left mouse click (Input.GetMouseButtonDown(0)), converts mouse position from screen coordinates to 2D world coordinates usingCamera.main.ScreenToWorldPoint, performs Raycast2D to find clicked object, and if object withItemcomponent is found calls itsOnClick()function. This is the main entry point for all mouse interactions in the game.
GameFlowManager.cs
Description: Manages different game phases and updates on-screen instructions accordingly. Holds current state (CurrentPhase) and coordinates between different gameplay stages.
Functions:
SetPhase(GamePhase newPhase)- Key function: Updates current game phase and shows appropriate UI instructions based on phase using switch statement. Each phase (adding eggplants, frying, assembling dish, serving, next customer) displays different guidance text to player throughUIInstructions.SetInstructions(). This helps player understand what next step to perform in game.
MainMenu.cs
Description: Manages game's main menu and scene transitions. Provides callback functions for main menu buttons.
Functions:
OnTutorialButtonClicked()- Loads tutorial scene (TutorialScene) when clicking tutorial button usingSceneManager.LoadScene
MusicPlayer.cs
Description: Singleton that manages game music and keeps it between scene changes. Uses DontDestroyOnLoad to ensure music continuity throughout entire game.
Functions:
Awake()- Key function: Implements Singleton pattern by checking if MusicPlayer instance already exists, and if so destroys new copy (Destroy(this.gameObject)). Otherwise, sets itself as Instance, initializes AudioSource reference, and sets object to survive between scene changes usingDontDestroyOnLoad. This ensures music continues smoothly without interruption.
ScoreManager.cs
Description: Singleton that manages player score (money/coins) and updates score display. Provides central interface for adding money and updating UI in real-time.
Functions:
AddMoney(int amount)- Adds money amount to current score and calls display update
SelectionList.cs
Description: Singleton that manages ingredient list player selected for assembling sababich. Keeps selection order and displays it on screen, including validation that first ingredient must be pita.
Functions:
TryAddIngredient(string ingredientName)- Key function: Tries to add ingredient to list, first converts name to lowercase, checks if list is empty and ingredient is not pita (prevents starting assembly without pita), adds ingredient and updates display. Returnstrueif addition succeeded andfalseif failed. This ensures every sandwich starts with pita as base.IsSelectionMatching(List<string> correctOrder)- Key function: Compares selected ingredient list to correct order list. First checks that list lengths match (if not returnsfalse), then iterates through each ingredient in correct order and checks it exists in selected list (Contains) - note that check is order-independent! Returnstrueonly if all ingredients from correct order are found in list.
TutorialManager (source)
Directs tutorial phases: frying eggplant, assembling sandwiches, and serving customers. Controls arrows, item clickability, customer rounds, and GamePhase updates. Key functions:
OnIngredientClicked(Item,string)(link) – Routes clicks by tutorial phase, starting frying or advancing sandwich steps.OnEggplantTrayFull()(link) – Switches to assembly, disables the eggplant row, enables the next ingredient, and updates arrows and phase.
GamePhase (source)
Enum describing gameplay phases across the tutorial loop. Used by GameFlowManager to drive instruction text. Key values: AddRowEggplant, FryingEggplant, AssembleDish, ServeCustomer, NextCustomer.
Player
Item (source)
Clickable ingredient that can join the current selection. Delegates tutorial progression after a successful add. Key functions:
OnClick()(link) – Adds the ingredient viaSelectionList(unless excluded types) and notifiesTutorialManager.
FryZoneEggplant (source)
State machine for the frying pan, handling timing, visuals, and readiness. Hands fried eggplant to the tray on click when ready. Key functions:
Update()(link) – Advances the fry timer while frying and transitions toReadywhen time elapses.OnMouseDown()(link) – When ready, clears the pan and callsEggplantTray.FillFromPan()to deliver eggplant.
EggplantTray (source)
Tracks tray fill visuals and signals tutorial progress when full. Starts empty and swaps to a full sprite once filled from the pan. Key functions:
FillFromPan()(link) – Enables the full-tray sprite and callsTutorialManager.OnEggplantTrayFull().
Utilities
UIInstructions (source)
Wrapper over TMP text for on-screen prompts. Caches the latest instruction string for reads. Key functions:
SetInstructions(string)(link) – Clears and writes the provided message to the TMP component.GetCurrentText()(link) – Returns the last stored instruction string.
FryTimerUI (source)
Displays frying progress as a UI fill tied to the pan state. Hides itself when no frying is active. Key functions:
Update()(link) – Toggles visibility byIsFryingand setsfillAmountto1 - FryProgresswhile active.
MuteButton (source)
UI toggle bound to the global music mute state. Swaps sprites to reflect mute/unmute after presses. Key functions:
| Status | Released |
| Platforms | HTML5 |
| Author | Itamar_Raz_Dev_Game |
| Made with | Unity |

Leave a comment
Log in with itch.io to leave a comment.