Begun fixing lockstep, just needs small fixes and features

This commit is contained in:
Rapandrasmus 2023-01-22 13:56:54 +01:00
parent 032e532416
commit 7a0f4e38ed
11 changed files with 390 additions and 150 deletions

View file

@ -0,0 +1,53 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: OffbeatMiss
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings: []
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 1
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a0391d705521050499f5e17f0c0e55f3
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,53 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: OffbeatMissRest
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings: []
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 1
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3a8aefb8918345043b3e2ba05f611993
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,53 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: OnbeatMiss
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings: []
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 1
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fd009c5e24879964c9b411e96aaaf553
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,53 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: OnbeatMissRest
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings: []
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 1
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c21dac4c6abf5c146b7c6087463d3f51
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -25,57 +25,28 @@ namespace HeavenStudio.Games.Loaders
}, },
defaultLength = 1f, defaultLength = 1f,
}, },
new GameAction("hai", "Hai!") new GameAction("hai", "Hai!")
{ {
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Hai(e.beat); }, function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Hai(e.beat); },
defaultLength = 1f, defaultLength = 1f,
inactiveFunction = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Hai(e.beat);} inactiveFunction = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Hai(e.beat);}
}, },
new GameAction("offbeatSwitch", "Switch to Offbeat") new GameAction("offbeatSwitch", "Switch to Offbeat")
{ {
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.OnbeatSwitch(e.beat); }, preFunction = delegate { var e = eventCaller.currentEntity; Lockstep.OffbeatSwitch(e.beat); },
defaultLength = 8f defaultLength = 8f
}, },
new GameAction("onbeatSwitch", "Switch to Onbeat") new GameAction("onbeatSwitch", "Switch to Onbeat")
{ {
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.OffbeatSwitch(e.beat); }, preFunction = delegate { var e = eventCaller.currentEntity; Lockstep.OnbeatSwitch(e.beat); },
defaultLength = 2f defaultLength = 2f
}, },
new GameAction("marching", "Marching")
new GameAction("marching", "Onbeat Stepping")
{ {
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.OnbeatStep(e.beat, e.length); }, preFunction = delegate {var e = eventCaller.currentEntity; Lockstep.Marching(e.beat, e.length);},
defaultLength = 4f, defaultLength = 4f,
resizable = true, resizable = true
hidden = true
},
new GameAction("startStepping", "Start Stepping")
{
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.BeginStepping(e.beat); },
defaultLength = 1f,
hidden = true
},
new GameAction("test1", "onbeat march test")
{
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.OnbeatMarch(e.beat); },
defaultLength = 1f,
hidden = true
} }
}); });
} }
@ -87,77 +58,52 @@ namespace HeavenStudio.Games
// using Scripts_Lockstep; // using Scripts_Lockstep;
public class Lockstep : Minigame public class Lockstep : Minigame
{ {
[Header("Components")]
[SerializeField] Animator stepswitcherP;
// private Animator stepswitcher; [SerializeField] Animator stepswitcher0;
[SerializeField] Animator stepswitcher1;
public Animator stepswitcherP;
public Animator stepswitcher0;
public Animator stepswitcher1;
public GameObject Player;
[Header("Properties")] [Header("Properties")]
public GameEvent bop = new GameEvent(); GameEvent bop = new GameEvent();
public bool goStep; static List<float> queuedInputs = new List<float>();
public float steppingLength; public static Lockstep instance;
public float steppingStartBeat;
private float lastReportedBeat = 0f;
public static Lockstep instance { get; set; }
// Start is called before the first frame update
void Awake() void Awake()
{ {
instance = this; instance = this;
goStep = false;
} }
// Update is called once per frame
public void Update() public void Update()
{ {
var cond = Conductor.instance; var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused)
if (goStep)
{ {
print("stepping is on"); if (queuedInputs.Count > 0)
if (Conductor.instance.ReportBeat(ref lastReportedBeat))
{ {
print("one small step for switch"); foreach (var input in queuedInputs)
Jukebox.PlayOneShotGame("Lockstep/marchOnBeat1"); {
stepswitcherP.DoScaledAnimationAsync("OnbeatMarch", 0.5f); ScheduleInput(input - 0.5f, 0.5f, InputType.STANDARD_DOWN, Just, Miss, Nothing);
stepswitcher0.DoScaledAnimationAsync("OnbeatMarch", 0.5f); BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
stepswitcher1.DoScaledAnimationAsync("OnbeatMarch", 0.5f); {
new BeatAction.Action(input, delegate { EvaluateMarch(); }),
});
} }
queuedInputs.Clear();
} }
if (PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN))
if (PlayerInput.Pressed() && !IsExpectingInputNow())
{ {
//Jukebox.PlayOneShot("miss"); var beatAnimCheck = Math.Round(cond.songPositionInBeats * 2);
var beatAnimCheck = Math.Round(Conductor.instance.songPositionInBeats * 2);
print("check: " + beatAnimCheck);
var stepPlayerAnim = (beatAnimCheck % 2 != 0 ? "OffbeatMarch" : "OnbeatMarch"); var stepPlayerAnim = (beatAnimCheck % 2 != 0 ? "OffbeatMarch" : "OnbeatMarch");
Jukebox.PlayOneShotGame("lockstep/miss");
stepswitcherP.DoScaledAnimationAsync(stepPlayerAnim, 0.5f); stepswitcherP.DoScaledAnimationAsync(stepPlayerAnim, 0.5f);
} }
}
} }
public void Bop(float beat, bool reset) public void Bop(float beat, bool reset)
{ {
if (reset) if (reset)
{ {
stepswitcher0.DoScaledAnimationAsync("BopReset", 0.5f); stepswitcher0.DoScaledAnimationAsync("BopReset", 0.5f);
@ -172,10 +118,6 @@ namespace HeavenStudio.Games
stepswitcherP.DoScaledAnimationAsync("Bop", 0.5f); stepswitcherP.DoScaledAnimationAsync("Bop", 0.5f);
} }
} }
public void Hai(float beat) public void Hai(float beat)
@ -183,20 +125,18 @@ namespace HeavenStudio.Games
Jukebox.PlayOneShotGame("lockstep/switch1"); Jukebox.PlayOneShotGame("lockstep/switch1");
} }
public void BeginStepping(float beat) public static void OnbeatSwitch(float beat)
{ {
MultiSound.Play(new MultiSound.Sound[]
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{ {
new BeatAction.Action(beat, delegate { goStep = true; }), new MultiSound.Sound("lockstep/switch5", beat),
}); new MultiSound.Sound("lockstep/switch6", beat + 0.5f),
new MultiSound.Sound("lockstep/switch5", beat + 1f),
print("Start Stepping"); new MultiSound.Sound("lockstep/switch6", beat + 1.5f)
print(goStep); }, forcePlay: true);
} }
public static void OffbeatSwitch(float beat)
public void OnbeatSwitch(float beat)
{ {
MultiSound.Play(new MultiSound.Sound[] MultiSound.Play(new MultiSound.Sound[]
{ {
@ -210,44 +150,100 @@ namespace HeavenStudio.Games
new MultiSound.Sound("lockstep/switch4", beat + 5.5f), new MultiSound.Sound("lockstep/switch4", beat + 5.5f),
new MultiSound.Sound("lockstep/switch4", beat + 6.5f), new MultiSound.Sound("lockstep/switch4", beat + 6.5f),
new MultiSound.Sound("lockstep/switch4", beat + 7.5f), new MultiSound.Sound("lockstep/switch4", beat + 7.5f),
}, forcePlay: false); }, forcePlay: true);
} }
public void OffbeatSwitch(float beat) public static void Marching(float beat, float length)
{ {
var sound = new MultiSound.Sound[] if (GameManager.instance.currentGame == "lockstep")
{ {
new MultiSound.Sound("lockstep/switch5", beat), for (int i = 0; i < length + 1; i++)
new MultiSound.Sound("lockstep/switch6", beat + 0.5f), {
new MultiSound.Sound("lockstep/switch5", beat + 1f), Lockstep.instance.ScheduleInput(beat - 1, 1 + i, InputType.STANDARD_DOWN, Lockstep.instance.Just, Lockstep.instance.Miss, Lockstep.instance.Nothing);
new MultiSound.Sound("lockstep/switch6", beat + 1.5f) BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
}; {
new BeatAction.Action(beat + i, delegate { Lockstep.instance.EvaluateMarch(); }),
});
MultiSound.Play(sound); }
}
else
{
for (int i = 0; i < length + 1; i++)
{
queuedInputs.Add(beat + i);
}
}
} }
public void OnbeatStep(float beat, float length) public void EvaluateMarch()
{ {
/*marching.length = length; var cond = Conductor.instance;
marching.startBeat = beat; var beatAnimCheck = Math.Round(cond.songPositionInBeats * 2);
print("onbeatstep len: " + marching.length); if (beatAnimCheck % 2 != 0)
print("onbeatstep start: " + marching.startBeat);*/ {
stepswitcher0.DoScaledAnimationAsync("OffbeatMarch", 0.5f);
stepswitcher1.DoScaledAnimationAsync("OffbeatMarch", 0.5f);
} }
else
public void OnbeatMarch(float beat)
{ {
stepswitcher0.DoScaledAnimationAsync("OnbeatMarch", 0.5f); stepswitcher0.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
stepswitcher1.DoScaledAnimationAsync("OnbeatMarch", 0.5f); stepswitcher1.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
}
}
public void Just(PlayerActionEvent caller, float state)
{
if (state >= 1f || state <= -1f)
{
var cond = Conductor.instance;
var beatAnimCheck = Math.Round(cond.songPositionInBeats * 2);
if (beatAnimCheck % 2 != 0)
{
Jukebox.PlayOneShotGame("lockstep/miss");
stepswitcherP.DoScaledAnimationAsync("OffbeatMarch", 0.5f);
}
else
{
Jukebox.PlayOneShotGame("lockstep/miss");
stepswitcherP.DoScaledAnimationAsync("OnbeatMarch", 0.5f); stepswitcherP.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
Jukebox.PlayOneShotGame("lockstep/marchOnbeat1"); }
Debug.Log("Barely");
return;
}
Success();
} }
public void Success()
{
var cond = Conductor.instance;
var beatAnimCheck = Math.Round(cond.songPositionInBeats * 2);
if (beatAnimCheck % 2 != 0)
{
Jukebox.PlayOneShotGame($"lockstep/marchOffbeat{UnityEngine.Random.Range(1, 3)}");
stepswitcherP.DoScaledAnimationAsync("OffbeatMarch", 0.5f);
}
else
{
Jukebox.PlayOneShotGame($"lockstep/marchOnbeat{UnityEngine.Random.Range(1, 3)}");
stepswitcherP.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
}
}
public void Miss(PlayerActionEvent caller)
{
var cond = Conductor.instance;
var beatAnimCheck = Math.Round(cond.songPositionInBeats * 2);
Jukebox.PlayOneShotGame("lockstep/wayOff");
if (beatAnimCheck % 2 != 0)
{
stepswitcherP.Play("OffbeatMiss", 0, 0);
}
else
{
stepswitcherP.Play("OnbeatMiss", 0, 0);
}
}
public void Nothing(PlayerActionEvent caller) {}
} }
} }