make bg controlled by code

simple ease + speed modifier and it's controlled by delta time
and that's cannery finished!! it truly looks amazing now.
This commit is contained in:
AstrlJelly 2024-03-03 20:46:12 -05:00
parent d80d9519b3
commit 962aec8b7a
32 changed files with 154 additions and 133 deletions

View file

@ -725,7 +725,6 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 8615374414734561705}
- component: {fileID: 2491713825135125463}
m_Layer: 0
m_Name: Conveyor3Angle
m_TagString: Untagged
@ -749,27 +748,6 @@ Transform:
m_Father: {fileID: 5813499711186931250}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 2.15}
--- !u!95 &2491713825135125463
Animator:
serializedVersion: 5
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2659786308152561463}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 999ca577510d16e408d34fb24be911b8, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
--- !u!1 &2751657772362777455
GameObject:
m_ObjectHideFlags: 0
@ -1115,7 +1093,6 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 3578108882218100712}
- component: {fileID: 4980712815265515627}
m_Layer: 0
m_Name: Conveyor1Angle
m_TagString: Untagged
@ -1139,27 +1116,6 @@ Transform:
m_Father: {fileID: 5813499711186931250}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 2}
--- !u!95 &4980712815265515627
Animator:
serializedVersion: 5
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3428754964196628754}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 999ca577510d16e408d34fb24be911b8, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
--- !u!1 &3504642808999640427
GameObject:
m_ObjectHideFlags: 0
@ -2330,7 +2286,6 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 7301854396171564631}
- component: {fileID: 4489137636915631815}
m_Layer: 0
m_Name: Conveyor2Angle
m_TagString: Untagged
@ -2354,27 +2309,6 @@ Transform:
m_Father: {fileID: 5813499711186931250}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -4.45}
--- !u!95 &4489137636915631815
Animator:
serializedVersion: 5
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5698069872256704531}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 999ca577510d16e408d34fb24be911b8, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
--- !u!1 &5813499711186931251
GameObject:
m_ObjectHideFlags: 0
@ -2437,14 +2371,15 @@ MonoBehaviour:
alarmMat: {fileID: 2100000, guid: cffd715f1564d4440881c6fe148baa9c, type: 2}
bgPlaneSR: {fileID: 0}
conveyorBeltAnim: {fileID: 3839135881600344077}
bgAnims:
- {fileID: 1312871934097871502}
- {fileID: 1330445918762147576}
- {fileID: 7967578891305360991}
alarmAnim: {fileID: 3637100343128600021}
dingAnim: {fileID: 7386547292618809648}
cannerAnim: {fileID: 7509521705116870356}
aStartBeat: 0
aLength: 0
aStartColor: {r: 0, g: 0, b: 0, a: 0}
aEndColor: {r: 0, g: 0, b: 0, a: 0}
aEase: 0
bgCurrentTime: 0
bgCurrentSpeed: 0
--- !u!1 &5862740553224149703
GameObject:
m_ObjectHideFlags: 0

View file

@ -3,5 +3,5 @@ guid: e46f5dcf26ef3494683666c938722e3e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName: mobcannery/common
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -18,5 +18,5 @@ AudioImporter:
ambisonic: 0
3D: 1
userData:
assetBundleName: mobcannery/common
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -18,5 +18,5 @@ AudioImporter:
ambisonic: 0
3D: 1
userData:
assetBundleName: mobcannery/common
assetBundleName: pcocannery/common
assetBundleVariant:

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 405 KiB

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName: mobcannery/common
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
userData:
assetBundleName: mobcannery/common
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName: mobcannery/common
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName: mobcannery/common
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
userData:
assetBundleName: mobcannery/common
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -48,6 +48,32 @@ AnimatorController:
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1102 &2909293221411300295
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Start
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 0
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 0}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1107 &6631440365927086464
AnimatorStateMachine:
serializedVersion: 6
@ -62,7 +88,10 @@ AnimatorStateMachine:
m_Position: {x: 260, y: 200, z: 0}
- serializedVersion: 1
m_State: {fileID: 7990101752887186977}
m_Position: {x: 235, y: 65, z: 0}
m_Position: {x: 260, y: 110, z: 0}
- serializedVersion: 1
m_State: {fileID: 2909293221411300295}
m_Position: {x: 30, y: 180, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
@ -80,7 +109,7 @@ AnimatorState:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: ClawConveyorScroll
m_Name: Scroll
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
userData:
assetBundleName:
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
userData:
assetBundleName:
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -20,9 +20,9 @@ AnimationClip:
m_Curve:
- serializedVersion: 3
time: 0
value: {x: -11.5, y: -3.772, z: 0}
value: {x: -12, y: -3.772, z: 0}
inSlope: {x: 0, y: 0, z: 0}
outSlope: {x: 132, y: 0, z: 0}
outSlope: {x: 135, y: 0, z: 0}
tangentMode: 0
weightedMode: 0
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
@ -30,7 +30,7 @@ AnimationClip:
- serializedVersion: 3
time: 0.16666667
value: {x: 10.5, y: -3.772, z: 0}
inSlope: {x: 132, y: 0, z: 0}
inSlope: {x: 135, y: 0, z: 0}
outSlope: {x: 0, y: 0, z: 0}
tangentMode: 0
weightedMode: 0
@ -84,9 +84,9 @@ AnimationClip:
m_Curve:
- serializedVersion: 3
time: 0
value: -11.5
value: -12
inSlope: 0
outSlope: 132
outSlope: 135
tangentMode: 69
weightedMode: 0
inWeight: 0.33333334
@ -94,7 +94,7 @@ AnimationClip:
- serializedVersion: 3
time: 0.16666667
value: 10.5
inSlope: 132
inSlope: 135
outSlope: 0
tangentMode: 69
weightedMode: 0

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
userData:
assetBundleName: mobcannery/common
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName: mobcannery/common
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
userData:
assetBundleName: mobcannery/common
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -4,5 +4,5 @@ NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName: mobcannery/common
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -582,5 +582,5 @@ TextureImporter:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName: mobcannery/common
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -163,5 +163,5 @@ TextureImporter:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleName: pcocannery/common
assetBundleVariant:

View file

@ -34,7 +34,7 @@ namespace HeavenStudio.Games.Scripts_Cannery
SoundByte.PlayOneShotGame("cannery/can");
anim.DoScaledAnimationAsync("Can", 0.5f, 0, 1);
if (state is >= 1 or <= -1) {
SoundByte.PlayOneShot("nearMiss");
SoundByte.PlayOneShot("miss");
game.cannerAnim.DoScaledAnimationAsync("CanBarely", 0.5f);
double beat = caller.startBeat + caller.timer;
BeatAction.New(this, new() {

View file

@ -47,6 +47,24 @@ namespace HeavenStudio.Games.Loaders
},
defaultLength = 0.5f,
},
new GameAction("backgroundModifiers", "Background Modifiers")
{
function = delegate {
var e = eventCaller.currentEntity;
if (eventCaller.gameManager.minigameObj.TryGetComponent(out Cannery instance)) {
instance.BackgroundModifiers(e.beat, e.length, e["startSpeed"], e["endSpeed"], e["ease"]);
}
},
defaultLength = 0.5f,
resizable = true,
parameters = new List<Param>()
{
// new Param("speed", new EntityTypes.Float(0, 50, 10), "Speed", "Set the speed of the background."),
new Param("startSpeed", new EntityTypes.Float(0, 50, 10), "Start Speed", "Set the speed at the start of the event."),
new Param("endSpeed", new EntityTypes.Float(0, 50, 10), "End Speed", "Set the speed at the end of the event."),
new Param("ease", Util.EasingFunction.Ease.Instant, "Ease", "Set the easing of the action.", new() { new((x, _) => (int)x == (int)Util.EasingFunction.Ease.Instant, "startSpeed") }),
}
},
new GameAction("alarmColor", "Alarm Color")
{
function = delegate {
@ -56,18 +74,18 @@ namespace HeavenStudio.Games.Loaders
}
},
defaultLength = 0.5f,
resizable = true,
parameters = new List<Param>()
{
new Param("startColor", Cannery.alarmColor , "Start Color", "Set the color at the start of the event.", new() { new((_, _) => true, new string[] { "startColor" }) }),
new Param("startColor", Cannery.alarmColor , "Start Color", "Set the color at the start of the event."),
new Param("endColor", Cannery.alarmColor, "End Color", "Set the color at the end of the event."),
new Param("ease", Util.EasingFunction.Ease.Instant, "Ease", "Set the easing of the action."),
new Param("ease", Util.EasingFunction.Ease.Instant, "Ease", "Set the easing of the action.", new() { new((x, _) => (int)x == (int)Util.EasingFunction.Ease.Instant, "startColor") }),
}
},
}
// ,
// new List<string>() { "mob", "normal" },
// "mobcannery", "en",
// new List<string>() { }
},
new List<string>() { "pco", "normal" },
"pcocannery", "en",
new List<string>() { }
);
}
}
@ -87,17 +105,26 @@ namespace HeavenStudio.Games
[Header("Animators")]
[SerializeField] Animator conveyorBeltAnim;
[SerializeField] Animator[] bgAnims;
[SerializeField] Animator alarmAnim;
public Animator dingAnim;
public Animator cannerAnim;
// private ColorEase bgColorEase = new(Color.white);
public static readonly Color alarmColor = new Color(0.8627f, 0.3725f, 0.0313f);
public double aStartBeat;
public float aLength;
public Color aStartColor, aEndColor;
public Util.EasingFunction.Ease aEase = Util.EasingFunction.Ease.Instant;
public Util.EasingFunction.Function aEaseFunc;
public float bgCurrentTime;
public float bgCurrentSpeed;
[NonSerialized] public double bgStartBeat;
[NonSerialized] public float bgLength;
[NonSerialized] public float bgStartSpeed, bgEndSpeed;
[NonSerialized] public Util.EasingFunction.Ease bgEase = Util.EasingFunction.Ease.Instant;
[NonSerialized] public Util.EasingFunction.Function bgEaseFunc;
[NonSerialized] public static readonly Color alarmColor = new Color(0.8627f, 0.3725f, 0.0313f);
[NonSerialized] public double aStartBeat;
[NonSerialized] public float aLength;
[NonSerialized] public Color aStartColor, aEndColor;
[NonSerialized] public Util.EasingFunction.Ease aEase = Util.EasingFunction.Ease.Instant;
[NonSerialized] public Util.EasingFunction.Function aEaseFunc;
private bool alarmBop = true;
@ -111,19 +138,32 @@ namespace HeavenStudio.Games
{
if (PlayerInput.GetIsAction(InputAction_BasicPress) && !IsExpectingInputNow(InputAction_BasicPress)) {
cannerAnim.DoScaledAnimationAsync("CanEmpty", 0.5f);
SoundByte.PlayOneShotGame("cannery/can");
// SoundByte.PlayOneShotGame("cannery/can");
SoundByte.PlayOneShot("nearMiss");
}
conveyorBeltAnim.DoNormalizedAnimation("Move", (conductor.songPositionInBeats / 2) % 1);
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(conductor.songPositionInBeatsAsDouble, aLength));
// bg stuff
float bgNormalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(bgStartBeat, bgLength));
if (!double.IsNaN(bgNormalizedBeat)) {
bgEaseFunc ??= Util.EasingFunction.GetEasingFunction(bgEase);
bgCurrentSpeed = bgEaseFunc(bgStartSpeed, bgEndSpeed, bgNormalizedBeat);
}
bgCurrentTime = (bgCurrentTime + (Time.deltaTime * (bgCurrentSpeed / 10))) % 1;
foreach (var anim in bgAnims) {
anim.DoNormalizedAnimation("Scroll", bgCurrentTime);
}
// alarm color stuff
float aNormalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(aStartBeat, aLength));
Color newColor = alarmColor;
if (!double.IsNaN(normalizedBeat)) {
if (!double.IsNaN(aNormalizedBeat)) {
aEaseFunc ??= Util.EasingFunction.GetEasingFunction(aEase);
float newR = aEaseFunc(aStartColor.r, aEndColor.r, normalizedBeat);
float newG = aEaseFunc(aStartColor.g, aEndColor.g, normalizedBeat);
float newB = aEaseFunc(aStartColor.b, aEndColor.b, normalizedBeat);
float newR = aEaseFunc(aStartColor.r, aEndColor.r, aNormalizedBeat);
float newG = aEaseFunc(aStartColor.g, aEndColor.g, aNormalizedBeat);
float newB = aEaseFunc(aStartColor.b, aEndColor.b, aNormalizedBeat);
newColor = new Color(newR, newG, newB);
}
@ -147,6 +187,13 @@ namespace HeavenStudio.Games
} else {
AlarmColor(0, 0, alarmColor, alarmColor, (int)Util.EasingFunction.Ease.Instant);
}
RiqEntity bgEvent = events.FindLast(e => e.datamodel == "cannery/backgroundModifiers" && e.beat < beat);
if (bgEvent != null) {
var e = alarmEvent;
BackgroundModifiers(e.beat, e.length, e["startSpeed"], e["endSpeed"], e["ease"]);
} else {
BackgroundModifiers(0, 0, 10, 10, (int)Util.EasingFunction.Ease.Instant);
}
}
public override void OnLateBeatPulse(double beat)
@ -168,16 +215,6 @@ namespace HeavenStudio.Games
}
}
public void AlarmColor(double beat, float length, Color startColor, Color endColor, int ease)
{
aStartBeat = beat;
aLength = length;
aStartColor = startColor;
aEndColor = endColor;
aEase = (Util.EasingFunction.Ease)ease;
aEaseFunc = Util.EasingFunction.GetEasingFunction(aEase);
}
public void SendCan(double beat)
{
// do the ding animation on the beat
@ -192,5 +229,25 @@ namespace HeavenStudio.Games
{
blackout.SetActive(!blackout.activeSelf);
}
public void BackgroundModifiers(double beat, float length, float startSpeed, float endSpeed, int ease)
{
bgStartBeat = beat;
bgLength = length;
bgStartSpeed = startSpeed;
bgEndSpeed = endSpeed;
bgEase = (Util.EasingFunction.Ease)ease;
bgEaseFunc = Util.EasingFunction.GetEasingFunction(bgEase);
}
public void AlarmColor(double beat, float length, Color startColor, Color endColor, int ease)
{
aStartBeat = beat;
aLength = length;
aStartColor = startColor;
aEndColor = endColor;
aEase = (Util.EasingFunction.Ease)ease;
aEaseFunc = Util.EasingFunction.GetEasingFunction(aEase);
}
}
}