From 8c60729806a52a8ca462c788dcb5691331dd7be3 Mon Sep 17 00:00:00 2001 From: fu-majime Date: Mon, 1 Apr 2024 00:58:54 +0900 Subject: [PATCH] Stack to Left --- .../Prefabs/Games/Fillbots/BotLarge.prefab | 6 +- .../Prefabs/Games/Fillbots/BotMedium.prefab | 6 +- .../Prefabs/Games/Fillbots/BotSmall.prefab | 6 +- Assets/Scripts/Games/Fillbots/Fillbots.cs | 72 ++++++++++---- Assets/Scripts/Games/Fillbots/NtrFillbot.cs | 96 ++++++++++--------- 5 files changed, 112 insertions(+), 74 deletions(-) diff --git a/Assets/Resources/Prefabs/Games/Fillbots/BotLarge.prefab b/Assets/Resources/Prefabs/Games/Fillbots/BotLarge.prefab index e84bb9f5c..3bf78439a 100644 --- a/Assets/Resources/Prefabs/Games/Fillbots/BotLarge.prefab +++ b/Assets/Resources/Prefabs/Games/Fillbots/BotLarge.prefab @@ -870,16 +870,14 @@ MonoBehaviour: size: 2 holdLength: 7 limbFallHeight: 15 - fuelColor: {r: 1, g: 0.385, b: 0.385, a: 1} - lampColorOff: {r: 0, g: 0, b: 0, a: 0} - lampColorOn: {r: 0, g: 0, b: 0, a: 0} + flyDistance: 2.05 + stackDistanceRate: 0.34 fullBody: {fileID: 7967358876063018519} legs: {fileID: 7489285146181854031} body: {fileID: 233663896046199226} head: {fileID: 1555999227183591988} fuelFill: {fileID: 1253665520920512372} fillAnim: {fileID: 3960380650713155144} - flyDistance: 2.05 --- !u!210 &755017336671867292 SortingGroup: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/Prefabs/Games/Fillbots/BotMedium.prefab b/Assets/Resources/Prefabs/Games/Fillbots/BotMedium.prefab index d1faaf349..cb4181d29 100644 --- a/Assets/Resources/Prefabs/Games/Fillbots/BotMedium.prefab +++ b/Assets/Resources/Prefabs/Games/Fillbots/BotMedium.prefab @@ -870,16 +870,14 @@ MonoBehaviour: size: 1 holdLength: 3 limbFallHeight: 15 - fuelColor: {r: 0, g: 0, b: 0, a: 0} - lampColorOff: {r: 0, g: 0, b: 0, a: 0} - lampColorOn: {r: 0, g: 0, b: 0, a: 0} + flyDistance: 2.05 + stackDistanceRate: 0.34 fullBody: {fileID: 7967358876063018519} legs: {fileID: 7489285146181854031} body: {fileID: 233663896046199226} head: {fileID: 1555999227183591988} fuelFill: {fileID: 1253665520920512372} fillAnim: {fileID: 3960380650713155144} - flyDistance: 2.05 --- !u!210 &755017336671867292 SortingGroup: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/Prefabs/Games/Fillbots/BotSmall.prefab b/Assets/Resources/Prefabs/Games/Fillbots/BotSmall.prefab index dfcad9276..465fe81b4 100644 --- a/Assets/Resources/Prefabs/Games/Fillbots/BotSmall.prefab +++ b/Assets/Resources/Prefabs/Games/Fillbots/BotSmall.prefab @@ -870,16 +870,14 @@ MonoBehaviour: size: 0 holdLength: 1 limbFallHeight: 15 - fuelColor: {r: 0, g: 0, b: 0, a: 0} - lampColorOff: {r: 0, g: 0, b: 0, a: 0} - lampColorOn: {r: 0, g: 0, b: 0, a: 0} + flyDistance: 2.05 + stackDistanceRate: 0.34 fullBody: {fileID: 7967358876063018519} legs: {fileID: 7489285146181854031} body: {fileID: 233663896046199226} head: {fileID: 1555999227183591988} fuelFill: {fileID: 1253665520920512372} fillAnim: {fileID: 3960380650713155144} - flyDistance: 2.05 --- !u!210 &755017336671867292 SortingGroup: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Games/Fillbots/Fillbots.cs b/Assets/Scripts/Games/Fillbots/Fillbots.cs index b9a9d4b74..bc21511f7 100644 --- a/Assets/Scripts/Games/Fillbots/Fillbots.cs +++ b/Assets/Scripts/Games/Fillbots/Fillbots.cs @@ -30,7 +30,7 @@ namespace HeavenStudio.Games.Loaders { preFunction = delegate { var e = eventCaller.currentEntity; - Fillbots.PreSpawnFillbot(e.beat, 3, Scripts_Fillbots.BotSize.Medium, e["colorFuel"], e["colorLampOff"], e["colorLampOn"], e["type"], e["alt"]); + Fillbots.PreSpawnFillbot(e.beat, 3, (int)Scripts_Fillbots.BotSize.Medium, e["colorFuel"], e["colorLampOff"], e["colorLampOn"], e["type"], e["alt"]); }, defaultLength = 8f, parameters = new List() @@ -46,7 +46,7 @@ namespace HeavenStudio.Games.Loaders { preFunction = delegate { var e = eventCaller.currentEntity; - Fillbots.PreSpawnFillbot(e.beat, 7, Scripts_Fillbots.BotSize.Large, e["colorFuel"], e["colorLampOff"], e["colorLampOn"], e["type"], e["alt"]); + Fillbots.PreSpawnFillbot(e.beat, 7, (int)Scripts_Fillbots.BotSize.Large, e["colorFuel"], e["colorLampOff"], e["colorLampOn"], e["type"], e["alt"]); }, defaultLength = 12f, parameters = new List() @@ -62,7 +62,7 @@ namespace HeavenStudio.Games.Loaders { preFunction = delegate { var e = eventCaller.currentEntity; - Fillbots.PreSpawnFillbot(e.beat, 1, Scripts_Fillbots.BotSize.Small, e["colorFuel"], e["colorLampOff"], e["colorLampOn"], e["type"], e["alt"]); + Fillbots.PreSpawnFillbot(e.beat, 1, (int)Scripts_Fillbots.BotSize.Small, e["colorFuel"], e["colorLampOff"], e["colorLampOn"], e["type"], e["alt"]); }, defaultLength = 6f, parameters = new List() @@ -74,6 +74,24 @@ namespace HeavenStudio.Games.Loaders new Param("colorLampOn", new Color(1f, 1f, 0.42f), "On Lamp Color", "Set the color of the on lamp."), }, }, + new GameAction("custom", "Custom Bot") + { + preFunction = delegate { + var e = eventCaller.currentEntity; + Fillbots.PreSpawnFillbot(e.beat, e.length-5, e["size"], e["colorFuel"], e["colorLampOff"], e["colorLampOn"], e["type"], e["alt"]); + }, + defaultLength = 6f, + resizable = true, + parameters = new List() + { + new Param("size", Scripts_Fillbots.BotSize.Medium, "Size", "Set the size of the Robot."), + new Param("alt", false, "Alternate OK"), + new Param("type", Scripts_Fillbots.EndAnim.Both, "Success Reaction", "Set the reaction of the Robot."), + new Param("colorFuel", new Color(1f, 0.385f, 0.385f), "Fuel Color", "Set the color of the fuel."), + new Param("colorLampOff", new Color(0.635f, 0.635f, 0.185f), "Off Lamp Color", "Set the color of the off lamp."), + new Param("colorLampOn", new Color(1f, 1f, 0.42f), "On Lamp Color", "Set the color of the on lamp."), + }, + }, new GameAction("blackout", "Blackout") { function = delegate { Fillbots.instance.Blackout();}, @@ -216,12 +234,11 @@ namespace HeavenStudio.Games } } - public static void PreSpawnFillbot(double beat, double holdLength, BotSize size, Color fuelColor, Color lampColorOff, Color lampColorOn, int endAnim, bool altOK) + public static void PreSpawnFillbot(double beat, double holdLength, int size, Color fuelColor, Color lampColorOff, Color lampColorOn, int endAnim, bool altOK) { - Debug.Log(altOK); if (GameManager.instance.currentGame == "fillbots") { - instance.SpawnFillbot(beat, holdLength, size, fuelColor, lampColorOff, lampColorOn, (EndAnim)endAnim, altOK); + instance.SpawnFillbot(beat, holdLength, (BotSize)size, fuelColor, lampColorOff, lampColorOn, (EndAnim)endAnim, altOK); } else { @@ -229,7 +246,7 @@ namespace HeavenStudio.Games { beat = beat, holdLength = holdLength, - size = size, + size = (BotSize)size, fuelColor = fuelColor, lampColorOff = lampColorOff, lampColorOn = lampColorOn, @@ -254,27 +271,46 @@ namespace HeavenStudio.Games spawnedBot.holdLength = holdLength; } + spawnedBot.startBeat = beat; spawnedBot.fuelColor = fuelColor; spawnedBot.lampColorOff = lampColorOff; spawnedBot.lampColorOn = lampColorOn; spawnedBot.endAnim = endAnim; spawnedBot.altOK = altOK; - spawnedBot.Init(beat); - BeatAction.New(instance, new List() - { - new BeatAction.Action(beat - 0.5, delegate + spawnedBot.Init(); + + var actions = new List(); + var fallingBots = currentBots.FindAll(x => x.startBeat < beat && x.startBeat + 3 >= beat); + if (fallingBots is null) { + actions.Add(new BeatAction.Action(beat - 0.5, delegate { if (conveyerStartBeat != -1) conveyerNormalizedOffset = Conductor.instance.GetPositionFromBeat(conveyerStartBeat, 1); conveyerStartBeat = -2; - }), - new BeatAction.Action(beat + 3, delegate + })); + } else { + actions.Add(new BeatAction.Action(beat - 0.25, delegate { - if (!PlayerInput.GetIsAction(InputAction_BasicPress)) filler.DoScaledAnimationAsync("FillerPrepare", 0.5f); - conveyerStartBeat = beat + 3; - fillerPosition = size; - }) - }); + foreach (var bot in fallingBots) + { + bot.StackToLeft(beat, 0.25); + } + conveyerStartBeat = beat - 0.25; + })); + actions.Add(new BeatAction.Action(beat, delegate + { + if (conveyerStartBeat != -1) conveyerNormalizedOffset = Conductor.instance.GetPositionFromBeat(conveyerStartBeat, 1); + conveyerStartBeat = -2; + })); + } + + actions.Add(new BeatAction.Action(beat + 3, delegate + { + if (!PlayerInput.GetIsAction(InputAction_BasicPress)) filler.DoScaledAnimationAsync("FillerPrepare", 0.5f); + conveyerStartBeat = beat + 3; + fillerPosition = size; + })); + BeatAction.New(instance, actions); } public void ToggleBop(double beat, float length, bool bopOrNah, bool autoBop) diff --git a/Assets/Scripts/Games/Fillbots/NtrFillbot.cs b/Assets/Scripts/Games/Fillbots/NtrFillbot.cs index 5f3b63950..fdd5f0020 100644 --- a/Assets/Scripts/Games/Fillbots/NtrFillbot.cs +++ b/Assets/Scripts/Games/Fillbots/NtrFillbot.cs @@ -39,11 +39,16 @@ namespace HeavenStudio.Games.Scripts_Fillbots [System.NonSerialized] public Color lampColorOn; double conveyerRestartLength = 0.5; + [System.NonSerialized] public double startBeat = -1; + private double conveyerStartBeat = -1; + private double conveyerLength = 1; + private Vector2 startPos; private float lerpDistance; + private float lerpIdleDistance; [SerializeField] private float flyDistance; - private float stackDistanceRate = 0.2f; + [SerializeField] private float stackDistanceRate; [Header("Body Parts")] [SerializeField] private Animator fullBody; @@ -62,9 +67,6 @@ namespace HeavenStudio.Games.Scripts_Fillbots private float bodyPosY; private float headPosY; - private double startBeat = -1; - private double conveyerStartBeat = -1; - private bool legsHaveFallen; private bool bodyHasFallen; private bool headHasFallen; @@ -79,6 +81,8 @@ namespace HeavenStudio.Games.Scripts_Fillbots private BotState botState = BotState.Idle; private bool isExplode = false; + [System.NonSerialized] public bool isStack; + private double stackBeat, stackLength; [System.NonSerialized] public EndAnim endAnim; [System.NonSerialized] public bool altOK; @@ -108,32 +112,20 @@ namespace HeavenStudio.Games.Scripts_Fillbots startPos = transform.position; lerpDistance = 0 - startPos.x; + lerpIdleDistance = lerpDistance; } - public void MoveConveyer(float normalized) + public void MoveConveyer(float normalized, float lerpDistance, float flyDistance = 0) { if (botState is BotState.Holding) { StopConveyer(); return; } - if (!headHasFallen || !bodyHasFallen || !legsHaveFallen) return; - transform.position = new Vector3(Mathf.LerpUnclamped(startPos.x, startPos.x + lerpDistance, normalized), startPos.y); - if (normalized >= 4) - { - game.currentBots.Remove(this); - Destroy(gameObject); - } - } - - public void FlyConveyer(float normalized) - { - if (botState is not BotState.Ace) return; - if (!headHasFallen || !bodyHasFallen || !legsHaveFallen) return; transform.position = new Vector3(Mathf.LerpUnclamped(startPos.x, startPos.x + lerpDistance, normalized), Mathf.LerpUnclamped(startPos.y, startPos.y + flyDistance, normalized)); - if (normalized >= 4) + if (normalized >= 5) { game.currentBots.Remove(this); Destroy(gameObject); @@ -142,14 +134,23 @@ namespace HeavenStudio.Games.Scripts_Fillbots public void StopConveyer() { - if (!headHasFallen || !bodyHasFallen || !legsHaveFallen) return; startPos = transform.position; + lerpIdleDistance = 0 - startPos.x; } - public void Init(double beat) + public void StackToLeft(double beat, double length) { - startBeat = beat; - conveyerStartBeat = beat + 3; + if (conveyerLength <= stackDistanceRate) return; + isStack = true; + stackBeat = beat - length; + stackLength = length; + conveyerStartBeat += stackDistanceRate; + conveyerLength -= stackDistanceRate; + } + + public void Init() + { + conveyerStartBeat = startBeat + 3; fullBodyMaterial = fullBody.GetComponent().material; fullBodyMaterial.SetColor("_ColorBravo", fuelColor); @@ -168,10 +169,10 @@ namespace HeavenStudio.Games.Scripts_Fillbots BeatAction.New(game, new List() { - new BeatAction.Action(beat, delegate { legs.Play("Impact", 0, 0); legsHaveFallen = true; legsTrans.position = new Vector3(legsTrans.position.x, legsPosY); }), - new BeatAction.Action(beat + 1, delegate { body.Play("Impact", 0, 0); bodyHasFallen = true; bodyTrans.position = new Vector3(bodyTrans.position.x, bodyPosY);}), - new BeatAction.Action(beat + 2, delegate { head.Play("Impact", 0, 0); headHasFallen = true; headTrans.position = new Vector3(headTrans.position.x, headPosY);}), - new BeatAction.Action(beat + 3, delegate + new BeatAction.Action(startBeat, delegate { legs.Play("Impact", 0, 0); legsHaveFallen = true; legsTrans.position = new Vector3(legsTrans.position.x, legsPosY); }), + new BeatAction.Action(startBeat + 1, delegate { body.Play("Impact", 0, 0); bodyHasFallen = true; bodyTrans.position = new Vector3(bodyTrans.position.x, bodyPosY);}), + new BeatAction.Action(startBeat + 2, delegate { head.Play("Impact", 0, 0); headHasFallen = true; headTrans.position = new Vector3(headTrans.position.x, headPosY);}), + new BeatAction.Action(startBeat + 3, delegate { fullBody.gameObject.SetActive(true); legs.gameObject.SetActive(false); @@ -190,9 +191,9 @@ namespace HeavenStudio.Games.Scripts_Fillbots MultiSound.Play(new MultiSound.Sound[] { - new MultiSound.Sound("fillbots/" + sizePrefix + "Fall", beat), - new MultiSound.Sound("fillbots/" + sizePrefix + "Fall", beat + 1), - new MultiSound.Sound("fillbots/" + sizePrefix + "Fall", beat + 2), + new MultiSound.Sound("fillbots/" + sizePrefix + "Fall", startBeat), + new MultiSound.Sound("fillbots/" + sizePrefix + "Fall", startBeat + 1), + new MultiSound.Sound("fillbots/" + sizePrefix + "Fall", startBeat + 2), }); game.ScheduleInput(startBeat, 4, Fillbots.InputAction_BasicPress, JustHold, Empty, Empty); @@ -226,16 +227,30 @@ namespace HeavenStudio.Games.Scripts_Fillbots float lerpedY = Mathf.Lerp(headPosY + limbFallHeight, headPosY, normalizedBeat); headTrans.position = new Vector3(headTrans.position.x, Mathf.Clamp(lerpedY, headPosY, headPosY + limbFallHeight)); } - if (true) + if (isStack) { - float normalizedBeat = cond.GetPositionFromBeat(this.conveyerStartBeat, 1); - if (normalizedBeat >= 0) + float normalizedBeat = cond.GetPositionFromBeat(stackBeat, stackLength); + if (normalizedBeat >= 0 && normalizedBeat < 1) { - if (botState is BotState.Ace) FlyConveyer(normalizedBeat); - else MoveConveyer(normalizedBeat); + MoveConveyer(normalizedBeat, lerpDistance*stackDistanceRate); + } + else if (normalizedBeat >= 1) + { + MoveConveyer(1, lerpDistance*stackDistanceRate); + StopConveyer(); + isStack = false; + } + } + if (headHasFallen && bodyHasFallen && legsHaveFallen) + { + float normalizedBeat = cond.GetPositionFromBeat(this.conveyerStartBeat, conveyerLength); + if (normalizedBeat >= 0) + { + if (botState is BotState.Ace) MoveConveyer(normalizedBeat, lerpDistance, flyDistance); + else if (botState is BotState.Idle) MoveConveyer(normalizedBeat, lerpIdleDistance); + else MoveConveyer(normalizedBeat, lerpDistance); } } - } if (botState is BotState.Holding) @@ -295,14 +310,6 @@ namespace HeavenStudio.Games.Scripts_Fillbots if (game.conveyerStartBeat == -1) game.conveyerStartBeat = this.conveyerStartBeat; releaseEvent.Disable(); } - } - else if (botState is BotState.Ace) - { - - } - else if (botState is BotState.Just) - { - } else { @@ -330,6 +337,7 @@ namespace HeavenStudio.Games.Scripts_Fillbots } if (game.conveyerStartBeat != -1) game.conveyerNormalizedOffset = Conductor.instance.GetPositionFromBeat(game.conveyerStartBeat, 1); game.conveyerStartBeat = -1; + conveyerLength = 1; transform.position = new Vector3(0, transform.position.y, 0); botState = BotState.Holding; fullBody.DoScaledAnimationAsync("Hold", 1f);