Ejemplo n.º 1
0
    void BreakBlock(Vector3Int pos)
    {
        if (Time.time - lastBreakTime < 0.1f)
        {
            return;
        }
        lastBreakTime = Time.time;

        breakingTime = 0;

        HideBreakingEffect();
        //DeleteBlockReq(WireFrameHelper.pos);

        NBTBlock generator = WireFrameHelper.generator;

        if (generator.hasDropItem)
        {
            try
            {
                string id   = generator.GetDropItemByData(WireFrameHelper.data);
                byte   data = generator.GetDropItemData(WireFrameHelper.data);
                Item.CreateBlockDropItem(id, data, pos);
            }
            catch (System.Exception e)
            {
                Debug.LogError("create item error, id=" + generator.GetDropItemByData(WireFrameHelper.data) + ",generator=" + generator);
            }
        }
        generator.OnDestroyBlock(WireFrameHelper.pos, WireFrameHelper.data);

        if (generator.isTileEntity)
        {
            NBTChunk chunk = NBTHelper.GetChunk(WireFrameHelper.pos);
            chunk.RemoveTileEntity(WireFrameHelper.pos);
            NBTHelper.SetBlockByteNoUpdate(WireFrameHelper.pos, 0);
        }
        else
        {
            NBTHelper.SetBlockByte(WireFrameHelper.pos, 0);
        }


        //Item.CreateBlockDropItem(type, WireFrameHelper.pos);
        BreakBlockEffect.Create(WireFrameHelper.type, WireFrameHelper.data, WireFrameHelper.pos);
        SoundManager.PlayBreakSound(WireFrameHelper.type, instance.gameObject);
    }
Ejemplo n.º 2
0
    void BreakBlock(Vector3Int pos)
    {
        breakTime = 0;

        handAnimator.SetBool("isBreaking", false);

        HideBreakingEffect();
        //DeleteBlockReq(WireFrameHelper.pos);

        NBTBlock generator = NBTGeneratorManager.GetMeshGenerator(WireFrameHelper.type);

        if (generator.hasDropItem)
        {
            Item.CreateBlockDropItem(generator.GetDropItemByData(WireFrameHelper.data), WireFrameHelper.data, pos);
        }

        NBTHelper.SetBlockByte(WireFrameHelper.pos, 0);

        //Item.CreateBlockDropItem(type, WireFrameHelper.pos);
        BreakBlockEffect.Create(WireFrameHelper.type, WireFrameHelper.data, WireFrameHelper.pos);
        SoundManager.PlayBreakSound(WireFrameHelper.type, instance.gameObject);
    }