/// <summary>
/// 二维向量结构体
/// </summary>
struct Vector2 {
public int x;
public int y;
}
/// <summary>
/// 游戏物体类型枚举
/// </summary>
enum GameObjectType {
Player = 0,
Normal ,
Torpedo ,//地雷
Tube ,//隧道
Pause, // 暂停
Roulette //轮盘
}
/// <summary>
/// 游戏物体结构体
/// </summary>
struct GameObject {
public Vector2 position;
public Vector2 size;
public string icon;
public GameObjectType type;
/// <summary>
/// 画游戏物体
/// </summary>
■□△▽○◇□☆▲▼●◆■★◎卍×☒
public void Draw() {
Console.SetCursorPosition(position.x * 2, position.y);
Console.Write(icon);
}
/// <summary>
/// 根据游戏物体类型设置图标
/// </summary>
public void SetIcon() {
switch (type)
{
case GameObjectType.Player:
icon = "★";
break;
case GameObjectType.Normal:
icon = "■";
break;
case GameObjectType.Torpedo:
icon = "▲";
break;
case GameObjectType.Tube:
icon = "◎";
break;
case GameObjectType.Pause:
icon = "×";
break;
case GameObjectType.Roulette:
icon = "卍";
break;
default:
break;
}
}
}
/// <summary>
/// 地图结构体
/// </summary>
struct Map {
public static int index;
public int length;
public GameObject[] mapData;
/// <summary>
/// 获取地图长度
/// </summary>
/// <param name="loopCount"></param>
void GetMapLength(int loopCount) {
for (int i = 0; i < loopCount; i++)
{
if (i % 4 == 0)
{
length += 10;
}
else if (i % 4 == 1)
{
length += 5;
}
else if ((i
C#控制台飞行棋(自定义地图长度,代码中已实现该功能只需要稍作改动即可)
最新推荐文章于 2022-02-04 17:54:30 发布