using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using XRTool.Util;

public class UserManager :Singleton<UserManager>
{
    public AccountData NowChoose = null;
    public GameObject NowChooseGo = null;

    public void removeUser()
    {
        NowChooseGo.SetActive(false);
        NowChoose = null;
    }

    public void setNowUser(AccountData ad,Transform t,Texture tex)
    {
        NowChoose = ad;
        if (Instance.NowChooseGo==null)
            Instance.NowChooseGo = GameObject.Instantiate(WindowsManager.Instance.GetPrefab(WindowConfig.windowType.Login,"UserIcon")).gameObject;

        Instance.NowChooseGo.GetComponent<RawImage>().texture = tex;
        Instance.NowChooseGo.transform.localScale = Vector3.one;
        Instance.NowChooseGo.transform.localEulerAngles = Vector3.zero;
        Instance.NowChooseGo.transform.position = t.position;
    }
    public void MoveIcon(Vector3 v3,Transform t,Action callback)
    {
        if (Instance!=null&&Instance.NowChooseGo != null)
        {
            Instance.NowChooseGo.transform.parent = t;
            Instance.NowChooseGo.transform.localEulerAngles = Vector3.zero;
            Instance.NowChooseGo.transform.localScale = Vector3.one;
            Instance.NowChooseGo.transform.DOLocalMove(v3, 0.5f).OnComplete(() => {
                callback.Invoke();
            });
            Instance.NowChooseGo.transform.GetComponent<RectTransform>().DOSizeDelta(t.GetComponent<RectTransform>().sizeDelta, 0.5f).OnComplete(() => {
            });
        }
    }
}
