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

@ -17,65 +17,36 @@ namespace HeavenStudio.Games.Loaders
return new Minigame("lockstep", "Lockstep \n<color=#eb5454>[WIP]</color>", "0058CE", false, false, new List<GameAction>()
{
new GameAction("bop", "Bop")
{
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Bop(e.beat, e["toggle"]); },
parameters = new List<Param>()
{
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Bop(e.beat, e["toggle"]); },
parameters = new List<Param>()
{
new Param("toggle", false, "Reset Pose", "Resets to idle pose.")
},
defaultLength = 1f,
new Param("toggle", false, "Reset Pose", "Resets to idle pose.")
},
defaultLength = 1f,
},
new GameAction("hai", "Hai!")
{
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Hai(e.beat); },
defaultLength = 1f,
inactiveFunction = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Hai(e.beat);}
},
{
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Hai(e.beat); },
defaultLength = 1f,
inactiveFunction = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Hai(e.beat);}
},
new GameAction("offbeatSwitch", "Switch to Offbeat")
{
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.OnbeatSwitch(e.beat); },
defaultLength = 8f
},
{
preFunction = delegate { var e = eventCaller.currentEntity; Lockstep.OffbeatSwitch(e.beat); },
defaultLength = 8f
},
new GameAction("onbeatSwitch", "Switch to Onbeat")
{
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.OffbeatSwitch(e.beat); },
defaultLength = 2f
},
new GameAction("marching", "Onbeat Stepping")
{
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.OnbeatStep(e.beat, e.length); },
defaultLength = 4f,
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
}
{
preFunction = delegate { var e = eventCaller.currentEntity; Lockstep.OnbeatSwitch(e.beat); },
defaultLength = 2f
},
new GameAction("marching", "Marching")
{
preFunction = delegate {var e = eventCaller.currentEntity; Lockstep.Marching(e.beat, e.length);},
defaultLength = 4f,
resizable = true
}
});
}
@ -87,78 +58,53 @@ namespace HeavenStudio.Games
// using Scripts_Lockstep;
public class Lockstep : Minigame
{
// private Animator stepswitcher;
public Animator stepswitcherP;
public Animator stepswitcher0;
public Animator stepswitcher1;
public GameObject Player;
[Header("Components")]
[SerializeField] Animator stepswitcherP;
[SerializeField] Animator stepswitcher0;
[SerializeField] Animator stepswitcher1;
[Header("Properties")]
public GameEvent bop = new GameEvent();
public bool goStep;
GameEvent bop = new GameEvent();
static List<float> queuedInputs = new List<float>();
public float steppingLength;
public float steppingStartBeat;
private float lastReportedBeat = 0f;
public static Lockstep instance;
public static Lockstep instance { get; set; }
// Start is called before the first frame update
void Awake()
{
instance = this;
goStep = false;
}
// Update is called once per frame
public void Update()
{
var cond = Conductor.instance;
if (goStep)
if (cond.isPlaying && !cond.isPaused)
{
print("stepping is on");
if (Conductor.instance.ReportBeat(ref lastReportedBeat))
if (queuedInputs.Count > 0)
{
print("one small step for switch");
Jukebox.PlayOneShotGame("Lockstep/marchOnBeat1");
stepswitcherP.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
stepswitcher0.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
stepswitcher1.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
foreach (var input in queuedInputs)
{
ScheduleInput(input - 0.5f, 0.5f, InputType.STANDARD_DOWN, Just, Miss, Nothing);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(input, delegate { EvaluateMarch(); }),
});
}
queuedInputs.Clear();
}
if (PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN))
{
var beatAnimCheck = Math.Round(cond.songPositionInBeats * 2);
var stepPlayerAnim = (beatAnimCheck % 2 != 0 ? "OffbeatMarch" : "OnbeatMarch");
stepswitcherP.DoScaledAnimationAsync(stepPlayerAnim, 0.5f);
}
}
if (PlayerInput.Pressed() && !IsExpectingInputNow())
{
//Jukebox.PlayOneShot("miss");
var beatAnimCheck = Math.Round(Conductor.instance.songPositionInBeats * 2);
print("check: " + beatAnimCheck);
var stepPlayerAnim = (beatAnimCheck % 2 != 0 ? "OffbeatMarch" : "OnbeatMarch");
Jukebox.PlayOneShotGame("lockstep/miss");
stepswitcherP.DoScaledAnimationAsync(stepPlayerAnim, 0.5f);
}
}
public void Bop(float beat, bool reset)
{
if(reset)
if (reset)
{
stepswitcher0.DoScaledAnimationAsync("BopReset", 0.5f);
stepswitcher1.DoScaledAnimationAsync("BopReset", 0.5f);
@ -172,10 +118,6 @@ namespace HeavenStudio.Games
stepswitcherP.DoScaledAnimationAsync("Bop", 0.5f);
}
}
public void Hai(float beat)
@ -183,23 +125,21 @@ namespace HeavenStudio.Games
Jukebox.PlayOneShotGame("lockstep/switch1");
}
public void BeginStepping(float beat)
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate { goStep = true; }),
});
print("Start Stepping");
print(goStep);
}
public void OnbeatSwitch(float beat)
public static void OnbeatSwitch(float beat)
{
MultiSound.Play(new MultiSound.Sound[]
{
{
new MultiSound.Sound("lockstep/switch5", beat),
new MultiSound.Sound("lockstep/switch6", beat + 0.5f),
new MultiSound.Sound("lockstep/switch5", beat + 1f),
new MultiSound.Sound("lockstep/switch6", beat + 1.5f)
}, forcePlay: true);
}
public static void OffbeatSwitch(float beat)
{
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("lockstep/switch1", beat),
new MultiSound.Sound("lockstep/switch1", beat + 1f),
new MultiSound.Sound("lockstep/switch1", beat + 2f),
@ -210,44 +150,100 @@ namespace HeavenStudio.Games
new MultiSound.Sound("lockstep/switch4", beat + 5.5f),
new MultiSound.Sound("lockstep/switch4", beat + 6.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")
{
for (int i = 0; i < length + 1; i++)
{
new MultiSound.Sound("lockstep/switch5", beat),
new MultiSound.Sound("lockstep/switch6", beat + 0.5f),
new MultiSound.Sound("lockstep/switch5", beat + 1f),
new MultiSound.Sound("lockstep/switch6", beat + 1.5f)
};
MultiSound.Play(sound);
Lockstep.instance.ScheduleInput(beat - 1, 1 + i, InputType.STANDARD_DOWN, Lockstep.instance.Just, Lockstep.instance.Miss, Lockstep.instance.Nothing);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + i, delegate { Lockstep.instance.EvaluateMarch(); }),
});
}
}
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;
marching.startBeat = beat;
print("onbeatstep len: " + marching.length);
print("onbeatstep start: " + marching.startBeat);*/
var cond = Conductor.instance;
var beatAnimCheck = Math.Round(cond.songPositionInBeats * 2);
if (beatAnimCheck % 2 != 0)
{
stepswitcher0.DoScaledAnimationAsync("OffbeatMarch", 0.5f);
stepswitcher1.DoScaledAnimationAsync("OffbeatMarch", 0.5f);
}
else
{
stepswitcher0.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
stepswitcher1.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
}
}
public void OnbeatMarch(float beat)
public void Just(PlayerActionEvent caller, float state)
{
stepswitcher0.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
stepswitcher1.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
stepswitcherP.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
Jukebox.PlayOneShotGame("lockstep/marchOnbeat1");
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);
}
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) {}
}
}