Beispiel #1
0
    public virtual bool ReactToPointerDown(float worldPointX, float worldPointY)
    {
        bool    react          = false;
        Vector3 centerPosition = Vector3.zero;
        Vector2 topLeft        = Vector2.zero;

        if (reactionType == ReactionType.NotReact)
        {
            return(false);
        }
        if (open && !autoClose)
        {
            if (reactionType == ReactionType.ReactPrecisely)
            {
                centerPosition = transform.position;

                /*halmeida - the boxArea is top-left anchored, so it already has the offsets from the center to the left and
                 * from the center to the top.*/
                topLeft.x = centerPosition.x + boxArea.x;
                topLeft.y = centerPosition.y + boxArea.y;
                react     = UsefulFunctions.AreaContainsPoint(topLeft.x, topLeft.y, boxArea.width, boxArea.height, worldPointX, worldPointY);
            }
            else
            {
                react = true;
            }
            if (react)
            {
                ReactToInteraction();
                return(true);
            }
        }
        return(false);
    }
Beispiel #2
0
    public virtual bool ReactToPointerDown(Vector2 canvasPosition)
    {
        bool    react   = false;
        Vector2 topLeft = Vector2.zero;

        if (reactionType == ReactionType.NotReact)
        {
            return(false);
        }
        if (open && !autoClose && (ownTransform != null))
        {
            if (reactionType == ReactionType.ReactPrecisely)
            {
                /*halmeida - the boxArea is top-left anchored, so it already has the offsets from the center to the left and
                 * from the center to the top.*/
                topLeft.x = ownTransform.anchoredPosition.x + boxArea.x;
                topLeft.y = ownTransform.anchoredPosition.y + boxArea.y;
                react     = UsefulFunctions.AreaContainsPoint(topLeft.x, topLeft.y, boxArea.width, boxArea.height, canvasPosition.x, canvasPosition.y);
            }
            else
            {
                react = true;
            }
            if (react)
            {
                ReactToInteraction();
                return(true);
            }
        }
        return(false);
    }
Beispiel #3
0
 private bool CheckTransformPointCollision(RectTransform rectTrans, Vector2 canvasPoint)
 {
     if (rectTrans != null)
     {
         float realWidth  = rectTrans.rect.width * rectTrans.localScale.x;
         float realHeight = rectTrans.rect.height * rectTrans.localScale.y;
         float xMin       = rectTrans.anchoredPosition.x - realWidth / 2f;
         float yMax       = rectTrans.anchoredPosition.y + realHeight / 2f;
         return(UsefulFunctions.AreaContainsPoint(xMin, yMax, realWidth, realHeight, canvasPoint.x, canvasPoint.y));
     }
     return(false);
 }
Beispiel #4
0
    protected virtual bool CheckOptionsHit(Vector2 canvasPoint)
    {
        RectTransform  optionTransform = null;
        ButtonAnimator optionComponent = null;
        float          realWidth       = 0f;
        float          realHeight      = 0f;
        float          xMin            = 0f;
        float          yMax            = 0f;

        if (optionTransforms != null)
        {
            for (int i = 0; i < optionTransforms.Length; i++)
            {
                optionTransform = optionTransforms[i];
                realWidth       = optionTransform.rect.width * optionTransform.localScale.x;
                realHeight      = optionTransform.rect.height * optionTransform.localScale.y;
                xMin            = optionTransform.anchoredPosition.x - realWidth / 2f;
                yMax            = optionTransform.anchoredPosition.y + realHeight / 2f;
                if (optionsParentTransform != null)
                {
                    xMin += optionsParentTransform.anchoredPosition.x;
                    yMax += optionsParentTransform.anchoredPosition.y;
                }
                if (UsefulFunctions.AreaContainsPoint(xMin, yMax, realWidth, realHeight, canvasPoint.x, canvasPoint.y))
                {
                    selectedOptionComponent = null;
                    if (optionComponents != null)
                    {
                        if (optionComponents.Length > i)
                        {
                            optionComponent = optionComponents[i];
                            if (optionComponent != null)
                            {
                                selectedOptionComponent = optionComponent;
                                selectedOptionComponent.SetPressed(true);
                            }
                        }
                    }
                    selectedChoiceEffect = ChoiceEffect.None;
                    if (optionEffects != null)
                    {
                        if (optionEffects.Length > i)
                        {
                            selectedChoiceEffect = optionEffects[i];
                        }
                    }
                    return(true);
                }
            }
        }
        return(false);
    }
Beispiel #5
0
 private bool CheckQuitHit(Vector2 canvasPoint)
 {
     if (quitTransform != null)
     {
         float realWidth  = quitTransform.rect.width * quitTransform.localScale.x;
         float realHeight = quitTransform.rect.height * quitTransform.localScale.y;
         float xMin       = quitTransform.anchoredPosition.x - realWidth / 2f;
         float yMax       = quitTransform.anchoredPosition.y + realHeight / 2f;
         if (UsefulFunctions.AreaContainsPoint(xMin, yMax, realWidth, realHeight, canvasPoint.x, canvasPoint.y))
         {
             selectedQuitComponent = quitComponent;
             selectedQuitComponent.SetPressed(true);
             ReactToQuitRequest(true);
             return(true);
         }
     }
     return(false);
 }