using System; using System.Collections.Generic; using Plugins.CxShine.Singleton; using UnityEngine; namespace Api { public class AccountManager : ScriptSingleton { private string _session; public PlayerInfo selfInfo; public List playerCocks = new List(); public void login(string phone, string code, bool isIndia, Action success, Action errAction) { ApiComp.Instance.NotSessionLoginVerifyCode(phone, code, isIndia, data => { // Debug.LogError("sesssion>>>>"+data.session); selfInfo = data.selfInfo; _session = data.session; PlayerPrefs.SetString("session", data.session); success?.Invoke(data); }, errAction); } public bool isLogin() { return !String.IsNullOrEmpty(GetSession()); } public void playerCocksEmpty() { playerCocks = new List(); } public void initPlayerCocks(List dataPlayerCocks) { playerCocks = dataPlayerCocks; } public int GetCockTimes(int cockId) { foreach (var cock in playerCocks) { if (cock.cockId == cockId) { return cock.times; } } return 0; } public int GetDiamond() { return selfInfo.diamond; } public void requestSelfInfo(Action action, Action errAction) { ApiComp.Instance.QuerySelfInfo(data => { _session = data.session; selfInfo = data.selfInfo; action.Invoke(data); }, errAction); } private const string PP_SESSION = "session"; public bool HasSession() { return PlayerPrefs.HasKey(PP_SESSION); } public string GetSession() { if (String.IsNullOrEmpty(_session)) { if (PlayerPrefs.HasKey(PP_SESSION)) { _session = PlayerPrefs.GetString(PP_SESSION); } } // Debug.LogError(api+"获取Session"+_session); return _session; } } }