それで、コンピュータークラス用のテキストアドベンチャーゲームを作ろうとしています。私は C# の基本を知っていますが、コードを正しく理解できないため、明らかに何かが欠けています。男性にプレーヤーに質問をさせたいと思います。プレーヤーがノーと答えた場合、ゲームを続行するにはイエスと答える必要があるため、基本的に質問を繰り返します。for ループを使用してみましたが、うまくいきませんでした。とにかく、これは私が持っているコードです:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("MINECRAFT TEXT ADVENTURE: PART 1!");
Console.WriteLine("\"Hello traveller!\" says a man. \"What's your name?\"");
string playerName = Console.ReadLine();
Console.WriteLine("\"Hi " + playerName + ", welcome to Minecraftia!\nI would give you a tour of our little town but there really isn't much left to\nsee since the attack.\"");
Console.WriteLine("He looks at the stone sword in your hand. \"Could you defeat the zombies in the hills and bring peace to our land?\"");
string answer1 = Console.ReadLine();
if (answer1 == "yes")
{
Console.WriteLine("\"Oh, many thanks to you " + playerName + "!\"");
answerNumber = 2;
}
else if (answer1 == "no")
{
Console.WriteLine("\"Please " + playerName + "! We need your help!\"\n\"Will you help us?\"");
answerNumber = 1;
}
else
{
Console.WriteLine("Pardon me?");
answerNumber = 0;
}
for (int answerNumber = 0; answerNumber < 2;)
{
Console.WriteLine("\"We need your help!\"\n\"Will you help us?\"");
}
}
}
}
アイデアが足りなくなったので、私ができることについての助けや提案をいただければ幸いです。