Exemple #1
0
        public static HorizontalDirections GetOppositeHorizontalDirection(HorizontalDirections dir)
        {
            HorizontalDirections result = HorizontalDirections.Left;

            switch (dir)
            {
            case HorizontalDirections.Left:
                result = HorizontalDirections.Right;
                break;

            case HorizontalDirections.Right:
                result = HorizontalDirections.Left;
                break;

            case HorizontalDirections.Top:
                result = HorizontalDirections.Bottom;
                break;

            case HorizontalDirections.Bottom:
                result = HorizontalDirections.Top;
                break;
            }

            return(result);
        }
Exemple #2
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);
        }
Exemple #3
0
 public void Reset()
 {
     Origin = Origins.NotDefined;
     Value  = 0;
     Possibles.SetAllTo(true);
     HorizontalDirections.SetAllTo(false);
     VerticalDirections.SetAllTo(false);
 }
Exemple #4
0
        public static HorizontalDirections GetHorizontalDirectionByVector(Vector3 dir)
        {
            HorizontalDirections result = HorizontalDirections.Top;

            if (dir.x > 0)
            {
                result = HorizontalDirections.Left;
            }
            else if (dir.x < 0)
            {
                result = HorizontalDirections.Right;
            }
            else if (dir.z > 0)
            {
                result = HorizontalDirections.Bottom;
            }
            else if (dir.z < 0)
            {
                result = HorizontalDirections.Top;
            }

            return(result);
        }