1dda4f9477
* Loading improvements: prepwork for loading from assetbundles * note for sfx * cleaner code * correct type * put loaded assetbundle in the minigame data instead also lays groundwork for future localization stuff * add samurai slice gold, coin toss assetbundles * very messy "already loaded" checks * make Dj School load from assetbundle
272 lines
10 KiB
C#
272 lines
10 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
using HeavenStudio.Util;
|
|
|
|
namespace HeavenStudio.Games.Loaders
|
|
{
|
|
using static Minigames;
|
|
public static class NtrDjLoader
|
|
{
|
|
public static Minigame AddGame(EventCaller eventCaller) {
|
|
return new Minigame("djSchool", "DJ School", "008c97", false, false, new List<GameAction>()
|
|
{
|
|
new GameAction("bop", delegate { DJSchool.instance.Bop(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 0.5f, true),
|
|
new GameAction("and stop ooh", delegate { var e = eventCaller.currentEntity; DJSchool.instance.AndStop(e.beat, e.toggle); }, 2.5f, false, new List<Param>()
|
|
{
|
|
new Param("toggle", true, "Ooh", "Whether or not the \"ooh\" sound should be played")
|
|
}),
|
|
new GameAction("break c'mon ooh", delegate { var e = eventCaller.currentEntity; DJSchool.instance.BreakCmon(e.beat, e.type, e.toggle); }, 3f, false, new List<Param>()
|
|
{
|
|
new Param("type", DJSchool.DJVoice.Standard, "Voice", "The voice line to play"),
|
|
new Param("toggle", true, "Ooh", "Whether or not the \"ooh\" sound should be played")
|
|
}),
|
|
new GameAction("scratch-o hey", delegate { DJSchool.instance.ScratchoHey(eventCaller.currentEntity.beat, eventCaller.currentEntity.type); }, 3f, false, new List<Param>()
|
|
{
|
|
new Param("type", DJSchool.DJVoice.Standard, "Voice", "The voice line to play"),
|
|
}),
|
|
},
|
|
new List<string>() {"ntr", "normal"},
|
|
"ntrdj", "en",
|
|
new List<string>(){}
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
namespace HeavenStudio.Games
|
|
{
|
|
using Scripts_DJSchool;
|
|
|
|
public class DJSchool : Minigame
|
|
{
|
|
public enum DJVoice
|
|
{
|
|
Standard,
|
|
Cool,
|
|
Hyped
|
|
}
|
|
|
|
[Header("Components")]
|
|
[SerializeField] private Student student;
|
|
[SerializeField] private GameObject djYellow;
|
|
private Animator djYellowAnim;
|
|
[SerializeField] private SpriteRenderer headSprite;
|
|
[SerializeField] private Sprite[] headSprites;
|
|
|
|
[Header("Properties")]
|
|
public GameEvent bop = new GameEvent();
|
|
private bool djYellowHolding;
|
|
|
|
public static DJSchool instance { get; private set; }
|
|
|
|
private void Awake()
|
|
{
|
|
instance = this;
|
|
djYellowAnim = djYellow.GetComponent<Animator>();
|
|
student.Init();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
var cond = Conductor.instance;
|
|
|
|
if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
|
|
{
|
|
if (cond.songPositionInBeats >= bop.startBeat && cond.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);
|
|
}
|
|
}
|
|
if (djYellowAnim.IsAnimationNotPlaying())
|
|
{
|
|
var yellowState = djYellowAnim.GetCurrentAnimatorStateInfo(0);
|
|
if (yellowState.IsName("Hey"))
|
|
{
|
|
PostScratchoFace();
|
|
}
|
|
|
|
if (djYellowHolding)
|
|
{
|
|
djYellowAnim.Play("HoldBop", 0, 0);
|
|
}
|
|
else
|
|
{
|
|
// todo: split between left and right bop based on beat
|
|
djYellowAnim.Play("IdleBop", 0, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Bop(float beat, float length)
|
|
{
|
|
bop.startBeat = beat;
|
|
bop.length = length;
|
|
}
|
|
|
|
public void BreakCmon(float beat, int type, bool ooh)
|
|
{
|
|
if (djYellowHolding) return;
|
|
|
|
string[] sounds = new string[] { };
|
|
|
|
switch (type)
|
|
{
|
|
case 0:
|
|
sounds = new string[] { "djSchool/breakCmon1", "djSchool/breakCmon2", "djSchool/ooh" };
|
|
break;
|
|
case 1:
|
|
sounds = new string[] { "djSchool/breakCmonAlt1", "djSchool/breakCmonAlt2", "djSchool/oohAlt" };
|
|
break;
|
|
case 2:
|
|
sounds = new string[] { "djSchool/breakCmonLoud1", "djSchool/breakCmonLoud2", "djSchool/oohLoud" };
|
|
break;
|
|
}
|
|
|
|
var sound = new MultiSound.Sound[]
|
|
{
|
|
new MultiSound.Sound(sounds[0], beat),
|
|
new MultiSound.Sound(sounds[1], beat + 1f, offset: 0.030f),
|
|
new MultiSound.Sound("", beat + 2f)
|
|
};
|
|
|
|
if (ooh)
|
|
sound[2] = new MultiSound.Sound(sounds[2], beat + 2f);
|
|
|
|
MultiSound.Play(sound);
|
|
|
|
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); SetupCue(beat, false); }),
|
|
new BeatAction.Action(beat + 2f, delegate
|
|
{
|
|
djYellow.GetComponent<Animator>().Play("Hold", 0, 0);
|
|
djYellowHolding = true;
|
|
}),
|
|
});
|
|
}
|
|
|
|
public void AndStop(float beat, bool ooh)
|
|
{
|
|
if (djYellowHolding) return;
|
|
|
|
var sound = new MultiSound.Sound[]
|
|
{
|
|
new MultiSound.Sound("djSchool/andStop1", beat),
|
|
new MultiSound.Sound("djSchool/andStop2", beat + .5f, offset: 0.1200f),
|
|
new MultiSound.Sound("", beat + 1.5f)
|
|
};
|
|
|
|
if (ooh)
|
|
sound[2] = new MultiSound.Sound("djSchool/oohAlt", beat + 1.5f);
|
|
|
|
MultiSound.Play(sound);
|
|
|
|
BeatAction.New(djYellow, new List<BeatAction.Action>()
|
|
{
|
|
new BeatAction.Action(beat + 0.5f, delegate { djYellow.GetComponent<Animator>().Play("BreakCmon", 0, 0); SetupCue(beat - 0.5f, false); }),
|
|
new BeatAction.Action(beat + 1.5f, delegate
|
|
{
|
|
djYellow.GetComponent<Animator>().Play("Hold", 0, 0);
|
|
djYellowHolding = true;
|
|
}),
|
|
});
|
|
}
|
|
|
|
public void ScratchoHey(float beat, int type)
|
|
{
|
|
string[] sounds = new string[] { };
|
|
|
|
if (type == 0)
|
|
{
|
|
sounds = new string[] { "djSchool/scratchoHey1", "djSchool/scratchoHey2", "djSchool/scratchoHey3", "djSchool/scratchoHey4", "djSchool/hey" };
|
|
}
|
|
else if (type == 1)
|
|
{
|
|
sounds = new string[] { "djSchool/scratchoHeyAlt1", "djSchool/scratchoHeyAlt2", "djSchool/scratchoHeyAlt3", "djSchool/scratchoHeyAlt4", "djSchool/heyAlt" };
|
|
}
|
|
else if (type == 2)
|
|
{
|
|
sounds = new string[] { "djSchool/scratchoHeyLoud1", "djSchool/scratchoHeyLoud2", "djSchool/scratchoHeyLoud3", "djSchool/scratchoHeyLoud4", "djSchool/heyLoud" };
|
|
}
|
|
|
|
MultiSound.Play(new MultiSound.Sound[]
|
|
{
|
|
new MultiSound.Sound(sounds[0], beat),
|
|
new MultiSound.Sound(sounds[1], beat + .25f),
|
|
new MultiSound.Sound(sounds[2], beat + .5f),
|
|
new MultiSound.Sound(sounds[3], beat + 1f, offset: 0.0500f),
|
|
new MultiSound.Sound(sounds[4], beat + 2f, offset: 0.070f),
|
|
});
|
|
|
|
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); SetupCue(beat, true); }),
|
|
new BeatAction.Action(beat + 2.05f, delegate
|
|
{
|
|
djYellow.GetComponent<Animator>().Play("Hey", 0, 0);
|
|
djYellowHolding = false;
|
|
}),
|
|
});
|
|
}
|
|
|
|
void SetupCue(float beat, bool swipe)
|
|
{
|
|
if (swipe)
|
|
student.swipeBeat = beat;
|
|
else
|
|
student.holdBeat = beat;
|
|
|
|
student.eligible = true;
|
|
student.ResetState();
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
} |