From 9eb976e57786024c85881355e93661f6ee0d0251 Mon Sep 17 00:00:00 2001 From: shnok Date: Wed, 27 Nov 2024 23:12:46 +0800 Subject: [PATCH] target name colors, npc level shared by server --- .../ServerPackets/Actor/NpcInfoPacket.cs | 1 + .../ServerPackets/Combat/MyTargetSetPacket.cs | 4 +- .../Assets/Scripts/UI/Game/TargetWindow.cs | 37 +++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Actor/NpcInfoPacket.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Actor/NpcInfoPacket.cs index 93f78b427..353d81c8c 100644 --- a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Actor/NpcInfoPacket.cs +++ b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Actor/NpcInfoPacket.cs @@ -90,6 +90,7 @@ public override void Parse() Stats.AttackRange = ReadI() / 52.5f; Stats.MaxHp = ReadI(); + Stats.Level = ReadI(); Debug.LogWarning(ToString()); } diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Combat/MyTargetSetPacket.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Combat/MyTargetSetPacket.cs index 2cf94f0bf..67c802645 100644 --- a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Combat/MyTargetSetPacket.cs +++ b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Combat/MyTargetSetPacket.cs @@ -4,7 +4,7 @@ public class MyTargetSetPacket : ServerPacket { public int TargetId { get; private set; } - public int LevelGap { get; private set; } + public int Color { get; private set; } public MyTargetSetPacket(byte[] d) : base(d) { @@ -14,6 +14,6 @@ public MyTargetSetPacket(byte[] d) : base(d) public override void Parse() { TargetId = ReadI(); - LevelGap = ReadH(); + Color = ReadH(); } } diff --git a/l2-unity/Assets/Scripts/UI/Game/TargetWindow.cs b/l2-unity/Assets/Scripts/UI/Game/TargetWindow.cs index 1e83bcb0b..da36774e4 100644 --- a/l2-unity/Assets/Scripts/UI/Game/TargetWindow.cs +++ b/l2-unity/Assets/Scripts/UI/Game/TargetWindow.cs @@ -1,3 +1,4 @@ +using System; using System.Collections; using UnityEngine; using UnityEngine.UIElements; @@ -114,6 +115,8 @@ private void FixedUpdate() { if (targetData.Identity.IsHpShowable) { + SetTargetColor(targetData.Stats.Level - PlayerEntity.Instance.Stats.Level); + if (!_HPBarContainer.ClassListContains("visible")) { _HPBarContainer.AddToClassList("visible"); @@ -129,6 +132,7 @@ private void FixedUpdate() } else { + SetTargetColor(0); if (_HPBarContainer.ClassListContains("visible")) { _HPBarContainer.RemoveFromClassList("visible"); @@ -158,4 +162,37 @@ public override void HideWindow() AudioManager.Instance.PlayUISound("window_close"); L2GameUI.Instance.WindowClosed(this); } + + public void SetTargetColor(int color) + { + Debug.Log(color); + if (color == 0) + { + _nameLabel.style.color = Color.white; + } + else if (color <= -3 && color > -6) + { + _nameLabel.style.color = new Color(0.6039f, 0.9490f, 0.6392f); + } + else if (color <= -6 && color > -9) + { + _nameLabel.style.color = new Color(0.4901f, 0.466f, 1f); + } + else if (color < -9) + { + _nameLabel.style.color = new Color(0, 0, 0.945f); + } + else if (color >= 3 && color < 6) + { + _nameLabel.style.color = new Color(0.9294f, 0.9412f, 0.5412f); + } + else if (color >= 6 && color < 9) + { + _nameLabel.style.color = new Color(0.8588f, 0.4980f, 0.4980f); + } + else if (color > 9) + { + _nameLabel.style.color = new Color(0.945f, 0, 0); + } + } }