小编Tor*_*giu的帖子

在C#中将char更改为int或字符串

我对C#Sharp非常陌生,可能无法很好地提出这个问题,但是可以解决。

我目前正在生成一个包含更多游戏对象的关卡。通过解析文本文件(这是我的字典)来生成地图。目前,由于char声明,如果对象的索引未超过9,则我拥有的代码可以完美运行。

我想知道一种如何将其更改为int或字符串格式(AZ)的方法。我附上了我当前的“地图生成器”的照片,并突出显示了10,目前被读取为1和0。在此处输入图片说明

private void CreateLevel() {

    Tiles = new Dictionary<Point, TileScript>();

    string[] mapData = ReadLevelText();

    int mapX = mapData[0].ToCharArray().Length;
    int mapY = mapData.Length;

    Vector3 maxTile = Vector3.zero;

    // Calculates the world start point, this is the top left corner of the screen, rememeber to use on the sprite the top left pivot point
    Vector3 worldStart = Camera.main.ScreenToWorldPoint(new Vector3(0, Screen.height));

    for (int y = 0; y < mapY; y++) // the Y position
    {

        char[] newTiles = mapData[y].ToCharArray();

        for (int …
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine

1
推荐指数
1
解决办法
99
查看次数

标签 统计

c# ×1

unity-game-engine ×1