示例#1
0
    /// <summary>
    /// 生成一列方块
    /// </summary>
    /// <param name="_mapX"></param>
    /// <param name="_mapZ"></param>
    private void GenerateOneColumBlock(int _mapX, int _mapZ)
    {
        if (!MapManager.IsMapped(_mapX, _mapZ))
        {
            MapManager.AddMappedPoint(_mapX, _mapZ);
            GameObject block = GameObject.Instantiate(GetBlock, transform);
            block.transform.position = new Vector3(_mapX, 0, _mapZ);


            int height = 0;
            if (m_setBlockHeightDelegate != null)
            {
                height = m_setBlockHeightDelegate(block.transform);
                if (height > 0)
                {
                    for (int h = 0; h < height; h++)
                    {
                        block = GameObject.Instantiate(GetBlock, transform);
                        block.transform.position = new Vector3(_mapX, h + 1, _mapZ);
                    }
                }
                else
                {
                    for (int h = 0; h > height; h--)
                    {
                        block = GameObject.Instantiate(GetBlock, transform);
                        block.transform.position = new Vector3(_mapX, h, _mapZ);
                    }
                }
            }
        }
    }