diff --git a/Assets/Resources/Games/bouncyRoad.prefab b/Assets/Resources/Games/bouncyRoad.prefab index 13cbc8e5d..dcce4e097 100644 --- a/Assets/Resources/Games/bouncyRoad.prefab +++ b/Assets/Resources/Games/bouncyRoad.prefab @@ -134,6 +134,7 @@ MonoBehaviour: CurveHolder: {fileID: 516527611092978913} ThingsTrans: {fileID: 2062427345527210161} PosCurve: {fileID: 1821895289258124684} + fallY: -10 --- !u!1 &2761970376181234193 GameObject: m_ObjectHideFlags: 0 @@ -179,9 +180,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: curve: {fileID: 1500121995971928353} - handleType: 0 + handleType: 1 leftHandleLocalPosition: {x: 0.25, y: 4.2, z: 0} - rightHandleLocalPosition: {x: -0.25, y: -4.2, z: -0} + rightHandleLocalPosition: {x: 0, y: 0, z: -0} --- !u!1 &2844308134730805784 GameObject: m_ObjectHideFlags: 0 @@ -400,7 +401,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &2554041347942322038 Transform: m_ObjectHideFlags: 0 @@ -511,7 +512,7 @@ SpriteRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 - m_Sprite: {fileID: 21300000, guid: dd5b80f32157bb44386e3d0147282351, type: 3} + m_Sprite: {fileID: 21300000, guid: 89cdbc339c5da68499d2877d62cf9018, type: 3} m_Color: {r: 1, g: 1, b: 0, a: 0.5686275} m_FlipX: 0 m_FlipY: 0 @@ -1704,6 +1705,10 @@ PrefabInstance: propertyPath: m_IsActive value: 1 objectReference: {fileID: 0} + - target: {fileID: 5824484732720336883, guid: 1a184ba123ced3944863abbdb7d41709, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 5860934180505614771, guid: 1a184ba123ced3944863abbdb7d41709, type: 3} propertyPath: m_RootOrder value: 12 diff --git a/Assets/Scripts/Games/BouncyRoad/Ball.cs b/Assets/Scripts/Games/BouncyRoad/Ball.cs index 8fae9828b..4df193782 100644 --- a/Assets/Scripts/Games/BouncyRoad/Ball.cs +++ b/Assets/Scripts/Games/BouncyRoad/Ball.cs @@ -18,13 +18,14 @@ namespace HeavenStudio.Games.Scripts_BouncyRoad public Color color; [System.NonSerialized] public bool goal; + private bool isMiss; + private BouncyRoad game; public void Init() { game = BouncyRoad.instance; - currentBeat = startBeat; GetComponent().color = color; Bounce(); } @@ -35,6 +36,12 @@ namespace HeavenStudio.Games.Scripts_BouncyRoad if (currentCurve is not null) { float curveProg = cond.GetPositionFromBeat(currentBeat, lengthBeat); + if (isMiss) { + curveProg = cond.GetPositionFromBeat(currentBeat, lengthBeat/2); + } else { + // curveProg /= (float)(1 + BouncyRoad.ngLateTime); + if (curveProg >= 1) curveProg = 1; + } transform.position = currentCurve.GetPoint(curveProg); } } @@ -49,12 +56,17 @@ namespace HeavenStudio.Games.Scripts_BouncyRoad MultiSound.Play(sounds.ToArray()); var actions = new List(); + + actions.Add(new BeatAction.Action(startBeat - lengthBeat, delegate { + currentCurve = curve[0]; + currentBeat = startBeat - lengthBeat; + })); for (int i = 0; i < 12 ; i++) { int currentItr = i; actions.Add(new BeatAction.Action(startBeat + currentItr * lengthBeat, delegate { game.ThingsAnim[currentItr].Play("podium", 0, 0); - currentCurve = curve[currentItr]; + currentCurve = curve[1+currentItr]; currentBeat = startBeat + currentItr * lengthBeat; })); } @@ -67,7 +79,7 @@ namespace HeavenStudio.Games.Scripts_BouncyRoad { SoundByte.PlayOneShotGame("bouncyRoad/ballRight"); game.ThingsAnim[12].Play("podium", 0, 0); - currentCurve = curve[12]; + currentCurve = curve[1+12]; currentBeat = startBeat + 12 * lengthBeat; game.ScheduleInput(startBeat + 12 * lengthBeat, lengthBeat, BouncyRoad.InputAction_Left, LeftSuccess, LeftMiss, Empty); @@ -76,10 +88,12 @@ namespace HeavenStudio.Games.Scripts_BouncyRoad public void RightMiss(PlayerActionEvent caller) { SoundByte.PlayOneShotGame("bouncyRoad/ballBounce"); + currentCurve = curve[^2]; currentBeat = Conductor.instance.songPositionInBeats; + isMiss = true; BeatAction.New(game, new List() { - new BeatAction.Action(startBeat + 13 * lengthBeat, delegate + new BeatAction.Action(currentBeat + lengthBeat / 2, delegate { Destroy(gameObject); }), @@ -90,7 +104,7 @@ namespace HeavenStudio.Games.Scripts_BouncyRoad { SoundByte.PlayOneShotGame("bouncyRoad/ballLeft"); game.ThingsAnim[13].Play("podium", 0, 0); - currentCurve = curve[13]; + currentCurve = curve[1+13]; currentBeat = startBeat + 13 * lengthBeat; if (goal) SoundByte.PlayOneShotGame("bouncyRoad/goal", startBeat + 14 * lengthBeat); @@ -99,7 +113,7 @@ namespace HeavenStudio.Games.Scripts_BouncyRoad new BeatAction.Action(startBeat + 14 * lengthBeat, delegate { game.ThingsAnim[14].Play("podium", 0, 0); - currentCurve = curve[14]; + currentCurve = curve[1+14]; currentBeat = startBeat + 14 * lengthBeat; }), new BeatAction.Action(startBeat + 15 * lengthBeat, delegate @@ -112,10 +126,12 @@ namespace HeavenStudio.Games.Scripts_BouncyRoad public void LeftMiss(PlayerActionEvent caller) { SoundByte.PlayOneShotGame("bouncyRoad/ballBounce"); + currentCurve = curve[^1]; currentBeat = Conductor.instance.songPositionInBeats; + isMiss = true; BeatAction.New(game, new List() { - new BeatAction.Action(startBeat + 14 * lengthBeat, delegate + new BeatAction.Action(currentBeat + lengthBeat / 2, delegate { Destroy(gameObject); }), diff --git a/Assets/Scripts/Games/BouncyRoad/BouncyRoad.cs b/Assets/Scripts/Games/BouncyRoad/BouncyRoad.cs index 8861e68a7..0170a5324 100644 --- a/Assets/Scripts/Games/BouncyRoad/BouncyRoad.cs +++ b/Assets/Scripts/Games/BouncyRoad/BouncyRoad.cs @@ -55,6 +55,8 @@ namespace HeavenStudio.Games [System.NonSerialized] public Dictionary CurveCache; [SerializeField] BezierCurve3D PosCurve; + [SerializeField] float fallY; + public static BouncyRoad instance; const int IALeft = 0; @@ -102,11 +104,11 @@ namespace HeavenStudio.Games ThingsAnim[childIndex++] = child.GetComponent(); } - var newCurves = new BezierCurve3D[ThingsTrans.childCount]; - // for (var i = 0; i < ThingsAnim.Length; ++i) + var newCurves = new BezierCurve3D[ThingsTrans.childCount + 3]; + // for (var i = 0; i < ThingsAnim.Length + 1; ++i) // { - // var prog1 = (float)i/(ThingsTrans.childCount-1); - // var prog2 = (float)(i+1)/(ThingsTrans.childCount-1); + // var prog1 = (float)(i-1)/(ThingsTrans.childCount-1); + // var prog2 = (float)(i)/(ThingsTrans.childCount-1); // var pos1 = PosCurve.GetPoint(prog1); // var pos2 = PosCurve.GetPoint(prog2); @@ -115,20 +117,28 @@ namespace HeavenStudio.Games // newCurves[i] = newCurve.GetComponent(); // } { + Vector3 pos1, pos2; + pos1 = PosCurve.GetPoint((float)(-1)/(ThingsAnim.Length-1)); + pos2 = PosCurve.GetPoint(0); + newCurves[0] = GenerateInitCurve(pos1, pos2).GetComponent(); + for (var i = 0; i < ThingsAnim.Length-1; ++i) { - var pos1 = ThingsTrans.GetChild(i).transform.localPosition; - var pos2 = ThingsTrans.GetChild(i+1).transform.localPosition; + pos1 = ThingsTrans.GetChild(i).transform.localPosition; + pos2 = ThingsTrans.GetChild(i+1).transform.localPosition; var newCurve = GenerateInitCurve(pos1, pos2); - newCurves[i] = newCurve.GetComponent(); + newCurves[1+i] = newCurve.GetComponent(); } - var posA = PosCurve.GetPoint(1); - var posB = PosCurve.GetPoint((float)(ThingsAnim.Length)/(ThingsAnim.Length-1)); - newCurves[ThingsAnim.Length-1] = GenerateInitCurve(posA, posB).GetComponent(); + pos1 = PosCurve.GetPoint(1); + pos2 = PosCurve.GetPoint((float)(ThingsAnim.Length)/(ThingsAnim.Length-1)); + newCurves[ThingsAnim.Length] = GenerateInitCurve(pos1, pos2).GetComponent(); } + newCurves[^2] = GenerateMissCurve(13).GetComponent(); + newCurves[^1] = GenerateMissCurve(14).GetComponent(); + CurveCache = new Dictionary(); CurveCache.Add(1, newCurves); } @@ -161,7 +171,7 @@ namespace HeavenStudio.Games BeatAction.New(instance, new List() { - new BeatAction.Action(beat, delegate + new BeatAction.Action(beat - length, delegate { newBall.Init(); newBall.gameObject.SetActive(true); @@ -189,6 +199,21 @@ namespace HeavenStudio.Games return newCurve; } + private Transform GenerateMissCurve(int number) + { + var curve = CurveHolder.GetChild(number); + + var newCurve = Instantiate(curve, CurveHolder).transform; + + var point0 = newCurve.GetChild(0); + var point1 = newCurve.GetChild(1); + + Vector3 pos1 = point1.transform.localPosition; + point1.transform.localPosition = pos1 + new Vector3(0, fallY, 0); + + return newCurve; + } + private BezierCurve3D[] GetHeightCurve(float length) { BezierCurve3D[] newCurves; @@ -208,8 +233,8 @@ namespace HeavenStudio.Games var point1 = child.GetChild(1); Vector3 scale = point0.transform.localScale; - point0.transform.localScale = new Vector3(scale.x, length, scale.z); - point1.transform.localScale = new Vector3(scale.x, length, scale.z); + point0.transform.localScale = new Vector3(scale.x, length * scale.y, scale.z); + point1.transform.localScale = new Vector3(scale.x, length * scale.y, scale.z); newCurves[childIndex++] = child.GetComponent(); } CurveCache.Add(length, newCurves);