mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-13 01:57:38 +02:00
Updated Inputs for some minigames
First Contact & DJ School has their inputs methods updated
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
using DG.Tweening;
|
||||
using HeavenStudio.Util;
|
||||
@ -19,6 +20,8 @@ namespace HeavenStudio.Games.Scripts_DJSchool
|
||||
public bool shouldBeHolding;
|
||||
public bool eligible;
|
||||
public bool missed;
|
||||
public bool swiping;
|
||||
public bool soundFX;
|
||||
|
||||
[Header("Components")]
|
||||
[SerializeField] private SpriteRenderer flash;
|
||||
@ -26,6 +29,7 @@ namespace HeavenStudio.Games.Scripts_DJSchool
|
||||
[SerializeField] private GameObject flashFXInverse;
|
||||
[SerializeField] private GameObject TurnTable;
|
||||
[SerializeField] private GameObject slamFX;
|
||||
AudioMixerGroup mixer;
|
||||
|
||||
private Animator tableAnim;
|
||||
|
||||
@ -37,103 +41,91 @@ namespace HeavenStudio.Games.Scripts_DJSchool
|
||||
anim = GetComponent<Animator>();
|
||||
tableAnim = TurnTable.GetComponent<Animator>();
|
||||
tableAnim.speed = 0;
|
||||
mixer = Resources.Load<AudioMixer>("MainMixer").FindMatchingGroups("Music")[0];
|
||||
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float beatToUse = shouldBeHolding ? swipeBeat : holdBeat;
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromMargin(beatToUse + 2, 1);
|
||||
|
||||
if (eligible)
|
||||
{
|
||||
StateCheck(normalizedBeat);
|
||||
|
||||
if (normalizedBeat > Minigame.LateTime())
|
||||
{
|
||||
eligible = false;
|
||||
missed = true;
|
||||
|
||||
if (shouldBeHolding)
|
||||
{
|
||||
shouldBeHolding = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
shouldBeHolding = true;
|
||||
game.SetDJYellowHead(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isHolding)
|
||||
{
|
||||
if (PlayerInput.Pressed())
|
||||
{
|
||||
if (!shouldBeHolding && state.perfect && eligible)
|
||||
{
|
||||
Hold(true);
|
||||
eligible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!shouldBeHolding)
|
||||
eligible = false;
|
||||
|
||||
Hold(false);
|
||||
|
||||
missed = true;
|
||||
game.SetDJYellowHead(3, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PlayerInput.PressedUp())
|
||||
{
|
||||
if (shouldBeHolding && state.perfect && eligible)
|
||||
{
|
||||
Swipe(true);
|
||||
eligible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (shouldBeHolding)
|
||||
{
|
||||
Swipe(false);
|
||||
eligible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
UnHold();
|
||||
}
|
||||
|
||||
missed = true;
|
||||
game.SetDJYellowHead(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Hold(bool ace)
|
||||
#region old hold
|
||||
//public void Hold(bool ace)
|
||||
//{
|
||||
// isHolding = true;
|
||||
|
||||
// if (ace)
|
||||
// {
|
||||
// missed = false;
|
||||
// shouldBeHolding = true;
|
||||
// game.SetDJYellowHead(1);
|
||||
// }
|
||||
|
||||
// Jukebox.PlayOneShotGame("djSchool/recordStop");
|
||||
|
||||
// anim.Play("Hold", 0, 0);
|
||||
// tableAnim.Play("Student_Turntable_Hold", 0, 0);
|
||||
// if (ace)
|
||||
// {
|
||||
// if (soundFX)
|
||||
// {
|
||||
// Conductor.instance.djSchoolHold.TransitionTo(.01f);
|
||||
// }
|
||||
|
||||
// FlashFX(true);
|
||||
// }
|
||||
|
||||
// // Settings.GetMusicMixer().audioMixer.FindSnapshot("DJSchool_Hold").TransitionTo(0.15f);
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region onHold
|
||||
public void OnHitHold(PlayerActionEvent caller, float beat)
|
||||
{
|
||||
isHolding = true;
|
||||
|
||||
if (ace)
|
||||
{
|
||||
missed = false;
|
||||
shouldBeHolding = true;
|
||||
game.SetDJYellowHead(1);
|
||||
}
|
||||
|
||||
missed = false;
|
||||
shouldBeHolding = true;
|
||||
game.SetDJYellowHead(1);
|
||||
|
||||
Jukebox.PlayOneShotGame("djSchool/recordStop");
|
||||
|
||||
anim.Play("Hold", 0, 0);
|
||||
//tableAnim.Play("Student_Turntable_Hold", 0, 0);
|
||||
|
||||
if (ace)
|
||||
if (soundFX)
|
||||
{
|
||||
FlashFX(true);
|
||||
mixer.audioMixer.FindSnapshot("DJSchool_Hold").TransitionTo(.01f);
|
||||
}
|
||||
FlashFX(true);
|
||||
}
|
||||
|
||||
// Settings.GetMusicMixer().audioMixer.FindSnapshot("DJSchool_Hold").TransitionTo(0.15f);
|
||||
public void OnMissHold(PlayerActionEvent caller)
|
||||
{
|
||||
//isHolding = true;
|
||||
|
||||
missed = true;
|
||||
game.SetDJYellowHead(3, true);
|
||||
}
|
||||
|
||||
public void OnMissHoldForPlayerInput()
|
||||
{
|
||||
isHolding = true;
|
||||
|
||||
missed = true;
|
||||
game.SetDJYellowHead(3, true);
|
||||
|
||||
Jukebox.PlayOneShotGame("djSchool/recordStop");
|
||||
|
||||
anim.Play("Hold", 0, 0);
|
||||
//tableAnim.Play("Student_Turntable_Hold", 0, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void OnEmpty(PlayerActionEvent caller)
|
||||
{
|
||||
//empty
|
||||
}
|
||||
|
||||
public void UnHold()
|
||||
@ -141,50 +133,125 @@ namespace HeavenStudio.Games.Scripts_DJSchool
|
||||
isHolding = false;
|
||||
|
||||
anim.Play("Unhold", 0, 0);
|
||||
|
||||
// Settings.GetMusicMixer().audioMixer.FindSnapshot("Main").TransitionTo(0.15f);
|
||||
missed = true;
|
||||
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
||||
}
|
||||
|
||||
public void Swipe(bool ace)
|
||||
#region onSwipe
|
||||
public void OnHitSwipe(PlayerActionEvent caller, float beat)
|
||||
{
|
||||
isHolding = false;
|
||||
|
||||
if (ace)
|
||||
if (!missed)
|
||||
{
|
||||
isHolding = false;
|
||||
|
||||
missed = false;
|
||||
shouldBeHolding = false;
|
||||
Jukebox.PlayOneShotGame("djSchool/recordSwipe");
|
||||
FlashFX(false);
|
||||
swiping = true;
|
||||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { anim.Play("Swipe", 0, 0); }),
|
||||
new BeatAction.Action(beat + 4f, delegate { swiping = false; }),
|
||||
});
|
||||
//anim.Play("Swipe", 0, 0);
|
||||
|
||||
tableAnim.speed = 1;
|
||||
tableAnim.Play("Student_Turntable_Swipe", 0, 0);
|
||||
|
||||
Instantiate(slamFX).SetActive(true);
|
||||
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Missed record swipe sound should play here.
|
||||
OnMissSwipeForPlayerInput();
|
||||
Jukebox.PlayOneShotGame("djSchool/recordSwipe");
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { anim.Play("Swipe", 0, 0); }),
|
||||
new BeatAction.Action(beat + 4f, delegate { swiping = false; }),
|
||||
});
|
||||
//anim.Play("Swipe", 0, 0);
|
||||
|
||||
tableAnim.speed = 1;
|
||||
tableAnim.Play("Student_Turntable_Swipe", 0, 0);
|
||||
|
||||
Instantiate(slamFX).SetActive(true);
|
||||
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
||||
}
|
||||
|
||||
anim.Play("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()
|
||||
public void OnMissSwipe(PlayerActionEvent caller)
|
||||
{
|
||||
if (!shouldBeHolding)
|
||||
{
|
||||
Hold(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Swipe(true);
|
||||
}
|
||||
|
||||
eligible = false;
|
||||
isHolding = false;
|
||||
//swiping = false;
|
||||
missed = true;
|
||||
game.SetDJYellowHead(3);
|
||||
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
||||
}
|
||||
|
||||
public void OnMissSwipeForPlayerInput()
|
||||
{
|
||||
isHolding = false;
|
||||
|
||||
missed = true;
|
||||
game.SetDJYellowHead(3);
|
||||
//swiping = false;
|
||||
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region old swipe
|
||||
//public void Swipe(bool ace)
|
||||
//{
|
||||
// isHolding = false;
|
||||
|
||||
// if (ace)
|
||||
// {
|
||||
// missed = false;
|
||||
// shouldBeHolding = false;
|
||||
// Jukebox.PlayOneShotGame("djSchool/recordSwipe");
|
||||
// FlashFX(false);
|
||||
// swiping = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Missed record swipe sound should play here.
|
||||
// }
|
||||
|
||||
// anim.Play("Swipe", 0, 0);
|
||||
|
||||
// tableAnim.speed = 1;
|
||||
// tableAnim.Play("Student_Turntable_Swipe", 0, 0);
|
||||
|
||||
// Instantiate(slamFX).SetActive(true);
|
||||
// Conductor.instance.normal.TransitionTo(.01f);
|
||||
// // Settings.GetMusicMixer().audioMixer.FindSnapshot("Main").TransitionTo(0.15f);
|
||||
// swiping = false;
|
||||
|
||||
//}
|
||||
|
||||
//public override void OnAce()
|
||||
//{
|
||||
// if (!shouldBeHolding)
|
||||
// {
|
||||
// //Hold(true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Conductor.instance.normal.TransitionTo(.01f);
|
||||
// //Swipe(true);
|
||||
// }
|
||||
|
||||
// eligible = false;
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
private void FlashFX(bool inverse)
|
||||
{
|
||||
GameObject prefab = flashFX;
|
||||
@ -194,11 +261,10 @@ namespace HeavenStudio.Games.Scripts_DJSchool
|
||||
|
||||
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);
|
||||
Destroy(flashFX_, 0.5f);
|
||||
}
|
||||
|
||||
public void TransitionBackToIdle()
|
||||
@ -210,5 +276,12 @@ namespace HeavenStudio.Games.Scripts_DJSchool
|
||||
anim.Play("Idle", 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Not sure but will do?
|
||||
private void OnDestroy()
|
||||
{
|
||||
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user