using SUIFW; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class MyCenterForms : BaseUIForms { public RawImage texIcon; public Text userName; public Text userAccount; public Text accountManager; public static Action swithAvatarAction; public AvatarList avatarList; public GameObject AvatarListObj; public Button showAcatarListBtn; public Button closeAcatarListBtn; public GameObject ChangeNameObj; public ChangeNamePop changeNamePop; public Button changeNameBtn; public GameObject LimitObj; public Button showLimitObjBtn; public Button closeLimitObjBtn; public GameObject ActivityObj; public ActivityMgr activityMgr; public Button activityBtn; public Text activityBtnText; public Button loginOutBtn; public Button returnBtn; private void Awake() { swithAvatarAction += OnSwithAvatar; showAcatarListBtn.onClick.AddListener(ShowAvatarListPop); closeAcatarListBtn.onClick.AddListener(CloseAvatarListPop); changeNameBtn.onClick.AddListener(ClickOnChangeName); showLimitObjBtn.onClick.AddListener(ShowLimitObj); closeLimitObjBtn.onClick.AddListener(HeidLimitObj); activityBtn.onClick.AddListener(ShowActivityObj); loginOutBtn.onClick.AddListener(ClickOnLoginOut); returnBtn.onClick.AddListener(ClickOnReturn); } private void Start() { avatarList.Init(); } #region 窗体生命周期 public override void Display() { base.Display(); Init(); } public override void Redisplay() { base.Redisplay(); } public override void Freeze() { base.Freeze(); } public override void Hiding() { base.Hiding(); } #endregion public void Init() { if (UserInfo.textIcon == null) { texIcon.texture = UserInfo.defaulttextIcon; } else { texIcon.texture = UserInfo.textIcon; } userAccount.text = "当前账号: " + UserInfo.Account; if (UserInfo.userName == "") { userName.text = "YCKJ" + UserInfo.Account.Substring(UserInfo.Account.Length - 4); } else { userName.text = UserInfo.userName; } activityBtn.gameObject.SetActive(true); switch (UserInfo.activateType) { case 1: accountManager.text = "未激活账号"; accountManager.color = Color.gray; activityBtnText.text = "激活"; break; case 2: string indate = UserInfo.indate.ToString(); if (indate == "0") { accountManager.text = "未激活账号"; accountManager.color = Color.gray; activityBtnText.text = "激活"; } else { string ti = GetTime(UserInfo.indate); accountManager.text = "账号已激活 有效期至" + ti; ChangeTextGreen(); activityBtnText.text = "续费"; } break; case 3: accountManager.text = "账号永久激活"; ChangeTextGreen(); activityBtn.gameObject.SetActive(false); break; } AvatarListObj.SetActive(false); ChangeNameObj.SetActive(false); LimitObj.SetActive(false); ActivityObj.SetActive(false); accountManager.gameObject.SetActive(false); showLimitObjBtn.gameObject.SetActive(false); } private void OnSwithAvatar(Texture tex) { texIcon.texture = tex; } public void LoginOut() { SaveNameandAvatar(); WSHandler.clientClosed(); CloseOrReturnUIForms(); ShowUIForms(SysConst.LoginForms); } private void SaveNameandAvatar() { if (userName.text != "") { UserInfo.userName = userName.text; } NetWorkHeaders.SetUserInfo(); } private void ClickOnReturn() { SaveNameandAvatar(); CloseOrReturnUIForms(); ShowUIForms(SysConst.MainPanelForms); } private void ClickOnLoginOut() { ShowUIForms(SysConst.PopForms); PopForms.Instance.ShowPublic(PopType.PopTwo, RtcStrConfig.outLoginmsg, "确定", () => { LoginOut(); }, "取消"); } public void ShowAvatarListPop() { AvatarListObj.SetActive(true); } public void CloseAvatarListPop() { AvatarListObj.SetActive(false); } public void ClickOnChangeName() { ChangeNameObj.SetActive(true); changeNamePop.Init(); } public void ShowLimitObj() { LimitObj.SetActive(true); } public void HeidLimitObj() { LimitObj.SetActive(false); } public void ShowActivityObj() { ActivityObj.SetActive(true); activityMgr.Init(); } private void ChangeTextGreen() { Color color = Color.white; color.r = 74 / 255f; color.g = 227 / 255f; color.b = 173 / 255f; color.a = 255 / 255f; accountManager.color = color; } public string GetTime(double timechu) { DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); DateTime dt = startTime.AddSeconds(timechu); string t = dt.ToString("yyyy-MM-dd HH:mm:ss"); string[] arr = t.Split(' '); return arr[0]; } private void OnDestroy() { swithAvatarAction -= OnSwithAvatar; } }