SceneChangeFinishEvent_CreateHUD.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using FairyGUI;
  2. namespace ET.Client
  3. {
  4. [Event(SceneType.Client)]
  5. public class SceneChangeFinishEvent_CreateUIHelp : AEvent<EventType.SceneLoadFinish>
  6. {
  7. protected override async ETTask Run(Scene scene, EventType.SceneLoadFinish args)
  8. {
  9. Log.Debug("loading HUD");
  10. var view = await UIHelper.Create("HUD");
  11. InitView(scene, view);
  12. }
  13. private void InitView(Scene scene, GComponent view)
  14. {
  15. var img = view.GetChild("img_direction");
  16. view.GetChild("btn_skill1").onClick.Add(() => {
  17. Scene currentScene = scene.GetComponent<CurrentScenesComponent>().Scene;
  18. var actor = currentScene.GetComponent<UnitComponent>().GetActor();
  19. if(actor != null)
  20. {
  21. actor.GetComponent<AnimatorComponent>().AppendCommand(AnimatorComponent.CommandType.Skill0);
  22. }
  23. });
  24. view.GetChild("btn_skill2").onClick.Add(() => {
  25. Scene currentScene = scene.GetComponent<CurrentScenesComponent>().Scene;
  26. var actor = currentScene.GetComponent<UnitComponent>().GetActor();
  27. if (actor != null)
  28. {
  29. actor.GetComponent<AnimatorComponent>().AppendCommand(AnimatorComponent.CommandType.Skill1);
  30. }
  31. });
  32. }
  33. }
  34. }