Lab 4 - 2D Roguelike: Setup and Level Generation
GitHub Classroom Assignment Page
This assignment is due on Wednesday 5/2.
In this lab we will be completing the first third or so of the 2D Roguelike tutorial.
You should be able to open up the template including all required assets on the Learn tab of the Unity startup window.
For Lab 4 we will complete these parts:
- Player and Enemy Animations
- Creating the Tile Prefabs
- Writing the Board Manager
- Writing the Game Manager
There is a lot going on in these videos so it will most likely be necessary to compelte the lab by playing the videos and following along.
I will outline some of the steps, but mostly just to give an overview and maybe so that more experienced Unity developers can skip some parts of the videos.
Player and Enemy Animations
Create Player Prefab
- Create empty game object
Player
- Find the spritesheet in included assets and expand it (right arrow)
- Click, Shift+Click to select the four idle frames and drag them onto the Player object
- Re-organize the created assets (AnimationController and Animation) into folders
- Do the same for player Chop and Hit animations
- Add box colider 2D and rigid Body 2D components to the player
- Make Body Type Kinematic
- Set the Layer to Blocking Layer
- Set the Sorting Layer to Units
- Drag the Player into the Assets to make it a Prefab, then delete the original object
Create Enemy Prefab
- Create Enemy1 Prefab
- Tag:
Enemy
- Layer:
BlockingLayer
- Sorting Layer:
Units
- Enemy1 animation controller and Enemy1Idle and Enemy1Hit animations
- Tag:
- Create Enemy2 Prefab
- Create Enemy2 Animation Override Controller using Enemy2Idle and Enemy2Hit animations
Creating the Tile Prefabs
- Create Floor1 - Floor8 prefabs
- Sprite Renderer component, no colliders
- Sorting Layer:
Floor
- Create Exit, Food, Soda prefabs
- Sorting Layer:
Items
- Box Collider 2D
- Is Trigger:
true
- Is Trigger:
- Tag:
Exit
,Food
,Soda
- Sorting Layer:
- Create OuterWall1-3 prefabs
- Box Collider 2D
- Is Trigger:
false
- Is Trigger:
- Tag:
Untagged
- Layer:
BlockingLayer
- Sorting Layer:
Floor
- Box Collider 2D
- Create Wall1-8 prefabs
- Box Collider 2D
- Is Trigger:
false
- Is Trigger:
- Tag:
Untagged
- Layer:
BlockingLayer
- Sorting Layer:
Items
- Box Collider 2D
Writing the Board Manager
- Write procedural board generation script in
BoardManager.cs
Writing the Game Manager
- Write board setup code in
GameManager.cs
- Create GameManager prefab
- Attach both manager scripts
- Add all tile prefabs to Board Manager arrays
- Make GameManager a singleton
- Add a
Loader.cs
script that creates the GameManager, attach to Main Camera