Exemple #1
0
    /// <summary>
    /// 获取凸出部分的圆所有坐标
    /// </summary>
    /// <param name="CenterVector"></param>
    /// <param name="edgeEnum"></param>
    ///  <param name="bulgeEnum"></param>
    /// <returns></returns>
    private List <Vector3> getCircleVertices(Vector3 centerVector, float bulgeR, JigsawStyleNormalEdgeEnum edgeEnum, JigsawBulgeEnum bulgeEnum)
    {
        if (edgeEnum == JigsawStyleNormalEdgeEnum.Left)
        {
            if (bulgeEnum == JigsawBulgeEnum.Bulge)
            {
                return(GeometryUtil.getCircleVertices(centerVector, bulgeR, m_JigsawTriangleNumber, true, CircleStartVectorEnum.Below));
            }
            else if (bulgeEnum == JigsawBulgeEnum.Sunken)
            {
                return(GeometryUtil.getCircleVertices(centerVector, bulgeR, m_JigsawTriangleNumber, false, CircleStartVectorEnum.Below));
            }
        }
        else if (edgeEnum == JigsawStyleNormalEdgeEnum.Above)
        {
            if (bulgeEnum == JigsawBulgeEnum.Bulge)
            {
                return(GeometryUtil.getCircleVertices(centerVector, bulgeR, m_JigsawTriangleNumber, true, CircleStartVectorEnum.Left));
            }
            else if (bulgeEnum == JigsawBulgeEnum.Sunken)
            {
                return(GeometryUtil.getCircleVertices(centerVector, bulgeR, m_JigsawTriangleNumber, false, CircleStartVectorEnum.Left));
            }
        }
        else if (edgeEnum == JigsawStyleNormalEdgeEnum.Right)
        {
            if (bulgeEnum == JigsawBulgeEnum.Bulge)
            {
                return(GeometryUtil.getCircleVertices(centerVector, bulgeR, m_JigsawTriangleNumber, true, CircleStartVectorEnum.Above));
            }
            else if (bulgeEnum == JigsawBulgeEnum.Sunken)
            {
                return(GeometryUtil.getCircleVertices(centerVector, bulgeR, m_JigsawTriangleNumber, false, CircleStartVectorEnum.Above));
            }
        }
        else if (edgeEnum == JigsawStyleNormalEdgeEnum.Below)
        {
            if (bulgeEnum == JigsawBulgeEnum.Bulge)
            {
                return(GeometryUtil.getCircleVertices(centerVector, bulgeR, m_JigsawTriangleNumber, true, CircleStartVectorEnum.Right));
            }
            else if (bulgeEnum == JigsawBulgeEnum.Sunken)
            {
                return(GeometryUtil.getCircleVertices(centerVector, bulgeR, m_JigsawTriangleNumber, false, CircleStartVectorEnum.Right));
            }
        }

        return(new List <Vector3>());
    }
 /// <summary>
 /// 设置边的合并状态
 /// </summary>
 /// <param name="edge"></param>
 /// <param name="mergeStatus"></param>
 public void setEdgeMergeStatus(JigsawStyleNormalEdgeEnum edge, JigsawMergeStatusEnum mergeStatus)
 {
     if (edge.Equals(JigsawStyleNormalEdgeEnum.Left))
     {
         edgeListMergeStatus[0] = mergeStatus;
     }
     else if (edge.Equals(JigsawStyleNormalEdgeEnum.Above))
     {
         edgeListMergeStatus[1] = mergeStatus;
     }
     else if (edge.Equals(JigsawStyleNormalEdgeEnum.Right))
     {
         edgeListMergeStatus[2] = mergeStatus;
     }
     else if (edge.Equals(JigsawStyleNormalEdgeEnum.Below))
     {
         edgeListMergeStatus[3] = mergeStatus;
     }
 }
    /// <summary>
    /// 比较相邻拼图碎片的凹凸情况 获取自身的凹凸情况
    /// </summary>
    /// <param name="jigsawBean"></param>
    /// <returns></returns>
    protected JigsawBulgeEnum compareBulge(JigsawBean compareJigsaw, JigsawStyleNormalEdgeEnum edgeEnum)
    {
        if (compareJigsaw == null)
        {
            return(JigsawBulgeEnum.Smooth);
        }
        //获取相邻拼图的凹凸情况
        JigsawBulgeEnum[] compareBulgeList = compareJigsaw.ListBulge;
        if (compareBulgeList == null || compareBulgeList.Length != 4)
        {
            int randonBulge = DevUtil.getRandomInt(1, 2);
            if (randonBulge == 1)
            {
                return(JigsawBulgeEnum.Bulge);
            }
            else
            {
                return(JigsawBulgeEnum.Sunken);
            }
        }

        int bulgeposition;

        if (edgeEnum == JigsawStyleNormalEdgeEnum.Left)
        {
            bulgeposition = 2;
        }
        else if (edgeEnum == JigsawStyleNormalEdgeEnum.Above)
        {
            bulgeposition = 3;
        }
        else if (edgeEnum == JigsawStyleNormalEdgeEnum.Right)
        {
            bulgeposition = 0;
        }
        else if (edgeEnum == JigsawStyleNormalEdgeEnum.Below)
        {
            bulgeposition = 1;
        }
        else
        {
            return(JigsawBulgeEnum.Smooth);
        }


        JigsawBulgeEnum compareBulgeEnum = compareBulgeList[bulgeposition];

        if (compareBulgeEnum == JigsawBulgeEnum.Smooth)
        {
            return(JigsawBulgeEnum.Smooth);
        }
        else if (compareBulgeEnum == JigsawBulgeEnum.Bulge)
        {
            return(JigsawBulgeEnum.Sunken);
        }
        else if (compareBulgeEnum == JigsawBulgeEnum.Sunken)
        {
            return(JigsawBulgeEnum.Bulge);
        }
        else
        {
            return(JigsawBulgeEnum.Smooth);
        }
    }
Exemple #4
0
    /// <summary>
    /// 获取普通拼图凸出部分点坐标
    /// </summary>
    /// <param name="circleVertices"></param>
    /// <param name="edgeEnum"></param>
    /// <returns></returns>
    private List <Vector3> getCirclePartEdgeVerticesForNormal(List <Vector3> circleVertices, Vector3 centerVecotr, JigsawStyleNormalEdgeEnum edgeEnum, JigsawBulgeEnum bulgeEnum)
    {
        List <Vector3> listVertices = new List <Vector3>();

        foreach (Vector3 itemVector in circleVertices)
        {
            if (edgeEnum == JigsawStyleNormalEdgeEnum.Left)
            {
                if (bulgeEnum == JigsawBulgeEnum.Bulge)
                {
                    if (itemVector.x <= centerVecotr.x)
                    {
                        listVertices.Add(itemVector);
                    }
                }
                else if (bulgeEnum == JigsawBulgeEnum.Sunken)
                {
                    if (itemVector.x >= centerVecotr.x)
                    {
                        listVertices.Add(itemVector);
                    }
                }
            }
            else if (edgeEnum == JigsawStyleNormalEdgeEnum.Above)
            {
                if (bulgeEnum == JigsawBulgeEnum.Bulge)
                {
                    if (itemVector.y >= centerVecotr.y)
                    {
                        listVertices.Add(itemVector);
                    }
                }
                else if (bulgeEnum == JigsawBulgeEnum.Sunken)
                {
                    if (itemVector.y <= centerVecotr.y)
                    {
                        listVertices.Add(itemVector);
                    }
                }
            }
            else if (edgeEnum == JigsawStyleNormalEdgeEnum.Right)
            {
                if (bulgeEnum == JigsawBulgeEnum.Bulge)
                {
                    if (itemVector.x >= centerVecotr.x)
                    {
                        listVertices.Add(itemVector);
                    }
                }
                else if (bulgeEnum == JigsawBulgeEnum.Sunken)
                {
                    if (itemVector.x <= centerVecotr.x)
                    {
                        listVertices.Add(itemVector);
                    }
                }
            }
            else if (edgeEnum == JigsawStyleNormalEdgeEnum.Below)
            {
                if (bulgeEnum == JigsawBulgeEnum.Bulge)
                {
                    if (itemVector.y <= centerVecotr.y)
                    {
                        listVertices.Add(itemVector);
                    }
                }
                else if (bulgeEnum == JigsawBulgeEnum.Sunken)
                {
                    if (itemVector.y >= centerVecotr.y)
                    {
                        listVertices.Add(itemVector);
                    }
                }
            }
        }
        return(listVertices);
    }