Beispiel #1
0
    //返回是否是 combobox
    public bool Click()
    {
        if (BattleManager.Instance.isBattle == false)
        {
            return(false);
        }
        ClickBox topbox = null;

        //是否触碰到box
        if (touchBox.Count > 0)
        {
            //获得最上面的box
            for (int i = 0; i < touchBox.Count; i++)
            {
                if (topbox != null)
                {
                    if (touchBox[i] != null)
                    {
                        ClickBox curbox = touchBox[i].GetComponent <ClickBox>();
                        if (topbox.sprite.depth < curbox.sprite.depth)
                        {
                            topbox = curbox;
                        }
                    }
                }
                else
                {
                    if (touchBox[i] != null)
                    {
                        topbox = touchBox[i].GetComponent <ClickBox>();
                    }
                    if (topbox == null && touchBox[i].gameObject != null && touchBox[i].gameObject.transform.parent.gameObject != null)
                    {
                        topbox = touchBox[i].gameObject.transform.parent.gameObject.GetComponent <ClickBox>();
                    }
                }
            }
            //处理click事件
            if (topbox != null && topbox.type != ClickBox.BoxType.ComboBox)
            {
                touchBox.Remove(topbox.gameObject);
                topbox.Click(topbox.type);
            }
            else if (topbox != null && topbox.type == ClickBox.BoxType.ComboBox)
            {
                dragBox = topbox.GetComponent <DragBox>();
                return(true);
            }
            else //有时候touchbox 没清干净
            {
                BattleManager.Instance.ClickBoxOver(ClickBox.BoxType.None);
            }
        }
        else  //什么都没点到
        {
            BattleManager.Instance.ClickBoxOver(ClickBox.BoxType.None);
        }
        return(false);
    }
Beispiel #2
0
    /* finds first clickBox that Contains both the starting
     * and ending click position, then runs it's event. */
    private void runClickEvent(Vector2 start, Vector2 end)
    {
        List <ClickBox> cbs      = ClickBoxes;
        ClickBox        clickBox = null;

        // Search list of clickBoxes in decending hierachical order
        for (int i = cbs.Count - 1; i >= 0; i--)
        {
            ClickBox cb = cbs[i];
            // Debug.Log($"{cb.gameObject.name}'s clickbox clicked.");
            if (cb.ContainsPoint(start) && cb.ContainsPoint(end))
            {
                clickBox = cb;
                break;
            }
        }

        if (clickBox != null)
        {
            clickBox.Click(start, end);
            lastClickTime = GetMillis();
        }
    }