#region 奥特曼打小怪兽
// Random r = new Random();
//定义奥特曼的数据
//string atmName = "奥特曼";
//int atmHP = 100;
//int atmATK = r.Next(8, 13);
//int atmRate = 30;
定义怪兽的数据
//string monsterName = "小怪兽";
//int monsterHP = 100;
//int monsterATK = r.Next(5, 9);
//int monsterRate = 100;
//每回合奥特曼先动手
//判断有没有命中
//如果命中了
//怪兽血量减去奥特曼的攻击力
//检测怪兽的血量有没有归零
//如果归零
//怪兽死亡,奥特曼胜利
//如果没死
//如果没有每命中
//怪兽攻击奥特曼
//判断有没有命中
//如果命中了
//奥特曼的血量减去怪兽的攻击力
//检测奥特曼有没有被打死
//如果奥特曼死亡,怪兽胜利
//如果没有每命中
//则开始新的回合
//while (true)
//{
// //奥特曼的回合
// Console.ReadKey(true);
// Console.WriteLine("{0}攻击了{1}", atmName, monsterName);
// int num = r.Next(1, 101);
// if (num <= atmRate)//代表奥特曼命中了
// {
// monsterHP -= atmATK;
// Console.WriteLine("{0}的攻击命中了,对{1}造成了{2}伤害,{1}还剩{3}点HP", atmName, monsterName, atmATK, monsterHP);
// if (monsterHP <= 0)//检测怪兽是否死亡
// {
// Console.WriteLine("{0}被残忍杀害,{1}沾满鲜血的双手获得胜利", monsterName, atmName);
// break;
// }
// }
// else
// {
// Console.WriteLine("{0}的攻击落空了", atmName);
// }
// //怪兽回合
// Console.ReadKey(true);
// Console.WriteLine("{0}攻击了{1}", monsterName, atmName);
// num = r.Next(1, 101);
// if (num <= monsterRate)//代表怪兽命中了
// {
// atmHP -= monsterATK;//奥特曼扣血
// Console.WriteLine("{0}的攻击命中了,对{1}造成了{2}伤害,{1}还剩{3}点HP", monsterName, atmName, monsterATK, atmHP);
// if (atmHP <= 0)//检测奥特曼是否死亡
// {
// Console.WriteLine("{0}终于被打败了,{1}的生存得以保证", atmName, monsterName);
// break;
// }
// }
// else
// {
// Console.WriteLine("{0}的攻击落空了", monsterName);
// }
//}
#endregion
#region 移动光标绘制不同的图形
//Console.BackgroundColor = ConsoleColor.Blue;
//Console.Clear();
//Console.ForegroundColor = ConsoleColor.Red;
//Console.WriteLine(" ");
如果在控制台里设置光标的位置
位置 = position
在控制台里,行间距是2个宽度
//int x = 10;
//int y = 5;
//Console.SetCursorPosition(x * 2, y);
//Console.WriteLine("■");
先监听玩家的按键
//int x1 = 10;
//int y1 = 5;
//Console.SetCursorPosition(x1 * 2, y1);
//Console.WriteLine("■");
//while (true)
//{
// Console.CursorVisible = false;
// char input = Console.ReadKey(true).KeyChar;
// switch (input)
// {
// case 'w':
// y -= 1;
// if (y <= 0)
// {
// y = 0;
// }
// break;
// case 's':
// y += 1;
// if (y >= 20)
// {
// y = 39;
// }
// break;
// case 'a':
// x -= 1;
// if (x <= 0)
// {
// x = 0;
// }
// break;
// case 'd':
// x += 1;
// if (x >= 39)
// {
// x = 39;
// }
// break;
// default:
// break;
// }
// //Console.Clear();
// Console.SetCursorPosition(x * 2, y);
// Console.WriteLine("■");
//}
#endregion