Example #1
0
    private void Init()
    {
        instance = this;

        float rateValue = (screenBaseSize.x * (float)Screen.height) / (screenBaseSize.y * (float)Screen.width);

        if (rateValue > 1f)  //비율이 screenBaseSize보다 세로로 더 김. fix width. //
        {
            screenWidth  = Mathf.RoundToInt(screenBaseSize.x);
            screenHeight = Mathf.RoundToInt((float)Screen.height * screenWidth / (float)Screen.width);
            screenRate   = (float)Screen.width / screenWidth;
        }
        else if (rateValue < 1f) //비율이 screenBaseSize보다 가로로 더 김. fix height//
        {
            screenHeight = Mathf.RoundToInt(screenBaseSize.y);
            screenWidth  = Mathf.RoundToInt((float)Screen.width * screenHeight / (float)Screen.height);
            screenRate   = (float)Screen.height / screenHeight;
        }
        else
        {
            screenWidth  = Mathf.RoundToInt(screenBaseSize.x);
            screenHeight = Mathf.RoundToInt(screenBaseSize.y);
            screenRate   = (float)Screen.width / screenWidth;
        }

        invScreenRate    = 1f / screenRate;
        screenHalfWidth  = screenWidth * 0.5f;
        screenHalfHeight = screenHeight * 0.5f;
        DontDestroyOnLoad(gameObject);
    }
    public void HideMessageBox(System.Action callback)
    {
        blocker.enabled = true;
        message.text    = "";

        float   value = (ScreenSizeGetter.width - ScreenSizeGetter.GetBaseScreenSize().x) * 0.5f;
        Vector3 from  = new Vector3(baseBodyShowXPos - value, height, 0f);
        Vector3 to    = new Vector3(baseBodyHideXPos - value, height, 0f);

        AnimCurveController.Move(hideCurve.bodyCurve, from, to, hideAnimTime, body, () =>
        {
            blocker.enabled = false;
            bOpend          = false;
            if (callback != null)
            {
                callback();
            }
        });

        from = new Vector3(0f, baseCharacterShowYPos, 0f);
        to   = new Vector3(0f, baseCharacterHideYPos, 0f);
        AnimCurveController.Move(hideCurve.characterCurve, from, to, hideAnimTime, character, null);

        from = Vector3.one;
        to   = new Vector3(0f, 0f, 1f);
        AnimCurveController.Scale(hideCurve.messageCurve, from, to, hideAnimTime, messageBody, null);
    }
Example #3
0
 private static void MakeInstance()
 {
     instance = FindObjectOfType(typeof(ScreenSizeGetter)) as ScreenSizeGetter;
     if (instance == null)
     {
         GameObject obj = new GameObject("ScreenSizeGetter");
         instance = obj.AddComponent <ScreenSizeGetter>();
     }
     instance.Init();
 }
    public void SetMessageBox(int textIdx, Vector3 pos, System.Action callback)
    {
        float value = (ScreenSizeGetter.width - ScreenSizeGetter.GetBaseScreenSize().x) * 0.5f;

        if (bOpend)
        {
            if (pos.y >= 0f && height != bottomHeight)
            {
                height             = bottomHeight;
                body.localPosition = new Vector3(baseBodyShowXPos - value, height, 0f);
            }
            else if (pos.y < 0f && height != topHeight)
            {
                height             = topHeight;
                body.localPosition = new Vector3(baseBodyShowXPos - value, height, 0f);
            }

            blocker.enabled = false;
            if (preTextIdx == textIdx)
            {
                if (callback != null)
                {
                    callback();
                }
            }
            else
            {
                preTextIdx   = textIdx;
                message.text = DataManager.GetText(textIdx);
                if (callback != null)
                {
                    callback();
                }
            }
        }
        else
        {
            blocker.enabled = true;
            message.text    = "";

            if (pos.y >= 0f)
            {
                height = bottomHeight;
            }
            else
            {
                height = topHeight;
            }

            Vector3 from = new Vector3(baseBodyHideXPos - value, height, 0f);
            Vector3 to   = new Vector3(baseBodyShowXPos - value, height, 0f);
            AnimCurveController.Move(showCurve.bodyCurve, from, to, showAnimTime, body, null);

            from = new Vector3(0f, baseCharacterHideYPos, 0f);
            to   = new Vector3(0f, baseCharacterShowYPos, 0f);
            AnimCurveController.Move(showCurve.characterCurve, from, to, showAnimTime, character, null);

            from = new Vector3(0f, 0f, 1f);
            to   = Vector3.one;
            AnimCurveController.Scale(showCurve.messageCurve, from, to, showAnimTime, messageBody, () =>
            {
                bOpend = true;
                if (preTextIdx == textIdx)
                {
                    if (callback != null)
                    {
                        callback();
                    }
                }
                else
                {
                    preTextIdx      = textIdx;
                    message.text    = DataManager.GetText(textIdx);
                    blocker.enabled = false;
                    if (callback != null)
                    {
                        callback();
                    }
                }
            });
        }
    }