250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- Unity
- Transform
- 플레이어 이동
- joystick
- 프리팹
- 유니티
- raycasting
- 플레이어 방향전환
- Vector3
- rigidbody
- Animation State Machine
- raycast
- Scrooling
- Hp바
- 패럴렉스
- 2D슈팅게임
- Prefabs
- CSharp #자료구조
- Parallax
- Blend Type
- Object Poling
- 스크롤링
- rotation
- Object Pooling
- Hpbar
- apk
- Ainimation Blending
- 오브젝트 풀링
- 일시정지
- LayerMark
Archives
- Today
- Total
주녘공부일지
[더 챌린저스] 게임 내 데이터 관리 본문
728x90
1. 제이슨 데이터 관리
- 제이슨 데이터를 빠르고 편리하게 사용하기 위해 파싱해서 딕셔너리로 사용
public void Init()
{
SkillDict = LoadJson<SkillData, int, Skill>("SkillData").MakeDict();
CharInfoDict = LoadJson<CharacterData, int, CharacterInfo>("CharacterData").MakeDict();
}
Loader LoadJson<Loader, Key, Value>(string path) where Loader : ILoader<Key, Value>
{
TextAsset textAsset = Managers.Resource.Load<TextAsset>($"Data/{path}");
return JsonUtility.FromJson<Loader>(textAsset.text);
}
[Serializable]
public class Skill
{
public int skillType; // ENUM_SKILL_TYPE (Key)
public float damage;
public float runTime;
public float stunTime;
public float risingPower;
public float pushingPower;
public int hitSoundType; // ENUM_SFX_TYPE (히트사운드)
}
public class SkillData : ILoader<int, Skill>
{
public List<Skill> Skills = new List<Skill>();
public Dictionary<int, Skill> MakeDict()
{
Dictionary<int, Skill> skillDict = new Dictionary<int, Skill>();
foreach (Skill skill in Skills)
skillDict.Add(skill.skillType, skill);
return skillDict;
}
}
{
"Skills": [
{
"skillType": 1,
"damage": 2.0,
"runTime": 0.2,
"stunTime": 0.35,
"risingPower": 0,
"pushingPower": 2.5,
"hitSoundType" : 301
},
{
"skillType": 2,
"damage": 2.0,
"runTime": 0.2,
"stunTime": 0.35,
"risingPower": 0,
"pushingPower": 2.5,
"hitSoundType" : 302
},
...
]
}
2. PlayerPrefs
유니티에서 제공해주는 데이터 관리 클래스로 유저가 게임 내에서 세팅한 정보를 저장, 불러오기하기 위해 사용
- 해당 클래스는 int, float, string 타입만 지원하기 때문에 동시에 사용되는 데이터의 일부만 저장, 불러오기를 할 수 없도록 데이터 클래스로 묶어서 사용함
ex) 키 설정 값, 볼륨 크기 및 뮤트 상태
[Serializable]
public class KeySettingData
{
public List<KeySettingDataElement> keySettingDataList = new List<KeySettingDataElement>();
public float opacity;
public KeySettingData(List<KeySettingDataElement> _keySettingDataList, float _opacity)
{
keySettingDataList = _keySettingDataList;
opacity = _opacity;
}
}
[Serializable]
public class KeySettingDataElement
{
public int key; // ENUM_KEYSETTING_NAME의 번호 (키 값)
public float scaleSize;
public float rectTrX;
public float rectTrY;
public KeySettingDataElement(int _key, float scaleSize, float _rectTrX, float _rectTrY)
{
this.key = _key;
this.scaleSize = scaleSize;
this.rectTrX = _rectTrX;
this.rectTrY = _rectTrY;
}
}
https://godgjwnsgur7.tistory.com/55
728x90
'GameEngine > Unity - Project' 카테고리의 다른 글
[더 챌린저스] 캐릭터 애니메이터 스테이트 관리 고찰 (0) | 2023.08.15 |
---|---|
[더 챌린저스] 캐릭터 (0) | 2023.08.04 |
[더 챌린저스] 캐릭터 애니메이션 제어 (0) | 2023.07.31 |
[더 챌린저스] 동기화되는 오브젝트 (0) | 2023.07.28 |
[더 챌린저스] 키 설정 시스템 (0) | 2023.07.14 |