标签:
namespace 火影忍者多人对战
{
class Program
{ //创建一个Player的结构体
struct Player
{
public string name;
public int hp;
public int attack;
public int defend;
public int grade;
public JiNeng jineng;
}
//创建一个JiNeng属于Player的子结构体
struct JiNeng
{
public string q;
public string w;
public string e;
public string r;
}
static void Main(string[] args)
{
Console.WriteLine("\t\t**************火影忍者大乱斗*************");
Console.WriteLine("可使用的英雄主要有:(1)日向宁次(2)漩涡鸣人(3)宇智波鼬(4)六道佩恩(5)纲手");
Player wanjia1 = new Player();
Player wanjia2 = new Player();
Random r = new Random();
wanjia1.hp = r.Next(500, 700) + 10000;
wanjia2.hp = r.Next(500, 700) + 10000;
wanjia1.attack = r.Next(100, 200) + 200;
wanjia2.attack = r.Next(100, 200) + 200;
wanjia1.defend = r.Next(50, 100) + 50;
wanjia2.defend = r.Next(50, 100) + 50;
wanjia1.grade = r.Next(1, 18);
wanjia2.grade = r.Next(1, 18);
Console.WriteLine("请第一个玩家选择您想要使用的英雄:");
int a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请第二个玩家选择您想要使用的英雄:");
int b = Convert.ToInt32(Console.ReadLine());
if (a == 1)
{
wanjia1.name = "日向宁次";
wanjia1.jineng.q = "八卦空掌";
wanjia1.jineng.w = "八卦掌·回天";
wanjia1.jineng.e = "白眼";
wanjia1.jineng.r = "八卦六十四掌";
}
else if (a == 2)
{
wanjia1.name = "漩涡鸣人";
wanjia1.jineng.q = "大玉螺旋丸";
wanjia1.jineng.w = "多重影分身术";
wanjia1.jineng.e = "漩涡鸣人2000连弹";
wanjia1.jineng.r = "仙法·风遁螺旋手里剑";
}
else if (a == 3)
{
wanjia1.name = "宇智波鼬";
wanjia1.jineng.q = "幻术·泡沫";
wanjia1.jineng.w = "幻术·月渎";
wanjia1.jineng.e = "万花筒写轮眼";
wanjia1.jineng.r = "瞳术·天照";
}
else if (a == 4)
{
wanjia1.name = "六道佩恩";
wanjia1.jineng.q = "万象天引";
wanjia1.jineng.w = "神罗天征";
wanjia1.jineng.e = "轮回眼";
wanjia1.jineng.r = "地爆天星";
}
else if (a == 5)
{
wanjia1.name = "纲手";
wanjia1.jineng.q = "治疗术";
wanjia1.jineng.w = "崩拳";
wanjia1.jineng.e = "怪力攻击";
wanjia1.jineng.r = "忍法·再生";
}
else
{
Console.WriteLine("请输入正确的选项");
}
if (b == 1)
{
wanjia2.name = "日向宁次";
wanjia2.jineng.q = "八卦空掌";
wanjia2.jineng.w = "八卦掌·回天";
wanjia2.jineng.e = "白眼";
wanjia2.jineng.r = "八卦六十四掌";
}
else if (b == 2)
{
wanjia2.name = "漩涡鸣人";
wanjia2.jineng.q = "大玉螺旋丸";
wanjia2.jineng.w = "多重影分身术";
wanjia2.jineng.e = "漩涡鸣人2000连弹";
wanjia2.jineng.r = "仙法·风遁螺旋手里剑";
}
else if (b == 3)
{
wanjia2.name = "宇智波鼬";
wanjia2.jineng.q = "幻术·泡沫";
wanjia2.jineng.w = "幻术·月渎";
wanjia2.jineng.e = "万花筒写轮眼";
wanjia2.jineng.r = "瞳术·天照";
}
else if (b == 4)
{
wanjia2.name = "六道佩恩";
wanjia2.jineng.q = "万象天引";
wanjia2.jineng.w = "神罗天征";
wanjia2.jineng.e = "轮回眼";
wanjia2.jineng.r = "地爆天星";
}
else if (b == 5)
{
wanjia2.name = "纲手";
wanjia2.jineng.q = "治疗术";
wanjia2.jineng.w = "崩拳";
wanjia2.jineng.e = "怪力攻击";
wanjia2.jineng.r = "忍法·再生";
}
else
{
Console.WriteLine("请输入正确的选项");
}
Console.WriteLine("第一个玩家的名字:"+wanjia1.name+"\t生命值:"+wanjia1.hp+"\t攻击力:"+wanjia1.attack+"\t防御力:"+wanjia1.defend+"\t等级:"+wanjia1.grade);
Console.WriteLine("所使用的技能:" + wanjia1.jineng.q+"\t"+wanjia1.jineng.w+"\t"+wanjia1.jineng.e+"\t"+wanjia1.jineng.r);
Console.WriteLine("第二个玩家的名字:" + wanjia2.name + "\t生命值:" + wanjia2.hp + "\t攻击力:" + wanjia2.attack + "\t防御力:" + wanjia2.defend + "\t等级:" + wanjia2.grade);
Console.WriteLine("所使用的技能:" + wanjia2.jineng.q + "\t" + wanjia2.jineng.w + "\t" + wanjia2.jineng.e + "\t" + wanjia2.jineng.r);
Console.WriteLine("按任意键开始游戏");
Console.ReadKey();
//下面开始进行对战
while (true)
{
//跳出循环的条件
if(wanjia1.hp<=0&&wanjia2.hp<=0)
{
Console.WriteLine("平局");
break;
}
if (wanjia1.hp <= 0)
{
Console.WriteLine(wanjia2.name+"把"+wanjia1.name+"打败。");
break;
}
if (wanjia2.hp <= 0)
{
Console.WriteLine(wanjia1.name + "把" + wanjia2.name + "打败。");
break;
}
if (wanjia2.hp < 0)
{
wanjia2.hp = 0;
}
//玩家1打玩家2
Random m=new Random();
if(m.Next(10)>7)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(wanjia1.name+"使用超大技能"+wanjia1.jineng.r);
wanjia2.hp = wanjia2.hp + wanjia2.defend - wanjia1.attack- m.Next(500, 1000) ;
Console.ForegroundColor = ConsoleColor.Red;
}
else if(m.Next(10)>5&&m.Next(10)<=7)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(wanjia1.name + "使用大技能" + wanjia1.jineng.e);
wanjia2.hp = wanjia2.hp + wanjia2.defend - wanjia1.attack - m.Next(300, 500);
Console.ForegroundColor = ConsoleColor.Red;
}
else if(m.Next(10)>3&&m.Next(10)<=5)
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine(wanjia1.name + "使用无敌技能" + wanjia1.jineng.w);
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(wanjia1.name + "剩余的气血为" + wanjia1.hp);
}
else if (m.Next(10) <= 3)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(wanjia1.name + "使用超小技能" + wanjia1.jineng.q);
wanjia2.hp = wanjia2.hp + wanjia2.defend - wanjia1.attack - m.Next(100, 200);
Console.ForegroundColor = ConsoleColor.Red;
}
else
{
Console.WriteLine(wanjia1.name + "使用普通攻击");
wanjia2.hp = wanjia2.hp + wanjia2.defend - wanjia1.attack;
Console.ForegroundColor = ConsoleColor.Red;
}
if (wanjia2.hp < 0)
{
wanjia2.hp = 0;
}
Console.WriteLine(wanjia2.name + "剩余的气血为" + wanjia2.hp);
//玩家2打玩家1
if (m.Next(10) > 7)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(wanjia2.name + "使用超大技能" + wanjia2.jineng.r);
wanjia1.hp = wanjia1.hp + wanjia1.defend - wanjia2.attack - m.Next(500, 1000);
Console.ForegroundColor = ConsoleColor.Red;
}
else if (m.Next(10) > 5 && m.Next(10) <= 7)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(wanjia2.name + "使用大技能" + wanjia2.jineng.e);
wanjia1.hp = wanjia1.hp + wanjia1.defend - wanjia2.attack - m.Next(300, 500);
Console.ForegroundColor = ConsoleColor.Red;
}
else if (m.Next(10) > 3 && m.Next(10) <= 5)
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine(wanjia2.name + "使用无敌技能" + wanjia2.jineng.w);
Console.ForegroundColor = ConsoleColor.Red;
}
else if (m.Next(10) <= 3)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(wanjia2.name + "使用超小技能" + wanjia2.jineng.q);
wanjia1.hp = wanjia1.hp + wanjia1.defend - wanjia2.attack - m.Next(100, 200);
Console.ForegroundColor = ConsoleColor.Red;
}
else
{
Console.WriteLine(wanjia2.name + "使用普通攻击");
wanjia1.hp = wanjia1.hp + wanjia1.defend - wanjia2.attack;
Console.ForegroundColor = ConsoleColor.Red;
}
if (wanjia1.hp < 0)
{
wanjia1.hp = 0;
}
Console.WriteLine(wanjia1.name + "剩余的气血为" + wanjia1.hp);
Thread.Sleep(500);
} //while的花括号
Console.ReadLine();
}
}
}
标签:
原文地址:http://www.cnblogs.com/lk-kk/p/4415474.html