using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; using Games.GlobeDefine; using GCGame.Table; using GCGame; public class SwornBroBirthRoot : UIControllerBase { void OnEnable() { SetInstance(this); } void OnDisable() { SetInstance(null); } #region static public static void ShowSwornBirth(List playerNames) { Hashtable hash = new Hashtable(); hash.Add("PlayerNames", playerNames); UIManager.ShowUI(UIInfo.SwornBroBirthRoot, OnSowrnBirthShow, hash); } static void OnSowrnBirthShow(bool bSuccess, object param) { Hashtable hash = param as Hashtable; if (!bSuccess) { return; } if (hash == null) { return; } if (SwornBroBirthRoot.Instance() != null) { SwornBroBirthRoot.Instance().Show((List)hash["PlayerNames"]); } } #endregion #region public Text _PlayerName; public Text _BirthDay; public GameObject _BtnPanel; public GameObject _SureTips; private System.DateTime _SelectBirth; public void Show(List playerNames) { string playerNameStr = ""; for (int i = 0; i < playerNames.Count; ++i) { playerNameStr += playerNames[i]; if (i < playerNames.Count - 1) { playerNameStr += ","; } } _PlayerName.text = StrDictionary.GetClientDictionaryString("#{36209}", playerNameStr); _BtnPanel.SetActive(true); _SureTips.SetActive(false); } public void SetBirthTime(System.DateTime birthDay) { _BirthDay.text = string.Format("{0:yyyy-MM-dd}", birthDay); _SelectBirth = birthDay; } public void OnSelectBirthDay() { DaySelectRoot.ShowDaySelect(SetBirthTime); } public void OnOkClick() { var deltaTime = _SelectBirth - new System.DateTime(); CG_RET_SWORN packet = (CG_RET_SWORN)PacketDistributed.CreatePacket(MessageID.PACKET_CG_RET_SWORN); packet.SetAgreeflag((int)CG_RET_SWORN.ERETSWORN.EAgree); packet.SetTm((int)deltaTime.TotalDays); packet.SendPacket(); _BtnPanel.SetActive(false); _SureTips.SetActive(true); //CloseWindow(); } public void OnCancel() { CG_RET_SWORN packet = (CG_RET_SWORN)PacketDistributed.CreatePacket(MessageID.PACKET_CG_RET_SWORN); packet.SetAgreeflag((int)CG_RET_SWORN.ERETSWORN.ERefuse); packet.SetTm(0); packet.SendPacket(); CloseWindow(); } public void CloseWindow() { UIManager.CloseUI(UIInfo.SwornBroBirthRoot); } #endregion }