コード例 #1
0
        public static void BindMapView(Grid grid, GridInfo info)
        {
            bool flag = grid != null;

            if (flag)
            {
                foreach (Tilemap tilemap in grid.GetComponentsInChildren <Tilemap>())
                {
                    TileInfos mapInfo = info.GetMapInfo(tilemap.name);
                    bool      flag2   = mapInfo == null;
                    if (!flag2)
                    {
                        tilemap.ClearAllTiles();
                        TileInfosView tileInfosView = new TileInfosView();
                        mapInfo.view          = tileInfosView;
                        tileInfosView.tilemap = tilemap;
                        int        num   = mapInfo.tileIDs.Length;
                        TileBase[] array = new TileBase[num];
                        for (int j = 0; j < num; j++)
                        {
                            array[j] = UnityMap2DUtil.ID2Tile(mapInfo.tileIDs[j]);
                        }
                        tilemap.SetTiles((from t in mapInfo.GetAllPositions()
                                          select t.ToVector3Int()).ToArray <Vector3Int>(), array);
                        bool isPlaying = Application.isPlaying;
                        if (isPlaying)
                        {
                            bool isTagMap = mapInfo.isTagMap;
                            if (isTagMap)
                            {
                                tilemap.GetComponent <TilemapRenderer>().enabled = false;
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        public void SetTileID(int idx, LVector2Int pos, ushort id)
        {
            TileBase tileBase = UnityMap2DUtil.ID2Tile(id);

            this.tilemap.SetTile(new Vector3Int(pos.x, pos.y, 0), tileBase);
        }