private Map2DCyclic <PMNode> MapCreator(string[][] maptext)
    {
        if (maptext == null)
        {
            return(null);
        }
        if (maptext.Length == 0)
        {
            return(null);
        }
        if (maptext[0].Length == 0)
        {
            return(null);
        }

        int sizeX = maptext[0].Length;
        int sizeY = maptext.Length;

        Map2DCyclic <PMNode> map = new Map2DCyclic <PMNode>(sizeX * 2, sizeY);

        for (int x = 0; x < sizeX; x++)
        {
            for (int y = 0; y < sizeY; y++)
            {
                int dx = map.SizeX - x - 1;
                int dy = map.SizeY - y - 1;

                map[x, dy] = GetNode(maptext[y][x]);

                //mirror half
                map[dx, dy] = GetNode(maptext[y][x]);
            }
        }
        return(map);
    }
Beispiel #2
0
    public override void CreateOrRefreshVisualData()
    {
        Map2DCyclic <PMNode> map = GameManager.Instance.Map;

        if (map != null)
        {
            _mapCellVis = new GameObject[map.SizeX * map.SizeY];

            for (int x = 0; x < map.SizeX; x++)
            {
                for (int y = 0; y < map.SizeY; y++)
                {
                    CreateTile(x, y);
                }
            }
        }
    }
Beispiel #3
0
    private GameObject GetTile(int x, int y, TEDouble16 ted16)
    {
        Map2DCyclic <PMNode> map = GameManager.Instance.Map;

        CellType ctype    = map[x, y].CType;
        int      bestTile = 15;

        //Check corners
        if (map[x - 1, y - 1].CType != ctype)
        {
            bestTile &= ~(1 << 0);
        }
        if (map[x + 1, y - 1].CType != ctype)
        {
            bestTile &= ~(1 << 1);
        }
        if (map[x - 1, y + 1].CType != ctype)
        {
            bestTile &= ~(1 << 2);
        }
        if (map[x + 1, y + 1].CType != ctype)
        {
            bestTile &= ~(1 << 3);
        }

        //Check Edges
        if (map[x - 1, y].CType != ctype)
        {
            bestTile &= ~(1 << 0); bestTile &= ~(1 << 2);
        }
        if (map[x + 1, y].CType != ctype)
        {
            bestTile &= ~(1 << 1); bestTile &= ~(1 << 3);
        }
        if (map[x, y - 1].CType != ctype)
        {
            bestTile &= ~(1 << 0); bestTile &= ~(1 << 1);
        }
        if (map[x, y + 1].CType != ctype)
        {
            bestTile &= ~(1 << 2); bestTile &= ~(1 << 3);
        }

        return(ted16.GetTileObject(bestTile));
    }