Exemplo n.º 1
0
    public void Update()
    {
        if (WaitingOnDialogue)
        {
            Cursor.SetCursor(chatCursor, Vector2.zero, CursorMode.Auto);
            if (Input.GetMouseButtonDown(0))
            {
                WaitingOnDialogue = false;
                Time.timeScale    = 1;
                DialogueSystem.NextClick();
            }
            return;
        }

        if (grabbed != null && grabbed.isGrabbed)
        {
            Cursor.SetCursor(grabbed.defaultCursor, Vector2.zero, CursorMode.Auto);
            if (Input.GetMouseButtonDown(0))
            {
                grabbed.OnClick(this);
            }
            return;
        }

        Vector3 point = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));

        point = new Vector3(point.x, point.y, 0);

        Texture2D cursor = defaultCursor;

        if (point.y <= transform.position.y)
        {
            cursor = defaultNoCursor;
        }

        Collider2D[] colls = Physics2D.OverlapPointAll(point, mask, 10);
        clickAction = false;
        foreach (Collider2D c in colls)
        {
            CursorSetter s = c.GetComponent <CursorSetter>();
            if (s != null)
            {
                cursor = s.myCursor;
                if (Input.GetMouseButtonDown(0))
                {
                    IMouseClickable m = s.GetComponent <IMouseClickable>();
                    if (m != null)
                    {
                        clickAction = m.OnClick(this) || clickAction;
                    }
                }
            }
        }
        Cursor.SetCursor(cursor, Vector2.zero, CursorMode.Auto);

        if (Input.GetMouseButtonDown(0) && !clickAction)
        {
            Arc.Apex(this.GetComponent <Rigidbody2D>(), Camera.main.ScreenToWorldPoint(Input.mousePosition));
        }
    }
Exemplo n.º 2
0
    public bool OnClick(MouseController mouse)
    {
        if (isGrabbable)
        {
            if (isGrabbed)
            {
                showSelect(false);
                Arc.Apex(rb, Camera.main.ScreenToWorldPoint(Input.mousePosition));
            }
            else
            {
                showSelect(true);
                mouse.grabbed = this;
            }
            return(true);
        }

        return(false);
    }