123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- using ET.EventType;
- using FairyGUI;
- namespace ET.Client
- {
- [Event]
- public class SceneChangeFinishEvent_CreateUIHelp : BEvent<SceneLoadFinish>
- {
- protected override async ETTask OnEvent(SceneLoadFinish a)
- {
- var view = await UIHelper.Create( "HUD" );
- HUDMgr.InitView( view );
- }
- }
- [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 progressBar1;
- GProgressBar progressBar2;
- GTextField txt1;
- GTextField txt2;
- protected override async ETTask OnEvent(HPRefresh a)
- {
- GProgressBar progress = null;
- GTextField txt = null;
- if(a.HPIndex == HPRefresh.Index.Tower)
- {
- if(progressBar1 == null)
- {
- var view = UIHelper.GetUI("HUD") as GComponent;
- progressBar1 = view.GetChild("HPBar1").asProgress;
- txt1 = progressBar1.GetChild("title").asTextField;
- }
- progress = progressBar1;
- txt = txt1;
- }
- else
- {
- if (progressBar2 == null)
- {
- var view = UIHelper.GetUI("HUD") as GComponent;
- 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<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 BattleMsgHandler : BEvent<BattleMsgEvent>
- {
- int CurIndex = 0;
- protected override async ETTask OnEvent(BattleMsgEvent a)
- {
- var view = UIHelper.GetUI("HUD") as GComponent;
- var list = view.GetChild("InfoList").asList;
- if(CurIndex >= list.numChildren)
- {
- CurIndex = 0;
- }
- var comp = list.GetChildAt(CurIndex).asCom;
- var txt = comp.GetChild("text");
- txt.text = a.msg;
- ++CurIndex;
- await ETTask.CompletedTask;
- }
- }
- public static class HUDMgr
- {
- public static void InitView(GComponent view)
- {
-
- 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 = "";
- }
- }
- }
|