diff --git a/Assets/Scenes/Editor.unity b/Assets/Scenes/Editor.unity index 041b2c9f..8f8882c1 100644 --- a/Assets/Scenes/Editor.unity +++ b/Assets/Scenes/Editor.unity @@ -187,7 +187,7 @@ MonoBehaviour: m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} m_PressedColor: {r: 0.7490196, g: 1, b: 1, a: 1} m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_DisabledColor: {r: 1, g: 1, b: 1, a: 1} m_ColorMultiplier: 1 m_FadeDuration: 0 m_SpriteState: @@ -274,7 +274,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 1906769993} - m_RootOrder: 2 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -3526,127 +3526,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 704039019} m_CullTransparentMesh: 1 ---- !u!1 &705284321 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 705284322} - - component: {fileID: 705284325} - - component: {fileID: 705284324} - - component: {fileID: 705284323} - m_Layer: 5 - m_Name: Button - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &705284322 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 705284321} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 1863720033} - m_Father: {fileID: 1906769993} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 68.148, y: 0} - m_SizeDelta: {x: -146.3, y: -10} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &705284323 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 705284321} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_WrapAround: 0 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_SelectedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_SelectedTrigger: Selected - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 705284324} - m_OnClick: - m_PersistentCalls: - m_Calls: [] ---- !u!114 &705284324 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 705284321} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0, g: 0, b: 0, a: 0.34117648} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!222 &705284325 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 705284321} - m_CullTransparentMesh: 1 --- !u!1 &708484803 GameObject: m_ObjectHideFlags: 0 @@ -4612,7 +4491,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 1906769993} - m_RootOrder: 3 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 0} @@ -6656,7 +6535,7 @@ MonoBehaviour: m_HighlightedColor: {r: 1, g: 1, b: 1, a: 1} m_PressedColor: {r: 0.7490196, g: 1, b: 1, a: 1} m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_DisabledColor: {r: 1, g: 1, b: 1, a: 1} m_ColorMultiplier: 1 m_FadeDuration: 0 m_SpriteState: @@ -6858,8 +6737,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f86858990a87c764892672104bdaef1f, type: 3} m_Name: m_EditorClassIdentifier: - level: {fileID: 4900000, guid: 244c565c8088cfa4597e0ebda9c7de98, type: 3} - music: {fileID: 8300000, guid: e5cf71158cc9bff4a8fbfbca1e73e500, type: 3} + level: {fileID: 4900000, guid: 4b7512c586e16a847a5b8490bf35e852, type: 3} + music: {fileID: 8300000, guid: 92cf585c80f8fb843964e525aef1406c, type: 3} debugUI: 0 playOnStart: 0 editor: 1 @@ -8211,7 +8090,7 @@ MonoBehaviour: m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} m_PressedColor: {r: 0.7490196, g: 1, b: 1, a: 1} m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_DisabledColor: {r: 1, g: 1, b: 1, a: 1} m_ColorMultiplier: 1 m_FadeDuration: 0 m_SpriteState: @@ -8597,140 +8476,6 @@ MonoBehaviour: PauseBTN: {fileID: 9435782} StopBTN: {fileID: 1783491359} MetronomeBTN: {fileID: 129013734} ---- !u!1 &1863720032 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1863720033} - - component: {fileID: 1863720035} - - component: {fileID: 1863720034} - m_Layer: 5 - m_Name: Text (TMP) - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1863720033 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1863720032} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 705284322} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &1863720034 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1863720032} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_text: Active - m_isRightToLeft: 0 - m_fontAsset: {fileID: 11400000, guid: c2df694f599b22b42817910ff570a9df, type: 2} - m_sharedMaterial: {fileID: -5829441969153149921, guid: c2df694f599b22b42817910ff570a9df, type: 2} - m_fontSharedMaterials: [] - m_fontMaterial: {fileID: 0} - m_fontMaterials: [] - m_fontColor32: - serializedVersion: 2 - rgba: 4294967295 - m_fontColor: {r: 1, g: 1, b: 1, a: 1} - m_enableVertexGradient: 0 - m_colorMode: 3 - m_fontColorGradient: - topLeft: {r: 1, g: 1, b: 1, a: 1} - topRight: {r: 1, g: 1, b: 1, a: 1} - bottomLeft: {r: 1, g: 1, b: 1, a: 1} - bottomRight: {r: 1, g: 1, b: 1, a: 1} - m_fontColorGradientPreset: {fileID: 0} - m_spriteAsset: {fileID: 0} - m_tintAllSprites: 0 - m_StyleSheet: {fileID: 0} - m_TextStyleHashCode: -1183493901 - m_overrideHtmlColors: 0 - m_faceColor: - serializedVersion: 2 - rgba: 4294967295 - m_fontSize: 14.89 - m_fontSizeBase: 14.89 - m_fontWeight: 400 - m_enableAutoSizing: 0 - m_fontSizeMin: 18 - m_fontSizeMax: 72 - m_fontStyle: 0 - m_HorizontalAlignment: 2 - m_VerticalAlignment: 512 - m_textAlignment: 65535 - m_characterSpacing: 0 - m_wordSpacing: 0 - m_lineSpacing: 0 - m_lineSpacingMax: 0 - m_paragraphSpacing: 0 - m_charWidthMaxAdj: 0 - m_enableWordWrapping: 1 - m_wordWrappingRatios: 0.4 - m_overflowMode: 0 - m_linkedTextComponent: {fileID: 0} - parentLinkedComponent: {fileID: 0} - m_enableKerning: 1 - m_enableExtraPadding: 0 - checkPaddingRequired: 0 - m_isRichText: 1 - m_parseCtrlCharacters: 1 - m_isOrthographic: 1 - m_isCullingEnabled: 0 - m_horizontalMapping: 0 - m_verticalMapping: 0 - m_uvLineOffset: 0 - m_geometrySortingOrder: 0 - m_IsTextObjectScaleStatic: 0 - m_VertexBufferAutoSizeReduction: 0 - m_useMaxVisibleDescender: 1 - m_pageToDisplay: 1 - m_margin: {x: 0, y: 0, z: 0, w: 0} - m_isUsingLegacyAnimationComponent: 0 - m_isVolumetricText: 0 - m_hasFontAssetChanged: 0 - m_baseMaterial: {fileID: 0} - m_maskOffset: {x: 0, y: 0, z: 0, w: 0} ---- !u!222 &1863720035 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1863720032} - m_CullTransparentMesh: 1 --- !u!1 &1906769992 GameObject: m_ObjectHideFlags: 0 @@ -8761,7 +8506,6 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 1274849046} - - {fileID: 705284322} - {fileID: 93132553} - {fileID: 947065510} m_Father: {fileID: 1671351975} diff --git a/Assets/Scripts/Games/ForkLifter/ForkLifter.cs b/Assets/Scripts/Games/ForkLifter/ForkLifter.cs index e8709d93..0eb882be 100644 --- a/Assets/Scripts/Games/ForkLifter/ForkLifter.cs +++ b/Assets/Scripts/Games/ForkLifter/ForkLifter.cs @@ -14,8 +14,6 @@ namespace RhythmHeavenMania.Games.ForkLifter [Header("References")] public ForkLifterHand ForkLifterHand; - private GameManager GameManager; - [Header("Objects")] public Animator handAnim; @@ -25,9 +23,6 @@ namespace RhythmHeavenMania.Games.ForkLifter public Sprite[] peaSprites; public Sprite[] peaHitSprites; - - private List allPlayerActions = new List(); - private void Awake() { instance = this; @@ -38,33 +33,6 @@ namespace RhythmHeavenMania.Games.ForkLifter ForkLifterHand.CheckNextFlick(); } - private void Start() - { - GameManager = GameManager.instance; - // allPlayerActions = GameManager.Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare" && c.eventName != "end"); - - /*List temp = new List(); - for (int i = 0; i < allPlayerActions.Count; i++) - { - if (i - 1 > 0) - { - if (Mathp.IsWithin(allPlayerActions[i - 1].spawnTime, allPlayerActions[i].spawnTime - 1f, allPlayerActions[i].spawnTime)) - { - // do nothing lul - continue; - } - } - Event e = (Event)allPlayerActions[i].Clone(); - e.spawnTime = allPlayerActions[i].spawnTime - 1; - e.eventName = "prepare"; - - temp.Add(e); - } - - string s = JsonConvert.SerializeObject(temp); - print(s);*/ - } - public void Flick(float beat, int type) { Jukebox.PlayOneShotGame("forkLifter/flick"); diff --git a/Assets/Scripts/Games/ForkLifter/ForkLifterPlayer.cs b/Assets/Scripts/Games/ForkLifter/ForkLifterPlayer.cs index 252f0122..0dd93c5c 100644 --- a/Assets/Scripts/Games/ForkLifter/ForkLifterPlayer.cs +++ b/Assets/Scripts/Games/ForkLifter/ForkLifterPlayer.cs @@ -26,12 +26,8 @@ namespace RhythmHeavenMania.Games.ForkLifter private Animator anim; - public List EligibleHits = new List(); private int currentHitInList = 0; - - public float timescale = 1; - private int currentEarlyPeasOnFork; private int currentPerfectPeasOnFork; private int currentLatePeasOnFork; @@ -44,15 +40,6 @@ namespace RhythmHeavenMania.Games.ForkLifter // ----------- - [System.Serializable] - public class Eligible - { - public Pea pea; - public bool early; - public bool perfect; - public bool late; - } - private void Awake() { instance = this; @@ -65,14 +52,12 @@ namespace RhythmHeavenMania.Games.ForkLifter private void Update() { - Time.timeScale = timescale; - if (PlayerInput.Pressed()) { Stab(); } - if (EligibleHits.Count == 0) + if (ForkLifter.instance.EligibleHits.Count == 0) { currentHitInList = 0; } @@ -134,136 +119,142 @@ namespace RhythmHeavenMania.Games.ForkLifter public void Stab() { if (isEating) return; - bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count); + var EligibleHits = ForkLifter.instance.EligibleHits; + bool canHit = (ForkLifter.instance.EligibleHits.Count > 0) && (currentHitInList < ForkLifter.instance.EligibleHits.Count); - if (canHit) + int events = ForkLifter.instance.MultipleEventsAtOnce(); + + for (int pt = 0; pt < events; pt++) { - GameObject pea = new GameObject(); - - if (EligibleHits[currentHitInList].perfect) + if (canHit) { - pea.transform.parent = perfect.transform; - pea.transform.localScale = Vector2.one; + GameObject pea = new GameObject(); - pea.transform.localPosition = Vector3.zero; - - for (int i = 0; i < perfect.transform.childCount; i++) + if (EligibleHits[currentHitInList].perfect) { - perfect.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentPerfectPeasOnFork); - } + pea.transform.parent = perfect.transform; + pea.transform.localScale = Vector2.one; - SpriteRenderer psprite = pea.AddComponent(); - psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type]; - psprite.sortingOrder = 20; - switch (EligibleHits[currentHitInList].pea.type) + pea.transform.localPosition = Vector3.zero; + + for (int i = 0; i < perfect.transform.childCount; i++) + { + perfect.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentPerfectPeasOnFork); + } + + SpriteRenderer psprite = pea.AddComponent(); + psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].gameObject.GetComponent().type]; + psprite.sortingOrder = 20; + switch (EligibleHits[currentHitInList].gameObject.GetComponent().type) + { + case 0: + psprite.sortingOrder = 101; + break; + case 1: + psprite.sortingOrder = 104; + break; + case 2: + psprite.sortingOrder = 103; + break; + case 3: + psprite.sortingOrder = 102; + break; + } + + GameObject hitFXo = new GameObject(); + hitFXo.transform.localPosition = new Vector3(1.9969f, -3.7026f); + hitFXo.transform.localScale = new Vector3(3.142196f, 3.142196f); + SpriteRenderer hfxs = hitFXo.AddComponent(); + hfxs.sprite = hitFX; + hfxs.sortingOrder = 100; + hfxs.DOColor(new Color(1, 1, 1, 0), 0.05f).OnComplete(delegate { Destroy(hitFXo); }); + + FastEffectHit(ForkLifter.instance.EligibleHits[currentHitInList].gameObject.GetComponent().type); + + Jukebox.PlayOneShotGame("forkLifter/stab"); + + currentPerfectPeasOnFork++; + + if (EligibleHits[currentHitInList].gameObject.GetComponent().type == 1) + { + topbun = true; + } + else if (EligibleHits[currentHitInList].gameObject.GetComponent().type == 2) + { + middleburger = true; + } + else if (EligibleHits[currentHitInList].gameObject.GetComponent().type == 3) + { + bottombun = true; + } + + RemovePea(); + + GameProfiler.instance.IncreaseScore(); + } + else if (EligibleHits[currentHitInList].early) { - case 0: - psprite.sortingOrder = 101; - break; - case 1: - psprite.sortingOrder = 104; - break; - case 2: - psprite.sortingOrder = 103; - break; - case 3: - psprite.sortingOrder = 102; - break; + pea.transform.parent = early.transform; + pea.transform.localScale = Vector2.one; + + pea.transform.localPosition = Vector3.zero; + pea.transform.localRotation = Quaternion.Euler(0, 0, 90); + + for (int i = 0; i < early.transform.childCount; i++) + { + early.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentEarlyPeasOnFork); + } + + SpriteRenderer psprite = pea.AddComponent(); + psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].gameObject.GetComponent().type]; + psprite.sortingOrder = 20; + HitFXMiss(new Vector2(1.0424f, -4.032f), new Vector2(1.129612f, 1.129612f)); + HitFXMiss(new Vector2(0.771f, -3.016f), new Vector2(1.71701f, 1.71701f)); + HitFXMiss(new Vector2(2.598f, -2.956f), new Vector2(1.576043f, 1.576043f)); + HitFXMiss(new Vector2(2.551f, -3.609f), new Vector2(1.200788f, 1.200788f)); + + FastEffectHit(ForkLifter.instance.EligibleHits[currentHitInList].gameObject.GetComponent().type); + + Jukebox.PlayOneShot("miss"); + + currentEarlyPeasOnFork++; + + RemovePea(); } - - GameObject hitFXo = new GameObject(); - hitFXo.transform.localPosition = new Vector3(1.9969f, -3.7026f); - hitFXo.transform.localScale = new Vector3(3.142196f, 3.142196f); - SpriteRenderer hfxs = hitFXo.AddComponent(); - hfxs.sprite = hitFX; - hfxs.sortingOrder = 100; - hfxs.DOColor(new Color(1, 1, 1, 0), 0.05f).OnComplete(delegate { Destroy(hitFXo); }); - - FastEffectHit(EligibleHits[currentHitInList].pea.type); - - Jukebox.PlayOneShotGame("forkLifter/stab"); - - currentPerfectPeasOnFork++; - - if (EligibleHits[currentHitInList].pea.type == 1) + else if (EligibleHits[currentHitInList].late) { - topbun = true; - } - else if (EligibleHits[currentHitInList].pea.type == 2) - { - middleburger = true; - } - else if (EligibleHits[currentHitInList].pea.type == 3) - { - bottombun = true; - } + pea.transform.parent = late.transform; + pea.transform.localScale = Vector2.one; - RemovePea(); + pea.transform.localPosition = Vector3.zero; + pea.transform.localRotation = Quaternion.Euler(0, 0, 90); - GameProfiler.instance.IncreaseScore(); + for (int i = 0; i < late.transform.childCount; i++) + { + late.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentLatePeasOnFork); + } + + SpriteRenderer psprite = pea.AddComponent(); + psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].gameObject.GetComponent().type]; + psprite.sortingOrder = 20; + HitFXMiss(new Vector2(1.0424f, -4.032f), new Vector2(1.129612f, 1.129612f)); + HitFXMiss(new Vector2(0.771f, -3.016f), new Vector2(1.71701f, 1.71701f)); + HitFXMiss(new Vector2(2.598f, -2.956f), new Vector2(1.576043f, 1.576043f)); + HitFXMiss(new Vector2(2.551f, -3.609f), new Vector2(1.200788f, 1.200788f)); + + FastEffectHit(ForkLifter.instance.EligibleHits[currentHitInList].gameObject.GetComponent().type); + + Jukebox.PlayOneShot("miss"); + + currentLatePeasOnFork++; + + RemovePea(); + } } - else if (EligibleHits[currentHitInList].early) + else { - pea.transform.parent = early.transform; - pea.transform.localScale = Vector2.one; - - pea.transform.localPosition = Vector3.zero; - pea.transform.localRotation = Quaternion.Euler(0, 0, 90); - - for (int i = 0; i < early.transform.childCount; i++) - { - early.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentEarlyPeasOnFork); - } - - SpriteRenderer psprite = pea.AddComponent(); - psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type]; - psprite.sortingOrder = 20; - HitFXMiss(new Vector2(1.0424f, -4.032f), new Vector2(1.129612f, 1.129612f)); - HitFXMiss(new Vector2(0.771f, -3.016f), new Vector2(1.71701f, 1.71701f)); - HitFXMiss(new Vector2(2.598f, -2.956f), new Vector2(1.576043f, 1.576043f)); - HitFXMiss(new Vector2(2.551f, -3.609f), new Vector2(1.200788f, 1.200788f)); - - FastEffectHit(EligibleHits[currentHitInList].pea.type); - - Jukebox.PlayOneShot("miss"); - - currentEarlyPeasOnFork++; - - RemovePea(); + Jukebox.PlayOneShotGame("forkLifter/stabnohit"); } - else if (EligibleHits[currentHitInList].late) - { - pea.transform.parent = late.transform; - pea.transform.localScale = Vector2.one; - - pea.transform.localPosition = Vector3.zero; - pea.transform.localRotation = Quaternion.Euler(0, 0, 90); - - for (int i = 0; i < late.transform.childCount; i++) - { - late.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentLatePeasOnFork); - } - - SpriteRenderer psprite = pea.AddComponent(); - psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type]; - psprite.sortingOrder = 20; - HitFXMiss(new Vector2(1.0424f, -4.032f), new Vector2(1.129612f, 1.129612f)); - HitFXMiss(new Vector2(0.771f, -3.016f), new Vector2(1.71701f, 1.71701f)); - HitFXMiss(new Vector2(2.598f, -2.956f), new Vector2(1.576043f, 1.576043f)); - HitFXMiss(new Vector2(2.551f, -3.609f), new Vector2(1.200788f, 1.200788f)); - - FastEffectHit(EligibleHits[currentHitInList].pea.type); - - Jukebox.PlayOneShot("miss"); - - currentLatePeasOnFork++; - - RemovePea(); - } - } - else - { - Jukebox.PlayOneShotGame("forkLifter/stabnohit"); } anim.Play("Player_Stab", 0, 0); @@ -297,12 +288,7 @@ namespace RhythmHeavenMania.Games.ForkLifter private void RemovePea() { - if (currentHitInList < EligibleHits.Count) - { - Destroy(EligibleHits[currentHitInList].pea.gameObject); - EligibleHits.Remove(EligibleHits[currentHitInList]); - currentHitInList++; - } + ForkLifter.instance.EligibleHits[currentHitInList].gameObject.GetComponent().RemoveObject(currentHitInList, true); } } } \ No newline at end of file diff --git a/Assets/Scripts/Games/ForkLifter/Pea.cs b/Assets/Scripts/Games/ForkLifter/Pea.cs index 5e2cf909..97be0301 100644 --- a/Assets/Scripts/Games/ForkLifter/Pea.cs +++ b/Assets/Scripts/Games/ForkLifter/Pea.cs @@ -6,34 +6,28 @@ using RhythmHeavenMania.Util; namespace RhythmHeavenMania.Games.ForkLifter { - public class Pea : MonoBehaviour + public class Pea : PlayerActionObject { - private Animator anim; public float startBeat; - private bool inList = false; - public int type; - private ForkLifterPlayer.Eligible e = new ForkLifterPlayer.Eligible(); - - public int estate, pstate, lstate, endstate; - private void Start() { anim = GetComponent(); Jukebox.PlayOneShotGame("forkLifter/zoom"); GetComponentInChildren().sprite = ForkLifter.instance.peaSprites[type]; - e = new ForkLifterPlayer.Eligible(); - e.pea = this; - for (int i = 0; i < transform.GetChild(0).childCount; i++) { transform.GetChild(0).GetChild(i).GetComponent().sprite = transform.GetChild(0).GetComponent().sprite; } + + PlayerActionInit(this.gameObject, startBeat, ForkLifter.instance.EligibleHits); + + isEligible = true; } private void Update() @@ -44,70 +38,13 @@ namespace RhythmHeavenMania.Games.ForkLifter float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, 2f); - // Early State - if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && estate <= 1) - { - MakeEligible(true, false, false); - estate++; - } - // Perfect State - else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime() && pstate <= 1) - { - MakeEligible(false, true, false); - pstate++; - } - // Late State - else if (normalizedBeat > Minigame.LateTime() && normalizedBeat < Minigame.EndTime() && lstate <= 1) - { - MakeEligible(false, false, true); - lstate++; - } - else if (normalizedBeat < Minigame.EarlyTime() || normalizedBeat > Minigame.EndTime()) - { - MakeInEligible(); - } - - if (normalizedBeat > Minigame.EndTime() && endstate <= 1) - { - endstate++; - Jukebox.PlayOneShot("audience/disappointed"); - } + StateCheck(normalizedBeat); if (normalizedBeat > 1.35f) { - MakeInEligible(); + Jukebox.PlayOneShot("audience/disappointed"); Destroy(this.gameObject); } } - - public void MakeEligible(bool early, bool perfect, bool late) - { - // print($"{early}, {perfect}, {late}"); - - if (!inList) - { - e.early = early; - e.perfect = perfect; - e.late = late; - - ForkLifterPlayer.instance.EligibleHits.Add(e); - inList = true; - } - else - { - ForkLifterPlayer.Eligible es = ForkLifterPlayer.instance.EligibleHits[ForkLifterPlayer.instance.EligibleHits.IndexOf(e)]; - es.early = early; - es.perfect = perfect; - es.late = late; - } - } - - public void MakeInEligible() - { - if (!inList) return; - - ForkLifterPlayer.instance.EligibleHits.Remove(e); - inList = false; - } } } \ No newline at end of file diff --git a/Assets/Scripts/Games/KarateMan/KarateJoe.cs b/Assets/Scripts/Games/KarateMan/KarateJoe.cs index aa1cad9d..7c6ee4d7 100644 --- a/Assets/Scripts/Games/KarateMan/KarateJoe.cs +++ b/Assets/Scripts/Games/KarateMan/KarateJoe.cs @@ -70,104 +70,107 @@ namespace RhythmHeavenMania.Games.KarateMan private void Swing() { - // you cant hit two pots at a time like this so i should fix this before a public build is eventually made. - var EligibleHits = KarateMan.instance.EligibleHits; bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count); bool punchLeft = true; - if (canHit) + int events = KarateMan.instance.MultipleEventsAtOnce(); + + for (int pt = 0; pt < events; pt++) { - Pot p = EligibleHits[currentHitInList].gameObject.GetComponent(); - - if (p.type == 2 || p.type == 3 || p.type == 4) + if (canHit) { - punchLeft = false; - } - else - { - punchLeft = true; - } + Pot p = EligibleHits[currentHitInList].gameObject.GetComponent(); - if (KarateMan.instance.EligibleHits[currentHitInList].perfect) - { - Jukebox.PlayOneShotGame(p.hitSnd); - p.Hit(); - - HitEffectF(HitEffect.transform.localPosition); - - switch (p.type) + if (p.type == 2 || p.type == 3 || p.type == 4) { - case 0: - // HitParticle.Play(); - break; - case 1: - GameObject bulbHit = Instantiate(BulbHit); - bulbHit.transform.parent = BulbHit.transform.parent; - bulbHit.SetActive(true); - Destroy(bulbHit, 0.7f); - break; - case 2: - // RockParticle.Play(); - break; - case 4: - if (kickC != null) StopCoroutine(kickC); - kickC = StartCoroutine(PrepareKick()); - for (int i = 0; i < 8; i++) - { - GameObject be = new GameObject(); - be.transform.localPosition = p.transform.localPosition; - be.transform.parent = this.transform.parent; - BarrelDestroyEffect bde = be.AddComponent(); - - switch (i) - { - case 0: - bde.spriteIndex = 0; - break; - case 1: - bde.spriteIndex = 0; - break; - case 2: - bde.spriteIndex = 1; - break; - case 3: - bde.spriteIndex = 2; - break; - case 4: - bde.spriteIndex = 3; - break; - case 5: - bde.spriteIndex = 3; - break; - case 6: - bde.spriteIndex = 4; - break; - case 7: - bde.spriteIndex = 4; - break; - } - } - break; + punchLeft = false; } + else + { + punchLeft = true; + } + + if (KarateMan.instance.EligibleHits[currentHitInList].perfect) + { + Jukebox.PlayOneShotGame(p.hitSnd); + p.Hit(); + + HitEffectF(HitEffect.transform.localPosition); + + switch (p.type) + { + case 0: + // HitParticle.Play(); + break; + case 1: + GameObject bulbHit = Instantiate(BulbHit); + bulbHit.transform.parent = BulbHit.transform.parent; + bulbHit.SetActive(true); + Destroy(bulbHit, 0.7f); + break; + case 2: + // RockParticle.Play(); + break; + case 4: + if (kickC != null) StopCoroutine(kickC); + kickC = StartCoroutine(PrepareKick()); + for (int i = 0; i < 8; i++) + { + GameObject be = new GameObject(); + be.transform.localPosition = p.transform.localPosition; + be.transform.parent = this.transform.parent; + BarrelDestroyEffect bde = be.AddComponent(); + + switch (i) + { + case 0: + bde.spriteIndex = 0; + break; + case 1: + bde.spriteIndex = 0; + break; + case 2: + bde.spriteIndex = 1; + break; + case 3: + bde.spriteIndex = 2; + break; + case 4: + bde.spriteIndex = 3; + break; + case 5: + bde.spriteIndex = 3; + break; + case 6: + bde.spriteIndex = 4; + break; + case 7: + bde.spriteIndex = 4; + break; + } + } + break; + } + } + else + { + Jukebox.PlayOneShot("miss"); + p.Miss(); + } + p.isEligible = false; + p.RemoveObject(currentHitInList); } else { - Jukebox.PlayOneShot("miss"); - p.Miss(); + Jukebox.PlayOneShotGame("karateman/swingNoHit"); } - p.isEligible = false; - p.RemoveObject(currentHitInList, EligibleHits); + if (punchLeft) + anim.Play("PunchLeft", 0, 0); + else + anim.Play("PunchRight", 0, 0); } - else - { - Jukebox.PlayOneShotGame("karateman/swingNoHit"); - } - if (punchLeft) - anim.Play("PunchLeft", 0, 0); - else - anim.Play("PunchRight", 0, 0); } public void HitEffectF(Vector3 pos) diff --git a/Assets/Scripts/Games/KarateMan/Pot.cs b/Assets/Scripts/Games/KarateMan/Pot.cs index 3cc9b369..aa8b74d7 100644 --- a/Assets/Scripts/Games/KarateMan/Pot.cs +++ b/Assets/Scripts/Games/KarateMan/Pot.cs @@ -38,7 +38,6 @@ namespace RhythmHeavenMania.Games.KarateMan private void Start() { - PlayerActionInit(this.gameObject); anim = GetComponent(); Sprite.transform.eulerAngles = new Vector3(0, 0, Random.Range(0, 360)); @@ -48,6 +47,8 @@ namespace RhythmHeavenMania.Games.KarateMan hitLength = 23.45f; else hitLength = 16f; + + PlayerActionInit(this.gameObject, createBeat, KarateMan.instance.EligibleHits); } private void Update() @@ -65,7 +66,7 @@ namespace RhythmHeavenMania.Games.KarateMan float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, 1); - StateCheck(normalizedBeat, KarateMan.instance.EligibleHits); + StateCheck(normalizedBeat); lastPos = Holder.transform.localPosition; lastShadowX = Shadow.transform.localPosition.x; diff --git a/Assets/Scripts/Games/Minigame.cs b/Assets/Scripts/Games/Minigame.cs index 9f31dfc6..91a3eb71 100644 --- a/Assets/Scripts/Games/Minigame.cs +++ b/Assets/Scripts/Games/Minigame.cs @@ -16,6 +16,7 @@ namespace RhythmHeavenMania.Games public bool early; public bool perfect; public bool late; + public float createBeat; } // hopefully these will fix the lowbpm problem @@ -50,5 +51,23 @@ namespace RhythmHeavenMania.Games { } + + public int MultipleEventsAtOnce() + { + int sameTime = 0; + for (int i = 0; i < EligibleHits.Count; i++) + { + float createBeat = EligibleHits[i].createBeat; + if (EligibleHits.FindAll(c => c.createBeat == createBeat).Count > 0) + { + sameTime += 1; + } + } + + if (sameTime == 0 && EligibleHits.Count > 0) + sameTime = 1; + + return sameTime; + } } } \ No newline at end of file diff --git a/Assets/Scripts/Games/PlayerActionObject.cs b/Assets/Scripts/Games/PlayerActionObject.cs index de7dc0c6..b573fc22 100644 --- a/Assets/Scripts/Games/PlayerActionObject.cs +++ b/Assets/Scripts/Games/PlayerActionObject.cs @@ -11,39 +11,43 @@ namespace RhythmHeavenMania.Games public Minigame.Eligible state = new Minigame.Eligible(); public bool isEligible; - public void PlayerActionInit(GameObject g) + public List eligibleHitsList = new List(); + + public void PlayerActionInit(GameObject g, float createBeat, List eligibleHitsList) { state.gameObject = g; + state.createBeat = createBeat; + this.eligibleHitsList = eligibleHitsList; } // could possibly add support for custom early, perfect, and end times if needed. - public void StateCheck(float normalizedBeat, List eligibleHitsList) + public void StateCheck(float normalizedBeat) { if (!isEligible) return; if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && lastState == 0) { - MakeEligible(true, false, false, eligibleHitsList); + MakeEligible(true, false, false); lastState++; } // Perfect State else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime() && lastState == 1) { - MakeEligible(false, true, false, eligibleHitsList); + MakeEligible(false, true, false); lastState++; } // Late State else if (normalizedBeat > Minigame.LateTime() && normalizedBeat < Minigame.EndTime() && lastState == 2) { - MakeEligible(false, false, true, eligibleHitsList); + MakeEligible(false, false, true); lastState++; } else if (normalizedBeat < Minigame.EarlyTime() || normalizedBeat > Minigame.EndTime()) { - MakeInEligible(eligibleHitsList); + MakeInEligible(); } } - public void MakeEligible(bool early, bool perfect, bool late, List eligibleHitsList) + public void MakeEligible(bool early, bool perfect, bool late) { if (!inList) { @@ -63,7 +67,7 @@ namespace RhythmHeavenMania.Games } } - public void MakeInEligible(List eligibleHitsList) + public void MakeInEligible() { if (!inList) return; @@ -71,12 +75,13 @@ namespace RhythmHeavenMania.Games inList = false; } - public void RemoveObject(int currentHitInList, List EligibleHits) + public void RemoveObject(int currentHitInList, bool destroyObject = false) { - if (currentHitInList < EligibleHits.Count) + if (currentHitInList < eligibleHitsList.Count) { - EligibleHits.Remove(EligibleHits[currentHitInList]); + eligibleHitsList.Remove(eligibleHitsList[currentHitInList]); currentHitInList++; + if (destroyObject) Destroy(this.gameObject); } } @@ -112,5 +117,10 @@ namespace RhythmHeavenMania.Games state.perfect = perfect; state.late = late; } + + private void OnDestroy() + { + MakeInEligible(); + } } } \ No newline at end of file diff --git a/Assets/Scripts/Games/Spaceball/Spaceball.cs b/Assets/Scripts/Games/Spaceball/Spaceball.cs index 034b8fbc..5d6de43d 100644 --- a/Assets/Scripts/Games/Spaceball/Spaceball.cs +++ b/Assets/Scripts/Games/Spaceball/Spaceball.cs @@ -34,9 +34,9 @@ namespace RhythmHeavenMania.Games.Spaceball for (int i = 1; i < BallsHolder.transform.childCount; i++) Destroy(BallsHolder.transform.GetChild(i).gameObject); GameManager.instance.GameCamera.orthographic = false; - if (SpaceballPlayer.instance != null) - if (SpaceballPlayer.instance.EligibleHits.Count > 0) - SpaceballPlayer.instance.EligibleHits.RemoveRange(0, SpaceballPlayer.instance.EligibleHits.Count); + + if (EligibleHits.Count > 0) + EligibleHits.RemoveRange(0, EligibleHits.Count); } public override void OnTimeChange() diff --git a/Assets/Scripts/Games/Spaceball/SpaceballBall.cs b/Assets/Scripts/Games/Spaceball/SpaceballBall.cs index f1463a5d..94bdde7f 100644 --- a/Assets/Scripts/Games/Spaceball/SpaceballBall.cs +++ b/Assets/Scripts/Games/Spaceball/SpaceballBall.cs @@ -8,12 +8,10 @@ using DG.Tweening; namespace RhythmHeavenMania.Games.Spaceball { - public class SpaceballBall : MonoBehaviour + public class SpaceballBall : PlayerActionObject { public float startBeat; - private Animator anim; - private int lastState; - private bool inList = false; + public Animator anim; public bool high; @@ -22,6 +20,12 @@ namespace RhythmHeavenMania.Games.Spaceball public GameObject Holder; public SpriteRenderer Sprite; + public bool hit; + public float hitBeat; + public Vector3 hitPos; + public float hitRot; + public float randomEndPosX; + private void Start() { anim = GetComponent(); @@ -30,120 +34,56 @@ namespace RhythmHeavenMania.Games.Spaceball float rot = Random.Range(0, 360); Sprite.gameObject.transform.eulerAngles = new Vector3(0, 0, rot); + + + PlayerActionInit(this.gameObject, startBeat, Spaceball.instance.EligibleHits); + + isEligible = true; } private void Update() { - float beatLength = 1f; - if (high) beatLength = 2f; - - float normalizedBeatAnim = Conductor.instance.GetLoopPositionFromBeat(startBeat, beatLength + 0.15f); - // print(normalizedBeatAnim + " " + Time.frameCount); - - if (high) + if (hit) { - anim.Play("BallHigh", 0, normalizedBeatAnim); + float nba = Conductor.instance.GetLoopPositionFromBeat(hitBeat, 14); + Holder.transform.localPosition = Vector3.Lerp(hitPos, new Vector3(randomEndPosX, 0f, -600f), nba); + Holder.transform.eulerAngles = Vector3.Lerp(new Vector3(0, 0, hitRot), new Vector3(0, 0, -2260), nba); } else { - anim.Play("BallLow", 0, normalizedBeatAnim); - } + float beatLength = 1f; + if (high) beatLength = 2f; - anim.speed = 0; + float normalizedBeatAnim = Conductor.instance.GetLoopPositionFromBeat(startBeat, beatLength + 0.15f); + // print(normalizedBeatAnim + " " + Time.frameCount); - float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, beatLength); - - if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && lastState == 0) - { - MakeEligible(true, false, false); - lastState++; - } - // Perfect State - else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime() && lastState == 1) - { - MakeEligible(false, true, false); - lastState++; - } - // Late State - else if (normalizedBeat > Minigame.LateTime() && normalizedBeat < Minigame.EndTime() && lastState == 2) - { - MakeEligible(false, false, true); - lastState++; - } - else if (normalizedBeat < Minigame.EarlyTime() || normalizedBeat > Minigame.EndTime()) - { - MakeInEligible(); - } - - // too lazy to make a proper fix for this - float endTime = 1.2f; - if (high) endTime = 1.1f; - - if (normalizedBeat > endTime) - { - Jukebox.PlayOneShotGame("spaceball/fall"); - Instantiate(Spaceball.instance.Dust, Spaceball.instance.Dust.transform.parent).SetActive(true); - Destroy(this.gameObject); - } - - if (PlayerInput.Pressed()) - { - if (e.perfect) + if (high) { - Jukebox.PlayOneShotGame("spaceball/hit"); - Holder.transform.DOLocalMove(new Vector3(Random.Range(5, 18), 0, -600), 4f).SetEase(Ease.Linear); - Holder.transform.GetChild(0).gameObject.AddComponent().rotateSpeed = -245; - - this.enabled = false; - gameObject.GetComponent().enabled = false; + anim.Play("BallHigh", 0, normalizedBeatAnim); } - else if (e.late || e.early) + else { - Holder.transform.GetChild(0).gameObject.AddComponent().rotateSpeed = -55; + anim.Play("BallLow", 0, normalizedBeatAnim); + } - this.enabled = false; - gameObject.GetComponent().enabled = false; + anim.speed = 0; - Rigidbody2D rb = gameObject.AddComponent(); - rb.bodyType = RigidbodyType2D.Dynamic; - rb.AddForce(transform.up * 1100); - rb.AddForce(transform.right * 400); - rb.gravityScale = 9; + float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, beatLength); - Jukebox.PlayOneShot("miss"); + StateCheck(normalizedBeat); + + // too lazy to make a proper fix for this + float endTime = 1.2f; + if (high) endTime = 1.1f; + + if (normalizedBeat > endTime) + { + Jukebox.PlayOneShotGame("spaceball/fall"); + Instantiate(Spaceball.instance.Dust, Spaceball.instance.Dust.transform.parent).SetActive(true); + Destroy(this.gameObject); } } } - - public void MakeEligible(bool early, bool perfect, bool late) - { - // print($"{early}, {perfect}, {late}"); - - if (!inList) - { - e.early = early; - e.perfect = perfect; - e.late = late; - - SpaceballPlayer.instance.EligibleHits.Add(e); - inList = true; - } - else - { - Minigame.Eligible es = SpaceballPlayer.instance.EligibleHits[SpaceballPlayer.instance.EligibleHits.IndexOf(e)]; - es.early = early; - es.perfect = perfect; - es.late = late; - } - } - - public void MakeInEligible() - { - if (!inList) return; - - SpaceballPlayer.instance.EligibleHits.Remove(e); - inList = false; - } } } \ No newline at end of file diff --git a/Assets/Scripts/Games/Spaceball/SpaceballPlayer.cs b/Assets/Scripts/Games/Spaceball/SpaceballPlayer.cs index 9cc2d5aa..bc2cf5bb 100644 --- a/Assets/Scripts/Games/Spaceball/SpaceballPlayer.cs +++ b/Assets/Scripts/Games/Spaceball/SpaceballPlayer.cs @@ -11,8 +11,7 @@ namespace RhythmHeavenMania.Games.Spaceball { private Animator anim; - public List EligibleHits = new List(); - [SerializeField] private int currentHitInList = 0; + private int currentHitInList = 0; public int costume; @@ -39,7 +38,7 @@ namespace RhythmHeavenMania.Games.Spaceball private void Update() { - if (EligibleHits.Count == 0) + if (Spaceball.instance.EligibleHits.Count == 0) currentHitInList = 0; if (PlayerInput.Pressed()) @@ -56,9 +55,52 @@ namespace RhythmHeavenMania.Games.Spaceball public void Swing() { - bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count); + var EligibleHits = Spaceball.instance.EligibleHits; + bool canHit = (Spaceball.instance.EligibleHits.Count > 0) && (currentHitInList < Spaceball.instance.EligibleHits.Count); - Jukebox.PlayOneShotGame("spaceball/swing"); + int events = Spaceball.instance.MultipleEventsAtOnce(); + + for (int eventI = 0; eventI < events; eventI++) + { + if (canHit) + { + SpaceballBall ball = EligibleHits[currentHitInList].gameObject.GetComponent(); + + if (EligibleHits[currentHitInList].perfect) + { + ball.hit = true; + ball.hitBeat = Conductor.instance.songPositionInBeats; + ball.hitPos = ball.Holder.transform.localPosition; + ball.hitRot = ball.Holder.transform.eulerAngles.z; + + Jukebox.PlayOneShotGame("spaceball/hit"); + + ball.randomEndPosX = Random.Range(40f, 55f); + + ball.anim.enabled = false; + } + else if (EligibleHits[currentHitInList].late || EligibleHits[currentHitInList].early) + { + ball.Holder.transform.GetChild(0).gameObject.AddComponent().rotateSpeed = -55; + + ball.enabled = false; + ball.anim.enabled = false; + + Rigidbody2D rb = ball.gameObject.AddComponent(); + rb.bodyType = RigidbodyType2D.Dynamic; + rb.AddForce(transform.up * 1100); + rb.AddForce(transform.right * 400); + rb.gravityScale = 9; + + Jukebox.PlayOneShot("miss"); + } + + ball.RemoveObject(currentHitInList); + } + } + + if (!canHit) + Jukebox.PlayOneShotGame("spaceball/swing", false); anim.Play("Swing", 0, 0); } diff --git a/Assets/Scripts/LevelEditor/EditorTheme.cs b/Assets/Scripts/LevelEditor/EditorTheme.cs index 6a8b0a7c..5ab16f97 100644 --- a/Assets/Scripts/LevelEditor/EditorTheme.cs +++ b/Assets/Scripts/LevelEditor/EditorTheme.cs @@ -29,6 +29,9 @@ namespace RhythmHeavenMania.Editor { tempoLayer.GetComponent().color = theme.properties.TempoLayerCol.Hex2RGB(); musicLayer.GetComponent().color = theme.properties.MusicLayerCol.Hex2RGB(); + Tooltip.instance.AddTooltip(tempoLayer.gameObject, $"Tempo Track"); + Tooltip.instance.AddTooltip(musicLayer.gameObject, $"Music Volume Track"); + layer.gameObject.SetActive(false); @@ -36,7 +39,7 @@ namespace RhythmHeavenMania.Editor { GameObject layer = Instantiate(this.layer.gameObject, this.layer.transform.parent); layer.SetActive(true); - layer.transform.GetChild(0).GetComponent().text = $"Layer {i + 1}"; + layer.transform.GetChild(0).GetComponent().text = $"Track {i + 1}"; Color c = Color.white; @@ -57,6 +60,7 @@ namespace RhythmHeavenMania.Editor } layer.GetComponent().color = c; + Tooltip.instance.AddTooltip(layer, $"Track {i + 1}"); } Destroy(layer); } diff --git a/Assets/Scripts/LevelEditor/Timeline.cs b/Assets/Scripts/LevelEditor/Timeline.cs index 6ac507ed..5ef7dd15 100644 --- a/Assets/Scripts/LevelEditor/Timeline.cs +++ b/Assets/Scripts/LevelEditor/Timeline.cs @@ -130,7 +130,6 @@ namespace RhythmHeavenMania.Editor } - if (Input.GetMouseButton(1) && !Conductor.instance.isPlaying && CheckIfMouseInTimeline()) { RectTransformUtility.ScreenPointToLocalPointInRectangle(TimelineContent, Input.mousePosition, Editor.instance.EditorCamera, out lastMousePos); @@ -244,27 +243,33 @@ namespace RhythmHeavenMania.Editor if (playEnabled) { PlayBTN.transform.GetChild(0).GetComponent().color = Color.green; + PlayBTN.enabled = true; } else { PlayBTN.transform.GetChild(0).GetComponent().color = Color.gray; + PlayBTN.enabled = false; } if (pauseEnabled) { + PauseBTN.enabled = true; PauseBTN.transform.GetChild(0).GetComponent().color = Color.blue; } else { PauseBTN.transform.GetChild(0).GetComponent().color = Color.gray; + PauseBTN.enabled = false; } if (stopEnabled) { + StopBTN.enabled = true; StopBTN.transform.GetChild(0).GetComponent().color = Color.red; } else { StopBTN.transform.GetChild(0).GetComponent().color = Color.gray; + StopBTN.enabled = false; } } #endregion diff --git a/Assets/Scripts/Util/Jukebox.cs b/Assets/Scripts/Util/Jukebox.cs index 1d3e5d9d..c84645f2 100644 --- a/Assets/Scripts/Util/Jukebox.cs +++ b/Assets/Scripts/Util/Jukebox.cs @@ -40,21 +40,22 @@ namespace RhythmHeavenMania.Util FindJukebox().GetComponent().volume = volume; } - public static void PlayOneShot(string name) + public static void PlayOneShot(string name, bool relyOnBeat = true) { GameObject oneShot = new GameObject("oneShot"); AudioSource aus = oneShot.AddComponent(); aus.playOnAwake = false; Sound snd = oneShot.AddComponent(); + snd.relyOnBeat = relyOnBeat; AudioClip clip = Resources.Load($"Sfx/{name}"); snd.clip = clip; // snd.pitch = (clip.length / Conductor.instance.secPerBeat); } - public static void PlayOneShotGame(string name) + public static void PlayOneShotGame(string name, bool relyOnBeat = true) { if (GameManager.instance.currentGame == name.Split('/')[0]) - PlayOneShot($"games/{name}"); + PlayOneShot($"games/{name}", relyOnBeat); } } diff --git a/Assets/Scripts/Util/Sound.cs b/Assets/Scripts/Util/Sound.cs index 08bea75a..7f1e94fd 100644 --- a/Assets/Scripts/Util/Sound.cs +++ b/Assets/Scripts/Util/Sound.cs @@ -15,6 +15,8 @@ namespace RhythmHeavenMania.Util private float startTime; + public bool relyOnBeat = true; + private void Start() { audioSource = GetComponent(); @@ -23,32 +25,45 @@ namespace RhythmHeavenMania.Util audioSource.PlayScheduled(Time.time); startTime = Conductor.instance.songPosition; + + if (!relyOnBeat) + { + StartCoroutine(NotRelyOnBeatSound()); + } } private void Update() { - if (Conductor.instance.isPaused && !Conductor.instance.isPlaying && pauseTimes == 0) + if (relyOnBeat) { - audioSource.Pause(); - pauseTimes = 1; - print("paused"); - } - else if (Conductor.instance.isPlaying && !Conductor.instance.isPaused && pauseTimes == 1) - { - audioSource.Play(); - print("played"); - pauseTimes = 0; - } + if (Conductor.instance.isPaused && !Conductor.instance.isPlaying && pauseTimes == 0) + { + audioSource.Pause(); + pauseTimes = 1; + print("paused"); + } + else if (Conductor.instance.isPlaying && !Conductor.instance.isPaused && pauseTimes == 1) + { + audioSource.Play(); + print("played"); + pauseTimes = 0; + } - else if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused) - { - Destroy(this.gameObject); + else if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused) + { + Destroy(this.gameObject); + } + if (Conductor.instance.songPosition > startTime + clip.length) + { + Destroy(this.gameObject); + } } + } - if (Conductor.instance.songPosition > startTime + clip.length) - { - Destroy(this.gameObject); - } + IEnumerator NotRelyOnBeatSound() + { + yield return new WaitForSeconds(clip.length); + Destroy(this.gameObject); } } } diff --git a/Assets/karateman.json b/Assets/karateman.json index 1892d587..388a2f20 100644 --- a/Assets/karateman.json +++ b/Assets/karateman.json @@ -1,45 +1 @@ -{ - "bpm": 119, - "entities": [ - { - "beat": 0, - "datamodel": "karateman/bgfxon" - }, - { - "beat": 1, - "datamodel": "karateman/bop" - }, - { - "beat": 2, - "datamodel": "karateman/kick" - }, - { - "beat": 14, - "datamodel": "karateman/rock" - }, - { - "beat": 20, - "datamodel": "karateman/pot" - }, - { - "beat": 22, - "datamodel": "karateman/pot" - }, - { - "beat": 24, - "datamodel": "karateman/pot" - }, - { - "beat": 26, - "datamodel": "karateman/pot" - }, - { - "beat": 28, - "datamodel": "karateman/pot" - }, - { - "beat": 30, - "datamodel": "karateman/bulb" - }, - ] -} \ No newline at end of file +{"bpm":119.0,"entities":[{"beat":14.0,"track":0,"datamodel":"karateman/pot"},{"beat":22.0,"track":2,"datamodel":"karateman/pot"},{"beat":30.0,"track":3,"datamodel":"karateman/pot"},{"beat":50.0,"track":0,"datamodel":"karateman/rock"},{"beat":56.0,"track":3,"datamodel":"karateman/bgfxon"},{"beat":58.0,"track":2,"datamodel":"karateman/pot"},{"beat":62.0,"track":2,"datamodel":"karateman/pot"},{"beat":66.0,"track":2,"datamodel":"karateman/pot"}]} \ No newline at end of file