Exemplo n.º 1
0
        /// <summary>
        /// 删除不合理的树的位置
        /// 比如此地块不可通行, 那么就不能种树
        /// </summary>
        public void DeleteBlockAtIllegalPostion(CAssetGrid terrainGrid)
        {
            var noneType = (int)CForestBlockSubType.None;
            var type     = (int)CPCGLayer.Block;

            for (int col = 0; col < m_numCols; col++)
            {
                for (int row = 0; row < m_numRows; row++)
                {
                    var node = m_grid.GetNode(col, row);
                    if (node.SubType == noneType)
                    {
                        continue;
                    }

                    var terrType = (CForestTerrainSubType)terrainGrid.GetNodeSubType(col, row);
                    if (CForestUtil.CanPlacePropsOnTerrainType(terrType))
                    {
                        continue;
                    }
                    m_grid.FillData(col, row, type, noneType, true);
                }
            }

            BreatheTree();
        }
Exemplo n.º 2
0
 //根据四周情况, 平滑单个的tile
 private void SmoothSingleTileSprite(CAssetGrid map, int x, int z)
 {
     SetTileCornerValue(map, x, z, CAssetNode.Corner.BottomRight, 4);
     SetTileCornerValue(map, x, z - 1, CAssetNode.Corner.TopRight, 1);
     SetTileCornerValue(map, x + 1, z, CAssetNode.Corner.BottomLeft, 8);
     SetTileCornerValue(map, x + 1, z - 1, CAssetNode.Corner.TopLeft, 2);
 }
Exemplo n.º 3
0
        private void SetTileCornerValue(CAssetGrid map, int x, int z, CAssetNode.Corner corner, int value)
        {
            CAssetNode tile = map.GetNode(x, z);

            if (tile == null)
            {
                return;
            }

            int fv = tile.GetFrogCornerValue(corner);

            if (fv == value)
            {
                return;
            }

            tile.SetFrogCornerValue(corner, fv + value);
        }
Exemplo n.º 4
0
        public void SmoothTileMapSprite(CAssetGrid tileMap)
        {
            //先将corner值都设置为0
            for (int x = 0; x < tileMap.NumCols; x++)
            {
                for (int z = 0; x < tileMap.NumRows; z++)
                {
                    CAssetNode tile = tileMap.GetNode(x, z);
                    tile.ResetCornerValue();
                }
            }

            //再重新计算
            for (int x = 0; x < tileMap.NumCols; x++)
            {
                for (int z = 0; x < tileMap.NumRows; z++)
                {
                    SmoothSingleTileSprite(tileMap, x, z);
                }
            }
        }
        //路标, 大块石头, 路灯等
        public void CreateDecoration(int decoBlockNum, CAssetGrid walkGrid, CAssetGrid typeGrid, CAssetGrid assetGrid)
        {
            string name;

            //添加阻碍装饰物
            for (int i = 0; i < decoBlockNum; ++i)
            {
                int col = CDarkRandom.Next(_numCols);
                int row = CDarkRandom.Next(_numRows);
                if (!walkGrid.IsWalkable(col, row))
                {
                    continue;
                }

                walkGrid.SetWalkable(col, row, false);

                int nameIndex = CDarkRandom.Next(1, 6);
                name = string.Format("Preb_Deco_Block_00{0}", nameIndex);
                //assetGrid.SetName(row, col, name);
            }
        }
        public void CreateDecal(string decalNameRoot, int decalStartIndex, CAssetGrid walkGrid, CAssetGrid typeGrid, CAssetGrid assetGrid)
        {
            string name;

            //添加贴花
            for (int i = 0; i < 30; ++i)
            {
                int col = CDarkRandom.Next(_numCols);
                int row = CDarkRandom.Next(_numRows);
                //if(typeGrid.IsSpecial(row, col))continue;
                if (!walkGrid.IsWalkable(row, col))
                {
                    continue;
                }

                //typeGrid.SetType(row, col, (int)RayConst.TileType.DECAL);

                int nameIndex = CDarkRandom.Next(decalStartIndex, decalStartIndex + 5);
                name = string.Format("{0}{1}", decalNameRoot, nameIndex);
                //assetGrid.SetName(row, col, name);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 删除不合理位置的贴花
        /// </summary>
        public void DeleteDecalAtIllegalBlockPostion(CAssetGrid blockGrid)
        {
            var noneType = 0;
            var type     = (int)CPCGLayer.Decal;

            for (int col = 0; col < m_numCols; col++)
            {
                for (int row = 0; row < m_numRows; row++)
                {
                    var node = m_grid.GetNode(col, row);
                    if (node.SubType == noneType)
                    {
                        continue;
                    }

                    var walkable = blockGrid.IsWalkable(col, row);
                    if (walkable)
                    {
                        continue;
                    }
                    m_grid.FillData(col, row, type, noneType, true);
                }
            }
        }
        //创建可以销毁的障碍物. 比如说坦克大战和炸弹人的地块
        public void CreateDestroyBlock(int decoDestroyNum, CAssetGrid walkGrid, CAssetGrid typeGrid, CAssetGrid assetGrid)
        {
            string name;

            //添加阻碍装饰物
            for (int i = 0; i < decoDestroyNum; ++i)
            {
                int col = CDarkRandom.Next(_numCols);
                int row = CDarkRandom.Next(_numRows);
                //if(typeGrid.IsSpecial(row, col))continue;
                if (!walkGrid.IsWalkable(row, col))
                {
                    continue;
                }

                //typeGrid.SetType(row, col, (int)RayConst.TileType.DECO_DESTROY);
                walkGrid.SetWalkable(row, col, false);

                //5个里面随机一个
                int nameIndex = CDarkRandom.Next(1, 6);
                name = string.Format("Preb_Deco_Destroy_00{0}", nameIndex);
                //assetGrid.SetName(row, col, name);
            }
        }
Exemplo n.º 9
0
 public void SetAssetGrid(CAssetGrid grid)
 {
     m_assetGrid = grid;
 }