using ET.EventType; using FairyGUI; namespace ET.Client { [Event] public class SceneChangeFinishEvent_CreateUIHelp : BEvent { protected override async ETTask OnEvent(ShowHUDEvent _) { var view = await UIHelper.Create( "HUD" ); HUDMgr.InitView( view ); } } [Event] public class SkillChangeEventHandler : BEvent { protected override async ETTask OnEvent(SkillChangeEvent a) { Log.Debug("actor's skill changed."); /*var view = UIHelper.GetUI("HUD") as GComponent; if(view != null) { HUDMgr.InitView(view); }*/ await ETTask.CompletedTask; } } [Event] public class HPRefreshEventHandler : BEvent { GProgressBar progressBar1; GProgressBar progressBar2; GTextField txt1; GTextField txt2; protected override async ETTask OnEvent(HPRefresh a) { var view = UIHelper.GetUI("HUD") as GComponent; if (view != null) { GProgressBar progress = null; GTextField txt = null; if (a.HPIndex == HPRefresh.Index.Tower) { if (progressBar1 == null) { progressBar1 = view.GetChild("HPBar1").asProgress; txt1 = progressBar1.GetChild("title").asTextField; } progress = progressBar1; txt = txt1; } else { if (progressBar2 == null) { progressBar2 = view.GetChild("HPBar2").asProgress; txt2 = progressBar2.GetChild("title").asTextField; } progress = progressBar2; txt = txt2; } progress.visible = true; progress.value = a.Progress; txt.text = a.Progress.ToString("F2") + "%"; } await ETTask.CompletedTask; } } [Event] public class RankEventHandler : BEvent { protected override async ETTask OnEvent(RankChangeEvent a) { var view = UIHelper.GetUI("HUD") as GComponent; if (view == null) return; var list = view.GetChild("list_rank").asList; if (list == null) return; list.visible = a.InfoList != null && a.InfoList.Count > 0; if(list.visible) { int i = 0; for (; i { protected override async ETTask OnEvent(ShowUIAnimation a) { var view = UIHelper.GetUI("HUD") as GComponent; if (view == null) return; switch(a.Type) { case ShowUIAnimation.AniType.Gift: var trans = view.GetTransition($"t_gift_00{a.Param1}"); if (trans != null) { trans.Play(); } else { Log.Error($"NotFound UIAni: {a.Type},{a.Param1}"); } break; case ShowUIAnimation.AniType.Monster: trans = view.GetTransition("t_warning"); trans.Play(); trans = view.GetTransition($"t_warning_00{a.Param1}"); if (trans != null) { trans.Play(); } else { Log.Error($"NotFound UIAni: {a.Type},{a.Param1}"); } break; case ShowUIAnimation.AniType.Tower: trans = view.GetTransition("t_help"); trans.Play(); break; } await ETTask.CompletedTask; } } public static class HUDMgr { public static void InitView(GComponent view) { /*var btn1 = view.GetChild("btn_skill1"); var btn2 = view.GetChild("btn_skill2"); var actor = UnitMgr.Instance.Actor; if (actor == null || !actor.IsSkillOk) { btn1.visible = false; btn2.visible = false; return; } btn1.visible = actor.GetSkill(0) != null; btn2.visible = actor.GetSkill(1) != null; var img = view.GetChild("img_direction"); btn1.onClick.Set(() => { EventSystem.Instance.Publish(LaunchSkillEvent.Static.Clone(0)) ; }); btn2.onClick.Set(() => { EventSystem.Instance.Publish(LaunchSkillEvent.Static.Clone(1)); }); btn1.visible = false; btn2.visible = false; for (int i=1; i<= 99; i++) { var btn = view.GetChild($"btn_func{i}"); if (btn == null) break; var index = i; btn.onClick.Set(() => { if(index == 1) { GlobalViewMgr.Instance.HeadbarView.visible = !GlobalViewComponent.Instance.HeadbarView.visible; return; } EventSystem.Instance.Publish(BattleFunc.Static.Clone(index)); }); } bool isMute = SoundManager.Instance.UnityAudioSource.mute; var btnmute = view.GetChild("btn_mute"); var gou = (btnmute as GComponent).GetChild("checked"); gou.visible = isMute; btnmute.onClick.Set(() => { isMute = !isMute; gou.visible = isMute; SoundManager.Instance.UnityAudioSource.mute = isMute; GameSetting.Instance.SetBool(GameSetting.Sets.Mute_int, isMute); });*/ var progress1 = view.GetChild("HPBar1") as GProgressBar; var progress2 = view.GetChild("HPBar2") as GProgressBar; progress1.visible = progress2.visible = false; var txthp1 = progress1.GetChild("title"); txthp1.text = ""; var txthp2 = progress2.GetChild("title"); txthp2.text = ""; var btn = view.GetChild("btn_start"); btn.onClick.Set( () => { btn.visible = false; EventSystem.Instance.Publish(BattleFunc.Static.Clone((int)BattleFunc.FUNC.Start)); }); } } }