Beispiel #1
0
        public bool HasOutlineOverride()
        {
            var tilemapsRoot    = RoomTemplateUtils.GetTilemapsRoot(gameObject);
            var outlineOverride = tilemapsRoot.transform.Find(GeneratorConstants.OutlineOverrideName);

            return(outlineOverride != null);
        }
Beispiel #2
0
        public void RemoveOutlineOverride()
        {
            if (!HasOutlineOverride())
            {
                return;
            }

            var tilemapsRoot    = RoomTemplateUtils.GetTilemapsRoot(gameObject);
            var outlineOverride = tilemapsRoot.transform.Find(GeneratorConstants.OutlineOverrideName).gameObject;

            PostProcessUtils.Destroy(outlineOverride);
        }
Beispiel #3
0
        /// <summary>
        /// Computes a polygon from points on given tilemaps.
        /// </summary>
        /// <param name="roomTemplate"></param>
        /// <returns></returns>
        public static GridPolygon GetPolygonFromRoomTemplate(GameObject roomTemplate)
        {
            var outlineHandler = roomTemplate.GetComponent <IRoomTemplateOutlineHandler>();

            if (outlineHandler != null)
            {
                var polygon2d = outlineHandler.GetRoomTemplateOutline();
                return(polygon2d?.GetGridPolygon());
            }

            var tilemaps = RoomTemplateUtils.GetTilemaps(roomTemplate);
            var outline  = RoomTemplateUtils.GetTilemapsForOutline(tilemaps);

            return(GetPolygonFromTilemaps(outline));
        }
Beispiel #4
0
        public void AddOutlineOverride()
        {
            if (HasOutlineOverride())
            {
                return;
            }

            var tilemapsRoot    = RoomTemplateUtils.GetTilemapsRoot(gameObject);
            var outlineOverride = new GameObject(GeneratorConstants.OutlineOverrideName);

            outlineOverride.transform.parent = tilemapsRoot.transform;
            outlineOverride.AddComponent <Tilemap>();
            outlineOverride.AddComponent <TilemapRenderer>();
            outlineOverride.AddComponent <OutlineOverride>();
            outlineOverride.GetComponent <TilemapRenderer>().sortingOrder = 1000;
        }
Beispiel #5
0
        /// <summary>
        /// Computes a polygon from points on given tilemaps.
        /// </summary>
        /// <param name="tilemaps"></param>
        /// <returns></returns>
        public static GridPolygon GetPolygonFromTilemaps(ICollection <Tilemap> tilemaps)
        {
            var usedTiles = GetUsedTiles(RoomTemplateUtils.GetTilemapsForOutline(tilemaps));

            return(GetPolygonFromTiles(usedTiles));
        }