123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using LitJson;
- using System;
- using MetaClient;
- public class MainAccountData
- {
- public static MainAccountData Instance = null;
- public static string ver = "1.0.1";
- public static string code = "";
- public static string NickName = "";
- public static string Avatar = "";
- public static string Gender = null;
- public static string Country = "中国";
- public static string Province = "";
- public static string City = "";
- public static string Device = "";
- public static string ShareId = "";
- public static string Scene = "";
- public MainAccountData(JsonData _data)
- {
- Instance = this;
- this.servertime = float.Parse(_data["t"].ToString());
- this.curtime = Time.realtimeSinceStartup;
- this.table_version = _data["table_version"].ToString();
- this.token = _data["token"].ToString();
- this.app_setting = _data["app_setting"];
- this.cdn_url = this.app_setting["cdn_url"].ToString();
- this.user = _data["user"];
- this.user_base = _data["user_base"];
- //this.user_sign = _data["user_sign"];
- //this.user_lottery = _data["user_lottery"];
- //this.userId = this.user["user_id"].ToString();
- //this.openid = this.user_base["openid"].ToString();
- //Debug.Log("user_id:" + userId);
- //Debug.Log("ver:" + ver);
- this.day_first = _data["day_first"].ToString() == "1";
- //this.is_new = ((IDictionary)_data).Contains("is_new") ? true : false;
- }
- public string cdn_url;
- public bool day_first;
- public string token;
- public JsonData app_setting;
- public string table_version;
- //public bool is_new;
- public JsonData user;
- public JsonData user_base;
- //public JsonData user_sign;
- //public JsonData user_lottery;
- //public JsonData user_share;
- //public JsonData user_video;
- //public JsonData user_client;
- //public JsonData user_deny;
- //public string message;
- //public string userId;
- //public string openid;
- public float servertime;
- public float curtime;
- public float ServerTime
- {
- get
- {
- var time = Time.realtimeSinceStartup;
- return this.servertime + Mathf.Ceil((time - this.curtime) * 0.001f);
- }
- }
- public static void OnUpdateAccount(string _data)
- {
- }
- public void OnGetAccountConfig(JsonData _config)
- {
- }
- public void JundgCfg(string ver, Action configokcallback)
- {
- WebManager.GetInstance.HttpPostRequest_Send(PROTOCOLS.Config, null, (jsonData) =>
- {
- DataController.SetCfg(jsonData["configs"]);
- if (configokcallback != null) configokcallback();
- }, (value) =>
- {
- Debug.Log("未加载到配置表");
- });
- }
- public void CheckConfig(System.Action getconfigcb)
- {
- //mgetconfigcb = getconfigcb;
- //var curconfig = PlayerPrefs.GetString("accountconfigkey");
- //var curconfigver = PlayerPrefs.GetString("accountconfigver", "");
- //curconfig = test ? null : curconfig;
- //if (curconfig != "")
- //{
- // if (curconfigver == this.table_version && !test)
- // {
- // Debug.Log("sever配置是最新的..." + this.table_version);
- // this.configs = curconfig;
- // this.OnGetAccountConfig(this.configs);
- // if (getconfigcb != null) getconfigcb();
- // }
- // else
- // {
- // Dictionary<string, string> agsdic = new Dictionary<string, string>();
- // agsdic.Add("version", table_version);
- // agsdic.Add("v", table_version);
- // WebManager.GetInstance.HttpPostRequest_Send(PROTOCOLS.Config, agsdic, this.CheckLocalConfig_completecb, this.CheckLocalConfig_errorcb);
- // }
- //}
- //else
- //{
- // Dictionary<string, string> agsdic = new Dictionary<string, string>();
- // agsdic.Add("version", table_version);
- // agsdic.Add("v", table_version);
- // WebManager.GetInstance.HttpPostRequest_Send(PROTOCOLS.Config, agsdic, this.CheckLocalConfig_completecb, this.CheckLocalConfig_errorcb);
- //}
- }
- private void CheckLocalConfig_completecb(object _objtext)
- {
- //string _text = _objtext as string;
- //JsonData hashtable = JsonMapper.ToObject(_text);
- //JsonData _config = hashtable["configs"];
- //this.OnGetAccountConfig(_config);
- //PlayerPrefs.SetString("accountconfigkey", _text);
- //PlayerPrefs.SetString("accountconfigver", table_version);
- //if (mgetconfigcb != null) mgetconfigcb();
- }
- private void CheckLocalConfig_errorcb(object _objtext)
- {
- //Debug.Log("未加载到配置表");
- }
- public static string LocalCode
- {
- get
- {
- var code = GameEntry.Setting.GetString("localcode");
- if (code == "")
- {
- System.DateTime _time = System.DateTime.Now;
- System.DateTime startTime = System.TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
- var _rimeStr = (long)(_time - startTime).TotalSeconds;
- var _rang = UnityEngine.Random.Range(10000, 99999);
- code = "xj_" + _rimeStr + _rang;
- GameEntry.Setting.SetString("localcode", code);
- Debug.Log("新用户" + code);
- }
- else
- {
- Debug.Log("老用户" + code);
- }
- return code;
- }
- }
- }
|