Esempio n. 1
0
    public void set_mouse_pos(Vector2 pos)
    {
        if (!GetNodeOrNull <singleton.InGameState>("/root/in_game_state").CURRENT_STATE.Equals(constant.StateNames.BUILD_TUNNEL))
        {
            return;
        }
        mouse_cell_pos = pos;

        int x = (int)pos.x;
        int y = (int)pos.y;

        if (x % 2 == 0 && y % 2 == 0 && start_pos == null)
        {
            var tl = mouse_preview.GetTranslation();
            tl.x = pos.x * 2;
            tl.y = pos.y * 2;
            mouse_preview.SetTranslation(tl);
        }
        else if (start_pos != null)
        {
            var tl = mouse_preview.GetTranslation();
            tl.x = pos.x * 2;
            tl.y = pos.y * 2;
            mouse_preview.SetTranslation(tl);
        }

        if (start_pos != null && !end_pos.Equals(pos))
        {
            end_pos = pos;
            generate_mesh();
        }

        if (Input.IsMouseButtonPressed((int)ButtonList.Left) && start_pos == null && x % 2 == 0 && y % 2 == 0)
        {
            GetNode <MeshInstance>("mouse_draw_preview").Visible = true;
            start_pos = pos;
        }
        else if (!Input.IsMouseButtonPressed((int)ButtonList.Left) && start_pos != null)
        {
            lastPoints = (Vector2[])curPoints.Clone();
            curPoints  = new Vector2[0];
            start_pos  = null;
            end_pos    = null;
            GD.Print(lastPoints);
            GetNode <MeshInstance>("mouse_draw_preview").Visible = false;
        }
    }