using SGModule.Common.Base;
using UnityEngine;

public class CommonTools 
    {
        // 设计分辨率宽高比
        private static readonly Vector2 DesignResolution = new Vector2(1080f, 2420f);
        // 最小和最大缩放比例
        private const float MinScale = 0.58f;
        private const float MaxScale = 1.0f;
        
        // 计算缩放比例
        // 计算缩放比例
        float CalculateScale(Vector2 currentResolution, Vector2 designResolution)
        {
            // 计算当前设备和设计分辨率的宽高比
            
            float currentAspectRatio = currentResolution.y / currentResolution.x;
            float designAspectRatio = designResolution.y / designResolution.x;

            // 通过宽高比计算缩放比例
            return currentAspectRatio / designAspectRatio;
        }


        public float GetScale()
        {
            
            // 获取当前设备的屏幕分辨率
            Vector2 currentResolution = new Vector2(Screen.width, Screen.height);
            
            // 计算缩放比例
            float scale = CalculateScale(currentResolution, DesignResolution);
            
            // 限制缩放比例在最大和最小范围内
            scale = Mathf.Clamp(scale, MinScale, MaxScale);
            
            return scale;
        }

        // public SkeletonAnimation InitAdBtnAnim(GGraph parent)
        // {
        //     // Action closeCallback = null;
        //     // var animation = FXManager.Instance.SetFx<SkeletonAnimation>(parent, Fx_Type.Fx_AdIcon, ref closeCallback);
        //     // animation.state.AddAnimation(0, "animation", true, 0);
        //     //
        //     // return animation;
        // }
    }