コード例 #1
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);
            }
        }
    }
コード例 #2
0
    public virtual Block.Tile TexturePosition(Block.Direction direction)
    {
        Block.Tile tile = new Block.Tile();

        switch (blockType)
        {
        case "Stone":
            Block blockStone = new Block();
            blockStone.upsideDown = upsideDown;
            tile = blockStone.TexturePosition(direction);
            return(tile);

        case "Grass":
            BlockGrass blockGrass = new BlockGrass();
            blockGrass.upsideDown = upsideDown;
            tile = blockGrass.TexturePosition(direction);
            return(tile);

        case "BrownWood":
            BlockBrownWood blockBrownWood = new BlockBrownWood();
            blockBrownWood.upsideDown = upsideDown;
            tile = blockBrownWood.TexturePosition(direction);
            return(tile);

        case "Lava":
            BlockLava blockLava = new BlockLava();
            blockLava.upsideDown = upsideDown;
            tile = blockLava.TexturePosition(direction);
            return(tile);

        case "GreenLeaves":
            BlockGreenLeaves blockGreenLeaves = new BlockGreenLeaves();
            blockGreenLeaves.upsideDown = upsideDown;
            tile = blockGreenLeaves.TexturePosition(direction);
            return(tile);

        case "OrangeLeaves":
            BlockOrangeLeaves blockOrangeLeaves = new BlockOrangeLeaves();
            blockOrangeLeaves.upsideDown = upsideDown;
            tile = blockOrangeLeaves.TexturePosition(direction);
            return(tile);

        case "StoneSnow":
            BlockStoneSnow blockStoneSnow = new BlockStoneSnow();
            blockStoneSnow.upsideDown = upsideDown;
            tile = blockStoneSnow.TexturePosition(direction);
            return(tile);

        case "Ice":
            BlockIce blockIce = new BlockIce();
            blockIce.upsideDown = upsideDown;
            tile = blockIce.TexturePosition(direction);
            return(tile);

        case "Glass":
            BlockGlass blockGlass = new BlockGlass();
            blockGlass.upsideDown = upsideDown;
            tile = blockGlass.TexturePosition(direction);
            return(tile);

        case "WhiteWood":
            BlockWhiteWood blockWhiteWood = new BlockWhiteWood();
            blockWhiteWood.upsideDown = upsideDown;
            tile = blockWhiteWood.TexturePosition(direction);
            return(tile);

        case "Apple":
            BlockApple blockApple = new BlockApple();
            blockApple.upsideDown = upsideDown;
            tile = blockApple.TexturePosition(direction);
            return(tile);

        case "Alphabet":
            BlockAlphabet blockAlphabet = new BlockAlphabet();
            blockAlphabet.upsideDown = upsideDown;
            tile = blockAlphabet.TexturePosition(direction);
            return(tile);

        case "Amazon":
            BlockAmazon blockAmazon = new BlockAmazon();
            blockAmazon.upsideDown = upsideDown;
            tile = blockAmazon.TexturePosition(direction);
            return(tile);

        case "Facebook":
            BlockFacebook blockFacebook = new BlockFacebook();
            blockFacebook.upsideDown = upsideDown;
            tile = blockFacebook.TexturePosition(direction);
            return(tile);

        case "IBM":
            BlockIBM blockIBM = new BlockIBM();
            blockIBM.upsideDown = upsideDown;
            tile = blockIBM.TexturePosition(direction);
            return(tile);

        case "Intel":
            BlockIntel blockIntel = new BlockIntel();
            blockIntel.upsideDown = upsideDown;
            tile = blockIntel.TexturePosition(direction);
            return(tile);

        case "Microsoft":
            BlockMicrosoft blockMicrosoft = new BlockMicrosoft();
            blockMicrosoft.upsideDown = upsideDown;
            tile = blockMicrosoft.TexturePosition(direction);
            return(tile);

        case "Netflix":
            BlockNetflix blockNetflix = new BlockNetflix();
            blockNetflix.upsideDown = upsideDown;
            tile = blockNetflix.TexturePosition(direction);
            return(tile);

        case "Twitter":
            BlockTwitter blockTwitter = new BlockTwitter();
            blockTwitter.upsideDown = upsideDown;
            tile = blockTwitter.TexturePosition(direction);
            return(tile);

        case "Yahoo":
            BlockYahoo blockYahoo = new BlockYahoo();
            blockYahoo.upsideDown = upsideDown;
            tile = blockYahoo.TexturePosition(direction);
            return(tile);

        case "Leaves0":
            BlockLeaves0 blockLeaves0 = new BlockLeaves0();
            blockLeaves0.upsideDown = upsideDown;
            tile = blockLeaves0.TexturePosition(direction);
            return(tile);

        case "Leaves1":
            BlockLeaves1 blockLeaves1 = new BlockLeaves1();
            blockLeaves1.upsideDown = upsideDown;
            tile = blockLeaves1.TexturePosition(direction);
            return(tile);

        case "Leaves2":
            BlockLeaves2 blockLeaves2 = new BlockLeaves2();
            blockLeaves2.upsideDown = upsideDown;
            tile = blockLeaves2.TexturePosition(direction);
            return(tile);

        case "Leaves3":
            BlockLeaves3 blockLeaves3 = new BlockLeaves3();
            blockLeaves3.upsideDown = upsideDown;
            tile = blockLeaves3.TexturePosition(direction);
            return(tile);

        case "Leaves4":
            BlockLeaves4 blockLeaves4 = new BlockLeaves4();
            blockLeaves4.upsideDown = upsideDown;
            tile = blockLeaves4.TexturePosition(direction);
            return(tile);
        }
        //just in case it's not registered
        Block blockAir = new BlockAir();

        tile = blockAir.TexturePosition(direction);
        return(tile);
    }