123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- using ET.EventType;
- using FairyGUI;
- namespace ET.Client
- {
- [Event(SceneType.Client)]
- public class SceneChangeFinishEvent_CreateUIHelp : BEvent<SceneLoadFinish>
- {
- public override void OnEvent(SceneLoadFinish a)
- {
- asyncTask().Coroutine();
- }
- private async ETTask asyncTask()
- {
- Log.Debug("loading HUD");
- var view = await UIHelper.Create("HUD");
- HUDMgr.InitView(view);
- }
- }
- [Event(SceneType.None)]
- public class SkillChangeEventHandler : BEvent<SkillChangeEvent>
- {
- public override void OnEvent(SkillChangeEvent a)
- {
- var view = UIHelper.GetUI("HUD") as GComponent;
- if(view != null)
- {
- HUDMgr.InitView(view);
- }
- }
- }
- public static class HUDMgr
- {
- public static void InitView(GComponent view)
- {
- var btn1 = view.GetChild("btn_skill1");
- var btn2 = view.GetChild("btn_skill2");
-
- btn1.visible = false;
- btn2.visible = false;
- for (int i=1; i<=4; i++)
- {
- var btn = view.GetChild($"btn_func{i}");
- var index = i;
- btn.onClick.Set(() =>
- {
- if(index == 1)
- {
- GlobalViewComponent.Instance.HeadbarView.visible = !GlobalViewComponent.Instance.HeadbarView.visible;
- return;
- }
- EventSystem.Instance.Publish<BattleFunc>(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);
- });
- }
- }
- }
|