Example #1
0
    // Update is called once per frame
    void Update()
    {
        VoxelInfo info = Engine.VoxelRaycast(Camera.main.transform.position, Camera.main.transform.forward, range, false);

        SelectBlock();
        if (info != null)
        {
            SelectedShow(info);
            if (Input.GetMouseButtonDown(0))
            {
                Voxel.DestroyBlock(info);
            }
            if (Input.GetMouseButtonDown(1))
            {
                VoxelInfo newinfo = new VoxelInfo(info.adjacentIndex, info.chunk);
                if (IsOntheBlock(playerPosition, playerPosition.position, info) == true)
                {
                    Voxel.PlaceBlock(newinfo, blockID);
                }
            }
        }
        else
        {
            SelectedShow(info);
        }
    }
Example #2
0
 public override void OnMouseDown(int mouseButton, VoxelInfo voxelInfo)
 {
     if (mouseButton == 0)
     {
         Voxel.DestroyBlock(voxelInfo);  // destroy with left click
     }
     else if (mouseButton == 1)
     {                                        // open/close with right click
         if (voxelInfo.GetVoxel() == 70)
         {                                    // if open door
             Voxel.ChangeBlock(voxelInfo, 7); // set to closed
         }
         else if (voxelInfo.GetVoxel() == 7)
         {                                     // if closed door
             Voxel.ChangeBlock(voxelInfo, 70); // set to open
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        SelectBlockID();

        VoxelInfo info = Engine.VoxelRaycast(Camera.main.transform.position, Camera.main.transform.forward, 10, false);

        if (info != null)
        {
            //print(info.index);
            if (Input.GetMouseButtonDown(0))
            {
                Voxel.DestroyBlock(info);
            }
            if (Input.GetMouseButtonDown(1))
            {
                VoxelInfo newInfo = new VoxelInfo(info.adjacentIndex, info.chunk);
                Voxel.PlaceBlock(newInfo, blockID);
            }
        }
        UpdateSelectedBlockEffect(info);
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        SelectBlockID();

        VoxelInfo voxelInfo = Engine.VoxelRaycast(Camera.main.transform.position, Camera.main.transform.forward, range, false);

        if (null != voxelInfo)
        {
            if (Input.GetMouseButtonDown(0))
            {
                Voxel.DestroyBlock(voxelInfo);
            }

            if (Input.GetMouseButtonDown(1))
            {
                VoxelInfo targetInfo = new VoxelInfo(voxelInfo.adjacentIndex, voxelInfo.chunk);
                Voxel.PlaceBlock(targetInfo, blockID);
            }
        }
        UpdateSelectedBlock(voxelInfo);
    }
    void Update()
    {
        SelectBolckId();

        // origin direction range ingoreTransparent
        VoxelInfo info = Engine.VoxelRaycast(Camera.main.transform.position, Camera.main.transform.forward, range, false);

        if (info != null)
        {
            // 左键销毁
            if (Input.GetMouseButtonDown(0))
            {
                Voxel.DestroyBlock(info);
            }
            // 中键摆放
            if (Input.GetMouseButtonDown(1))
            {
                VoxelInfo newInfo = new VoxelInfo(info.adjacentIndex, info.chunk);
                Voxel.PlaceBlock(newInfo, blockId);
            }
        }

        UpdateSelectBolckEffect(info);
    }
    void Update()
    {
        SelectBlock();

        Transform camTrans = Camera.main.transform;

        VoxelInfo info = Engine.VoxelRaycast(camTrans.position, camTrans.forward, range, false);

        if (info != null)
        {
            if (Input.GetMouseButtonDown(0))
            {
                Voxel.DestroyBlock(info);
            }

            if (Input.GetMouseButtonDown(1))
            {
                VoxelInfo neighbourInfo = new VoxelInfo(info.adjacentIndex, info.chunk);
                Voxel.PlaceBlock(neighbourInfo, blockID);
            }
        }

        UpdateSelectEffect(info);
    }