Instantly share code, notes, and snippets.

@MuoTK /宝探し.cs
Last active Aug 29, 2015

Embed
What would you like to do?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Treasure_Quest
{
class Program
{
static void Main(string[] args)
{
char[] title = { 'T', 'r', 'e', 'a', 's', 'u', 'r', 'e', ' ', 'Q', 'u', 'e', 's', 't' }; //13
string subtitle = "Treasure Quest";
string[] mess1 = {"エレベーターに挟まれる", "階段から落ちた", "バスジャックされた", "電車に乗り遅れた" ,"自転車盗まれた" ,"女の子から平手打ち" ,"百円なくした",
"携帯の画面が割れた", "コーヒーをこぼした", "やけどした", "彼女に振られた", "PCが壊れた", "箪笥で小指をぶつけた", "海でおぼれた", "母親に0点テストが見つかった",
"車にひかれた", "親父の雷が落ちた", "こけた", "クラゲにさされた", "猫にひっかかれた", "犬にかまれた"};
string[] mess2 = { "隕石がおちた", "リストラされた", "アカウントが消えた", "携帯をなくした", "家が倒壊した" };
string[] mess3 = { "お小遣いをもらった", "ジラーチが願いをかなえてくれた", "お年玉が増えた", "弁当を食べた" };
string speace = " ";
//string sspe = "  ";
string message = "";
int rand;
string dmg = "";
Console.Write("\n\n" + speace);
for (int i = 0; i < title.Length; i++)
{
Console.Write(title[i]);
//System.Threading.Thread.Sleep(200);
}
System.Threading.Thread.Sleep(700);
Console.WriteLine("\n\n\n\n" + speace + speace + speace + speace + "");
Console.ReadLine();
Console.Clear();
Console.WriteLine(subtitle);
string name;
while (true)
{
Console.WriteLine("\n\n\nプレイヤー名を入力してください ▼");
Console.Write("名前:");
name = Console.ReadLine();
Console.WriteLine("\n" + name + " でよろしいですか? [Y/N]");
string ans1 = Console.ReadLine();
//name = Console.ReadLine();
//Console.WriteLine("Y or N でお答えください。");
//Console.WriteLine("\n" + name + " でよろしいですか? [Y/N]");
//ans1 = Console.ReadLine();
if (ans1 == "y" || ans1 == "Y")
{
break;
//Console.Clear();
Console.WriteLine(subtitle);
}
else if (ans1 == "n" || ans1 == "N")
{
Console.Clear();
Console.WriteLine(subtitle);
}
}
Console.WriteLine("\nようこそ、" + name + "様! ▼");
Console.ReadLine();
Console.Clear();
Console.WriteLine(subtitle + "\n");
Console.WriteLine("これからゲームの説明を軽くしていきます。 ▼");
Console.ReadLine();
Console.Clear();
char[,] ground =
{
{' ' , '一' , '二', '三', '四' , '五' , '六', '七' , '八', '九', '十'},
{'一' , '■' , '■', '■', '■' , '■' , '■', '■' , '■', '■', '■'},
{'二' , '■' , '■', '■', '■' , '■' , '■', '■' , '■', '■', '■'},
{'三' , '■' , '■', '■', '■' , '■' , '■', '■' , '■', '■', '■'},
{'四' , '■' , '■', '■', '■' , '■' , '■', '■' , '■', '■', '■'},
{'五' , '■' , '■', '■', '■' , '■' , '■', '■' , '■', '■', '■'},
{'六' , '■' , '■', '■', '■' , '■' , '■', '■' , '■', '■', '■'},
{'七' , '■' , '■', '■', '■' , '■' , '■', '■' , '■', '■', '■'},
{'八' , '■' , '■', '■', '■' , '■' , '■', '■' , '■', '■', '■'},
{'九' , '■' , '■', '■', '■' , '■' , '■', '■' , '■', '■', '■'},
{'十' , '■' , '■', '■', '■' , '■' , '■', '■' , '■', '■', '■'}
};
Random random = new Random();
int takara_row = random.Next(1, 10);
int takara_column = random.Next(1, 10);
int row;
int column;
int hazure_row;
int hazure_column;
int kaihuku1_row;
int kaihuku1_column;
int kaihuku2_row;
int kaihuku2_column;
int stam = 100;
while (true)
{
hazure_row = random.Next(1, 10);
hazure_column = random.Next(1, 10);
if (takara_row - 1 <= hazure_row && hazure_row <= takara_row + 1 &&
takara_column - 1 <= hazure_column && hazure_column <= takara_column + 1)
{
continue;
}
else
{
break;
}
}
while (true)
{
kaihuku1_row = random.Next(1, 10);
kaihuku1_column = random.Next(1, 10);
if (takara_row - 1 <= kaihuku1_row && kaihuku1_row <= takara_row + 1 &&
takara_column - 1 <= kaihuku1_column && kaihuku1_column <= takara_column ||
hazure_row - 1 <= kaihuku1_row && kaihuku1_row <= hazure_row + 1 &&
hazure_column - 1 <= kaihuku1_column && kaihuku1_column <= hazure_column)
{
continue;
}
else
{
break;
}
}
while (true)
{
kaihuku2_row = random.Next(1, 10);
kaihuku2_column = random.Next(1, 10);
if (takara_row - 1 <= kaihuku2_row && kaihuku2_row <= takara_row + 1 &&
takara_column - 1 <= kaihuku2_column && kaihuku2_column <= takara_column ||
hazure_row - 1 <= kaihuku2_row && kaihuku2_row <= hazure_row + 1 &&
hazure_column - 1 <= kaihuku2_column && kaihuku2_column <= hazure_column ||
kaihuku1_row == kaihuku2_row && kaihuku1_column == kaihuku2_column)
{
continue;
}
else
{
break;
}
}
Console.WriteLine(subtitle);
Console.Write("\n");
for (int i = 0; i < 11;
i++)
{
for (int j = 0; j < 11; j++)
{
Console.Write(ground[i, j]);
}
Console.WriteLine();
}
Console.WriteLine("" + takara_row + "" + takara_column);
Console.WriteLine("" + kaihuku1_row + "" + kaihuku1_column + "//" + kaihuku2_row + "" + kaihuku2_column);
Console.WriteLine("×" + hazure_row + "" + hazure_column);
do
{
Console.WriteLine("\n--------------------------------");
Console.WriteLine("\nName: " + name);
Console.WriteLine("HP: " + stam);
Console.WriteLine(message + "" + dmg); //効果
Console.WriteLine("地面を掘ります。行と列を指定してください。");
Console.Write("行:");
row = int.Parse(Console.ReadLine());
Console.Write("列:");
column = int.Parse(Console.ReadLine());
if (takara_row - 1 <= row && row <= takara_row + 1 &&
takara_column - 1 <= column && column <= takara_column + 1 ||
hazure_row - 1 <= row && row <= hazure_row + 1 &&
hazure_column - 1 <= column && column <= hazure_column + 1)
{
ground[row, column] = '近';
if (row == takara_row && column == takara_column)
{
ground[row, column] = '宝';
}
else if (row == hazure_row && column == hazure_column)
{
ground[row, column] = '×';
stam -= 50;
rand = random.Next(mess2.Length);
message = mess2[rand];
dmg = "50 のダメージをうけた!";
}
}
else if (row == kaihuku1_row && column == kaihuku1_column)
{
ground[row, column] = '復';
stam += 40;
rand = random.Next(mess3.Length);
message = mess3[rand];
dmg = "HPが 40 回復した!";
}
else if (row == kaihuku2_row && column == kaihuku2_column)
{
ground[row, column] = '復';
stam += 40;
rand = random.Next(mess3.Length);
message = mess3[rand];
dmg = "HPが 40 回復した!";
}
else
{
if (stam > 100)
{
ground[row, column] = '5';
stam -= 5;
dmg = "5 のダメージをうけた!";
}
else
{
ground[row, column] = '1';
stam -= 100;
dmg = "1 のダメージをうけた!";
}
rand = random.Next(mess1.Length);
message = mess1[rand];
}
Console.Clear();
Console.WriteLine(subtitle);
Console.Write("\n");
if (stam <= 0)
{
Console.Clear();
Console.WriteLine(subtitle + "\n");
Console.WriteLine(speace + speace + speace + "Game Over...");
Console.ReadLine();
return;
}
else
{
for (int i = 0; i < 11; i++)
{
for (int j = 0; j < 11; j++)
{
Console.Write(ground[i, j]);
}
Console.WriteLine();
}
}
Console.WriteLine("" + takara_row + "" + takara_column);
Console.WriteLine("" + kaihuku1_row + "" + kaihuku1_column + "//" + kaihuku2_row + "" + kaihuku2_column);
Console.WriteLine("×" + hazure_row + "" + hazure_column);
} while (row != takara_row || column != takara_column);
Console.Clear();
Console.WriteLine(subtitle + "\n");
Console.WriteLine(speace + speace + speace + "GAME CLEAR");
Console.WriteLine(speace + speace + speace + "o゚*。o");
Console.WriteLine(speace + speace + speace + "      /⌒ヽ*゚*");
Console.WriteLine(speace + speace + speace + "  ∧∧ /ヽ  )。*o");
Console.WriteLine(speace + speace + speace + " (・ω・)丿゙ ̄ ̄゜");
Console.WriteLine(speace + speace + speace + "ノ/ /    ッパ");
Console.WriteLine(speace + speace + speace + "ノ ̄ゝ");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment