Example #1
0
    public override void BaseAddVertsUVsColors(Chunk chunk, Vector3Int localPosition, BlockDirectionEnum direction, DirectionEnum face, Vector3[] vertsAdd, Vector2[] uvsAdd, Color[] colorsAdd)
    {
        BlockBean blockData = chunk.GetBlockData(localPosition);

        if (blockData != null && face == DirectionEnum.UP)
        {
            BlockMetaPlough blockMetaPlough = Block.FromMetaData <BlockMetaPlough>(blockData.meta);
            //判断是否浇水
            if (blockMetaPlough != null && blockMetaPlough.waterState == 1)
            {
                base.BaseAddVertsUVsColors(chunk, localPosition, direction, face, vertsAdd, uvsAdd, colorAddWater);
            }
            else
            {
                base.BaseAddVertsUVsColors(chunk, localPosition, direction, face, vertsAdd, uvsAdd, colorsAdd);
            }
            return;
        }
        base.BaseAddVertsUVsColors(chunk, localPosition, direction, face, vertsAdd, uvsAdd, colorsAdd);
    }
    public override void ItemUseHandle(ItemsBean itemsData, Vector3Int targetPosition, Block targetBlock, BlockDirectionEnum targetBlockDirection, Chunk targetChunk)
    {
        if (targetBlock == null)
        {
            return;
        }
        if (targetBlock.blockInfo.GetBlockShape() != BlockShapeEnum.Plough)
        {
            return;
        }
        ItemsDetailsToolBean itemsDetailsTool = itemsData.GetMetaData <ItemsDetailsToolBean>();

        //如果没有耐久了 则不执行
        if (itemsDetailsTool.life <= 0)
        {
            return;
        }
        //扣除耐久
        itemsDetailsTool.AddLife(-1);
        //保存数据 道具数据
        itemsData.SetMetaData(itemsDetailsTool);
        //回调
        EventHandler.Instance.TriggerEvent(EventsInfo.ItemsBean_MetaChange, itemsData);

        //修改耕地的状态
        BlockBean       blockData       = targetChunk.GetBlockData(targetPosition - targetChunk.chunkData.positionForWorld);
        BlockMetaPlough blockMetaPlough = Block.FromMetaData <BlockMetaPlough>(blockData.meta);

        if (blockMetaPlough == null)
        {
            blockMetaPlough = new BlockMetaPlough();
        }
        blockMetaPlough.waterState = 1;
        blockData.meta             = Block.ToMetaData(blockMetaPlough);
        targetChunk.SetBlockData(blockData);
        //更新区块
        WorldCreateHandler.Instance.manager.AddUpdateChunk(targetChunk, 1);
    }