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.

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