============================================================================
___________________ _____ __________ ___________ _____
/ _____/\______ \ / _ \ \______ \\__ ___// _ \
\_____ \ | ___// /_\ \ | _/ | | / /_\ \
/ \ | | / | \| | \ | | / | \
/_______ / |____| \____|__ /|____|_ / |____| \____|__ /
\/ \/ \/ \/
________ ____ ___ _______ ________ ___________________ _______
\______ \ | | \\ \ / _____/ \_ _____/\_____ \ \ \
| | \ | | // | \ / \ ___ | __)_ / | \ / | \
| ` \| | // | \\ \_\ \ | \/ | \/ | \
/_______ /|______/ \____|__ / \______ //_______ /\_______ /\____|__ /
\/ \/ \/ \/ \/ \/
============================================================================
Console.WriteLine(string.Format("PRESS ANYKEY TO START").PadLeft(77 - (38- ("PRESS ANYKEY TO START".Length / 2))));
๐ ์ ์ฒด ๋ฌธ์ฅ์ ๊ธธ์ด - (์ ์ฒด ๋ฌธ์ฅ์ ๊ธธ์ด / 2 - (๊ฐ์ด๋ฐ ์ ๋ ฌ ์ํค๋ ค๋ ๋ฌธ์ฅ์ ๊ธธ์ด / 2)))
ex) ์์ ์ฝ๋์ ๊ฒฝ์ฐ, "========="๊ฐ 77๊ฐ ์๊ธฐ ๋๋ฌธ์ ์ ์ฒด ๋ฌธ์ฅ์ ๊ธธ์ด๋ฅผ 77๋ก ์ค์ ํ๋ค.
Console.ReadKey();
Console.ReadKey();๋ฅผ ํตํด ์๋ฌด ํค์ ์ ๋ ฅ์ด ๋ค์ด์ฌ ๊ฒฝ์ฐ, ๋ค์์ผ๋ก ๋์ด๊ฐ ์ ์๋ค.

// ํ๋ ์ด์ด์ ํ๋ ์
๋ ฅ ๋ฐ๊ธฐ
static int getBehavior(int min, int max)
{
int behavior;
bool isNumeric;
// ์๋ชป๋ ์
๋ ฅ ์ ์๋ฌ ๋ฉ์ธ์ง ์ถ๋ ฅ
while (true)
{
Console.WriteLine("\n์ํ์๋ ํ๋์ ์
๋ ฅํด์ฃผ์ธ์.");
Console.Write(">> ");
try
{
isNumeric = int.TryParse(Console.ReadLine(), out behavior); // ์
๋ ฅ ๋ฐ์ ๊ฐ์ด ์ ์ํ int ๊ฐ์ธ์ง ํ์ธํด์ ๋ง์ ๊ฒฝ์ฐ Parse ์์ผ์ฃผ๊ธฐ
if (!isNumeric || CheckValidInput(behavior, min, max) == false)
{ throw new CheckInputException("์๋ชป๋ ์
๋ ฅ์
๋๋ค.\n"); } // ์๋ ๊ฒฝ์ฐ ์๋ฌ ๋ฉ์์ง ์ถ๋ ฅ
else break;
}
catch (CheckInputException ex)
{
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine(ex.Message);
Console.ResetColor();
}
}
return behavior;
}
private static bool CheckValidInput(int behavior, int min, int max)
{
if(behavior >= min && behavior <= max) { return true; }
return false;
}
StartVillage()์์ ํ๋ ์ด์ด ํ๋ ๊ฐ ๋ฐ๊ธฐ
// ํ๋ ์ด์ด์ ํ๋ ๊ฐ ๋ฐ๊ธฐ
switch (getBehavior(0, 5))
{
case 1:
ShowMyStats();
break;
case 2:
ShowMyInventory();
break;
case 3:
ShowShop();
break;
case 4:
EntertheDungeon();
break;
case 5:
GotoInn();
break;
default:
return;
}

static public void LoadItemsFromJson()
{
string json = File.ReadAllText(filePath + "\\Equipment.json");
equipments = JsonConvert.DeserializeObject<Equipment[]>(json)!;
}
๐ ๋ฌธ์ !!!
jsonํ์ผ์ ์ฝ์ ๋, ๋ฐ๋์ json ํ์ผ์ด UTF-8 ์ธ์ฝ๋ฉ์ด ๋์ด ์๋์ง ํ์ธํ์~!
static public void SaveItemsToJson()
{
string json = JsonConvert.SerializeObject(equipments, Newtonsoft.Json.Formatting.Indented);
File.WriteAllText(filePath + "\\Equipment.json", json);
}