From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XMainClient/XCombatHUDMgr.cs | 144 +++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XCombatHUDMgr.cs (limited to 'Client/Assets/Scripts/XMainClient/XCombatHUDMgr.cs') diff --git a/Client/Assets/Scripts/XMainClient/XCombatHUDMgr.cs b/Client/Assets/Scripts/XMainClient/XCombatHUDMgr.cs new file mode 100644 index 00000000..76c83f2b --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XCombatHUDMgr.cs @@ -0,0 +1,144 @@ +using System; +using UnityEngine; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XCombatHUDMgr : XSingleton + { + public static string HUD_NORMAL = "UI/Billboard/HUDNormal2"; + + public static string HUD_CRITICAL = "UI/Billboard/HUDCritical"; + + public static string HUD_POFANG = "UI/Billboard/HUDPofang"; + + public static string HUD_PLAYER = "UI/Billboard/HUDPlayer"; + + public static string HUD_IMMORTAL = "UI/Billboard/HUDImmortal"; + + public static string HUD_MISS = "UI/Billboard/HUDMiss"; + + public bool Initialize() + { + return true; + } + + public GameObject GetHUDTemplateByDamageResult(ProjectDamageResult config, bool isPlayer) + { + bool flag = config.Result == ProjectResultType.PJRES_IMMORTAL; + GameObject result; + if (flag) + { + GameObject gameObject = XSingleton.singleton.CreateFromPrefab(XCombatHUDMgr.HUD_IMMORTAL, Vector3.zero, Quaternion.identity, true, false); + result = gameObject; + } + else + { + bool flag2 = config.Result == ProjectResultType.PJRES_MISS; + if (flag2) + { + GameObject gameObject = XSingleton.singleton.CreateFromPrefab(XCombatHUDMgr.HUD_MISS, Vector3.zero, Quaternion.identity, true, false); + result = gameObject; + } + else if (isPlayer) + { + GameObject gameObject = XSingleton.singleton.CreateFromPrefab(XCombatHUDMgr.HUD_PLAYER, Vector3.zero, Quaternion.identity, true, false); + result = gameObject; + } + else + { + bool flag3 = config.IsCritical(); + GameObject gameObject; + if (flag3) + { + gameObject = XSingleton.singleton.CreateFromPrefab(XCombatHUDMgr.HUD_CRITICAL, Vector3.zero, Quaternion.identity, true, false); + } + else + { + gameObject = XSingleton.singleton.CreateFromPrefab(XCombatHUDMgr.HUD_NORMAL, Vector3.zero, Quaternion.identity, true, false); + } + result = gameObject; + } + } + return result; + } + + public string GetHUDText(ProjectDamageResult config, bool isDigitalText) + { + string text = ""; + bool flag = config.Result == ProjectResultType.PJRES_IMMORTAL; + string result; + if (flag) + { + result = XStringDefineProxy.GetString("BATTLE_IMMORTAL"); + } + else + { + bool accept = config.Accept; + if (accept) + { + string elementSprite = this.GetElementSprite(config.ElementType); + text = elementSprite; + float num = (float)config.Value; + text += ((num > 0f) ? Mathf.RoundToInt(num).ToString() : Mathf.RoundToInt(-num).ToString()); + } + result = text; + } + return result; + } + + public string GetElementSprite(DamageElement element) + { + string result; + switch (element) + { + case DamageElement.DE_FIRE: + result = "c"; + break; + case DamageElement.DE_WATER: + result = "b"; + break; + case DamageElement.DE_LIGHT: + result = "a"; + break; + case DamageElement.DE_DARK: + result = "d"; + break; + default: + result = ""; + break; + } + return result; + } + + public void GetElementColor(DamageElement element, ref bool applyGradient, ref Color top, ref Color bottom) + { + switch (element) + { + case DamageElement.DE_FIRE: + applyGradient = true; + top = new Color32(173, 60, 58, byte.MaxValue); + bottom = new Color32(121, 33, 32, byte.MaxValue); + break; + case DamageElement.DE_WATER: + top = new Color32(103, 209, 228, byte.MaxValue); + bottom = new Color32(54, 121, 131, byte.MaxValue); + applyGradient = true; + break; + case DamageElement.DE_LIGHT: + top = new Color32(234, 226, 156, byte.MaxValue); + bottom = new Color32(178, 182, 117, byte.MaxValue); + applyGradient = true; + break; + case DamageElement.DE_DARK: + top = new Color32(149, 140, 237, byte.MaxValue); + bottom = new Color32(104, 95, 169, byte.MaxValue); + applyGradient = true; + break; + default: + applyGradient = false; + break; + } + } + } +} -- cgit v1.1-26-g67d0