C#をもっと学ぶためにコンソールベースのテキストゲームを作っていますが、今はこだわっていてSOに頼っています。コンソールキー操作が機能していませんか?
これは明らかな答えかもしれませんが、私は私を助けるためにもう一組の目が必要です。私はここで他の質問をチェックして、彼らは私を助けるように見えません。私Main()
で
、私は次のようにあります
int age;
Console.Write("Before entering the unknown, could you please confirm your age? ");
age = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("");
if (age < 18)
{
Console.WriteLine("I'm sorry, you'll now be transferred to a non-explicit version.");
Console.WriteLine("\n<Press any key to continue>");
Console.ReadKey();
Console.Write("\nPlease wait...");
for (int t = 5; t >= 0; t--)
{
Console.CursorLeft = 22;
Console.Write("{0:00}" + " seconds remaining", t);
Thread.Sleep(1000);
}
Console.WriteLine("");
Console.WriteLine("\nTo proceed, please press any key...");
Console.ReadLine();
NonExplicit();
}
自明。それはNonExplicit()
方法を打つたら、次が呼び出されます。
1)それがヒットするように入力が必要です。
char yes = Console.ReadKey().KeyChar;
string name;
Console.WriteLine("\nYou're awake? It's about time. Not old enough, eh? That sucks. \n\nListen, I really need your help. Would you be interested? Y/N");
Console.ReadKey();
if (yes == 'y' || yes == 'Y')
{
Console.Write("\nYou will?! Wow, That's fantastic. Right then, where shall I start? \nI know! How about telling me your name? ");
name = Console.ReadKey().ToString();
Console.WriteLine("\nAhh yes, now you mention it, I certainly remember you, {0}!", name);
}
else
{
Console.WriteLine("\nYou don't want to help me? Oh, that's unfortunate... ");
}
起こるようです何「Y」または「Y」が押されたときに、ということです上記を登録してください。
2)if
& else
WriteLines
が実行されます。これは1)と組み合わせて使用すると仮定していますか?
「y/Y」を押すと、正しい基準が読み取られるように、コードをどのように修正できますか?またはEnterを押して続行する必要性を取り除くにはどうすればよいですか?
'char yes = Console.ReadKey()。KeyChar;'次に 'WriteLine'の後に別の' Console.ReadKey(); '? 2番目の 'ReadKey()'を置き換えるには 'char yes = Console.ReadKey()。KeyChar;'を動かしてみてください。 –