public void SimpleShapeShouldReturnLWhenHasTwoAdjacentOrthogonalConnections()
        {
            AdjacencyMap adjacencyMapNorthEast = new AdjacencyMap();

            adjacencyMapNorthEast.SetConnection(Direction.North, existingConnection);
            adjacencyMapNorthEast.SetConnection(Direction.East, existingConnection);
            AdjacencyMap adjacencyMapSouthEast = new AdjacencyMap();

            adjacencyMapSouthEast.SetConnection(Direction.South, existingConnection);
            adjacencyMapSouthEast.SetConnection(Direction.East, existingConnection);
            AdjacencyMap adjacencyMapSouthWest = new AdjacencyMap();

            adjacencyMapSouthWest.SetConnection(Direction.South, existingConnection);
            adjacencyMapSouthWest.SetConnection(Direction.West, existingConnection);
            AdjacencyMap adjacencyMapNorthWest = new AdjacencyMap();

            adjacencyMapNorthWest.SetConnection(Direction.North, existingConnection);
            adjacencyMapNorthWest.SetConnection(Direction.West, existingConnection);

            AdjacencyShape resultNorthEast = AdjacencyShapeResolver.GetSimpleShape(adjacencyMapNorthEast);
            AdjacencyShape resultSouthEast = AdjacencyShapeResolver.GetSimpleShape(adjacencyMapSouthEast);
            AdjacencyShape resultSouthWest = AdjacencyShapeResolver.GetSimpleShape(adjacencyMapSouthWest);
            AdjacencyShape resultNorthWest = AdjacencyShapeResolver.GetSimpleShape(adjacencyMapNorthWest);

            Assert.IsTrue(resultNorthEast == AdjacencyShape.L);
            Assert.IsTrue(resultSouthEast == AdjacencyShape.L);
            Assert.IsTrue(resultSouthWest == AdjacencyShape.L);
            Assert.IsTrue(resultNorthWest == AdjacencyShape.L);
        }
        public void AdvancedShapeShouldReturnXOppositeWhenHasFourOrthogonalAndTwoOppositeDiagonalConnections()
        {
            AdjacencyMap adjacencyMap1 = new AdjacencyMap();

            adjacencyMap1.SetConnection(Direction.North, existingConnection);
            adjacencyMap1.SetConnection(Direction.East, existingConnection);
            adjacencyMap1.SetConnection(Direction.South, existingConnection);
            adjacencyMap1.SetConnection(Direction.West, existingConnection);
            adjacencyMap1.SetConnection(Direction.NorthEast, existingConnection);
            adjacencyMap1.SetConnection(Direction.SouthWest, existingConnection);
            AdjacencyMap adjacencyMap2 = new AdjacencyMap();

            adjacencyMap2.SetConnection(Direction.North, existingConnection);
            adjacencyMap2.SetConnection(Direction.East, existingConnection);
            adjacencyMap2.SetConnection(Direction.South, existingConnection);
            adjacencyMap2.SetConnection(Direction.West, existingConnection);
            adjacencyMap2.SetConnection(Direction.NorthWest, existingConnection);
            adjacencyMap2.SetConnection(Direction.SouthEast, existingConnection);

            AdjacencyShape result1 = AdjacencyShapeResolver.GetAdvancedShape(adjacencyMap1);
            AdjacencyShape result2 = AdjacencyShapeResolver.GetAdvancedShape(adjacencyMap2);

            Assert.IsTrue(result1 == AdjacencyShape.XOpposite);
            Assert.IsTrue(result2 == AdjacencyShape.XOpposite);
        }
        public void AdvancedShapeShouldReturnLSingleWhenHasThreeConsecutiveConnections()
        {
            AdjacencyMap adjacencyMapNorthEast = new AdjacencyMap();

            adjacencyMapNorthEast.SetConnection(Direction.North, existingConnection);
            adjacencyMapNorthEast.SetConnection(Direction.NorthEast, existingConnection);
            adjacencyMapNorthEast.SetConnection(Direction.East, existingConnection);
            AdjacencyMap adjacencyMapSouthEast = new AdjacencyMap();

            adjacencyMapSouthEast.SetConnection(Direction.South, existingConnection);
            adjacencyMapSouthEast.SetConnection(Direction.SouthEast, existingConnection);
            adjacencyMapSouthEast.SetConnection(Direction.East, existingConnection);
            AdjacencyMap adjacencyMapSouthWest = new AdjacencyMap();

            adjacencyMapSouthWest.SetConnection(Direction.South, existingConnection);
            adjacencyMapSouthWest.SetConnection(Direction.SouthWest, existingConnection);
            adjacencyMapSouthWest.SetConnection(Direction.West, existingConnection);
            AdjacencyMap adjacencyMapNorthWest = new AdjacencyMap();

            adjacencyMapNorthWest.SetConnection(Direction.North, existingConnection);
            adjacencyMapNorthWest.SetConnection(Direction.NorthWest, existingConnection);
            adjacencyMapNorthWest.SetConnection(Direction.West, existingConnection);

            AdjacencyShape resultNorthEast = AdjacencyShapeResolver.GetAdvancedShape(adjacencyMapNorthEast);
            AdjacencyShape resultSouthEast = AdjacencyShapeResolver.GetAdvancedShape(adjacencyMapSouthEast);
            AdjacencyShape resultSouthWest = AdjacencyShapeResolver.GetAdvancedShape(adjacencyMapSouthWest);
            AdjacencyShape resultNorthWest = AdjacencyShapeResolver.GetAdvancedShape(adjacencyMapNorthWest);

            Assert.IsTrue(resultNorthEast == AdjacencyShape.LSingle);
            Assert.IsTrue(resultSouthEast == AdjacencyShape.LSingle);
            Assert.IsTrue(resultSouthWest == AdjacencyShape.LSingle);
            Assert.IsTrue(resultNorthWest == AdjacencyShape.LSingle);
        }
        public void OffsetShapeShouldReturn0WhenNoConnections()
        {
            AdjacencyMap   adjacencyMap = new AdjacencyMap();
            AdjacencyShape result       = AdjacencyShapeResolver.GetOffsetShape(adjacencyMap);

            Assert.IsTrue(result == AdjacencyShape.O);
        }
        public void OffsetShapeShouldReturn0WhenHasOnlyDiagonalConnections()
        {
            AdjacencyMap adjacencyMap = new AdjacencyMap();

            adjacencyMap.SetConnection(Direction.NorthEast, existingConnection);
            adjacencyMap.SetConnection(Direction.SouthWest, existingConnection);

            AdjacencyShape result = AdjacencyShapeResolver.GetOffsetShape(adjacencyMap);

            Assert.IsTrue(result == AdjacencyShape.O);
        }
        public void OffsetShapeShouldReturnLSouthEastWhenHasAllSouthWestConnections()
        {
            AdjacencyMap adjacencyMap = new AdjacencyMap();

            adjacencyMap.SetConnection(Direction.West, existingConnection);
            adjacencyMap.SetConnection(Direction.SouthWest, existingConnection);
            adjacencyMap.SetConnection(Direction.South, existingConnection);

            AdjacencyShape result = AdjacencyShapeResolver.GetOffsetShape(adjacencyMap);

            Assert.IsTrue(result == AdjacencyShape.LSouthEast);
        }
        public void OffsetShapeShouldReturnTNorthEastWestWhenMissingWestConnection()
        {
            AdjacencyMap adjacencyMap = new AdjacencyMap();

            adjacencyMap.SetConnection(Direction.North, existingConnection);
            adjacencyMap.SetConnection(Direction.East, existingConnection);
            adjacencyMap.SetConnection(Direction.South, existingConnection);

            AdjacencyShape result = AdjacencyShapeResolver.GetOffsetShape(adjacencyMap);

            Assert.IsTrue(result == AdjacencyShape.TNorthEastWest);
        }
        public void AdvancedShapeShouldReturnTNoneWhenHasThreeOrthogonalConnections()
        {
            AdjacencyMap adjacencyMap = new AdjacencyMap();

            adjacencyMap.SetConnection(Direction.North, existingConnection);
            adjacencyMap.SetConnection(Direction.East, existingConnection);
            adjacencyMap.SetConnection(Direction.West, existingConnection);

            AdjacencyShape result = AdjacencyShapeResolver.GetAdvancedShape(adjacencyMap);

            Assert.IsTrue(result == AdjacencyShape.TNone);
        }
        public void SimpleShapeShouldReturnTWhenHasThreeOrthogonalConnections()
        {
            AdjacencyMap adjacencyMap = new AdjacencyMap();

            adjacencyMap.SetConnection(Direction.North, existingConnection);
            adjacencyMap.SetConnection(Direction.East, existingConnection);
            adjacencyMap.SetConnection(Direction.South, existingConnection);

            AdjacencyShape result = AdjacencyShapeResolver.GetSimpleShape(adjacencyMap);

            Assert.IsTrue(result == AdjacencyShape.T);
        }
        public void SimpleShapeShouldReturnUWhenHasSingleOrthogonalAndManyDiagonalConnections()
        {
            AdjacencyMap adjacencyMap = new AdjacencyMap();

            adjacencyMap.SetConnection(Direction.North, existingConnection);
            adjacencyMap.SetConnection(Direction.NorthEast, existingConnection);
            adjacencyMap.SetConnection(Direction.SouthEast, existingConnection);
            adjacencyMap.SetConnection(Direction.SouthWest, existingConnection);
            adjacencyMap.SetConnection(Direction.NorthWest, existingConnection);

            AdjacencyShape result = AdjacencyShapeResolver.GetSimpleShape(adjacencyMap);

            Assert.IsTrue(result == AdjacencyShape.U);
        }
        public void OffsetShapeShouldReturnUNorthWhenHasSingleConnectionNorthOrEast()
        {
            AdjacencyMap adjacencyMapNorth = new AdjacencyMap();

            adjacencyMapNorth.SetConnection(Direction.North, existingConnection);
            AdjacencyMap adjacencyMapEast = new AdjacencyMap();

            adjacencyMapEast.SetConnection(Direction.East, existingConnection);

            AdjacencyShape resultNorth = AdjacencyShapeResolver.GetOffsetShape(adjacencyMapNorth);
            AdjacencyShape resultEast  = AdjacencyShapeResolver.GetOffsetShape(adjacencyMapEast);

            Assert.IsTrue(resultNorth == AdjacencyShape.UNorth);
            Assert.IsTrue(resultEast == AdjacencyShape.UNorth);
        }
        public void OffsetShapeShouldReturnUSouthWhenHasSingleConnectionSouthOrWest()
        {
            AdjacencyMap adjacencyMapSouth = new AdjacencyMap();

            adjacencyMapSouth.SetConnection(Direction.South, existingConnection);
            AdjacencyMap adjacencyMapWest = new AdjacencyMap();

            adjacencyMapWest.SetConnection(Direction.West, existingConnection);

            AdjacencyShape resultSouth = AdjacencyShapeResolver.GetOffsetShape(adjacencyMapSouth);
            AdjacencyShape resultWest  = AdjacencyShapeResolver.GetOffsetShape(adjacencyMapWest);

            Assert.IsTrue(resultSouth == AdjacencyShape.USouth);
            Assert.IsTrue(resultWest == AdjacencyShape.USouth);
        }
예제 #13
0
        public MeshDirectionInfo GetMeshAndDirection(AdjacencyMap adjacencyMap)
        {
            // Determine rotation and mesh specially for every single case.
            float rotation = 0.0f;
            Mesh  mesh;

            AdjacencyShape shape = AdjacencyShapeResolver.GetSimpleShape(adjacencyMap);

            switch (shape)
            {
            case AdjacencyShape.O:
                mesh = o;
                break;

            case AdjacencyShape.U:
                mesh     = u;
                rotation = TileHelper.AngleBetween(Direction.North, adjacencyMap.GetSingleConnection());
                break;

            case AdjacencyShape.I:
                mesh     = i;
                rotation = TileHelper.AngleBetween(Direction.North, adjacencyMap.HasConnection(Direction.North) ? Direction.North : Direction.East);
                break;

            case AdjacencyShape.L:
                mesh     = l;
                rotation = TileHelper.AngleBetween(Direction.NorthEast, adjacencyMap.GetDirectionBetweenTwoConnections());
                break;

            case AdjacencyShape.T:
                mesh     = t;
                rotation = TileHelper.AngleBetween(Direction.North, adjacencyMap.GetSingleNonConnection());
                break;

            case AdjacencyShape.X:
                mesh = x;
                break;

            default:
                Debug.LogError($"Received unexpected shape from simple shape resolver: {shape}");
                mesh = o;
                break;
            }

            return(new MeshDirectionInfo {
                Mesh = mesh, Rotation = rotation
            });
        }
        public void SimpleShapeShouldReturnIWhenHasTwoOppositeOrthogonalConnections()
        {
            AdjacencyMap adjacencyMapNorthSouth = new AdjacencyMap();

            adjacencyMapNorthSouth.SetConnection(Direction.North, existingConnection);
            adjacencyMapNorthSouth.SetConnection(Direction.South, existingConnection);
            AdjacencyMap adjacencyMapEastWest = new AdjacencyMap();

            adjacencyMapEastWest.SetConnection(Direction.East, existingConnection);
            adjacencyMapEastWest.SetConnection(Direction.West, existingConnection);

            AdjacencyShape resultNorthSouth = AdjacencyShapeResolver.GetSimpleShape(adjacencyMapNorthSouth);
            AdjacencyShape resultEastWest   = AdjacencyShapeResolver.GetSimpleShape(adjacencyMapEastWest);

            Assert.IsTrue(resultNorthSouth == AdjacencyShape.I);
            Assert.IsTrue(resultEastWest == AdjacencyShape.I);
        }
        public void AdvancedShapeShouldReturnXQuadWhenHasFourOrthogonalAndDiagonalConnections()
        {
            AdjacencyMap adjacencyMap = new AdjacencyMap();

            adjacencyMap.SetConnection(Direction.North, existingConnection);
            adjacencyMap.SetConnection(Direction.East, existingConnection);
            adjacencyMap.SetConnection(Direction.South, existingConnection);
            adjacencyMap.SetConnection(Direction.West, existingConnection);
            adjacencyMap.SetConnection(Direction.NorthEast, existingConnection);
            adjacencyMap.SetConnection(Direction.SouthEast, existingConnection);
            adjacencyMap.SetConnection(Direction.SouthWest, existingConnection);
            adjacencyMap.SetConnection(Direction.NorthWest, existingConnection);

            AdjacencyShape result = AdjacencyShapeResolver.GetAdvancedShape(adjacencyMap);

            Assert.IsTrue(result == AdjacencyShape.XQuad);
        }
        public void AdvancedShapeShouldReturnXSingleWhenHasFourOrthogonalAndOneDiagonalConnection()
        {
            AdjacencyMap adjacencyMapNorthEast = new AdjacencyMap();

            adjacencyMapNorthEast.SetConnection(Direction.North, existingConnection);
            adjacencyMapNorthEast.SetConnection(Direction.East, existingConnection);
            adjacencyMapNorthEast.SetConnection(Direction.South, existingConnection);
            adjacencyMapNorthEast.SetConnection(Direction.West, existingConnection);
            adjacencyMapNorthEast.SetConnection(Direction.NorthEast, existingConnection);
            AdjacencyMap adjacencyMapNorthWest = new AdjacencyMap();

            adjacencyMapNorthWest.SetConnection(Direction.North, existingConnection);
            adjacencyMapNorthWest.SetConnection(Direction.East, existingConnection);
            adjacencyMapNorthWest.SetConnection(Direction.South, existingConnection);
            adjacencyMapNorthWest.SetConnection(Direction.West, existingConnection);
            adjacencyMapNorthWest.SetConnection(Direction.NorthWest, existingConnection);
            AdjacencyMap adjacencyMapSouthEast = new AdjacencyMap();

            adjacencyMapSouthEast.SetConnection(Direction.North, existingConnection);
            adjacencyMapSouthEast.SetConnection(Direction.East, existingConnection);
            adjacencyMapSouthEast.SetConnection(Direction.South, existingConnection);
            adjacencyMapSouthEast.SetConnection(Direction.West, existingConnection);
            adjacencyMapSouthEast.SetConnection(Direction.SouthEast, existingConnection);
            AdjacencyMap adjacencyMapSouthWest = new AdjacencyMap();

            adjacencyMapSouthWest.SetConnection(Direction.North, existingConnection);
            adjacencyMapSouthWest.SetConnection(Direction.East, existingConnection);
            adjacencyMapSouthWest.SetConnection(Direction.South, existingConnection);
            adjacencyMapSouthWest.SetConnection(Direction.West, existingConnection);
            adjacencyMapSouthWest.SetConnection(Direction.SouthWest, existingConnection);

            AdjacencyShape resultNorthEast = AdjacencyShapeResolver.GetAdvancedShape(adjacencyMapNorthEast);
            AdjacencyShape resultNorthWest = AdjacencyShapeResolver.GetAdvancedShape(adjacencyMapNorthWest);
            AdjacencyShape resultSouthEast = AdjacencyShapeResolver.GetAdvancedShape(adjacencyMapSouthEast);
            AdjacencyShape resultSouthWest = AdjacencyShapeResolver.GetAdvancedShape(adjacencyMapSouthWest);

            Assert.IsTrue(resultNorthEast == AdjacencyShape.XSingle);
            Assert.IsTrue(resultNorthWest == AdjacencyShape.XSingle);
            Assert.IsTrue(resultSouthEast == AdjacencyShape.XSingle);
            Assert.IsTrue(resultSouthWest == AdjacencyShape.XSingle);
        }
        public void AdvancedShapeShouldReturnTNoneWhenHasThreeOrthogonalAndOneOppositeDiagonalConnection()
        {
            AdjacencyMap adjacencyMapL = new AdjacencyMap();

            adjacencyMapL.SetConnection(Direction.North, existingConnection);
            adjacencyMapL.SetConnection(Direction.East, existingConnection);
            adjacencyMapL.SetConnection(Direction.West, existingConnection);
            adjacencyMapL.SetConnection(Direction.SouthWest, existingConnection);
            AdjacencyMap adjacencyMapR = new AdjacencyMap();

            adjacencyMapR.SetConnection(Direction.North, existingConnection);
            adjacencyMapR.SetConnection(Direction.East, existingConnection);
            adjacencyMapR.SetConnection(Direction.West, existingConnection);
            adjacencyMapR.SetConnection(Direction.SouthEast, existingConnection);

            AdjacencyShape resultL = AdjacencyShapeResolver.GetAdvancedShape(adjacencyMapL);
            AdjacencyShape resultR = AdjacencyShapeResolver.GetAdvancedShape(adjacencyMapR);

            Assert.IsTrue(resultL == AdjacencyShape.TNone);
            Assert.IsTrue(resultR == AdjacencyShape.TNone);
        }
        public void SimpleShapeShouldReturnUWhenSingleOrthogonalConnection()
        {
            AdjacencyMap adjacencyMap = new AdjacencyMap();

            adjacencyMap.SetConnection(Direction.North, existingConnection);
            AdjacencyShape resultN = AdjacencyShapeResolver.GetSimpleShape(adjacencyMap);

            adjacencyMap.SetConnection(Direction.North, missingConnection);
            adjacencyMap.SetConnection(Direction.East, existingConnection);
            AdjacencyShape resultE = AdjacencyShapeResolver.GetSimpleShape(adjacencyMap);

            adjacencyMap.SetConnection(Direction.East, missingConnection);
            adjacencyMap.SetConnection(Direction.South, existingConnection);
            AdjacencyShape resultS = AdjacencyShapeResolver.GetSimpleShape(adjacencyMap);

            adjacencyMap.SetConnection(Direction.South, missingConnection);
            adjacencyMap.SetConnection(Direction.West, existingConnection);
            AdjacencyShape resultW = AdjacencyShapeResolver.GetSimpleShape(adjacencyMap);

            Assert.IsTrue(resultN == AdjacencyShape.U);
            Assert.IsTrue(resultE == AdjacencyShape.U);
            Assert.IsTrue(resultS == AdjacencyShape.U);
            Assert.IsTrue(resultW == AdjacencyShape.U);
        }
예제 #19
0
        public MeshDirectionInfo GetMeshAndDirection(AdjacencyMap adjacencyMap)
        {
            float rotation = 0.0f;
            Mesh  mesh;

            AdjacencyShape shape = AdjacencyShapeResolver.GetAdvancedShape(adjacencyMap);

            switch (shape)
            {
            case AdjacencyShape.O:
                mesh = o;
                break;

            case AdjacencyShape.U:
                mesh     = u;
                rotation = TileHelper.AngleBetween(Direction.North, adjacencyMap.GetSingleConnection());
                break;

            case AdjacencyShape.I:
                mesh     = i;
                rotation = TileHelper.AngleBetween(Direction.North, adjacencyMap.HasConnection(Direction.North) ? Direction.North : Direction.East);
                break;

            case AdjacencyShape.LNone:
                mesh     = lNone;
                rotation = TileHelper.AngleBetween(Direction.NorthEast, adjacencyMap.GetDirectionBetweenTwoConnections());
                break;

            case AdjacencyShape.LSingle:
                mesh     = lSingle;
                rotation = TileHelper.AngleBetween(Direction.NorthEast, adjacencyMap.GetDirectionBetweenTwoConnections());
                break;

            case AdjacencyShape.TNone:
                mesh     = tNone;
                rotation = TileHelper.AngleBetween(Direction.North, adjacencyMap.GetSingleNonConnection());
                break;

            case AdjacencyShape.TSingleLeft:
                mesh     = tSingleLeft;
                rotation = TileHelper.AngleBetween(Direction.North, adjacencyMap.GetSingleNonConnection());
                break;

            case AdjacencyShape.TSingleRight:
                mesh     = tSingleRight;
                rotation = TileHelper.AngleBetween(Direction.North, adjacencyMap.GetSingleNonConnection());
                break;

            case AdjacencyShape.TDouble:
                mesh     = tDouble;
                rotation = TileHelper.AngleBetween(Direction.North, adjacencyMap.GetSingleNonConnection());
                break;

            case AdjacencyShape.XNone:
                mesh = xNone;
                break;

            case AdjacencyShape.XSingle:
                mesh = xSingle;
                Direction connectingDiagonal = adjacencyMap.GetSingleConnection(false);
                rotation = connectingDiagonal == Direction.NorthEast ? 0f :
                           connectingDiagonal == Direction.SouthEast ? 90f :
                           connectingDiagonal == Direction.SouthWest ? 180f : -90f;
                break;

            case AdjacencyShape.XOpposite:
                mesh     = xOpposite;
                rotation = adjacencyMap.HasConnection(Direction.NorthEast) ? 0f : 90f;
                break;

            case AdjacencyShape.XSide:
                mesh     = xSide;
                rotation = TileHelper.AngleBetween(Direction.NorthWest, adjacencyMap.GetDirectionBetweenTwoConnections(false)) - 45f;
                break;

            case AdjacencyShape.XTriple:
                mesh = xTriple;
                Direction nonConnectingDiagonal = adjacencyMap.GetSingleNonConnection(false);
                rotation = nonConnectingDiagonal == Direction.NorthEast ? -90f :
                           nonConnectingDiagonal == Direction.SouthEast ? 0f :
                           nonConnectingDiagonal == Direction.SouthWest ? 90f : 180f;
                break;

            case AdjacencyShape.XQuad:
                mesh = xQuad;
                break;

            default:
                Debug.LogError($"Received unexpected shape from advanced shape resolver: {shape}");
                mesh = o;
                break;
            }

            //If someone knows of a more elegant way to do the same without switching the same variable twice, I'd like to hear it :)
            if (opaque)
            {
                switch (shape)
                {
                case AdjacencyShape.U:
                    viewObstacles[0].SetActive(false);
                    viewObstacles[1].SetActive(false);
                    viewObstacles[2].SetActive(true);
                    viewObstacles[3].SetActive(false);
                    break;

                case AdjacencyShape.I:
                    viewObstacles[0].SetActive(false);
                    viewObstacles[1].SetActive(false);
                    viewObstacles[2].SetActive(true);
                    viewObstacles[3].SetActive(true);
                    break;

                case AdjacencyShape.LNone:
                case AdjacencyShape.LSingle:
                    viewObstacles[0].SetActive(false);
                    viewObstacles[1].SetActive(true);
                    viewObstacles[2].SetActive(true);
                    viewObstacles[3].SetActive(false);
                    break;

                case AdjacencyShape.TNone:
                case AdjacencyShape.TSingleLeft:
                case AdjacencyShape.TSingleRight:
                    viewObstacles[0].SetActive(true);
                    viewObstacles[1].SetActive(true);
                    viewObstacles[2].SetActive(false);
                    viewObstacles[3].SetActive(true);
                    break;

                case AdjacencyShape.TDouble:
                case AdjacencyShape.XNone:
                case AdjacencyShape.XSingle:
                case AdjacencyShape.XOpposite:
                case AdjacencyShape.XSide:
                case AdjacencyShape.XTriple:
                case AdjacencyShape.XQuad:
                    viewObstacles[0].SetActive(true);
                    viewObstacles[1].SetActive(true);
                    viewObstacles[2].SetActive(true);
                    viewObstacles[3].SetActive(true);
                    break;
                }
            }

            return(new MeshDirectionInfo {
                Mesh = mesh, Rotation = rotation
            });
        }
예제 #20
0
        public MeshDirectionInfo GetMeshAndDirection(AdjacencyMap adjacencyMap)
        {
            // Determine rotation and mesh specially for every single case.
            float rotation = 0.0f;
            Mesh  mesh;

            AdjacencyShape shape = AdjacencyShapeResolver.GetOffsetShape(adjacencyMap);

            switch (shape)
            {
            case AdjacencyShape.O:
                mesh        = o;
                orientation = OffsetOrientation.o;
                break;

            case AdjacencyShape.UNorth:
                mesh        = uNorth;
                orientation = OffsetOrientation.uNorth;
                rotation    = TileHelper.AngleBetween(Direction.North, adjacencyMap.GetSingleConnection());
                break;

            case AdjacencyShape.USouth:
                mesh        = uSouth;
                orientation = OffsetOrientation.uSouth;
                rotation    = TileHelper.AngleBetween(Direction.South, adjacencyMap.GetSingleNonConnection());
                break;

            case AdjacencyShape.I:
                mesh        = i;
                orientation = OffsetOrientation.i;
                rotation    = TileHelper.AngleBetween(Direction.North, adjacencyMap.HasConnection(Direction.North) ? Direction.North : Direction.East);
                break;

            case AdjacencyShape.LNorthWest:
                mesh        = lNW;
                orientation = OffsetOrientation.lNW;
                rotation    = 90;
                break;

            case AdjacencyShape.LNorthEast:
                mesh        = lNE;
                orientation = OffsetOrientation.lSE;
                rotation    = 90;
                break;

            case AdjacencyShape.LSouthEast:
                mesh        = lSE;
                orientation = OffsetOrientation.lSW;
                rotation    = 90;
                break;

            case AdjacencyShape.LSouthWest:
                mesh        = lSW;
                orientation = OffsetOrientation.lNW;
                rotation    = 90;
                break;

            case AdjacencyShape.TNorthSouthEast:
                mesh        = tNSE;
                orientation = OffsetOrientation.tSWE;
                rotation    = 90;
                break;

            case AdjacencyShape.TSouthWestEast:
                mesh        = tSWE;
                orientation = OffsetOrientation.tNSW;
                rotation    = 90;
                break;

            case AdjacencyShape.TNorthSouthWest:
                mesh        = tNSW;
                orientation = OffsetOrientation.tNEW;
                rotation    = 90;
                break;

            case AdjacencyShape.TNorthEastWest:
                mesh        = tNEW;
                orientation = OffsetOrientation.tNSE;
                rotation    = 90;
                break;

            case AdjacencyShape.X:
                mesh        = x;
                orientation = OffsetOrientation.x;
                rotation    = 90;
                break;

            default:
                Debug.LogError($"Received unexpected shape from offset shape resolver: {shape}");
                mesh = o;
                break;
            }

            return(new MeshDirectionInfo {
                Mesh = mesh, Rotation = rotation
            });
        }