Ejemplo n.º 1
0
    public static void Build(Chunk chunk, BlockPos pos, TerrainGen terrainGen)
    {
        int leaves = terrainGen.GetNoise(pos.x + chunk.pos.x, 0, pos.z + chunk.pos.z, 1f, 2, 1) + 1;

        for (int x = -leaves; x <= leaves; x++)
        {
            for (int y = 3; y <= 6; y++)
            {
                for (int z = -leaves; z <= leaves; z++)
                {
                    TerrainGen.SetBlock(chunk, "leaves", pos.Add(x, y, z), true);
                }
            }
        }
        for (int y = 0; y <= 5; y++)
        {
            TerrainGen.SetBlock(chunk, "log", pos.Add(0, y, 0), true);
        }
    }
Ejemplo n.º 2
0
    //same tree every time
    public void CreateTree(int x, int y, int z, Chunk chunk, bool upsideDown, string company, int height)
    {
        StockInventory inven = GameObject.Find("StockDatabase").GetComponent <StockInventory>();


        Company       c    = (Company)inven.companyTranslation[company];
        int           seas = GameObject.Find("Clock").GetComponent <Calendar>().month;
        List <double> list = (List <double>)inven.stocksValue[c];

        double curr = list[seas];
        double min  = c.min;
        double inc  = c.incrementer;
        double temp = (curr - min) / inc;
        int    type = (int)temp;

        type = Mathf.Min(type, 4);
        type = Mathf.Max(type, 0);
        //create leaves
        if (height >= 3)
        {
            for (int xi = -2; xi <= 2; xi++)
            {
                for (int yi = height; yi <= height + 4; yi++)
                {
                    for (int zi = -2; zi <= 2; zi++)
                    {
                        if (!upsideDown)
                        {
                            Block leavesBlock;
                            //TODO change leaf color
                            if (type == 0)
                            {
                                leavesBlock = new BlockLeaves0();
                                //leavesBlock.SetCompany(company);
                            }
                            else if (type == 1)
                            {
                                leavesBlock = new BlockLeaves1();
                            }
                            else if (type == 2)
                            {
                                leavesBlock = new BlockLeaves2();
                            }
                            else if (type == 3)
                            {
                                leavesBlock = new BlockLeaves3();
                            }
                            else
                            {
                                leavesBlock = new BlockLeaves4();
                            }
                            //BlockGreenLeaves leavesBlock = new BlockGreenLeaves();
                            leavesBlock.SetCompany(company);
                            //TerrainGen.SetBlock(x + xi, y + yi, z + zi, leavesBlock, chunk, true);
                            SetBlock(x + xi, y + yi, z + zi, leavesBlock);
                        }
                        else
                        {
                            TerrainGen.SetBlock(x - xi, y - yi, z - zi, new BlockOrangeLeaves(), chunk, true);
                        }
                    }
                }
            }
        }

        //create trunk
        //replace height avg
        //   int height = 6;
        for (int yt = 0; yt < height; yt++)
        {
            if (!upsideDown)
            {
                Block block = GetCompanyBlock(company);

                SetBlock(x, y + yt, z, block, chunk, true);
                SetBlock(x, y + yt, z, block);
            }
            else
            {
                SetBlock(x, y - yt, z, new BlockWhiteWood(), chunk, true);
            }
        }
    }
Ejemplo n.º 3
0
 public virtual void SetBlock(int x, int y, int z, Block block)
 {
     terrain.SetBlock(x, y, z, block);
 }