标签:iss amp .text str public value console rand void
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("请输入P1角色名:"); s1.Name = Console.ReadLine(); s1.Attack = r.Next(10, 101); s1.Blood = r.Next(2000, 3501); zhaoshi z1 = new zhaoshi(); Console.Write("请输入技能1名称:"); z1.Name = Console.ReadLine(); z1.Attack = r.Next(100, 201); s1.Skill = z1; zhaoshi z2 = new zhaoshi(); Console.Write("请输入技能2名称:"); z2.Name1 = Console.ReadLine(); z2.Attack1 = r.Next(150, 250); s1.Skill1 = z2; zhaoshi z3 = new zhaoshi(); Console.Write("请输入必杀技名称:"); z3.Name = Console.ReadLine(); z3.Attack = r.Next(1050, 1501); s1.Slay = z3; //闪避 s1.Miss = r.Next(0, 20); //格挡 s1.block = r.Next(0, 50); Soldier s2 = new Soldier(); Console.Write("请输入P2角色名:"); s2.Name = Console.ReadLine(); s2.Attack = r.Next(10, 101); s2.Blood = r.Next(2000, 3501); zhaoshi z4 = new zhaoshi(); Console.Write("请输入技能1名称:"); z4.Name = Console.ReadLine(); z4.Attack = r.Next(100, 201); s2.Skill = z4; zhaoshi z5 = new zhaoshi(); Console.Write("请输入技能2名称:"); z5.Name1 = Console.ReadLine(); z5.Attack1 = r.Next(150, 250); s2.Skill1 = z5; zhaoshi z6 = new zhaoshi(); Console.Write("请输入必杀技名称:"); z6.Name = Console.ReadLine(); z6.Attack = r.Next(1050, 1501); s2.Slay = z6; s2.Miss = r.Next(0, 20); s2.block = r.Next(0, 50); 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 = 1; while (true) { Console.WriteLine("==========================第" + count + "回合=========================="); System.Threading.Thread.Sleep(1500); if (r.Next(0, 101) < s2.Miss) { Console.WriteLine(s2.Name + "躲避了此次攻击!!!"); } else { if (r.Next(0, 101) < s2.block) { { Console.WriteLine(s2.Name + "格挡了此次攻击!!!"); } } else { int ss1 = r.Next(0, 100); if (ss1 > 90)//开大招 { 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 >= 70 && ss1 <= 90)//开小招 { int ss3 = r.Next(0, 100); if (ss3 >= 0 && ss3 < 50) { 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 <= 0) { Console.WriteLine("【" + s2.Name + "】已阵亡!【" + s1.Name + "】是获胜者!!!"); break; } } //战士2开始攻击 System.Threading.Thread.Sleep(1500); if (r.Next(0, 101) < s1.Miss) { Console.WriteLine(s1.Name + "躲避了此次攻击!!!"); } else { if (r.Next(0, 101) < s1.block) { { Console.WriteLine(s1.Name + "格挡了此次攻击!!!"); } } else { int ss2 = r.Next(0, 100); if (ss2 > 90)//开大招 { 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 >= 70 && ss2 <= 90)//开小招 { int ss4 = r.Next(0, 100); if (ss4 >= 0 && ss4 < 50) { 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 <= 0) { 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; } } } }
标签:iss amp .text str public value console rand void
原文地址:http://www.cnblogs.com/1030351096zzz/p/6107069.html