Beispiel #1
0
        private bool TryFind2By2(BuildingTile a, int xDir, int zDir, out IEnumerable <BuildingTile> tiles)
        {
            var b = GetOrCreateBuildingTile(a, xDir, 0);

            if (b.hasBuilding)
            {
                tiles = null;
                return(false);
            }

            var c = GetOrCreateBuildingTile(a, xDir, zDir);

            if (c.hasBuilding)
            {
                tiles = null;
                return(false);
            }

            var d = GetOrCreateBuildingTile(a, 0, zDir);

            if (d.hasBuilding)
            {
                tiles = null;
                return(false);
            }

            tiles = new[]
            {
                a, b, c, d
            };

            return(true);
        }
Beispiel #2
0
        private void UpdateNearbyTiles(Vector3 coord)
        {
            CurrentTile = tiles.GetOrCreateBuildingTile(coord);

            if (CurrentTile == null)
            {
                return;
            }

            for (var i = -searchNumGrids; i <= searchNumGrids; i++)
            {
                for (var k = -searchNumGrids; k <= searchNumGrids; k++)
                {
                    if (i == 0 && k == 0)
                    {
                        continue;
                    }

                    tiles.GetOrCreateBuildingTile(CurrentTile, i, k);
                }
            }
        }
Beispiel #3
0
        public BuildingTile GetOrCreateBuildingTile(BuildingTile tile, int i, int k)
        {
            var next = tile.bounds.center.FloorToInt() + new Vector3Int(i, 0, k) * gridSize;

            return(GetOrCreateBuildingTile(next));
        }