Skip to content

Commit

Permalink
target name colors, npc level shared by server
Browse files Browse the repository at this point in the history
  • Loading branch information
shnok committed Nov 27, 2024
1 parent 2e2dc73 commit 9eb976e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public override void Parse()

Stats.AttackRange = ReadI() / 52.5f;
Stats.MaxHp = ReadI();
Stats.Level = ReadI();

Debug.LogWarning(ToString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -14,6 +14,6 @@ public MyTargetSetPacket(byte[] d) : base(d)
public override void Parse()
{
TargetId = ReadI();
LevelGap = ReadH();
Color = ReadH();
}
}
37 changes: 37 additions & 0 deletions l2-unity/Assets/Scripts/UI/Game/TargetWindow.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.UIElements;
Expand Down Expand Up @@ -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");
Expand All @@ -129,6 +132,7 @@ private void FixedUpdate()
}
else
{
SetTargetColor(0);
if (_HPBarContainer.ClassListContains("visible"))
{
_HPBarContainer.RemoveFromClassList("visible");
Expand Down Expand Up @@ -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);
}
}
}

0 comments on commit 9eb976e

Please sign in to comment.