第一代,不是很完善,会在后续增加更多的功能
主:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace 对战游戏
{
class Program
{
static void Main(string[] args)
{
Random r = new Random(); Soldier s1 = new Soldier(); Console.Write("请输入角色名:");
s1.Name = Console.ReadLine();
s1.Attack = r.Next(, );
s1.Blood = r.Next(, );
zhaoshi z1 = new zhaoshi();
Console.Write("请输入技能1名称:");
z1.Name = Console.ReadLine();
z1.Attack= r.Next(, );
s1.Skill = z1;
zhaoshi z2 = new zhaoshi();
Console.Write("请输入技能2名称:");
z2.Name1 = Console.ReadLine();
z2.Attack1 = r.Next(, );
s1.Skill1 = z2;
zhaoshi z3 = new zhaoshi();
Console.Write("请输入必杀技名称:");
z3.Name = Console.ReadLine();
z3.Attack = r.Next(, );
s1.Slay= z3;
//闪避
s1.Miss = r.Next(, );
//格挡
s1.block = r.Next(, ); Soldier s2 = new Soldier();
Console.Write("请输入角色名:");
s2.Name = Console.ReadLine();
s2.Attack = r.Next(, );
s2.Blood = r.Next(, );
zhaoshi z4 = new zhaoshi();
Console.Write("请输入技能1名称:");
z4.Name = Console.ReadLine();
z4.Attack = r.Next(, );
s2.Skill = z4;
zhaoshi z5 = new zhaoshi();
Console.Write("请输入技能2名称:");
z5.Name1 = Console.ReadLine();
z5.Attack1 = r.Next(, );
s2.Skill1 = z5;
zhaoshi z6 = new zhaoshi();
Console.Write("请输入必杀技名称:");
z6.Name = Console.ReadLine();
z6.Attack = r.Next(, );
s2.Slay = z6; s2.Miss = r.Next(, );
s2.block = r.Next(, ); Console.WriteLine("============================================战士信息展示=============================================");
Console.WriteLine("战士1:" + s1.Name + ",攻击:" + s1.Attack + ",闪避:" + s1.Miss + ",格挡:" + s1.block + ", 血量:" + s1.Blood + ",技能1:" + s1.Skill.Name + "," + s1.Skill.Attack + ",技能2:" + s1.Skill1.Name1 + "," + s1.Skill1.Attack1 + ",必杀技:" + s1.Slay.Name + "," + s1.Slay.Attack);
Console.WriteLine("战士2:" + s2.Name + ",攻击:" + s2.Attack + ",闪避:" + s2.Miss + ",格挡:" + s1.block + ",血量:" + s2.Blood + ",技能1:" + s2.Skill.Name + "," + s2.Skill.Attack + ",技能2:" + s2.Skill1.Name1 + "," + s2.Skill1.Attack1 + ",必杀技:" + s2.Slay.Name + "," + s2.Slay.Attack);
Console.WriteLine("按下任意键开始战斗!!!");
Console.ReadKey(); int count = ;
while (true)
{
Console.WriteLine("==========================第" + count + "回合==========================");
System.Threading.Thread.Sleep(); if (r.Next(, ) < s2.Miss)
{
Console.WriteLine(s2.Name + "躲避了此次攻击!!!");
}
else
{
if (r.Next(, ) < s2.block)
{
{
Console.WriteLine(s2.Name + "格挡了此次攻击!!!");
}
}
else
{
int ss1 = r.Next(, ); if (ss1 > )//开大招
{
Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("【" + s1.Name + "】对【" + s2.Name + "】释放了★★★★★▄︻┻═┳一" + s1.Slay.Name + "★★★★★,造成" + s1.Slay.Attack + "点伤害,【" + s2.Name + "】剩余" + (s2.Blood - s1.Slay.Attack) + "点血量");
Console.WriteLine();
//S2扣血
s2.Blood -= s1.Slay.Attack;
}
else if (ss1 >= && ss1 <= )//开小招
{
int ss3 = r.Next(, ); if (ss3 >= && ss3 < )
{
Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("【" + s1.Name + "】对【" + s2.Name + "】释放了☆☆☆" + s1.Skill.Name + "☆☆☆,造成" + s1.Skill.Attack + "点伤害,【" + s2.Name + "】剩余" + (s2.Blood - s1.Skill.Attack) + "点血量");
Console.WriteLine();
//S2扣血
s2.Blood -= s1.Skill.Attack;
}
else
{
Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("【" + s1.Name + "】对【" + s2.Name + "】释放了☆☆☆" + s1.Skill1.Name1 + "☆☆☆,造成" + s1.Skill1.Attack1 + "点伤害,【" + s2.Name + "】剩余" + (s2.Blood - s1.Skill1.Attack1) + "点血量");
Console.WriteLine();
//S2扣血
s2.Blood -= s1.Skill.Attack;
}
}
else//普通攻击
{
Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("【" + s1.Name + "】攻击了【" + s2.Name + "】,造成" + s1.Attack + "点伤害,【" + s2.Name + "】剩余" + (s2.Blood - s1.Attack) + "点血量");
Console.WriteLine();
//S2扣血
s2.Blood -= s1.Attack;
} //判断战士2是否阵亡
if (s2.Blood <= )
{
Console.WriteLine("【" + s2.Name + "】已阵亡!【" + s1.Name + "】是获胜者!!!");
break;
}
}
//战士2开始攻击 System.Threading.Thread.Sleep(); if (r.Next(, ) < s1.Miss)
{
Console.WriteLine(s1.Name + "躲避了此次攻击!!!");
}
else
{
if (r.Next(, ) < s1.block)
{
{
Console.WriteLine(s1.Name + "格挡了此次攻击!!!");
}
}
else
{
int ss2 = r.Next(, ); if (ss2 > )//开大招
{
Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("【" + s2.Name + "】对【" + s1.Name + "】释放了★★★★★▄︻┻═┳一" + s2.Slay.Name + "★★★★★,造成" + s2.Slay.Attack + "点伤害,【" + s1.Name + "】剩余" + (s1.Blood - s2.Slay.Attack) + "点血量");
Console.WriteLine();
//S2扣血
s1.Blood -= s2.Slay.Attack;
}
else if (ss2 >= && ss2 <= )//开小招
{
int ss4 = r.Next(, );
if (ss4 >= && ss4 < )
{
Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("【" + s2.Name + "】对【" + s1.Name + "】释放了☆☆☆" + s2.Skill.Name + "☆☆☆,造成" + s2.Skill.Attack + "点伤害,【" + s1.Name + "】剩余" + (s1.Blood - s2.Skill.Attack) + "点血量");
Console.WriteLine();
//S2扣血
s1.Blood -= s2.Skill.Attack;
}
else
{
Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("【" + s2.Name + "】对【" + s1.Name + "】释放了☆☆☆" + s2.Skill1.Name1 + "☆☆☆,造成" + s2.Skill1.Attack1 + "点伤害,【" + s1.Name + "】剩余" + (s1.Blood - s2.Skill1.Attack1) + "点血量");
Console.WriteLine();
//S2扣血
s1.Blood -= s2.Skill.Attack;
}
}
else//普通攻击
{
Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("【" + s2.Name + "】攻击了【" + s1.Name + "】,造成" + s2.Attack + "点伤害,【" + s1.Name + "】剩余" + (s1.Blood - s2.Attack) + "点血量");
Console.WriteLine();
//S2扣血
s1.Blood -= s2.Attack;
}
if (s1.Blood <= )
{
Console.WriteLine("【" + s1.Name + "】已阵亡!【" + s2.Name + "】是获胜者!!!");
break;
}
}
}
} count++;
}
Console.ReadKey(); }
}
}
辅:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace 对战游戏
{
class zhaoshi
{
private string name; /// <summary>
/// 招式名称
/// </summary>
public string Name
{
get { return name; }
set { name = value; }
} private string name1; /// <summary>
/// 招式名称
/// </summary>
public string Name1
{
get { return name1; }
set { name1 = value; }
} private int attack; /// <summary>
/// 招式攻击
/// </summary>
public int Attack
{
get { return attack; }
set { attack = value; }
} private int attack1; /// <summary>
/// 招式攻击
/// </summary>
public int Attack1
{
get { return attack1; }
set { attack1 = value; }
} }
}
技能
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace 对战游戏
{
class Soldier
{
//名字
private string name; public string Name
{
get { return name; }
set { name = value; }
}
//血量
private int blood; public int Blood
{
get { return blood; }
set { blood = value; }
}
//攻击力
private int attack; public int Attack
{
get { return attack; }
set { attack = value; }
}
//技能
private zhaoshi skill; public zhaoshi Skill
{
get { return skill; }
set { skill = value; }
} private zhaoshi skill1; public zhaoshi Skill1
{
get { return skill1; }
set { skill1 = value; }
}
//必杀技
private zhaoshi slay; internal zhaoshi Slay
{
get { return slay; }
set { slay = value; }
}
//闪避
private int miss; public int Miss
{
get { return miss; }
set { miss = value; }
}
//暴击
private int critical; public int Critical
{
get { return critical; }
set { critical = value; }
}
//格挡
private int Block; public int block
{
get { return Block; }
set { Block = value; }
} }
}
人物属性
内容截图: