1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using CommonAI.Zone;
- 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");
- 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>(LaunchSkillEvent.Static.Clone(0)) ;
- });
- btn2.onClick.Set(() => {
- EventSystem.Instance.Publish<LaunchSkillEvent>(LaunchSkillEvent.Static.Clone(1));
- });
- }
- }
- }
|