Some DJ School logic and animations, DJ Yellow is not currently animatable.

This commit is contained in:
Braedon
2022-02-04 22:48:35 -05:00
parent c91d306a41
commit 7a624d0581
46 changed files with 3062 additions and 41 deletions

View File

@ -45,7 +45,7 @@ namespace RhythmHeavenMania
private void Awake()
{
autoplay = true;
// autoplay = true;
instance = this;
}

View File

@ -1,9 +1,17 @@
using UnityEngine;
using RhythmHeavenMania.Util;
namespace RhythmHeavenMania.Games.DJSchool
{
public class DJSchool : Minigame
{
[Header("Components")]
[SerializeField] private Student student;
[Header("Properties")]
public GameEvent bop = new GameEvent();
public static DJSchool instance { get; private set; }
private void Awake()
@ -11,6 +19,33 @@ namespace RhythmHeavenMania.Games.DJSchool
instance = this;
}
private void Update()
{
if (Conductor.instance.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
{
if (Conductor.instance.songPositionInBeats >= bop.startBeat && Conductor.instance.songPositionInBeats < bop.startBeat + bop.length)
{
if (student.anim.IsAnimationNotPlaying())
{
if (student.isHolding)
{
student.anim.Play("HoldBop", 0, 0);
}
else
{
student.anim.Play("IdleBop", 0, 0);
}
}
}
}
}
public void Bop(float beat, float length)
{
bop.startBeat = beat;
bop.length = length;
}
public void BreakCmon(float beat)
{
MultiSound.Play(new MultiSound.Sound[]
@ -19,6 +54,9 @@ namespace RhythmHeavenMania.Games.DJSchool
new MultiSound.Sound("djSchool/breakCmon2", beat + 1f),
new MultiSound.Sound("djSchool/ooh", beat + 2f),
});
student.holdBeat = beat;
student.ResetState();
}
public void ScratchoHey(float beat)
@ -29,6 +67,9 @@ namespace RhythmHeavenMania.Games.DJSchool
new MultiSound.Sound("djSchool/scratchoHey2", beat + 1f),
new MultiSound.Sound("djSchool/hey", beat + 2f),
});
student.swipeBeat = beat;
student.ResetState();
}
}
}

View File

@ -0,0 +1,135 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using RhythmHeavenMania.Util;
using Starpelly;
namespace RhythmHeavenMania.Games.DJSchool
{
public class Student : PlayerActionObject
{
public Animator anim;
[Header("Properties")]
public float holdBeat;
public float swipeBeat;
public bool isHolding;
[Header("Components")]
[SerializeField] private SpriteRenderer flash;
[SerializeField] private GameObject flashFX;
[SerializeField] private GameObject flashFXInverse;
[SerializeField] private GameObject TurnTable;
[SerializeField] private GameObject slamFX;
private void Start()
{
anim = GetComponent<Animator>();
TurnTable.GetComponent<Animator>().speed = 0;
}
private void Update()
{
if (!isHolding)
{
float normalizedBeatHold = Conductor.instance.GetPositionFromBeat(holdBeat, 2);
StateCheck(normalizedBeatHold);
if (PlayerInput.Pressed())
{
if (state.perfect)
{
Hold(true);
}
else if (state.notPerfect())
{
Hold(false);
}
}
}
else if (isHolding)
{
float normalizedBeatSwipe = Conductor.instance.GetPositionFromBeat(swipeBeat, 2);
StateCheck(normalizedBeatSwipe);
print(normalizedBeatSwipe); ;
if (PlayerInput.PressedUp())
{
if (state.perfect)
{
Swipe();
}
else if (state.notPerfect())
{
UnHold();
}
}
}
}
public void Hold(bool ace)
{
isHolding = true;
Jukebox.PlayOneShotGame("djSchool/recordStop");
anim.Play("Hold", 0, 0);
if (ace)
{
FlashFX(true);
}
}
public void UnHold()
{
anim.speed = -1;
anim.Play("Hold", 0, 0);
}
public void Swipe()
{
isHolding = false;
Jukebox.PlayOneShotGame("djSchool/recordSwipe");
anim.Play("Swipe", 0, 0);
FlashFX(false);
TurnTable.GetComponent<Animator>().speed = 1;
TurnTable.GetComponent<Animator>().Play("Student_Turntable_Swipe", 0, 0);
Instantiate(slamFX).SetActive(true);
}
private void FlashFX(bool inverse)
{
GameObject prefab = flashFX;
if (inverse)
prefab = flashFXInverse;
GameObject flashFX_ = Instantiate(prefab, this.transform.parent);
flashFX_.SetActive(true);
Destroy(flashFX_, 0.5f);
flash.color = "D0FBFF".Hex2RGB();
flash.color = new Color(flash.color.r, flash.color.g, flash.color.b, 0.85f);
flash.DOColor(new Color(flash.color.r, flash.color.g, flash.color.b, 0), 0.15f);
}
public void TransitionBackToIdle()
{
// for letting go of "hold"
if (anim.speed == 0)
{
anim.speed = 1;
anim.Play("Idle", 0, 0);
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 23185f6d213e9184fae5e6841b42c226
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -152,8 +152,9 @@ namespace RhythmHeavenMania
new GameAction("keep-up", delegate { }, 4f, true),
new GameAction("high kick-toe!", delegate { }, 3f),
}),
new Minigame("djSchool", "DJ School \n<color=#eb5454>[Non-Playable]</color>", "B888F8", false, false, new List<GameAction>()
new Minigame("djSchool", "DJ School \n<color=#eb5454>[Non-Playable]</color>", "008c97", false, false, new List<GameAction>()
{
new GameAction("bop", delegate { DJSchool.instance.Bop(eventCaller.currentBeat, eventCaller.currentLength); }, 0.5f, true),
new GameAction("break c'mon ooh", delegate { DJSchool.instance.BreakCmon(eventCaller.currentBeat); }, 3f),
new GameAction("scratch-o hey", delegate { DJSchool.instance.ScratchoHey(eventCaller.currentBeat); }, 3f),
}),

View File

@ -111,6 +111,7 @@ namespace RhythmHeavenMania.Util
public static float Instant(float start, float end, float value)
{
// this is lazy
return Mathf.Lerp(end, end, value);
}