GAME 1303 — Tier 7: Simulation (Pet Sim, Saving, Store Sim)
Sixteen scripts serving two very different games plus a save system everyone can use.
One v1.1 update in Tier1_Updates/: CollectionTracker gains GetAllCounts() so SaveSystem can write item counts to disk. Drop it over the original.
Scripts/
Pet/ NeedStat, PetBrain, CareAction, PersonalityTracker
Save/ SaveData, SaveSystem
Store/ FirstPersonController, ProductType, Carryable, PickupCarry, ShelfSlot,
StoreEconomy, CustomerAI, Register, CustomerSpawner
Tier1_Updates/ CollectionTracker (v1.1)
Cozy Critters (Rhys) — the whole game
Rhys was explicit that "the fear of the pet dying after 2 seconds of not paying attention does not exist," so nothing in this tier can kill the pet. NeedStat decay is measured per minute, not per second: at the default 3/minute a full bar lasts over half an hour. Low needs make the pet slower and sadder — never dead.
NeedStat— one per need (hunger, energy, happiness). A low need optionally drags happiness down, which is how "care for it, increasing happiness" from the pitch actually works mechanically.PetBrain— idle / wander / sleep / react, driving Tier 5'sTopDownMoverin AI mode. Rhys's "one area" is either a box collider or a wander radius.CareAction— one per button (feed, play, clean). Each names a personality trait it feeds.PersonalityTracker— counts those traits over time and settles on a nature once there's enough evidence and one clearly leads. That's the pitch's "changing the nature of the pet," and it's deliberately descriptive rather than a score: there's no wrong personality, which is what keeps it cozy.
Offline decay is the Tamagotchi part done kindly: SaveSystem tells every NeedStat how many real minutes the player was away, capped by maxOfflineMinutes so a week off doesn't empty everything.
SaveSystem — for everyone
Writes JSON to Application.persistentDataPath. Turn on Log Save Path and have students open the file in Notepad — seeing their own save as readable text does more for understanding serialization than any lecture.
It saves flags and counters (Tier 4), item counts (Tier 1), optional player position and health, pet stats and personality, and discovered clues (Tier 6). Every section is optional and skipped safely if the component isn't in the scene.
Note the deliberate split: Tier 4's LevelProgress (PlayerPrefs) handles level unlocks and best times; this handles the state of the world. Keeping them separate means a student can use one without the other.
Worth explaining once in class: JsonUtility can't serialize dictionaries, which is why flags and stats are stored as parallel name/value lists. That's a real limitation students will hit on their own.
Store Simulator (Sanad) — the whole loop
The only 3D corner of the kit. FirstPersonController uses a CharacterController, and is deliberately plain — walk, look, crouch, jump. Sanad needs a body to carry boxes with, not a shooter.
The loop: StoreEconomy.OrderBox spends cash and delivers a Carryable box after a delay → the player carries it with PickupCarry → ShelfSlot takes units out of the box and spawns visible product meshes → CustomerAI (NavMesh) walks in, takes items off shelves, queues at the Register → the player scans each item → StoreEconomy.Earn. Rent is deducted nightly, which is the pressure that stops it being a sandbox.
The NavMesh must be baked or nothing moves. In Unity 6 that means the AI Navigation package and a NavMeshSurface on the floor. That's the first thing to check when Sanad says customers aren't walking.
autoServe on the Register lets him test the economy before building the interaction, and CustomerSpawner's rateImprovementPerDay is the entire progression curve in one float.
AudioManager names referenced
care, pickup, drop, stock, beep, cash.
Notes for the instructor
PersonalityTrackerstores its counters in Tier 4'sChoiceFlagManager, so the pet's history survives scene loads for free.ShelfSlotcaps spawned display meshes at three layers so a big store doesn't instantiate hundreds of objects.RegisterandShelfSlotread the E key directly rather than through PlayerInput messages, because they're not on the player object. If Sanad rebinds interact, those two lines need changing — flagged in both files.FindObjectsByType/FindFirstObjectByTypeare Unity 2023+/6; on 2022 useFindObjectsOfType/FindObjectOfType.- Hand-reviewed, not compiled.