for (int i = 0; i < 30; i++)
{
if (playPos[0] == i && playPos[1] == i) 如果我想把这一段写成一个方法怎么写?
{
Console.Write("<>");
}
else if (playPos[0] == i)
{
Console.Write("A");
}
else if (playPos[1] == i)
{
Console.Write("B");
}
else
{
switch(map[i])
{
case 0:
Console.Write("□");
break;
case 1:
Console.Write("◎");
break;
case 2:
Console.Write("●");
break;
case 3:
Console.Write("→");
break;
case 4:
Console.Write("↓");
break;
}
}
}
Console.WriteLine();
for (int i = 30; i < 35;i++)
{
for(int j=1;j<30;j++)
{
Console.Write(" ");
}
if (playPos[0] == i && playPos[1] == i)
{
Console.Write("<>");
}
else if (playPos[0] == i)
{
Console.Write("A");
}
else if (playPos[1] == i)
{
Console.Write("B");
}
else
{
switch (map[i])
{
case 0:
Console.Write("□");
break;
case 1:
Console.Write("◎");
break;
case 2:
Console.Write("●");
break;
case 3:
Console.Write("→");
break;
case 4:
Console.Write("↓");
break;
}
}
Console.Write("\n");
}
for (int i = 64; i >= 35; i--)
{
if (playPos[0] == i && playPos[1] == i)
{
Console.Write("<>");
}
else if (playPos[0] == i)
{
Console.Write("A");
}
else if (playPos[1] == i)
{
Console.Write("B");
}
else
{
switch (map[i])
{
case 0:
Console.Write("□");
break;
case 1:
Console.Write("◎");
break;
case 2:
Console.Write("●");
break;
case 3:
Console.Write("→");
break;
case 4:
Console.Write("↓");
break;
}
}
}
Console.WriteLine();
for (int i = 65; i < 70; i++)
{
if (playPos[0] == i && playPos[1] == i)
{
Console.Write("<>");
}
else if (playPos[0] == i)
{
Console.Write("A");
}
else if (playPos[1] == i)
{
Console.Write("B");
}
else
{
switch (map[i])
{
case 0:
Console.Write("□");
break;
case 1:
Console.Write("◎");
break;
case 2:
Console.Write("●");
break;
case 3:
Console.Write("→");
break;
case 4:
Console.Write("↓");
break;
}
}
Console.WriteLine();
}
for (int i = 70; i < 100; i++)
{
if (playPos[0] == i && playPos[1] == i)
{
Console.Write("<>");
}
else if (playPos[0] == i)
{
Console.Write("A");
}
else if (playPos[1] == i)
{
Console.Write("B");
}
else
{
switch (map[i])
{
case 0:
Console.Write("□");
break;
case 1:
Console.Write("◎");
break;
case 2:
Console.Write("●");
break;
case 3:
Console.Write("→");
break;
case 4:
Console.Write("↓");
break;
}
}
}
|