2022-02-05 03:48:35 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
2022-07-08 05:27:10 +00:00
|
|
|
using UnityEngine.Audio;
|
2022-02-05 03:48:35 +00:00
|
|
|
|
|
|
|
using DG.Tweening;
|
2022-03-14 14:21:05 +00:00
|
|
|
using HeavenStudio.Util;
|
2022-02-05 03:48:35 +00:00
|
|
|
using Starpelly;
|
|
|
|
|
2022-03-14 14:21:05 +00:00
|
|
|
namespace HeavenStudio.Games.Scripts_DJSchool
|
2022-02-05 03:48:35 +00:00
|
|
|
{
|
|
|
|
public class Student : PlayerActionObject
|
|
|
|
{
|
|
|
|
public Animator anim;
|
|
|
|
|
|
|
|
[Header("Properties")]
|
|
|
|
public float holdBeat;
|
|
|
|
public float swipeBeat;
|
|
|
|
public bool isHolding;
|
2022-02-20 17:28:56 +00:00
|
|
|
public bool shouldBeHolding;
|
|
|
|
public bool eligible;
|
|
|
|
public bool missed;
|
2022-07-08 05:27:10 +00:00
|
|
|
public bool swiping;
|
|
|
|
public bool soundFX;
|
2022-02-05 03:48:35 +00:00
|
|
|
|
|
|
|
[Header("Components")]
|
|
|
|
[SerializeField] private SpriteRenderer flash;
|
|
|
|
[SerializeField] private GameObject flashFX;
|
|
|
|
[SerializeField] private GameObject flashFXInverse;
|
|
|
|
[SerializeField] private GameObject TurnTable;
|
|
|
|
[SerializeField] private GameObject slamFX;
|
2022-07-08 05:27:10 +00:00
|
|
|
AudioMixerGroup mixer;
|
2022-02-05 03:48:35 +00:00
|
|
|
|
2022-02-20 17:28:56 +00:00
|
|
|
private Animator tableAnim;
|
|
|
|
|
|
|
|
private DJSchool game;
|
|
|
|
|
2022-03-26 02:08:46 +00:00
|
|
|
public void Init()
|
2022-02-05 03:48:35 +00:00
|
|
|
{
|
2022-02-20 17:28:56 +00:00
|
|
|
game = DJSchool.instance;
|
2022-02-05 03:48:35 +00:00
|
|
|
anim = GetComponent<Animator>();
|
2022-02-20 17:28:56 +00:00
|
|
|
tableAnim = TurnTable.GetComponent<Animator>();
|
|
|
|
tableAnim.speed = 0;
|
2022-07-08 05:27:10 +00:00
|
|
|
mixer = Resources.Load<AudioMixer>("MainMixer").FindMatchingGroups("Music")[0];
|
|
|
|
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
2022-02-05 03:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
2022-07-08 05:27:10 +00:00
|
|
|
|
|
|
|
}
|
2022-02-20 17:28:56 +00:00
|
|
|
|
2022-07-08 05:27:10 +00:00
|
|
|
#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;
|
2022-02-05 03:48:35 +00:00
|
|
|
|
2022-07-08 05:27:10 +00:00
|
|
|
missed = false;
|
|
|
|
shouldBeHolding = true;
|
|
|
|
game.SetDJYellowHead(1);
|
2022-02-20 17:28:56 +00:00
|
|
|
|
2022-07-08 05:27:10 +00:00
|
|
|
Jukebox.PlayOneShotGame("djSchool/recordStop");
|
|
|
|
|
|
|
|
anim.Play("Hold", 0, 0);
|
|
|
|
//tableAnim.Play("Student_Turntable_Hold", 0, 0);
|
|
|
|
|
|
|
|
if (soundFX)
|
2022-02-05 03:48:35 +00:00
|
|
|
{
|
2022-07-08 05:27:10 +00:00
|
|
|
mixer.audioMixer.FindSnapshot("DJSchool_Hold").TransitionTo(.01f);
|
2022-02-05 03:48:35 +00:00
|
|
|
}
|
2022-07-08 05:27:10 +00:00
|
|
|
FlashFX(true);
|
2022-02-05 03:48:35 +00:00
|
|
|
}
|
|
|
|
|
2022-07-08 05:27:10 +00:00
|
|
|
public void OnMissHold(PlayerActionEvent caller)
|
|
|
|
{
|
|
|
|
//isHolding = true;
|
|
|
|
|
|
|
|
missed = true;
|
|
|
|
game.SetDJYellowHead(3, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnMissHoldForPlayerInput()
|
2022-02-05 03:48:35 +00:00
|
|
|
{
|
|
|
|
isHolding = true;
|
2022-07-08 05:27:10 +00:00
|
|
|
|
|
|
|
missed = true;
|
|
|
|
game.SetDJYellowHead(3, true);
|
2022-02-05 03:48:35 +00:00
|
|
|
|
|
|
|
Jukebox.PlayOneShotGame("djSchool/recordStop");
|
|
|
|
|
2022-07-08 05:27:10 +00:00
|
|
|
anim.Play("Hold", 0, 0);
|
|
|
|
//tableAnim.Play("Student_Turntable_Hold", 0, 0);
|
|
|
|
}
|
|
|
|
#endregion
|
2022-02-05 04:40:33 +00:00
|
|
|
|
2022-07-08 05:27:10 +00:00
|
|
|
public void OnEmpty(PlayerActionEvent caller)
|
|
|
|
{
|
|
|
|
//empty
|
2022-02-05 03:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void UnHold()
|
|
|
|
{
|
2022-02-05 20:28:04 +00:00
|
|
|
isHolding = false;
|
|
|
|
|
2022-02-20 17:28:56 +00:00
|
|
|
anim.Play("Unhold", 0, 0);
|
2022-07-08 05:27:10 +00:00
|
|
|
missed = true;
|
|
|
|
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
2022-02-05 03:48:35 +00:00
|
|
|
}
|
|
|
|
|
2022-07-08 05:27:10 +00:00
|
|
|
#region onSwipe
|
|
|
|
public void OnHitSwipe(PlayerActionEvent caller, float beat)
|
2022-02-05 03:48:35 +00:00
|
|
|
{
|
2022-07-08 05:27:10 +00:00
|
|
|
if (!missed)
|
2022-02-20 17:28:56 +00:00
|
|
|
{
|
2022-07-08 05:27:10 +00:00
|
|
|
isHolding = false;
|
|
|
|
|
2022-02-20 17:28:56 +00:00
|
|
|
missed = false;
|
|
|
|
shouldBeHolding = false;
|
|
|
|
Jukebox.PlayOneShotGame("djSchool/recordSwipe");
|
|
|
|
FlashFX(false);
|
2022-07-08 05:27:10 +00:00
|
|
|
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);
|
|
|
|
|
2023-01-05 04:04:31 +00:00
|
|
|
Instantiate(slamFX, this.transform.parent).SetActive(true);
|
2022-07-08 05:27:10 +00:00
|
|
|
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
2022-02-20 17:28:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-08 05:27:10 +00:00
|
|
|
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);
|
2022-02-05 03:48:35 +00:00
|
|
|
|
2022-07-08 05:27:10 +00:00
|
|
|
tableAnim.speed = 1;
|
|
|
|
tableAnim.Play("Student_Turntable_Swipe", 0, 0);
|
2022-02-05 03:48:35 +00:00
|
|
|
|
2023-01-05 04:04:31 +00:00
|
|
|
Instantiate(slamFX, this.transform.parent).SetActive(true);
|
2022-07-08 05:27:10 +00:00
|
|
|
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2022-02-05 04:40:33 +00:00
|
|
|
|
2022-07-08 05:27:10 +00:00
|
|
|
public void OnMissSwipe(PlayerActionEvent caller)
|
|
|
|
{
|
|
|
|
isHolding = false;
|
|
|
|
//swiping = false;
|
|
|
|
missed = true;
|
|
|
|
game.SetDJYellowHead(3);
|
|
|
|
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
2022-02-05 03:48:35 +00:00
|
|
|
}
|
|
|
|
|
2022-07-08 05:27:10 +00:00
|
|
|
public void OnMissSwipeForPlayerInput()
|
2022-02-20 17:28:56 +00:00
|
|
|
{
|
2022-07-08 05:27:10 +00:00
|
|
|
isHolding = false;
|
|
|
|
|
|
|
|
missed = true;
|
|
|
|
game.SetDJYellowHead(3);
|
|
|
|
//swiping = false;
|
|
|
|
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
2022-02-20 17:28:56 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-07-08 05:27:10 +00:00
|
|
|
#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
|
|
|
|
|
2022-02-05 03:48:35 +00:00
|
|
|
private void FlashFX(bool inverse)
|
|
|
|
{
|
|
|
|
GameObject prefab = flashFX;
|
|
|
|
|
|
|
|
if (inverse)
|
|
|
|
prefab = flashFXInverse;
|
|
|
|
|
|
|
|
GameObject flashFX_ = Instantiate(prefab, this.transform.parent);
|
|
|
|
flashFX_.SetActive(true);
|
|
|
|
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);
|
2022-07-08 05:27:10 +00:00
|
|
|
Destroy(flashFX_, 0.5f);
|
2022-02-05 03:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void TransitionBackToIdle()
|
|
|
|
{
|
|
|
|
// for letting go of "hold"
|
|
|
|
if (anim.speed == 0)
|
|
|
|
{
|
|
|
|
anim.speed = 1;
|
|
|
|
anim.Play("Idle", 0, 0);
|
|
|
|
}
|
|
|
|
}
|
2022-07-08 05:27:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
//Not sure but will do?
|
|
|
|
private void OnDestroy()
|
|
|
|
{
|
|
|
|
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
|
|
|
}
|
2022-02-05 03:48:35 +00:00
|
|
|
}
|
|
|
|
}
|