mu3-mods/PlatinumTiming/MU3/patch_UIResultTechScore.cs
akanyan 946402fa82 feat: implement PlatinumTiming
* Also fix icons in InfiniteGP.
2024-07-21 02:24:09 +09:00

64 lines
2.1 KiB
C#

using MU3.CustomUI;
using MU3.Game;
using MU3.Sequence;
using MU3.Util;
using System.Collections;
using UnityEngine;
namespace MU3;
class patch_UIResultTechScore: UIResultTechScore {
private MU3UICounter counterFast_;
private MU3UICounter counterLate_;
private Animator animator_;
private static readonly int State_TechnicalScore_Loop;
private void cloneCounter(MU3UICounter counter, Color color, int value) {
var otherValue = counter.CounterAsInt;
var offset = 12;
while(otherValue > 9) {
otherValue /= 10;
offset += 8;
}
var cpy = Instantiate(counter);
cpy.color = color;
cpy.gameObject.transform.SetParent(counter.transform.parent, false);
var pos = counter.gameObject.transform.localPosition;
cpy.gameObject.transform.localPosition = new Vector3(pos.x - offset, pos.y, pos.z);
cpy.gameObject.SetActive(true);
cpy.CounterAsInt = value;
}
private void drawCounters() {
float posXf = counterFast_.gameObject.transform.localPosition.x + 5.0f;
float posXl = counterLate_.gameObject.transform.localPosition.x + 5.0f;
float posY = counterLate_.gameObject.transform.localPosition.y;
counterFast_.gameObject.transform.localPosition = new Vector3(posXf, posY, 0.0f);
counterLate_.gameObject.transform.localPosition = new Vector3(posXl, posY, 0.0f);
var sessionResult = (patch_SessionResult)Singleton<PlayInfo>.instance.sessionResult;
cloneCounter(
counterFast_,
new Color(0.630f, 0.766f, 0.829f, 1.000f),
sessionResult.PlatinumFastCount
);
cloneCounter(
counterLate_,
new Color(0.809f, 0.396f, 0.365f, 1.000f),
sessionResult.PlatinumLateCount
);
}
private extern IEnumerator orig_showPlatinumScore(PlayInfo playInfo);
private IEnumerator showPlatinumScore(PlayInfo playInfo) {
StartCoroutine(orig_showPlatinumScore(playInfo));
while(!AnimatorState.stateEquals(animator_, State_TechnicalScore_Loop)) {
yield return null;
}
drawCounters();
}
}