12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using System;
- using System.Collections.Generic;
- using Plugins.CxShine.Singleton;
- using UnityEngine;
- namespace Api
- {
- public class AccountManager : ScriptSingleton<AccountManager>
- {
- private string _session;
- public PlayerInfo selfInfo;
- public List<Cock> playerCocks = new List<Cock>();
- public void login(string phone, string code, bool isIndia, Action<ResponseSuccessData> success,
- Action<int, string> 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<Cock>();
- }
- public void initPlayerCocks(List<Cock> 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<ResponseSuccessData> action, Action<int, string> 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;
- }
- }
- }
|