public void CreateDroppedBlock(int id, BlockType type, Vector3 pos)
    {
        DroppedBlock block = Instantiate(droppedBlockPrefab, pos, Quaternion.identity).GetComponent <DroppedBlock>();

        block.Init(type, pos);
        droppedBlocks.Add(id, block);
    }
Esempio n. 2
0
        // TODO Future, Do raycast on server instead of client side
        public void Interact(Vector3Int point, bool leftClick)
        {
            if ((head.position - point).sqrMagnitude > Settings.DigDistance * Settings.DigDistance)
            {
                Debug.Log("To far away to Interact");
                return;
            }

            if (leftClick)
            {
                Vector3 pos = point + new Vector3(0.5f + UnityEngine.Random.Range(0, 0.1f), 0.15f, 0.5f + UnityEngine.Random.Range(0, 0.1f));
                DroppedBlock.Instantiate(World.Get.GetBlock(point.x, point.y, point.z), pos);
                World.Get.Interact(point.x, point.y, point.z, BlockType.Air);
            }
            else
            {
                World.Get.SetBlock(point.x, point.y, point.z, inventory.HeldBlock);
                if (PlayerCollider.AnyCollision())
                {
                    World.Get.SetBlock(point.x, point.y, point.z, BlockType.Air);
                }
                else
                {
                    World.Get.Interact(point.x, point.y, point.z, inventory.HeldBlock);
                }
            }
        }