using System;
namespace groupwork
{
class MainClass
{
public static void Main(string[] args)
{
string[] map = {
"┌", "─", "─", "─", "┬", "─", "─", "─", "┬", "─", "─", "─", "┬", "─", "┐",
"│", "G", " ", " ", "│", "o", " ", "n", "│", "l", " ", "m", "│", "✝", "│",
"├", "─", "─", "─", "┼", "─", "─", "─", "┼", "─", "─", "─", "┤", " ", "│",
"│", " ", "i", " ", "│", " ", "j", " ", "│", " ", "k", " ", "│", " ", "│",
"│", " ", " ", " ", "│", " ", " ", " ", "│", " ", " ", " ", "│", " ", "│",
"├", "─", "─", "─", "┼", "─", "─", "┬", "┴", "─", "┬", "─", "┴", "─", "┤",
"│", " ", " ", " ", "│", " ", " ", "│", " ", " ", "│", " ", " ", " ", "│",
"│", " ", "h", " ", "│", "g", " ", "│", "f", " ", "│", " ", "e", " ", "│",
"│", " ", " ", " ", "│", " ", " ", "│", " ", " ", "│", " ", " ", " ", "│",
"├", "─", "─", "┬", "┴", "─", "┬", "┴", "─", "─", "┼", "─", "─", "─", "┤",
"│", " ", " ", "│", " ", " ", "│", " ", " ", " ", "│", " ", " ", " ", "│",
"│", "a", " ", "│", "b", " ", "│", " ", "c", " ", "│", " ", "d", " ", "│",
"│", "P", " ", "│", " ", " ", "│", " ", " ", " ", "│", " ", " ", " ", "│",
"└", "─", "─", "┴", "─", "─", "┴", "─", "─", "─", "┴", "─", "─", "─", "┘"};
// キー入力を受け取る->keyInputに格納
Method(map);
while (true)
{
Console.WriteLine("Wで上に、Aで左に、Dで右に、Sで下に動きます。");
// キー入力を受け付ける
string keyInput = Console.ReadLine();
// もし「A」が押されたら、
if (keyInput == "A" || keyInput == "a")
{
int positionP = Array.IndexOf(map, "P");
if (map[positionP - 1] == " ")
{
map[positionP] = " ";
map[positionP - 1] = "P";
}
//bのループ
else if (map[positionP - 1] == "b")
{
map[positionP] = " ";
map[positionP + 17] = "P";
}
//jのループ
else if (map[positionP - 1] == "j")
{
map[positionP] = " ";
map[positionP + 17] = "P";
}
//jのループ
else if (map[positionP - 1] == "o")
{
map[positionP] = " ";
map[positionP + - 3] = "P";
}
//jのループ
else if (map[positionP - 1] == "k")
{
map[positionP] = " ";
map[positionP - 31] = "P";
}
//bのループ
else if (map[positionP - 1] == "g")
{
map[positionP] = " ";
map[positionP + 10] = "P";
}
//ゴール時
else if (map[positionP - 1] == "G")
{
map[positionP] = " ";
map[positionP - 1] = "P";
Console.WriteLine("おめでとうございます。ゴールです。");
break;
}
else
{
Console.WriteLine("壁なので移動できません");
}
Method(map);
}
if (keyInput == "D" || keyInput == "d")
{
int positionP = Array.IndexOf(map, "P");
if (map[positionP + 1] == " ")
{
map[positionP] = " ";
map[positionP + 1] = "P";
}
//eのわーぷ
else if (map[positionP + 1] == "e")
{
map[positionP] = " ";
map[positionP + 12] = "P";
}
//iのわーぷ
else if (map[positionP + 1] == "i")
{
map[positionP] = " ";
map[positionP + 19] = "P";
}
//iのわーぷ
else if (map[positionP + 1] == "m")
{
map[positionP] = " ";
map[positionP - 4] = "P";
}
else
{
Console.WriteLine("壁なので移動できません");
}
Method(map);
}
// もし「W」が押されたら、
if (keyInput == "W" || keyInput == "w")
{
int positionP = Array.IndexOf(map, "P");
if (map[positionP - 15] == " ")
{
map[positionP] = " ";
map[positionP - 15] = "P";
}
if (map[positionP - 15] == "h")
{
map[positionP] = " ";
map[positionP - 60] = "P";
}
else if (map[positionP - 15] == "✝")
{
map[positionP] = " ";
map[positionP + 138] = "P";
Console.WriteLine("ほたるの光 まどの雪 書(ふみ)よむつき日かさねつつ いつしか年もすぎのとを あけてぞけさはわかれゆく");
Console.WriteLine("ゲームオーバー。はじめから");
}
//cのループ
else if (map[positionP - 15] == "c")
{
map[positionP] = " ";
map[positionP + 3] = "P";
}
else
{
Console.WriteLine("壁なので移動できません");
}
Method(map);
}
// もし「S」が押されたら、
if (keyInput == "S" || keyInput == "s")
{
int positionP = Array.IndexOf(map, "P");
if (map[positionP + 15] == " ")
{
map[positionP] = " ";
map[positionP + 15] = "P";
}
//もし↓が押されたら
else if (map[positionP + 15] == "a")
{
map[positionP] = " ";
map[positionP + 33] = "P";
}
//もし↓が押されたら
else if (map[positionP + 15] == "f")
{
map[positionP] = " ";
map[positionP + 27] = "P";
}
//dのループ
else if (map[positionP + 15] == "d")
{
map[positionP] = " ";
map[positionP - 30] = "P";
}
else if (map[positionP + 15] == "b")
{
map[positionP] = " ";
map[positionP - 135] = "P";
}
else
{
Console.WriteLine("壁なので移動できません");
}
Method(map);
}
}
}
static void Method(string[] map)
{
for (int i = 0; i < 210; i++)
{
if ((i + 1) % 15 == 0)
{
Console.WriteLine(map[i]);
}
else
{
Console.Write(map[i]);
}
}
}
}
}
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
22