コード例 #1
0
        public void resetData()
        {
            if (gameObject == null || m_mapSizeX <= 0 || m_mapSizeY <= 0)
            {
                return;
            }
            if (m_curData == null)
            {
                m_curData = new CellMapData(2, 2);
            }
            m_mapSizeX = m_curData.mapSizeX;
            m_mapSizeY = m_curData.mapSizeY;
            m_cellData = new Cell[m_mapSizeX, m_mapSizeY];
            float di = (3 + m_spacing * Mathf.Sqrt(3)) * 0.5f;
            float dj = Mathf.Sqrt(3) + m_spacing;

            float dx, dy;

            if (m_isCenter == true)
            {
                if (m_mapSizeX > 1)
                {
                    dx = -(m_mapSizeX - 1) * di * 0.5f;
                    dy = -(m_mapSizeY - 1.5f) * dj * 0.5f;
                }
                else
                {
                    dx = 0;
                    dy = -(m_mapSizeY - 1) * dj * 0.5f;
                }
            }
            else
            {
                dx = 0;
                dy = 0;
            }

            for (int i = 0; i < m_mapSizeX; i++)
            {
                if (i % 2 == 0)
                {
                    for (int j = 0; j < m_mapSizeY; j++)
                    {
                        createCell(new Vector3(i * di + dx, 0, j * dj + dy), m_curData.cellData[i * m_mapSizeY + j], i, j);
                    }
                }
                else
                {
                    for (int j = 0; j < m_mapSizeY; j++)
                    {
                        createCell(new Vector3(i * di + dx, 0, (j - 0.5f) * dj + dy), m_curData.cellData[i * m_mapSizeY + j], i, j);
                    }
                }
            }
        }
コード例 #2
0
 public void resetData(CellMapData newData)
 {
     m_curData = newData;
     resetData();
 }