Ejemplo n.º 1
0
        void CreateTerrain()
        {
            GameObject terrainRoot = GameObject.Find("TerrainBlocks");

            if (terrainRoot != null)
            {
                GameObject.Destroy(terrainRoot);
            }
            terrainRoot = new GameObject("TerrainBlocks");
            m_dictLayers.Clear();

            TerrainBlock.GRID_NUM = 32;
            GridDef.GridSize      = 32;

            for (int i = 0; i < (int)BaseLayer.LayerType.eLayerMax; i++)
            {
                BaseLayer.LayerType type = (BaseLayer.LayerType)i;
                BaseLayer           bl   = null;
                if (type == BaseLayer.LayerType.eLayerNormal)
                {
                    bl = new BaseLayer(type, terrainRoot.transform);
                }
                else if (type == BaseLayer.LayerType.eLayerBlock)
                {
                    bl = new BlockLayer(terrainRoot.transform);
                }
                else if (type == BaseLayer.LayerType.eLayerPK)
                {
                    bl = new PKLayer(terrainRoot.transform);
                }
                else if (type == BaseLayer.LayerType.eLayerSafe)
                {
                    bl = new SafeLayer(terrainRoot.transform);
                }
                else if (type == BaseLayer.LayerType.eLayerBoss)
                {
                    bl = new BossLayer(terrainRoot.transform);
                }
                else if (type == BaseLayer.LayerType.eLayerBattle)
                {
                    bl = new BattleLayer(terrainRoot.transform);
                }
                if (bl != null)
                {
                    m_dictLayers.Add((BaseLayer.LayerType)i, bl);
                    bl.Create(ar_width / GridDef.GridSize, ar_height / GridDef.GridSize);
                    bl.RefreshGridColor();
                }
            }
            if (terrainRoot.GetComponent <MapAreaRoot>() == null)
            {
                terrainRoot.AddComponent <MapAreaRoot>().Init(ar_width, ar_width, m_strFilePath);
            }
        }
Ejemplo n.º 2
0
        public LayerData(BaseLayer.LayerType type, uint blockNumX, uint blockNumZ)
        {
            layerType = type;

            BlockNumX = blockNumX;
            BlockNumZ = blockNumZ;

            GridX = TerrainBlock.GRID_NUM * blockNumX;
            GridZ = TerrainBlock.GRID_NUM * blockNumZ;

            VertexCountX = GridX + 1;
            VertexCountZ = GridZ + 1;

            m_uTotalBlock = blockNumX * blockNumZ;

            //Debug.Log(BlockNumX + " " + BlockNumZ);
            //Debug.Log(VertexCountX + " " + VertexCountZ);

            m_TerrainVertices = new VertexInfo[VertexCountX * VertexCountZ];
            for (int z = 0; z < VertexCountZ; z++)
            {
                for (int x = 0; x < VertexCountX; x++)
                {
                    VertexInfo pTemp = new VertexInfo();
                    int        index = x + (int)VertexCountX * z;
                    pTemp.x                  = x * TerrainBlock.GRID_LEN;
                    pTemp.z                  = z * TerrainBlock.GRID_LEN;
                    pTemp.height             = 0;
                    m_TerrainVertices[index] = pTemp;
                }
            }

            m_TerranGrids = new GridInfo[(GridX) * (GridZ)];
            for (int z = 0; z < GridZ; ++z)
            {
                for (int x = 0; x < GridX; ++x)
                {
                    GridInfo pTemp = new GridInfo();
                    int      index = x + (int)GridX * z;
                    pTemp.x              = x;
                    pTemp.z              = z;
                    pTemp.IsMask         = type == BaseLayer.LayerType.eLayerNormal ? true : false;
                    m_TerranGrids[index] = pTemp;
                }
            }
        }