Demo
Setting Environment
- Asset Store
- Download Medieval Town Exteriors
- change folder name
- Import from own Unity Framework
- create player
- create Scene Manager
- create Main Camera
Move
- Layer
- Change Layer to
Wall
in Terrain - if camera doesn’t move, drag and drop player to player of CameraController Component
- Change Layer to
Block
in Buildings, Components and Fence
- Change Layer to
- Navigation
Bake
means create files before execute- Bake is related with static option of objects
-
from Navigation, we can define whether player can go
- Nav Mesh Agent
- add
Nav Mesh Component
to player
- add
- PlayerController.cs
Stat
Monster
- Download Monster in Asset Store
- download any knight model with animation
- organize folder
Content
- Scripts\Contents\Stat.cs
-
change before Stat Class to
Data.Stat
-
Scripts\Contents\PlayerStat.cs
- Add Component
- add PlayerStat.cs component in Player
- add Stat.cs component in Monster
Layer
- Change Layer
- Change Layer name
Wall
toGround
- Change Terrain layer to
Ground
- Change Layer name
- Add Layer
- add Layer
Monster
in Monster
- add Layer
- PlayerController.cs
- change
_speed
to_stat.MoveSpeed
- change
Test
Cursor
Cursor
- Download Cursor in Asset Store
- Select cursors and Move those to Resources\Textures\Cursor
- Change Texture type to
Cursor
in all Cursor
Change Cursor
- PlayerController.cs
Test
Targeting
- Click vs Press
- Click: press mouse button shortly
- Press: press mouse button for several seconds
- you can define Click and Press
Mouse Event
- Define.cs
- PlayerController.cs
- when you press mouse button, player still moves
Test
Attack
Mouse Event
- InputManager.cs
- Define Click and Press
- PlayerController.cs
- included code organization
Animation
- use CrossFade method
- delete all parameters in PlayerAnimController
- add
ATTACK
Animation from Knight animation resources in PlayerAnimController
UI
- Create sword prefab from knight and paste to player
Test
Hp
- reduce monster’s Hp gage when player attaks monster
UI
- Create Hp bar by
Slider
- Create Prefab
- Change transform
Componenets
- UIManager.cs
- PlayerController.cs
- if myStat.Attack - targetStat.Defense is negative, then damage is 0
- Scripts\UI\WordSpace\UI_HPBar.cs
- ratio controlls hp
- int / int = int, so we need float casting
- add UI_HPBar.cs component to monster
- UI_Base.cs
- you should remove all start function in this project
Test
Monster AI
- monster can detect player
- monster can follow player
- monster can attack player
State Controll
-
Change state by enum and switch
-
PlayerController.cs
- include code organization
- change PlayerState to Define.State
- Define.cs
- Scripts\Controllers\BaseController.cs
- Scripts\Controllers\MonsterController.cs
Animation
- MonsterAnimController
Components
- Remove NavMeshAgent Component from player
- Add
player
tag in player
Test
Destroy
- you cannot make player to null directly
- because other managers or componenets still use player
Prefab
- Player
- remove original player prefab and create new player prefab(Drag and Drop hierarchy object to Prefabs folder)
- Monster
- remove original monster prefab and create new monster prefab(Drag and Drop hierarchy object to Prefabs folder)
Componenets
- Define.cs
- BaseController.cs
- Manager.cs
- MonsterController.cs
- PlayerController.cs
- Extension.cs
- only null checking is not enough
- because player has poolable component
- so you need activate cheking
- CameraController.cs
- Scripts\Managers\Contents\GameManagerEx.cs
- if you make GameManager.cs, then the icon is wheel
- Folder Organization
Test
- GameScene.cs
Level
Camera Zoom
- CameraController.cs
- when player is behind buildings, camera will zoom player
Leveling
- GameManagerEx.cs
- StatData.json
- for player
- Stat.cs
- PlayerStat.cs
- MonsterController.cs
- PlayerController.cs
Test
Monster Generator
Spawning
-
Monster is generated automatically for same number
-
Scripts\Contents\SpawningPool.cs
- GameManagerEx.cs
Test
- PlayerController.cs
- to avoid player going up
- GameScene.cs