2022-02-06 04:03:31 +00:00
|
|
|
using System.Collections.Generic;
|
2022-02-05 03:48:35 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
2022-02-03 02:09:50 +00:00
|
|
|
using RhythmHeavenMania.Util;
|
|
|
|
|
|
|
|
namespace RhythmHeavenMania.Games.DJSchool
|
|
|
|
{
|
|
|
|
public class DJSchool : Minigame
|
|
|
|
{
|
2022-02-05 03:48:35 +00:00
|
|
|
[Header("Components")]
|
|
|
|
[SerializeField] private Student student;
|
2022-02-06 04:03:31 +00:00
|
|
|
[SerializeField] private GameObject djYellow;
|
2022-02-09 07:46:49 +00:00
|
|
|
private Animator djYellowAnim;
|
|
|
|
[SerializeField] private SpriteRenderer headSprite;
|
|
|
|
[SerializeField] private Sprite[] headSprites;
|
2022-02-05 03:48:35 +00:00
|
|
|
|
|
|
|
[Header("Properties")]
|
|
|
|
public GameEvent bop = new GameEvent();
|
2022-02-09 07:46:49 +00:00
|
|
|
private bool djYellowHolding;
|
2022-02-05 03:48:35 +00:00
|
|
|
|
2022-02-03 02:09:50 +00:00
|
|
|
public static DJSchool instance { get; private set; }
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
instance = this;
|
|
|
|
}
|
|
|
|
|
2022-02-09 07:46:49 +00:00
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
djYellowAnim = djYellow.GetComponent<Animator>();
|
|
|
|
}
|
|
|
|
|
2022-02-05 03:48:35 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2022-02-09 07:46:49 +00:00
|
|
|
if (djYellowAnim.IsAnimationNotPlaying())
|
|
|
|
{
|
|
|
|
if (djYellowHolding)
|
|
|
|
{
|
|
|
|
djYellowAnim.Play("HoldBop", 0, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// there is no sprite for the alternate idle bop, oh well
|
|
|
|
djYellowAnim.Play("IdleBop", 0, 0);
|
|
|
|
}
|
|
|
|
}
|
2022-02-05 03:48:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Bop(float beat, float length)
|
|
|
|
{
|
|
|
|
bop.startBeat = beat;
|
|
|
|
bop.length = length;
|
|
|
|
}
|
|
|
|
|
2022-02-09 07:46:49 +00:00
|
|
|
public void BreakCmon(float beat, int type)
|
2022-02-03 02:09:50 +00:00
|
|
|
{
|
2022-02-09 07:46:49 +00:00
|
|
|
if (djYellowHolding) return;
|
|
|
|
|
|
|
|
string[] sounds = new string[] { };
|
|
|
|
|
|
|
|
if (type == 0)
|
|
|
|
{
|
|
|
|
sounds = new string[] { "djSchool/breakCmon1", "djSchool/breakCmon2", "djSchool/ooh" };
|
|
|
|
}
|
|
|
|
else if (type == 1)
|
|
|
|
{
|
|
|
|
sounds = new string[] { "djSchool/breakCmonAlt1", "djSchool/breakCmonAlt2", "djSchool/oohAlt" };
|
|
|
|
}
|
|
|
|
else if (type == 2)
|
|
|
|
{
|
|
|
|
SetDJYellowHead(2);
|
|
|
|
sounds = new string[] { "djSchool/breakCmonLoud1", "djSchool/breakCmonLoud2", "djSchool/oohLoud" };
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-03 02:09:50 +00:00
|
|
|
MultiSound.Play(new MultiSound.Sound[]
|
|
|
|
{
|
2022-02-09 07:46:49 +00:00
|
|
|
new MultiSound.Sound(sounds[0], beat),
|
|
|
|
new MultiSound.Sound(sounds[1], beat + 1f),
|
|
|
|
new MultiSound.Sound(sounds[2], beat + 2f),
|
2022-02-03 02:09:50 +00:00
|
|
|
});
|
2022-02-05 03:48:35 +00:00
|
|
|
|
2022-02-06 04:03:31 +00:00
|
|
|
BeatAction.New(djYellow, new List<BeatAction.Action>()
|
|
|
|
{
|
|
|
|
new BeatAction.Action(beat, delegate { djYellow.GetComponent<Animator>().Play("BreakCmon", 0, 0); }),
|
|
|
|
new BeatAction.Action(beat + 1f, delegate { djYellow.GetComponent<Animator>().Play("BreakCmon", 0, 0); }),
|
2022-02-09 07:46:49 +00:00
|
|
|
new BeatAction.Action(beat + 2f, delegate
|
|
|
|
{
|
|
|
|
djYellow.GetComponent<Animator>().Play("Hold", 0, 0);
|
|
|
|
djYellowHolding = true;
|
|
|
|
SetDJYellowHead(1);
|
|
|
|
}),
|
2022-02-06 04:03:31 +00:00
|
|
|
});
|
|
|
|
|
2022-02-05 03:48:35 +00:00
|
|
|
student.holdBeat = beat;
|
|
|
|
student.ResetState();
|
2022-02-03 02:09:50 +00:00
|
|
|
}
|
|
|
|
|
2022-02-09 07:46:49 +00:00
|
|
|
public void AndStop(float beat)
|
2022-02-03 02:09:50 +00:00
|
|
|
{
|
2022-02-09 07:46:49 +00:00
|
|
|
if (djYellowHolding) return;
|
|
|
|
|
2022-02-03 02:09:50 +00:00
|
|
|
MultiSound.Play(new MultiSound.Sound[]
|
|
|
|
{
|
2022-02-09 07:46:49 +00:00
|
|
|
new MultiSound.Sound("djSchool/andStop1", beat),
|
|
|
|
new MultiSound.Sound("djSchool/andStop2", beat + 0.35f),
|
|
|
|
new MultiSound.Sound("djSchool/oohAlt", beat + 1.5f),
|
|
|
|
});
|
|
|
|
|
|
|
|
BeatAction.New(djYellow, new List<BeatAction.Action>()
|
|
|
|
{
|
|
|
|
new BeatAction.Action(beat + 0.5f, delegate { djYellow.GetComponent<Animator>().Play("BreakCmon", 0, 0); }),
|
|
|
|
new BeatAction.Action(beat + 1.5f, delegate
|
|
|
|
{
|
|
|
|
djYellow.GetComponent<Animator>().Play("Hold", 0, 0);
|
|
|
|
djYellowHolding = true;
|
|
|
|
SetDJYellowHead(1);
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
|
|
|
student.holdBeat = beat - 0.5f;
|
|
|
|
student.ResetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ScratchoHey(float beat, int type)
|
|
|
|
{
|
|
|
|
string[] sounds = new string[] { };
|
|
|
|
|
|
|
|
if (type == 0)
|
|
|
|
{
|
|
|
|
sounds = new string[] { "djSchool/scratchoHey1", "djSchool/scratchoHey2", "djSchool/hey" };
|
|
|
|
}
|
|
|
|
else if (type == 1)
|
|
|
|
{
|
|
|
|
sounds = new string[] { "djSchool/scratchoHeyAlt1", "djSchool/scratchoHeyAlt2", "djSchool/heyAlt" };
|
|
|
|
}
|
|
|
|
else if (type == 2)
|
|
|
|
{
|
|
|
|
sounds = new string[] { "djSchool/scratchoHeyLoud1", "djSchool/scratchoHeyLoud2", "djSchool/heyLoud" };
|
|
|
|
}
|
|
|
|
|
|
|
|
MultiSound.Play(new MultiSound.Sound[]
|
|
|
|
{
|
|
|
|
new MultiSound.Sound(sounds[0], beat),
|
|
|
|
new MultiSound.Sound(sounds[1], beat + 1f),
|
|
|
|
new MultiSound.Sound(sounds[2], beat + 2f),
|
2022-02-03 02:09:50 +00:00
|
|
|
});
|
2022-02-05 03:48:35 +00:00
|
|
|
|
2022-02-06 04:03:31 +00:00
|
|
|
BeatAction.New(djYellow, new List<BeatAction.Action>()
|
|
|
|
{
|
|
|
|
new BeatAction.Action(beat, delegate { djYellow.GetComponent<Animator>().Play("Scratcho", 0, 0); }),
|
|
|
|
new BeatAction.Action(beat + 1f, delegate { djYellow.GetComponent<Animator>().Play("Scratcho2", 0, 0); }),
|
2022-02-09 07:46:49 +00:00
|
|
|
new BeatAction.Action(beat + 2.05f, delegate
|
|
|
|
{
|
|
|
|
djYellow.GetComponent<Animator>().Play("Hey", 0, 0);
|
|
|
|
djYellowHolding = false;
|
|
|
|
}),
|
2022-02-06 04:03:31 +00:00
|
|
|
});
|
|
|
|
|
2022-02-05 03:48:35 +00:00
|
|
|
student.swipeBeat = beat;
|
|
|
|
student.ResetState();
|
2022-02-03 02:09:50 +00:00
|
|
|
}
|
2022-02-09 07:46:49 +00:00
|
|
|
|
|
|
|
private void SetDJYellowHead(int type)
|
|
|
|
{
|
|
|
|
headSprite.sprite = headSprites[type];
|
|
|
|
}
|
2022-02-03 02:09:50 +00:00
|
|
|
}
|
|
|
|
}
|