Если пользователь хочет сыграть 2 игроков, ему нужно сразиться друг с другом, и я не знаю, как мне это удастся, пожалуйста, помогите мне
class Program
{
static void Main(string[] args)
{
Character n = new Character();
Console.WriteLine("Welcome to Fight Game\n\n");
//User starts with choose if he/she wants to play 1 or 2 player
string answer = Functionality.Select(new string[] { "1 Player", "2 Player" });
Console.Clear();
Я хочу, если пользователь выберет 1 игрок и пользователь выбрали персонажа, с которым он должен сражаться против случайно сгенерированного персонажа.
//If user choosed 1player user will play against a random character that program has choosed
if (answer == "1 Player")
{
string character = Functionality.Select(new string[] { "Orc Lord", "Elf Lord", "Human Lord", "Dog Lord", "Cat Lord" });
switch (character)
{
case "Orc Lord":
n.OrcLord();
break;
case "Elf Lord":
n.ElfLord();
break;
case "Human Lord":
n.HumanLord();
break;
case "Dog Lord":
n.DogLord();
break;
case "Cat Lord":
n.CatLord();
break;
}
//Start of random character for robot
Random rnd = new Random();
string[] BotChar = { "Orc Lord", "Elf Lord", "Human Lord", "Dog Lord", "Cat Lord" };
int BotIndex = rnd.Next(BotChar.Length);
Console.WriteLine("Robot character: {0}", BotChar[BotIndex]);
}
//if user choosed 2 player that means it is 2 humans play against each other
if(answer == "2 Player")
{
Console.WriteLine("Player 1: ");
//This is code so user can choose different characters with arrow keys
string character = Functionality.Select(new string[] { "Orc Lord", "Elf Lord", "Human Lord", "Dog Lord", "Cat Lord" });
//switch case about diiferent characters
switch(character)
{
case "Orc Lord":
n.OrcLord();
break;
case "Elf Lord":
n.ElfLord();
break;
case "Human Lord":
n.HumanLord();
break;
case "Dog Lord":
n.DogLord();
break;
case "Cat Lord":
n.CatLord();
break;
}
Console.WriteLine("\nPlayer 2: ");
string character1 = Functionality.Select(new string[] { "Orc Lord", "Elf Lord", "Human Lord", "Dog Lord", "Cat Lord" });
switch (character1)
{
case "Orc Lord":
n.OrcLord();
break;
case "Elf Lord":
n.ElfLord();
break;
case "Human Lord":
n.HumanLord();
break;
case "Dog Lord":
n.DogLord();
break;
case "Cat Lord":
n.CatLord();
break;
}
Console.ReadKey();
Console.Clear();
if(character == "Orc Lord")
{
int hp = Character.hp;
int hit = Character.MaxHit;
}
}
Console.ReadLine();
}
}
Когда 1 игрок выбирает персонажа в этом классе, а 2 игрока - тоже. Я хочу, чтобы два персонажа сражались. Но я не знаю, как это сделать.
//Character class
class Character
{
//Specs about OrcLord character
public static int hp = 100;
public static int MaxHit = 20;
public void OrcLord()
{
Console.WriteLine("\nhp: " + hp + "\nstrenght: " + MaxHit + "\n");
}
//specs about other characters
public void ElfLord()
{
int hp = 100;
int str = 10;
Console.WriteLine("\nhp: " + hp + "\nstrenght: " + str + "\n");
}
public void HumanLord()
{
int hp = 100;
int str = 8;
Console.WriteLine("\nhp: " + hp + "\nstrenght: " + str + "\n");
}
public void DogLord()
{
int hp = 100;
int str = 11;
Console.WriteLine("\nhp: " + hp + "\nstrenght: " + str + "\n");
}
public void CatLord()
{
int hp = 100;
int str = 6;
Console.WriteLine("\nhp: " + hp + "\nstrenght: " + str + "\n");
}
}
Если вы можете мне помочь, это будет большая помощь.