From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/UI/BattleTargetHandler.cs | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/BattleTargetHandler.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/BattleTargetHandler.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/BattleTargetHandler.cs b/Client/Assets/Scripts/XMainClient/UI/BattleTargetHandler.cs new file mode 100644 index 00000000..2ed6e6ab --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/BattleTargetHandler.cs @@ -0,0 +1,76 @@ +using System; +using UnityEngine; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class BattleTargetHandler : DlgHandlerBase + { + public GameObject TargetFx; + + public GameObject PretargetFx; + + protected override void Init() + { + base.Init(); + this.TargetFx = base.PanelObject.transform.Find("Taget2").gameObject; + this.PretargetFx = base.PanelObject.transform.Find("Taget1").gameObject; + this.TargetFx.transform.localPosition = XGameUI.Far_Far_Away; + this.PretargetFx.transform.localPosition = XGameUI.Far_Far_Away; + } + + public void ShowTargetFx(bool show, XEntity e) + { + bool flag = !show; + if (flag) + { + this.TargetFx.transform.localPosition = XGameUI.Far_Far_Away; + } + bool flag2 = !XEntity.ValideEntity(e); + if (!flag2) + { + XSingleton.singleton.HasTarget = true; + this.TargetFx.transform.position = this.EntityOnUI(e); + Vector3 localPosition = this.TargetFx.transform.localPosition; + localPosition.x = (float)Mathf.FloorToInt(localPosition.x); + localPosition.y = (float)Mathf.FloorToInt(localPosition.y); + localPosition.z = 0f; + this.TargetFx.transform.localPosition = localPosition; + } + } + + public void ShowPretargetFx(bool show, XEntity e) + { + bool flag = !show; + if (flag) + { + this.PretargetFx.transform.localPosition = XGameUI.Far_Far_Away; + } + bool flag2 = !XEntity.ValideEntity(e); + if (!flag2) + { + this.PretargetFx.transform.position = this.EntityOnUI(e); + bool flag3 = this.PretargetFx.transform.position.z < 0f; + if (flag3) + { + this.PretargetFx.transform.localPosition = XGameUI.Far_Far_Away; + } + else + { + Vector3 localPosition = this.PretargetFx.transform.localPosition; + localPosition.x = (float)Mathf.FloorToInt(localPosition.x); + localPosition.y = (float)Mathf.FloorToInt(localPosition.y); + localPosition.z = 0f; + this.PretargetFx.transform.localPosition = localPosition; + } + } + } + + protected Vector3 EntityOnUI(XEntity e) + { + Vector3 vector = e.EngineObject.Position + new Vector3(0f, e.Height / 2f, 0f); + Vector3 vector2 = XSingleton.singleton.GameCamera.UnityCamera.WorldToViewportPoint(vector); + return XSingleton.singleton.UICamera.ViewportToWorldPoint(vector2); + } + } +} -- cgit v1.1-26-g67d0