Skip to content

Commit

Permalink
fix: button light pos and animation
Browse files Browse the repository at this point in the history
  • Loading branch information
LingFeng-bbben committed Oct 31, 2024
1 parent 20d6cf9 commit 906b830
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Assets/Scenes/Game.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 3cd085963a2b0924587ac210ff73f837, type: 3}
m_Name:
m_EditorClassIdentifier:
buttonGoodColor: {r: 0, g: 0.4867924, b: 0, a: 1}
buttonGreatColor: {r: 0.735849, g: 0, b: 0.5863867, a: 1}
buttonPerfectColor: {r: 0.7132075, g: 0.6563782, b: 0, a: 1}
--- !u!4 &592746511
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -3052,8 +3055,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a603b2d1fbc471d4abf512e887e20c8e, type: 3}
m_Name:
m_EditorClassIdentifier:
noteSpeed: 7
touchSpeed: 7.5
tapPrefab: {fileID: 7955322054321000439, guid: de312956ab0060a49a3f3585e600c39a, type: 3}
holdPrefab: {fileID: 7566527781932749496, guid: 558452b6e8eb68f44b4f035c27e37c25, type: 3}
starPrefab: {fileID: 3599915660479470153, guid: 279b1bd0701d99f4183a5258db1374b2, type: 3}
Expand Down
14 changes: 14 additions & 0 deletions Assets/Script/DontDestroy/IO/LightManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ public void SetButtonLight(Color lightColor, int button)
}
}

Coroutine[] timers = new Coroutine[8];
public void SetButtonLightWithTimeout(Color lightColor, int button)
{
SetButtonLight(lightColor, button);
if (timers[button] != null)
StopCoroutine(timers[button]);
timers[button] = StartCoroutine(TurnWhiteAfter(button));
}
IEnumerator TurnWhiteAfter(int button)
{
yield return new WaitForSeconds(0.3f);
SetButtonLight(Color.white, button);
}

IEnumerator DebugLights()
{
while (true)
Expand Down
10 changes: 7 additions & 3 deletions Assets/Script/Game/NoteEffectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public class NoteEffectManager : MonoBehaviour
GameObject _fireworkEffect;
Animator _fireworkEffectAnimator;

public Color buttonGoodColor = Color.green;
public Color buttonGreatColor = Color.red;
public Color buttonPerfectColor = Color.yellow;

void Awake()
{
MajInstanceHelper<NoteEffectManager>.Instance = this;
Expand Down Expand Up @@ -45,22 +49,22 @@ public void PlayEffect(int position, in JudgeResult judgeResult)
{
case JudgeType.LateGood:
case JudgeType.FastGood:
MajInstances.LightManager.SetButtonLight(Color.green, position);
MajInstances.LightManager.SetButtonLightWithTimeout(buttonGoodColor, position-1);
break;
case JudgeType.LateGreat:
case JudgeType.LateGreat1:
case JudgeType.LateGreat2:
case JudgeType.FastGreat2:
case JudgeType.FastGreat1:
case JudgeType.FastGreat:
MajInstances.LightManager.SetButtonLight(new Color(1, 0.54f, 1f), position);
MajInstances.LightManager.SetButtonLightWithTimeout(buttonGreatColor, position-1);
break;
case JudgeType.LatePerfect2:
case JudgeType.FastPerfect2:
case JudgeType.LatePerfect1:
case JudgeType.FastPerfect1:
case JudgeType.Perfect:
MajInstances.LightManager.SetButtonLight(new Color(0.99f, 0.99f, 0.717f), position);
MajInstances.LightManager.SetButtonLightWithTimeout(buttonPerfectColor, position-1);
break;
}
_effectPool.Play(judgeResult, position);
Expand Down

0 comments on commit 906b830

Please sign in to comment.