Esempio n. 1
0
        private Dictionary <Vector3d, ITileStorer> GetNonCollidingStorableTiles(bool useArea, List <AreaMeta> allAreas, AreaMeta area, bool useExtraArea, AreaMeta extraArea, ITileMeta tileMeta)
        {
            var storableTiles = new Dictionary <Vector3d, ITileStorer>();

            if (!useArea)
            {
                return(storableTiles);
            }

            var nonCollidingTiles = TileUtil.NonCollidingTiles(area, allAreas, extraArea, useExtraArea).ToList();

            foreach (var tile in nonCollidingTiles)
            {
                var tile3d     = new Vector3d(tile.x, tile.y, 19);
                var tileStorer = tileStorers.Find(ts => ts.CanStoreTile(tile3d, tileMeta));
                if (tileStorer == null)
                {
                    Debug.LogError("Cannot find valid storer for tile " + tile3d);
                    return(null);
                }

                storableTiles.Add(tile3d, tileStorer);
            }

            return(storableTiles);
        }
        public static IEnumerable <Vector2d> NonCollidingTiles(AreaMeta area, IEnumerable <AreaMeta> allAreas, AreaMeta extraArea, bool useExtraArea)
        {
            // But not everything has to be removed so we get the limits relevant to the old gameplayArea considering
            var possibleCollidingAreas = allAreas;

            // If we use the extra area we add it to the set
            if (useExtraArea)
            {
                possibleCollidingAreas = possibleCollidingAreas.Union(new[] { extraArea });
            }

            // And finally we get the relevant limits (only overlapping limits)
            var limitsToConsiderBeforeRemoving = GetLimitsRelevantTo(possibleCollidingAreas, area).ToArray();

            // And finally we iterate over the limits where the tile is not contained in any limit
            foreach (var tile in TileUtil.Tiles(area.Limits).Where(t => !limitsToConsiderBeforeRemoving.Any(l => l.Contains(t))))
            {
                yield return(tile);
            }
        }