Exemple #1
0
    /// <summary>
    /// 是否是大于
    /// </summary>
    /// <param name="cell1"></param>
    /// <param name="cell2"></param>
    /// <returns></returns>
    private bool IsBig(SceneBkgCell cell1, SceneBkgCell cell2)
    {
        if (Mathf.Abs(cell1.xMin - cell2.xMin) <= EPS_EQUAL)
        {
            return(cell1.yMin > cell2.yMin);
        }

        return(cell1.xMin > cell2.xMin);
    }
Exemple #2
0
    /// <summary>
    /// 拼接一行
    /// </summary>
    /// <param name="list"></param>
    /// <param name="pre"></param>
    private void DoWork(List <SceneBkgCell> list, SceneBkgCell pre = null)
    {
        if (list == null ||
            list.Count <= 0)
        {
            return;
        }

        SortSceneBkgCell(list);

        SceneBkgCell now;

        for (int i = 0, imax = list.Count; i < imax; i++)
        {
            now = list[i];

            if (now.m_bWorked)
            {
                continue;
            }

            if (pre != null)
            {
                if (i == 0)
                {
                    now.m_vtPos.x = pre.m_vtPos.x - pre.m_vtSizeHalf.x + now.m_vtSizeHalf.x;
                    now.m_vtPos.y = pre.m_vtPos.y + pre.m_vtSizeHalf.y + now.m_vtSizeHalf.y - EPS_OVERLAP;
                }
                else
                {
                    now.m_vtPos.x = pre.m_vtPos.x + pre.m_vtSizeHalf.x + now.m_vtSizeHalf.x - EPS_OVERLAP;
                    now.m_vtPos.y = pre.m_vtPos.y - pre.m_vtSizeHalf.y + now.m_vtSizeHalf.y;
                }
                now.m_vtPos.z = 0;
                now.m_tfTransform.position = now.m_vtPos;
                now.m_bWorked = true;
            }

            pre = now;

            DoWork(GetTop(list, now), now);
        }
    }
    /// <summary>
    /// 拼接一行
    /// </summary>
    /// <param name="list"></param>
    /// <param name="pre"></param>
    private void DoWork(List<SceneBkgCell> list, SceneBkgCell pre = null)
    {
        if (list == null
            || list.Count <= 0)
        {
            return;
        }

        SortSceneBkgCell(list);

        SceneBkgCell now;

        for (int i = 0, imax = list.Count; i < imax; i++)
        {
            now = list[i];

            if (now.m_bWorked)
            {
                continue;
            }

            if (pre != null)
            {
                if (i == 0)
                {
                    now.m_vtPos.x = pre.m_vtPos.x - pre.m_vtSizeHalf.x + now.m_vtSizeHalf.x;
                    now.m_vtPos.y = pre.m_vtPos.y + pre.m_vtSizeHalf.y + now.m_vtSizeHalf.y - EPS_OVERLAP;
                }
                else
                {
                    now.m_vtPos.x = pre.m_vtPos.x + pre.m_vtSizeHalf.x + now.m_vtSizeHalf.x - EPS_OVERLAP;
                    now.m_vtPos.y = pre.m_vtPos.y - pre.m_vtSizeHalf.y + now.m_vtSizeHalf.y;
                }
                now.m_vtPos.z = 0;
                now.m_tfTransform.position = now.m_vtPos;
                now.m_bWorked = true;
            }

            pre = now;

            DoWork(GetTop(list, now), now);
        }
    }
Exemple #4
0
    /// <summary>
    /// 提取正上方的
    /// </summary>
    /// <param name="list"></param>
    /// <param name="cell"></param>
    /// <returns></returns>
    private List <SceneBkgCell> GetTop(List <SceneBkgCell> list, SceneBkgCell cell)
    {
        List <SceneBkgCell> retList = new List <SceneBkgCell>();

        foreach (SceneBkgCell sc in list)
        {
            if (sc.m_bWorked)
            {
                continue;
            }

            if ((cell.xMax - sc.xMin > 2 * EPS_OVERLAP && (sc.xMin >= cell.xMin || cell.xMin - sc.xMin <= 2 * EPS_OVERLAP)) ||
                sc.yMin > cell.yMin)
            {
                retList.Add(sc);
            }
        }

        return(retList);
    }
    /// <summary>
    /// 是否是大于
    /// </summary>
    /// <param name="cell1"></param>
    /// <param name="cell2"></param>
    /// <returns></returns>
    private bool IsBig(SceneBkgCell cell1, SceneBkgCell cell2)
    {
        if (Mathf.Abs(cell1.xMin - cell2.xMin) <= EPS_EQUAL)
        {
            return cell1.yMin > cell2.yMin;
        }

        return cell1.xMin > cell2.xMin;
    }
    /// <summary>
    /// 提取正上方的
    /// </summary>
    /// <param name="list"></param>
    /// <param name="cell"></param>
    /// <returns></returns>
    private List<SceneBkgCell> GetTop(List<SceneBkgCell> list, SceneBkgCell cell)
    {
        List<SceneBkgCell> retList = new List<SceneBkgCell>();

        foreach (SceneBkgCell sc in list)
        {
            if (sc.m_bWorked)
            {
                continue;
            }

            if ((cell.xMax - sc.xMin > 2 * EPS_OVERLAP && (sc.xMin >= cell.xMin || cell.xMin - sc.xMin <= 2 * EPS_OVERLAP))
               || sc.yMin > cell.yMin)
            {
                retList.Add(sc);
            }
        }

        return retList;
    }