Пример #1
0
        static void ProcessTrees( ForesterArgs args, IList<Tree> treeList ) {
            TreeShape[] shapeChoices;
            switch( args.Shape ) {
                case TreeShape.Stickly:
                    shapeChoices = new[]{ TreeShape.Normal,
                                          TreeShape.Bamboo,
                                          TreeShape.Palm };
                    break;
                case TreeShape.Procedural:
                    shapeChoices = new[]{ TreeShape.Round,
                                          TreeShape.Cone };
                    break;
                default:
                    shapeChoices = new[] { args.Shape };
                    break;
            }

            for( int i = 0; i < treeList.Count; i++ ) {
                TreeShape newShape = shapeChoices[args.Rand.Next( 0, shapeChoices.Length )];
                Tree newTree;
                switch( newShape ) {
                    case TreeShape.Normal:
                        newTree = new NormalTree();
                        break;
                    case TreeShape.Bamboo:
                        newTree = new BambooTree();
                        break;
                    case TreeShape.Palm:
                        newTree = new PalmTree();
                        break;
                    case TreeShape.Round:
                        newTree = new RoundTree();
                        break;
                    case TreeShape.Cone:
                        newTree = new ConeTree();
                        break;
                    case TreeShape.Rainforest:
                        newTree = new RainforestTree();
                        break;
                    case TreeShape.Mangrove:
                        newTree = new MangroveTree();
                        break;
                    default:
                        throw new ArgumentException( "Unknown tree shape type" );
                }
                newTree.Copy( treeList[i] );

                if( args.MapHeightLimit ) {
                    int height = newTree.Height;
                    int yBase = newTree.Pos[1];
                    int mapHeight = args.Map.Height;
                    int foliageHeight;
                    if( args.Shape == TreeShape.Rainforest ) {
                        foliageHeight = 2;
                    } else {
                        foliageHeight = 4;
                    }
                    if( yBase + height + foliageHeight > mapHeight ) {
                        newTree.Height = mapHeight - yBase - foliageHeight;
                    }
                }

                if( newTree.Height < 1 ) newTree.Height = 1;
                newTree.Prepare();
                treeList[i] = newTree;
            }
        }
Пример #2
0
        void ProcessTrees(List<Tree> treelist)
        {
            TreeShape[] shape_choices;
            switch (args.SHAPE)
            {
                case TreeShape.Stickly:
                    shape_choices = new TreeShape[]{ TreeShape.Normal,
                                                     TreeShape.Bamboo,
                                                     TreeShape.Palm};
                    break;
                case TreeShape.Procedural:
                    shape_choices = new TreeShape[]{ TreeShape.Round,
                                                     TreeShape.Cone };
                    break;
                default:
                    shape_choices = new TreeShape[] { args.SHAPE };
                    break;
            }

            for (int i = 0; i < treelist.Count; i++)
            {
                TreeShape newshape = shape_choices[args.rand.Next(0, shape_choices.Length)];
                Tree newtree;
                switch (newshape)
                {
                    case TreeShape.Normal:
                        newtree = new NormalTree();
                        break;
                    case TreeShape.Bamboo:
                        newtree = new BambooTree();
                        break;
                    case TreeShape.Palm:
                        newtree = new PalmTree();
                        break;
                    case TreeShape.Round:
                        newtree = new RoundTree();
                        break;
                    case TreeShape.Cone:
                        newtree = new ConeTree();
                        break;
                    case TreeShape.Rainforest:
                        newtree = new RainforestTree();
                        break;
                    case TreeShape.Mangrove:
                        newtree = new MangroveTree();
                        break;
                    default:
                        throw new ArgumentException();
                }
                newtree.Copy(treelist[i]);

                if (args.MAPHEIGHTLIMIT)
                {
                    int height = newtree.height;
                    int ybase = newtree.pos[1];
                    int mapheight = args.inMap.MapSizeZ;
                    int foliageheight;
                    if (args.SHAPE == TreeShape.Rainforest)
                    {
                        foliageheight = 2;
                    }
                    else
                    {
                        foliageheight = 4;
                    }
                    if (ybase + height + foliageheight > mapheight)
                    {
                        newtree.height = mapheight - ybase - foliageheight;
                    }
                }

                if (newtree.height < 1) newtree.height = 1;
                newtree.Prepare();
                treelist[i] = newtree;
            }
        }
Пример #3
0
        static void ProcessTrees(ForesterArgs args, IList <Tree> treelist)
        {
            TreeShape[] shapeChoices;
            switch (args.Shape)
            {
            case TreeShape.Stickly:
                shapeChoices = new[] { TreeShape.Normal,
                                       TreeShape.Bamboo,
                                       TreeShape.Palm };
                break;

            case TreeShape.Procedural:
                shapeChoices = new[] { TreeShape.Round,
                                       TreeShape.Cone };
                break;

            default:
                shapeChoices = new[] { args.Shape };
                break;
            }

            for (int i = 0; i < treelist.Count; i++)
            {
                TreeShape newshape = shapeChoices[args.Rand.Next(0, shapeChoices.Length)];
                Tree      newTree;
                switch (newshape)
                {
                case TreeShape.Normal:
                    newTree = new NormalTree();
                    break;

                case TreeShape.Bamboo:
                    newTree = new BambooTree();
                    break;

                case TreeShape.Palm:
                    newTree = new PalmTree();
                    break;

                case TreeShape.Round:
                    newTree = new RoundTree();
                    break;

                case TreeShape.Cone:
                    newTree = new ConeTree();
                    break;

                case TreeShape.Rainforest:
                    newTree = new RainforestTree();
                    break;

                case TreeShape.Mangrove:
                    newTree = new MangroveTree();
                    break;

                default:
                    throw new ArgumentException("Unknown tree shape type");
                }
                newTree.Copy(treelist[i]);

                if (args.MapHeightLimit)
                {
                    int height    = newTree.Height;
                    int ybase     = newTree.Pos[1];
                    int mapHeight = args.Map.Height;
                    int foliageHeight;
                    if (args.Shape == TreeShape.Rainforest)
                    {
                        foliageHeight = 2;
                    }
                    else
                    {
                        foliageHeight = 4;
                    }
                    if (ybase + height + foliageHeight > mapHeight)
                    {
                        newTree.Height = mapHeight - ybase - foliageHeight;
                    }
                }

                if (newTree.Height < 1)
                {
                    newTree.Height = 1;
                }
                newTree.Prepare();
                treelist[i] = newTree;
            }
        }
Пример #4
0
        void ProcessTrees(List <Tree> treelist)
        {
            TreeShape[] shape_choices;
            switch (args.SHAPE)
            {
            case TreeShape.Stickly:
                shape_choices = new TreeShape[] { TreeShape.Normal,
                                                  TreeShape.Bamboo,
                                                  TreeShape.Palm };
                break;

            case TreeShape.Procedural:
                shape_choices = new TreeShape[] { TreeShape.Round,
                                                  TreeShape.Cone };
                break;

            default:
                shape_choices = new TreeShape[] { args.SHAPE };
                break;
            }

            for (int i = 0; i < treelist.Count; i++)
            {
                TreeShape newshape = shape_choices[args.rand.Next(0, shape_choices.Length)];
                Tree      newtree;
                switch (newshape)
                {
                case TreeShape.Normal:
                    newtree = new NormalTree();
                    break;

                case TreeShape.Bamboo:
                    newtree = new BambooTree();
                    break;

                case TreeShape.Palm:
                    newtree = new PalmTree();
                    break;

                case TreeShape.Round:
                    newtree = new RoundTree();
                    break;

                case TreeShape.Cone:
                    newtree = new ConeTree();
                    break;

                case TreeShape.Rainforest:
                    newtree = new RainforestTree();
                    break;

                case TreeShape.Mangrove:
                    newtree = new MangroveTree();
                    break;

                default:
                    throw new ArgumentException();
                }
                newtree.Copy(treelist[i]);

                if (args.MAPHEIGHTLIMIT)
                {
                    int height    = newtree.height;
                    int ybase     = newtree.pos[1];
                    int mapheight = args.inMap.MapSizeZ;
                    int foliageheight;
                    if (args.SHAPE == TreeShape.Rainforest)
                    {
                        foliageheight = 2;
                    }
                    else
                    {
                        foliageheight = 4;
                    }
                    if (ybase + height + foliageheight > mapheight)
                    {
                        newtree.height = mapheight - ybase - foliageheight;
                    }
                }

                if (newtree.height < 1)
                {
                    newtree.height = 1;
                }
                newtree.Prepare();
                treelist[i] = newtree;
            }
        }