Merge pull request #55 from jakobwcrowe/master

DJ School: Additional gameplay implementation and tuning.
This commit is contained in:
Jenny Crowe 2022-02-20 10:29:31 -07:00 committed by GitHub
commit 41ca962595
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 218 additions and 50 deletions

View file

@ -52,6 +52,33 @@ AnimatorState:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &-1143804635325942891
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Unhold
m_Speed: -1
m_CycleOffset: 0
m_Transitions:
- {fileID: 5013820772242190312}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 3958816d51b511b4a9c0505c45de204a, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &-295531023391595954
AnimatorStateTransition:
m_ObjectHideFlags: 1
@ -148,6 +175,28 @@ AnimatorState:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &5013820772242190312
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -4698968861401447970}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 0
m_HasExitTime: 1
m_HasFixedDuration: 0
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1107 &6962450605454016305
AnimatorStateMachine:
serializedVersion: 6
@ -159,7 +208,7 @@ AnimatorStateMachine:
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: -7055007684483605004}
m_Position: {x: 430, y: -30, z: 0}
m_Position: {x: 490, y: -90, z: 0}
- serializedVersion: 1
m_State: {fileID: 1884598382658345919}
m_Position: {x: 580, y: -160, z: 0}
@ -172,6 +221,9 @@ AnimatorStateMachine:
- serializedVersion: 1
m_State: {fileID: 7914765862687888288}
m_Position: {x: 330, y: -170, z: 0}
- serializedVersion: 1
m_State: {fileID: -1143804635325942891}
m_Position: {x: 490, y: -30, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

@ -124,8 +124,8 @@ namespace RhythmHeavenMania
}
}
// LateUpdate works a bit better but causes a bit of bugs, so remind me to fix those eventually
private void LateUpdate()
// LateUpdate works a bit better(?) but causes some bugs (like issues with bop animations).
private void Update()
{
if (Beatmap.entities.Count < 1)
return;

View file

@ -7,6 +7,13 @@ namespace RhythmHeavenMania.Games.DJSchool
{
public class DJSchool : Minigame
{
public enum DJVoice
{
Standard,
Cool,
Hyped
}
[Header("Components")]
[SerializeField] private Student student;
[SerializeField] private GameObject djYellow;
@ -32,9 +39,11 @@ namespace RhythmHeavenMania.Games.DJSchool
private void Update()
{
if (Conductor.instance.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
var cond = Conductor.instance;
if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
{
if (Conductor.instance.songPositionInBeats >= bop.startBeat && Conductor.instance.songPositionInBeats < bop.startBeat + bop.length)
if (cond.songPositionInBeats >= bop.startBeat && cond.songPositionInBeats < bop.startBeat + bop.length)
{
if (student.anim.IsAnimationNotPlaying())
{
@ -49,6 +58,12 @@ namespace RhythmHeavenMania.Games.DJSchool
}
if (djYellowAnim.IsAnimationNotPlaying())
{
var yellowState = djYellowAnim.GetCurrentAnimatorStateInfo(0);
if (yellowState.IsName("Hey"))
{
PostScratchoFace();
}
if (djYellowHolding)
{
djYellowAnim.Play("HoldBop", 0, 0);
@ -75,21 +90,19 @@ namespace RhythmHeavenMania.Games.DJSchool
string[] sounds = new string[] { };
if (type == 0)
switch (type)
{
case 0:
sounds = new string[] { "djSchool/breakCmon1", "djSchool/breakCmon2", "djSchool/ooh" };
}
else if (type == 1)
{
break;
case 1:
sounds = new string[] { "djSchool/breakCmonAlt1", "djSchool/breakCmonAlt2", "djSchool/oohAlt" };
}
else if (type == 2)
{
SetDJYellowHead(2);
break;
case 2:
sounds = new string[] { "djSchool/breakCmonLoud1", "djSchool/breakCmonLoud2", "djSchool/oohLoud" };
break;
}
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound(sounds[0], beat),
@ -105,11 +118,11 @@ namespace RhythmHeavenMania.Games.DJSchool
{
djYellow.GetComponent<Animator>().Play("Hold", 0, 0);
djYellowHolding = true;
SetDJYellowHead(1);
}),
});
student.holdBeat = beat;
student.eligible = true;
student.ResetState();
}
@ -131,11 +144,11 @@ namespace RhythmHeavenMania.Games.DJSchool
{
djYellow.GetComponent<Animator>().Play("Hold", 0, 0);
djYellowHolding = true;
SetDJYellowHead(1);
}),
});
student.holdBeat = beat - 0.5f;
student.eligible = true;
student.ResetState();
}
@ -177,12 +190,44 @@ namespace RhythmHeavenMania.Games.DJSchool
});
student.swipeBeat = beat;
student.eligible = true;
student.ResetState();
}
private void SetDJYellowHead(int type)
public void SetDJYellowHead(int type, bool resetAfterBeats = false)
{
headSprite.sprite = headSprites[type];
if (resetAfterBeats)
{
BeatAction.New(djYellow, new List<BeatAction.Action>()
{
new BeatAction.Action(Mathf.Floor(Conductor.instance.songPositionInBeats) + 2f, delegate
{
var yellowState = djYellowAnim.GetCurrentAnimatorStateInfo(0);
if (yellowState.IsName("Idle")
|| yellowState.IsName("IdleBop")
|| yellowState.IsName("IdleBop2")
|| yellowState.IsName("BreakCmon"))
{
SetDJYellowHead(0);
}
})
});
}
}
public void PostScratchoFace()
{
if (student.missed)
{
student.missed = false;
SetDJYellowHead(3, true);
}
else
{
SetDJYellowHead(2, true);
}
}
}
}

View file

@ -16,6 +16,9 @@ namespace RhythmHeavenMania.Games.DJSchool
public float holdBeat;
public float swipeBeat;
public bool isHolding;
public bool shouldBeHolding;
public bool eligible;
public bool missed;
[Header("Components")]
[SerializeField] private SpriteRenderer flash;
@ -24,50 +27,89 @@ namespace RhythmHeavenMania.Games.DJSchool
[SerializeField] private GameObject TurnTable;
[SerializeField] private GameObject slamFX;
private Animator tableAnim;
private DJSchool game;
private void Start()
{
game = DJSchool.instance;
anim = GetComponent<Animator>();
TurnTable.GetComponent<Animator>().speed = 0;
tableAnim = TurnTable.GetComponent<Animator>();
tableAnim.speed = 0;
}
private void Update()
{
if (!isHolding)
{
float normalizedBeatHold = Conductor.instance.GetPositionFromBeat(holdBeat, 2);
float beatToUse = shouldBeHolding ? swipeBeat : holdBeat;
float normalizedBeat = Conductor.instance.GetPositionFromMargin(beatToUse + 2, 1);
StateCheck(normalizedBeatHold);
if (eligible)
{
StateCheck(normalizedBeat);
if (PlayerInput.Pressed())
if (normalizedBeat > Minigame.LateTime())
{
if (state.perfect)
eligible = false;
missed = true;
if (shouldBeHolding)
{
Hold(true);
shouldBeHolding = false;
}
else
{
Hold(false);
shouldBeHolding = true;
game.SetDJYellowHead(3);
}
}
}
else if (isHolding)
if (!isHolding)
{
float normalizedBeatSwipe = Conductor.instance.GetPositionFromBeat(swipeBeat, 2);
if (PlayerInput.Pressed())
{
if (!shouldBeHolding && state.perfect && eligible)
{
Hold(true);
eligible = false;
}
else
{
if (!shouldBeHolding)
eligible = false;
StateCheck(normalizedBeatSwipe);
print(normalizedBeatSwipe); ;
Hold(false);
missed = true;
game.SetDJYellowHead(3, true);
}
}
}
else
{
if (PlayerInput.PressedUp())
{
if (state.perfect)
if (shouldBeHolding && state.perfect && eligible)
{
Swipe();
Swipe(true);
eligible = false;
}
else
{
if (shouldBeHolding)
{
Swipe(false);
eligible = false;
}
else
{
UnHold();
}
missed = true;
game.SetDJYellowHead(3);
}
}
}
}
@ -76,6 +118,13 @@ namespace RhythmHeavenMania.Games.DJSchool
{
isHolding = true;
if (ace)
{
missed = false;
shouldBeHolding = true;
game.SetDJYellowHead(1);
}
Jukebox.PlayOneShotGame("djSchool/recordStop");
anim.Play("Hold", 0, 0);
@ -91,29 +140,51 @@ namespace RhythmHeavenMania.Games.DJSchool
{
isHolding = false;
anim.speed = -1;
anim.Play("Hold", 0, 0);
anim.Play("Unhold", 0, 0);
// Settings.GetMusicMixer().audioMixer.FindSnapshot("Main").TransitionTo(0.15f);
}
public void Swipe()
public void Swipe(bool ace)
{
isHolding = false;
if (ace)
{
missed = false;
shouldBeHolding = false;
Jukebox.PlayOneShotGame("djSchool/recordSwipe");
FlashFX(false);
}
else
{
// Missed record swipe sound should play here.
}
anim.Play("Swipe", 0, 0);
FlashFX(false);
TurnTable.GetComponent<Animator>().speed = 1;
TurnTable.GetComponent<Animator>().Play("Student_Turntable_Swipe", 0, 0);
tableAnim.speed = 1;
tableAnim.Play("Student_Turntable_Swipe", 0, 0);
Instantiate(slamFX).SetActive(true);
// Settings.GetMusicMixer().audioMixer.FindSnapshot("Main").TransitionTo(0.15f);
}
public override void OnAce()
{
if (!shouldBeHolding)
{
Hold(true);
}
else
{
Swipe(true);
}
eligible = false;
}
private void FlashFX(bool inverse)
{
GameObject prefab = flashFX;

View file

@ -191,11 +191,11 @@ namespace RhythmHeavenMania
new GameAction("and stop ooh", delegate { DJSchool.instance.AndStop(eventCaller.currentEntity.beat); }, 2.5f),
new GameAction("break c'mon ooh", delegate { DJSchool.instance.BreakCmon(eventCaller.currentEntity.beat, eventCaller.currentEntity.type); }, 3f, false, new List<Param>()
{
new Param("type", new EntityTypes.Integer(0, 2, 0), "Type"),
new Param("type", DJSchool.DJVoice.Standard, "Voice"),
}),
new GameAction("scratch-o hey", delegate { DJSchool.instance.ScratchoHey(eventCaller.currentEntity.beat, eventCaller.currentEntity.type); }, 3f, false, new List<Param>()
{
new Param("type", new EntityTypes.Integer(0, 2, 0), "Type"),
new Param("type", DJSchool.DJVoice.Standard, "Voice"),
}),
}),
new Minigame("rhythmTweezers", "Rhythm Tweezers", "98b389", false, false, new List<GameAction>()