0

これは私が C# 2010 で作成したゲームですが、[1] 防御力を上げます。

        bool jet = false;


        int userinput;

        Console.WriteLine("Pick your team color, Blue or Green. ");
        string userName = Console.ReadLine();

        if (userName == "blue")
        {
            user.Name = "Blue Fighterjet";
            comp.Name = "Green Fighterjet";
        }

        else
        {
            user.Name = "Green Fighterjet";
            comp.Name = "Blue Fighterjet";
        }

        Console.Clear();

        Console.WriteLine("You are now the {0}.", user.Name);
        Console.ReadLine();

        Console.Clear();

        Console.WriteLine("What do you want to do for your first move?");
        Console.ReadLine();

        while (jet == false)
        {
            Console.Clear();
            Console.WriteLine("Your stats:");
            Console.WriteLine("Health {0} \n Defense {1} \n Attack {2}", user.Health, user.Defense, user.Attack);

            Console.WriteLine("Comp stats:");
            Console.WriteLine("Health {0} \n Defense {2} \n Attack {2}", comp.Health, comp.Defense, comp.Attack);
            Console.ReadLine();

            Console.WriteLine("[1] Increase your Defense.");
            Console.WriteLine("[2] Regain some of your Health.");
            Console.WriteLine("[3] Attack the {0}.", comp.Name);
            userinput = int.Parse(Console.ReadLine());


            if (userinput == 1)
            {
                user.Defense = user.Defense + random.Next(1, 10);

                if (userinput == 1)
                {
                    comp.Attack = comp.Attack - user.Defense + random.Next(1, 10);
                }
            }


            if (userinput == 2)
            {
                user.Health = user.Health + random.Next(1, 10);

                if (userinput == 2)
                {
                    comp.Defense = comp.Defense + random.Next(1, 10);
                }
            }


            if (userinput == 3)
            {
                user.Attack = user.Attack + random.Next(1, 10);

                if (userinput == 3)
                {
                    comp.Health = comp.Health - user.Attack + random.Next(1, 10);
                }
            }
        }
    }
}
class jet
{
    private string name;
    private int health = 100;
    private int defense = 0;
    private int attack = 5;

    public string Name
    {
        get { return name; }
        set { name = value; }
    }

    public int Health
    {
        get
        {
            return health;
        }

        set
        {
            if (value <= 100)
            {
                health = value;
            }
            else
            {
                health = 100;
            }
        }

    }

    public int Defense
    {
        get
        {
            return defense;
        }
        set
        {
            if (value <= 10)
            {
                defense = value;
            }
            else
            {
                defense = 10;
            }
        }
    }

    public int Attack
    {
        get
        {
            return attack;
        }
        set
        {
            if (value <= 5)
            {
                attack = value;
            }
            else
            {
                attack = 5;
            }
        }
    }
}

これを簡単に修正する方法に関するヒントはありますか?

私のユーザー入力は間違っていますか?

4

1 に答える 1