using System;
using Cysharp.Threading.Tasks;
using Game.Plugins.App;
using Script.battle;
using UnityEngine;
using UnityEngine.UI;

namespace Script
{
    public class UIMain : MonoBehaviour
    {
        public Text frameLabel;
        float f = 1.23456789f;
        
        private void Awake()
        {
            for (int i = 1000 - 1; i >= 0; i--)
            {
                // 进行一些基本的浮点数运算  
                f = f + f;  
                f = f - (f / 2);  
                f = f * (f / 2);  
                f = f / (f / 2);  
                f = (float)Math.Sqrt(f);  
                f = Math.Abs(f);  
                f = (float)Math.Log(f);  
                f = (float)Math.Log10(f);  
                f = (float)Math.Exp(f);  
            }
            DontDestroyOnLoad(this.gameObject);
        }

        //重置
        public void OnClickReset()
        {
            GBattleModeManager.Instance.Open(GBattleMode.Default).Forget();
        }

        private void Update()
        {
            this.frameLabel.text = $"{Application.identifier} 浮点数计算: {f} 服务器帧数: {App.Sync.NServerFrame} 本地运行帧 {App.Sync.NLocalFrame} 本地已执行帧 {App.Sync.NLocalRunFrame} 是否正在请求{App.Sync.IsRequestServerData} \nFPS:{1f/Time.deltaTime} \nthis.DyTime():{App.Sync.DyTime()} \n一帧执行时间:{App.Sync.frameTime} \n是否追帧:{App.Sync.IsLoop}";
        }
    }
}