Exemplo n.º 1
0
        protected void expandUpdateElem()
        {
            // 计算正常位置
            int validCount = getValidElemCount(m_elemList);

            m_posList.Clear();
            UtilMath.newRectSplit(m_centerPos, m_elemNormalWidth, m_radius, m_yDelta, validCount, ref m_posList);

            // 更新元素信息
            float deltaX = 0;
            int   posIdx = 0;

            float origX        = 0;
            float origZ        = 0;
            float expandDeltaX = 0;
            float expandDeltaZ = 0;
            float nextOrigX    = 0;     // 后面一个的位置
            float nextExpandX  = 0;     // 后面一个的位置

            for (int elemIdx = 0; elemIdx < m_elemList.Count(); ++elemIdx)
            {
                if (m_elemList[elemIdx].bValid)
                {
                    m_posList[posIdx] += new Vector3(deltaX, 0, 0);

                    if (!m_elemList[elemIdx].isNormalState())
                    {
                        // 计算原始的位置
                        origX = m_posList[posIdx].x;
                        origZ = m_posList[posIdx].z;
                        // 计算由于放大需要的偏移量
                        expandDeltaX = (m_elemList[elemIdx].getExpandWidth() - m_elemList[elemIdx].getNormalWidth()) / 2;
                        expandDeltaZ = (m_elemList[elemIdx].getExpandHeight() - m_elemList[elemIdx].getNormalHeight()) / 2;
                        // 计算正确的中心位置
                        m_posList[posIdx] += new Vector3(expandDeltaX, 0, expandDeltaZ);
                        // 如果后面还有元素
                        if (posIdx < validCount - 1)
                        {
                            // 计算下一个元素在当前元素没有扩大的情况下,中心点位置
                            nextOrigX = m_posList[posIdx + 1].x + deltaX;
                            // 计算下一个元素在当前元素有扩大的情况下,中心点位置
                            nextExpandX = m_posList[posIdx].x + m_elemList[elemIdx].getExpandWidth() / 2 + m_elemList[elemIdx + 1].getNormalWidth() / 2;
                            // 计算后面的元素应该偏移量
                            deltaX += (nextExpandX - nextOrigX);
                        }
                    }

                    m_elemList[elemIdx].setExpandPos(m_posList[posIdx]);

                    ++posIdx;
                }
            }
        }
Exemplo n.º 2
0
        protected void normalUpdateElem()
        {
            // 计算位置信息
            m_posList.Clear();
            UtilMath.newRectSplit(m_centerPos, m_elemNormalWidth, m_radius, m_yDelta, getValidElemCount(m_elemList), ref m_posList);

            // 更新元素信息
            int posIdx = 0;

            for (int idx = 0; idx < m_elemList.Count(); ++idx)
            {
                if (m_elemList[idx].bValid)
                {
                    m_elemList[idx].setNormalPos(m_posList[posIdx]);
                    ++posIdx;
                }
            }
        }