123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- using ET.EventType;
- using FairyGUI;
- namespace ET.Client
- {
- [Event]
- public class ShowHUDEventHandler : BEvent<ShowHUDEvent>
- {
- protected override async ETTask OnEvent(ShowHUDEvent _)
- {
- var view = await UIHelper.Create( "HUD" );
- var pgTower = view.GetChild("HPBarTower") as GProgressBar;
- var pgBoss1 = view.GetChild("HPBarBoss1") as GProgressBar;
- var pgBoss2 = view.GetChild("HPBarBoss2") as GProgressBar;
- var pgBoss3 = view.GetChild("HPBarBoss3") as GProgressBar;
- var progresslike = view.GetChild("EnergyBar") as GProgressBar;
- pgTower.visible = false;
- pgBoss1.visible = false;
- pgBoss2.visible = false;
- pgBoss3.visible = false;
- progresslike.visible = false;
- var compIcon = view.GetChild("Comp_gifticon");
- var compTips = view.GetChild("Comp_tips");
- var btn = view.GetChild("btn_start");
- btn.onClick.Set(() =>
- {
- btn.visible = false;
- compIcon.visible = false;
- compTips.visible = false;
- CameraMgr.PlayStartAnimation(() =>
- {
- compIcon.visible = true;
- EventSystem.Instance.Publish(BattleFunc.Clone((int)BattleFunc.FUNC.Start));
- }).Coroutine();
- });
- EventSystem.Instance.Publish(BattleFunc.Clone((int)BattleFunc.FUNC.ClientIsReady));
- }
- }
- [Event]
- public class SkillChangeEventHandler : BEvent<SkillChangeEvent>
- {
- protected override async ETTask OnEvent(SkillChangeEvent a)
- {
- Log.Debug("actor's skill changed.");
-
- await ETTask.CompletedTask;
- }
- }
- [Event]
- public class HPRefreshEventHandler : BEvent<HPRefresh>
- {
- GProgressBar pgTower;
- GProgressBar pgBoss1;
- GProgressBar pgBoss2;
- GProgressBar pgBoss3;
- GProgressBar pgTKLike;
- protected override async ETTask OnEvent(HPRefresh a)
- {
- var view = UIHelper.GetUI("HUD") as GComponent;
- if (view != null)
- {
- GProgressBar progress = null;
- switch (a.HPIndex)
- {
- case HPRefresh.Index.Tower:
- if (pgTower == null)
- {
- pgTower = view.GetChild("HPBarTower").asProgress;
- }
- progress = pgTower;
- break;
- case HPRefresh.Index.Boss1:
- if (pgBoss1 == null)
- {
- pgBoss1 = view.GetChild("HPBarBoss1").asProgress;
- }
- progress = pgBoss1;
- break;
- case HPRefresh.Index.Boss2:
- if (pgBoss2 == null)
- {
- pgBoss2 = view.GetChild("HPBarBoss2").asProgress;
- }
- progress = pgBoss2;
- break;
- case HPRefresh.Index.Boss3:
- if (pgBoss3 == null)
- {
- pgBoss3 = view.GetChild("HPBarBoss3").asProgress;
- }
- progress = pgBoss3;
- break;
- case HPRefresh.Index.TiktokLike:
- if (pgTKLike == null)
- {
- pgTKLike = view.GetChild("EnergyBar").asProgress;
- }
- progress = pgTKLike;
- break;
- }
-
- progress.visible = a.Visible;
- if (a.Visible)
- {
- progress.value = a.Progress;
- var name = progress.GetChild("name");
- if (name != null)
- {
- name.text = a.Name;
- }
- var txt = progress.GetChild("title");
- if (txt != null)
- {
- txt.text = a.Title;
- }
- }
- }
- await ETTask.CompletedTask;
- }
- }
- [Event]
- public class RankEventHandler : BEvent<RankChangeEvent>
- {
- 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<a.InfoList.Count; i++)
- {
- var chd = list.GetChildAt(i).asCom;
- if(chd == null)
- {
- Log.Error($"rank list child not exist: {i}");
- continue;
- }
- var txt = chd.GetChild("text");
- txt.text = a.InfoList[i].Name;
- chd.visible = true;
- }
- for(; i < 3; i++)
- {
- var chd = list.GetChildAt(i);
- if(chd != null)
- {
- chd.visible = false;
- }
- }
- }
- await ETTask.CompletedTask;
- }
- }
- [Event]
- public class ShowUIAnimationHandler : BEvent<ShowUIAnimation>
- {
- 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;
- case ShowUIAnimation.AniType.LikeEnergy:
- trans = view.GetTransition("t_help");
- trans.Play();
- break;
- default:
- Log.Error($"unknow ui animation: {a.Type}");
- break;
- }
- await ETTask.CompletedTask;
- }
- }
- [Event]
- public class ShowOrHideHeadBarHandler : BEvent<ShowOrHideHeadBar>
- {
- protected override async ETTask OnEvent(ShowOrHideHeadBar a)
- {
- if(a != null)
- {
- GlobalViewMgr.Instance.HeadbarView.visible = a.Flag;
- }
- else
- {
- GlobalViewMgr.Instance.HeadbarView.visible = !GlobalViewMgr.Instance.HeadbarView.visible;
- }
- await ETTask.CompletedTask;
- }
- }
- [Event]
- public class SoundMuteEventHandler : BEvent<SoundMuteEvent>
- {
- protected override async ETTask OnEvent(SoundMuteEvent a)
- {
- bool isMute = SoundManager.Instance.UnityAudioSource.mute;
- if (a != null)
- {
- isMute = a.Flag;
- }
- else
- {
- isMute = !isMute;
- }
- SoundManager.Instance.UnityAudioSource.mute = isMute;
- GameSetting.Instance.SetBool(GameSetting.Sets.Mute_int, isMute);
- await ETTask.CompletedTask;
- }
- }
- }
|