제작 기간 : 1주일
팀원 : 박건원, 이진우, 오승희, 최재성
사용 기술 : c#
1. 데이터 저장
Newtonsoft.json라이브러리 활용과 인터페이스 저장을 위해 Custom JsonConverter 제작하기
c# NewtonSoft.json 활용 데이터 저장 <interface 데이터 추가>
문제 Interface의 경우 데이터를 불러 올 상황에 JsonConvert 오류가 발생하게 된다. 따라서 이를 해결하기 위한 방안을 소개한다. 0. 데이터 저장 클래스 ▶ 예제 클래스 및 인터페이스 선언 class Player
rimugiri.tistory.com
2. c# 음악 재생하기
c# Console 음악 출력 방법 (.wav, .mp3)
1. using System.Media; 이 라이브러리를 사용 하면 .wav파일을 콘솔 상에서 재생할 수 있다. 새로운 쓰레드를 자동으로 생성해 주어 그 쓰레드에서 작동하여 아래에서 자신이 하고싶은 동작을 구현 할
rimugiri.tistory.com
3. 핵심적임 흐름제어 코드
흐름을 한곳에서 관리하게 하기 위하여 GameManager를 singleton으로 두어 하나의 함수로 선택에 대한 호출이 가능하게 하였다.
public void SetNextAction(int minValue, int maxValue)
{
Console.WriteLine("\n원하는 행동을 입력해 주세요");
while (IsInValidAction(minValue, maxValue) == false) { Console.WriteLine("잘못된 입력입니다 다시 선택해 주세요"); }
Console.WriteLine();
}
bool IsInValidAction(int minValue, int maxValue)
{
if (int.TryParse(Console.ReadLine(), out action) == false) return false;
if (action > maxValue || action < minValue) return false;
return true;
}
https://github.com/gunwonpark/TextRPGGame?tab=readme-ov-file
GitHub - gunwonpark/TextRPGGame: MakeTextRPGGame
MakeTextRPGGame. Contribute to gunwonpark/TextRPGGame development by creating an account on GitHub.
github.com
'언어 정리 > c#' 카테고리의 다른 글
c# 기초 정리하기 - 진법변환, 및 확장형 메소드 (0) | 2024.11.07 |
---|---|
c# Console 음악 출력 방법 (.wav, .mp3) (0) | 2024.01.16 |
c# 2차원 배열 정렬 방법 (0) | 2024.01.15 |
c# int[,]와 int[][]의 차이점 (0) | 2024.01.11 |
c# NewtonSoft.json 활용 데이터 저장 <interface 데이터 추가> (0) | 2024.01.07 |