123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using FairyGUI;
- using FL.Data;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class MainHomePanelCtrl : UIController<MainHomePanelVM>
- {
- protected override void OnEnable(object intent)
- {
- AddUIListenres();
- RefreshPlayerInfo();
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- }
- #region UI事件
- private void AddUIListenres()
- {
- VM.SysMenuBtn.onClick.Add(OnClickSysMenuBtn);
- VM.FriendBtn.onClick.Add(OnClickFriendBtn);
- VM.MailBtn.onClick.Add(OnClickMailBtn);
- VM.NoticeBtn.onClick.Add(OnClickNoticeBtn);
- VM.SettingBtn.onClick.Add(OnClickSettingBtn);
- VM.ExchangeBtn.onClick.Add(OnClickExchangeBtn);
- VM.BagBtn.onClick.Add(OnClickBagBtn);
- VM.MapRewardBtn.onClick.Add(OnClickMapRewardBtn);
- }
- private void RemoveUIListenres()
- {
- VM.SysMenuBtn.onClick.Remove(OnClickSysMenuBtn);
- VM.FriendBtn.onClick.Remove(OnClickFriendBtn);
- VM.MailBtn.onClick.Remove(OnClickMailBtn);
- VM.NoticeBtn.onClick.Remove(OnClickNoticeBtn);
- VM.SettingBtn.onClick.Remove(OnClickSettingBtn);
- VM.ExchangeBtn.onClick.Remove(OnClickExchangeBtn);
- VM.BagBtn.onClick.Remove(OnClickBagBtn);
- VM.MapRewardBtn.onClick.Remove(OnClickMapRewardBtn);
- }
- private void OnClickSysMenuBtn(EventContext context)
- {
- VM.SysMenuActive = !VM.SysMenuActive;
- }
- private void OnClickFriendBtn(EventContext context)
- {
- Context.ShowTips("OnClickFriendBtn");
- VM.SysMenuActive = false;
- }
- private void OnClickMailBtn(EventContext context)
- {
- Context.ShowTips("OnClickMailBtn");
- VM.SysMenuActive = false;
- }
- private void OnClickNoticeBtn(EventContext context)
- {
- Context.ShowTips("OnClickNoticeBtn");
- VM.SysMenuActive = false;
- // 临时测试GM消息按钮
- Context.UI.OpenAsync(UIKeys.GmToolSendMsgPanel);
- }
- private void OnClickSettingBtn(EventContext context)
- {
- Context.ShowTips("OnClickSettingBtn");
- VM.SysMenuActive = false;
- }
- private void OnClickExchangeBtn(EventContext context)
- {
- Context.ShowTips("OnClickExchangeBtn");
- VM.SysMenuActive = false;
- }
- private void OnClickBagBtn(EventContext context)
- {
- Context.UI.OpenAsync(UIKeys.BagBackpackPanel);
- VM.SysMenuActive = false;
- }
- private void OnClickMapRewardBtn(EventContext context)
- {
- Context.ShowTips("OnClickMapRewardBtn");
- }
- #endregion
- void RefreshPlayerInfo()
- {
- //TODO
- var player = PlayerData.Instance;
- VM.PlayerHead.icon = "itemicon_99"; // player.HeadIcon;
- VM.PlayerNameTxt.text = player.Name;
- VM.PlayerLvTxt.text = player.Level.ToString();
- VM.PlayerPowerIcon.icon = AddressableDefine.itemicon_power;
- VM.PlayerPowerTxt.text = player.Power.FormatNumber();
- }
- }
- }
|