예제 #1
0
        public static List <BuildElement> GetConnectedElements(Vector3Int center, List <Vector3Int> directions = null)
        {
            var elements = new List <BuildElement>();

            var validDirections = directions ?? AllDirections;

            if (gameController.GameMode != GameMode.Replace && BuiltElementsStoreController.ContainsKey(center))
            {
                var buildPositionFor = BuiltElementsStoreController.GetElementAtPosition(center).GetComponent <BuildElement>().BuildBaseOn;
                validDirections = ResolveDirectionsValidForBuildBasePosition(buildPositionFor);
            }

            foreach (var direction in validDirections)
            {
                var position = direction + center;

                if (BuiltElementsStoreController.ContainsKey(position))
                {
                    var buildBaseFor = BuiltElementsStoreController.GetElementAtPosition(position).GetComponent <BuildElement>().BuildBaseOn;

                    if (HorizontalDirections.Contains(direction) &&
                        buildBaseFor == BuildPosition.Top)
                    {
                        continue;
                    }

                    elements.Add(BuiltElementsStoreController.GetElementAtPosition(position));
                }
            }

            return(elements);
        }
예제 #2
0
        public static bool IsGroundOrBuiltElementBellow(Vector3 position)
        {
            var positionBellow = position + Vector3.down;

            return(terrainSpawner.IsGroundAtPosition(positionBellow) ||
                   BuiltElementsStoreController.ContainsKey(positionBellow));
        }
예제 #3
0
 public static List <BuildElement> GetSurroundingElements(BuildElement origin)
 {
     return((from direction
             in AllDirections
             select direction + origin.transform.position
             into checkedPosition
             where BuiltElementsStoreController.ContainsKey(checkedPosition)
             select BuiltElementsStoreController.GetElementAtPosition(checkedPosition.ToVector3Int()))
            .ToList());
 }
예제 #4
0
 public static bool ElementBellowIsNotDetached(Vector3 transformPosition)
 {
     return(terrainSpawner.GridMap.ContainsKey(transformPosition.ToVector2IntXZ()) ||
            BuiltElementsStoreController.ContainsKey(transformPosition));
 }