Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions AccuracyIndicator/Indicator/InGameIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public InGameIndicator(IntPtr intPtr) : base(intPtr)
private readonly List<Object> _hitEntries = new();
private readonly List<Object> _hitReport = new();
private GameObject _canvas;
private RectTransform _centerIndicator;
private RectTransform _arrowRt;
private float _totalDelay;
private int _totalHits;
Expand All @@ -44,7 +45,7 @@ private void Start()
// Ok : 0.1 = 280px
// Perfect : 0.05 = 140px

Utils.CreateBars(_canvas, 0, DefaultY, 730, 280, 140);
_centerIndicator = Utils.CreateBars(_canvas, 0, DefaultY, 730, 280, 140).GetComponent<RectTransform>();

var arrow = new GameObject("Arrow");
arrow.transform.SetParent(_canvas.transform);
Expand Down Expand Up @@ -81,20 +82,21 @@ public void AddHit(float time)

var color = time switch
{
< 0.025f and > -0.025f => new Color(0, 0.73F, 0.83F),
< 0.05f and > -0.05f => new Color(0.29F, 0.68F, 0.31F),
_ => new Color(1f, 0.59F, 0)
< 0.025f and > -0.025f => Utils.ColorPerfect,
< 0.05f and > -0.05f => Utils.ColorAlmostPerfect,
_ => Utils.ColorGreat
};

var hitIndicator = new GameObject("Hit");
hitIndicator.transform.SetParent(_canvas.transform);
var hitRt = hitIndicator.AddComponent<RectTransform>();
var hitRi = hitIndicator.AddComponent<RawImage>();
hitRi.color = color;
hitRi.color = color.AlphaMultiplied(0.4f);
hitRt.anchoredPosition = new Vector2(x, DefaultY);
hitRt.sizeDelta = new Vector2(Utils.ConvertWidthFrom1920P(5), Utils.ConvertHeightFrom1080P(40));

_hitEntries.Add(new HitEntry(Time.time, time, hitIndicator, hitRi));
_centerIndicator.SetAsLastSibling();

// -130 = 0
// -125 = 1
Expand Down Expand Up @@ -136,11 +138,11 @@ private void Update()
float alpha;
if (since < 2f)
{
alpha = 1f;
alpha = 0.4f;
}
else
{
alpha = 1f - (since - 2f) / 3f;
alpha = (1f - (since - 2f) / 3f) * 0.4f;
}

var color = hitEntry.RawImage.color;
Expand Down
13 changes: 9 additions & 4 deletions AccuracyIndicator/Indicator/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,34 @@ public static class Utils
public static float ConvertWidthFrom1920P(float x) => x / 1920f * Screen.width;
public static float ConvertHeightFrom1080P(float x) => x / 1080f * Screen.height;

public static void CreateBars(GameObject canvas, float x, float y, int greatBarWidth, int okBarWidth, int perfectBarWidth)
public static readonly Color ColorPerfect = new Color(0.2f, 0.74f, 0.91f);
public static readonly Color ColorAlmostPerfect = new Color(0.34f, 0.89f, 0.07f);
public static readonly Color ColorGreat = new Color(1, 0.59f, 0);

public static GameObject CreateBars(GameObject canvas, float x, float y, int greatBarWidth, int okBarWidth, int perfectBarWidth)
{
var greatBar = new GameObject("GreatBar");
greatBar.transform.SetParent(canvas.transform);
var greatRt = greatBar.AddComponent<RectTransform>();
var greatRi = greatBar.AddComponent<RawImage>();
greatRt.anchoredPosition = new Vector2(x, y);
greatRi.color = new Color(1f, 0.59F, 0);
greatRi.color = ColorGreat;
greatRt.sizeDelta = new Vector2(ConvertWidthFrom1920P(greatBarWidth), ConvertHeightFrom1080P(10));

var almostPerfectBar = new GameObject("AlmostPerfectBar");
almostPerfectBar.transform.SetParent(canvas.transform);
var almostPerfectRt = almostPerfectBar.AddComponent<RectTransform>();
var almostPerfectRi = almostPerfectBar.AddComponent<RawImage>();
almostPerfectRt.anchoredPosition = new Vector2(x, y);
almostPerfectRi.color = new Color(0.29F, 0.68F, 0.31F);
almostPerfectRi.color = ColorAlmostPerfect;
almostPerfectRt.sizeDelta = new Vector2(ConvertWidthFrom1920P(okBarWidth), ConvertHeightFrom1080P(10));

var perfectBar = new GameObject("PerfectBar");
perfectBar.transform.SetParent(canvas.transform);
var perfectRt = perfectBar.AddComponent<RectTransform>();
var perfectRi = perfectBar.AddComponent<RawImage>();
perfectRt.anchoredPosition = new Vector2(x, y);
perfectRi.color = new Color(0, 0.73F, 0.83F);
perfectRi.color = ColorPerfect;
perfectRt.sizeDelta = new Vector2(ConvertWidthFrom1920P(perfectBarWidth), ConvertHeightFrom1080P(10));

var centerIndicator = new GameObject("CenterIndicator");
Expand All @@ -42,6 +46,7 @@ public static void CreateBars(GameObject canvas, float x, float y, int greatBarW
centerRt.anchoredPosition = new Vector2(x, y);
centerRi.color = new Color(1, 1, 1);
centerRt.sizeDelta = new Vector2(ConvertWidthFrom1920P(3), ConvertHeightFrom1080P(50));
return centerIndicator;
}

}
6 changes: 3 additions & 3 deletions AccuracyIndicator/Indicator/VictoryIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ private void Render()

ri.color = time switch
{
< 0.025f and > -0.025f => new Color(0, 0.73F, 0.83F),
< 0.05f and > -0.05f => new Color(0.29F, 0.68F, 0.31F),
_ => new Color(1f, 0.59F, 0)
< 0.025f and > -0.025f => Utils.ColorPerfect.AlphaMultiplied(0.4f),
< 0.05f and > -0.05f => Utils.ColorAlmostPerfect.AlphaMultiplied(0.4f),
_ => Utils.ColorGreat.AlphaMultiplied(0.4f)
};

var height = (int)(hits.Amount / (float)max * 300);
Expand Down