Ejemplo n.º 1
0
    void RemoveBlock()
    {
        Vector3Int?pos = BlockRaycast.RaycastBlockPosition(Game.cameratr.position, Game.cameratr.forward, .1f, 1000);

        if (move.enabled && pos.HasValue)
        {
            World.RemoveBlock(pos.Value);
        }
    }
Ejemplo n.º 2
0
    static void SelectChunk()
    {
        if (!Circle.isActive && !EventSystem.current.IsPointerOverGameObject())
        {
            Vector3Int?pos = BlockRaycast.RaycastBlockPosition(camera.position, Game.camera.ScreenPointToRay(Input.mousePosition).direction, .1f, 1000);
            if (!pos.HasValue)
            {
                while (SelectedChunks.Count > 0)
                {
                    UnselectChunk(SelectedChunks[0]);
                }
                return;
            }

            tempchunk = GetChunkByBlock(pos.Value.x, pos.Value.z);

            if (Input.GetKey(KeyCode.LeftControl))
            {
                if (SelectedChunks.Contains(tempchunk))
                {
                    UnselectChunk(tempchunk);
                }
                else
                {
                    SelectChunk(tempchunk);
                }
            }
            else
            {
                while (SelectedChunks.Count > 0)
                {
                    UnselectChunk(SelectedChunks[0]);
                }
                SelectChunk(tempchunk);
            }
        }
    }
Ejemplo n.º 3
0
    void SetOutline()
    {
        Vector3Int?pos = BlockRaycast.RaycastBlockPosition(Game.cameratr.position, Game.cameratr.forward, .1f, 1000);

        if (pos.HasValue && building.Chunks.Contains(World.GetChunkByBlock(pos.Value.x, pos.Value.z)))
        {
            const float size     = 1.05f;
            Vector3     blockPos = pos.Value - Vector3.one * (size - 1f) / 2f;

            GL.PushMatrix();
            GL.Begin(GL.LINES);
            GL.Color(new Color(.1f, .1f, .1f));

            Vector3 temp = new Vector3();
            GL.Vertex(blockPos + temp);
            temp.y = size;
            GL.Vertex(blockPos + temp);
            GL.Vertex(blockPos + temp);
            temp.x = size;
            GL.Vertex(blockPos + temp);
            GL.Vertex(blockPos + temp);
            temp.y = 0f;
            GL.Vertex(blockPos + temp);
            GL.Vertex(blockPos + temp);
            temp.x = 0f;
            GL.Vertex(blockPos + temp);
            GL.Vertex(blockPos + temp);
            temp.z = size;
            GL.Vertex(blockPos + temp);
            GL.Vertex(blockPos + temp);
            temp.y = size;
            GL.Vertex(blockPos + temp);
            GL.Vertex(blockPos + temp);
            temp.z = 0f;
            GL.Vertex(blockPos + temp);

            temp.Set(size, 0f, 0f);
            GL.Vertex(blockPos + temp);
            temp.z = size;
            GL.Vertex(blockPos + temp);
            GL.Vertex(blockPos + temp);
            temp.y = size;
            GL.Vertex(blockPos + temp);
            GL.Vertex(blockPos + temp);
            temp.z = 0f;
            GL.Vertex(blockPos + temp);

            temp.Set(0f, 0f, size);
            GL.Vertex(blockPos + temp);
            temp.x = size;
            GL.Vertex(blockPos + temp);

            temp.Set(0f, size, size);
            GL.Vertex(blockPos + temp);
            temp.x = size;
            GL.Vertex(blockPos + temp);

            GL.End();
            GL.PopMatrix();
        }
    }