Beispiel #1
0
    public static void UpdateGuideTextPos(NewbieGuideSpecialTipConf tipConf, GameObject inParentObj, CUIFormScript inGuideForm, CUIFormScript inOriginalForm, GameObject rootPanel)
    {
        if (tipConf == null || inParentObj == null || inGuideForm == null || inOriginalForm == null)
        {
            return;
        }
        RectTransform rectTransform  = (RectTransform)rootPanel.transform.FindChild("RightSpecial").transform;
        RectTransform rectTransform2 = (RectTransform)rootPanel.transform;
        Vector3       position       = inParentObj.transform.position;
        Vector2       vector         = CUIUtility.WorldToScreenPoint(inOriginalForm.GetCamera(), position);
        float         num            = vector.x;
        float         num2           = vector.y;
        float         num3           = 142f;
        float         num4           = 85f;
        Vector2       vector2        = new Vector2(0f, 0f);

        switch (tipConf.bSpecialTipPos)
        {
        case 0:
            vector2 = new Vector2(-num3, num4);
            break;

        case 1:
            vector2 = new Vector2(-num3, -num4);
            break;

        case 2:
            vector2 = new Vector2(num3, num4);
            break;

        case 3:
            vector2 = new Vector2(num3, -num4);
            break;
        }
        if (tipConf.iOffsetX != 0)
        {
            vector2.x += (float)tipConf.iOffsetX;
        }
        if (tipConf.iOffsetY != 0)
        {
            vector2.y += (float)tipConf.iOffsetY;
        }
        vector2.x = inGuideForm.ChangeFormValueToScreen(vector2.x);
        vector2.y = inGuideForm.ChangeFormValueToScreen(vector2.y);
        rectTransform2.sizeDelta = rectTransform.sizeDelta;
        float num5 = rectTransform2.rect.width / 2f;

        num5  = inGuideForm.ChangeFormValueToScreen(num5);
        num5 += 3f;
        float num6 = rectTransform2.rect.height / 2f;

        num6  = inGuideForm.ChangeFormValueToScreen(num6);
        num6 += 3f;
        num  += vector2.x;
        num2 += vector2.y;
        if (num < num5)
        {
            num = num5;
        }
        else if (num + num5 > (float)Screen.width)
        {
            num = (float)Screen.width - num5;
        }
        if (num2 < num6)
        {
            num2 = num6;
        }
        else if (num2 + num6 > (float)Screen.height)
        {
            num2 = (float)Screen.height - num6;
        }
        num  = inGuideForm.ChangeScreenValueToForm(num);
        num2 = inGuideForm.ChangeScreenValueToForm(num2);
        rectTransform2.anchoredPosition = new Vector2(num, num2);
    }
    public static void UpdateGuideTextPos(NewbieGuideSpecialTipConf tipConf, GameObject inParentObj, CUIFormScript inGuideForm, CUIFormScript inOriginalForm, GameObject rootPanel)
    {
        if (((tipConf != null) && (inParentObj != null)) && ((inGuideForm != null) && (inOriginalForm != null)))
        {
            CUIFormScript script     = inGuideForm;
            RectTransform transform  = (RectTransform)rootPanel.transform.FindChild("RightSpecial").transform;
            RectTransform transform2 = (RectTransform)rootPanel.transform;
            Vector3       position   = inParentObj.transform.position;
            Vector2       vector2    = CUIUtility.WorldToScreenPoint(inOriginalForm.GetCamera(), position);
            float         x          = vector2.x;
            float         y          = vector2.y;
            float         num3       = 142f;
            float         num4       = 85f;
            Vector2       vector3    = new Vector2(0f, 0f);
            switch (tipConf.bSpecialTipPos)
            {
            case 0:
                vector3 = new Vector2(-num3, num4);
                break;

            case 1:
                vector3 = new Vector2(-num3, -num4);
                break;

            case 2:
                vector3 = new Vector2(num3, num4);
                break;

            case 3:
                vector3 = new Vector2(num3, -num4);
                break;
            }
            if (tipConf.iOffsetX != 0)
            {
                vector3.x += tipConf.iOffsetX;
            }
            if (tipConf.iOffsetY != 0)
            {
                vector3.y += tipConf.iOffsetY;
            }
            float num5 = Mathf.Max(transform2.rect.width, transform.rect.width) / 2f;
            num5 = script.ChangeFormValueToScreen(num5) + 3f;
            float num6 = Mathf.Max(transform2.rect.height, transform.rect.height) / 2f;
            num6 = script.ChangeFormValueToScreen(num6) + 3f;
            x   += vector3.x;
            y   += vector3.y;
            if (x < num5)
            {
                x = num5;
            }
            else if ((x + num5) > Screen.width)
            {
                x = Screen.width - num5;
            }
            if (y < num6)
            {
                y = num6;
            }
            else if ((y + num6) > Screen.height)
            {
                y = Screen.height - num6;
            }
            x = script.ChangeScreenValueToForm(x);
            y = script.ChangeScreenValueToForm(y);
            transform2.anchoredPosition = new Vector2(x, y);
        }
    }