大神请指点改进方法!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FeiXingGame
{
class Program
{
static void Main(string[] args)
{
showUI();
drawGame(0);
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("请开始游戏........");
Console.WriteLine("请输入用户名:");
string gameA = Console.ReadLine();
while (true)
{
Console.Clear();
Random rD = new Random();
drawGame(rD.Next(1,7));
Console.ReadLine();
}
}
public static void showUI()
{
Console.WriteLine("**************************************************");
Console.WriteLine("* *");
Console.WriteLine("* 飞 行 棋 游 戏 *");
Console.WriteLine("* *");
Console.WriteLine("**************************************************");
}
static int PosA = 0;
public static void drawGame(int gamePlayer)
{
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine(@"图例:""□""表示普通,""☆""表示炸弹,""◆""表示暂停,""◎""表示幸运轮盘");
string[] game = new string[100];
int[] stop = { 3, 27, 45, 92 };//暂停1
int[] lucky = { 5, 35, 66, 88, 99 };//幸运轮盘2
int[] guy = { 4, 65, 34, 57, 87,98 };//炸弹3
int[] change = new int[100];//change控制方格效果
PosA += gamePlayer;
if (PosA >= 100)
{
Console.Clear();
Console.WriteLine("玩家A胜利,游戏结束!");
return;
}
#region 令change制0表普通,制1表暂停,制2表轮盘,制3表炸弹
foreach(int i in stop)
{
change[i] = 1;
}
foreach (int i in lucky)
{
change[i] = 2;
}
foreach (int i in guy)
{
change[i] = 3;
}
#endregion
for (int i = 0; i < 100; i++)
{
switch (change[i])
{
case 0:
Console.ForegroundColor = ConsoleColor.White;
game[i] = "□";
break;
case 1:
Console.ForegroundColor = ConsoleColor.Green;
game[i] = "◆";
break;
case 2:
Console.ForegroundColor = ConsoleColor.Blue;
game[i] = "◎";
break;
case 3:
Console.ForegroundColor = ConsoleColor.Red;
game[i] = "☆";
break;
default:
game[i] = "□";
break;
}
if (PosA == i)
{
game[PosA] = "A";
}
if(i<30)
{
Console.Write(game[i]);
}
else if (i == 30)
{
Console.WriteLine();
for (int j = 0; j < 29; j++)
{
Console.Write(" ");
}
Console.WriteLine(game[i]);
}
else if(i<35)
{
for (int j = 0; j < 29; j++)
{
Console.Write(" ");
}
Console.WriteLine(game[i]);
}
else if (i < 65)
{
if (i == 64)
{
for (int q = 64; q>34;q--)
{
#region 判断颜色
switch (change[q])
{
case 0:
Console.ForegroundColor = ConsoleColor.White;
break;
case 1:
Console.ForegroundColor = ConsoleColor.Green;
break;
case 2:
Console.ForegroundColor = ConsoleColor.Blue;
break;
case 3:
Console.ForegroundColor = ConsoleColor.Red;
break;
default:
break;
}
#endregion
Console.Write(game[q]);
}
}
}
else if (i == 65)
{
Console.WriteLine();
Console.WriteLine(game[i]);
}
else if (i < 70)
{
Console.WriteLine(game[i]);
}
else if (i < 100)
{
if (i == 99)
Console.WriteLine(game[i]);
else
Console.Write(game[i]);
}
}
/* Console.WriteLine();
for (int i = 30; i < 35; i++)
{
for (int j = 0; j < 29; j++)
{
Console.Write(" ");
}
Console.WriteLine(game[i]);
}
for (int i = 64; i > 34; i--)
{
Console.Write(game[i]);
}
Console.WriteLine();
for (int i = 65; i < 70; i++)
{
Console.WriteLine(game[i]);
}
for (int i = 70; i < 100; i++)
{
Console.Write(game[i]);
}
*/
}
}
}
|
|