diff --git a/Assets/Resources/Cursors.meta b/Assets/Resources/Cursors.meta new file mode 100644 index 00000000..c4b09433 --- /dev/null +++ b/Assets/Resources/Cursors.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ec1e8097a1b4776448cb5c472786c398 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Cursors/horizontal_resize.png b/Assets/Resources/Cursors/horizontal_resize.png new file mode 100644 index 00000000..4455290d Binary files /dev/null and b/Assets/Resources/Cursors/horizontal_resize.png differ diff --git a/Assets/Resources/Cursors/horizontal_resize.png.meta b/Assets/Resources/Cursors/horizontal_resize.png.meta new file mode 100644 index 00000000..0dcce0bd --- /dev/null +++ b/Assets/Resources/Cursors/horizontal_resize.png.meta @@ -0,0 +1,120 @@ +fileFormatVersion: 2 +guid: 2f4585c2b61ec7942bd207c28d783787 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 1 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 0 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 7 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Editor.unity b/Assets/Scenes/Editor.unity index 8f8882c1..f4c8c205 100644 --- a/Assets/Scenes/Editor.unity +++ b/Assets/Scenes/Editor.unity @@ -740,6 +740,175 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 163092848} m_CullTransparentMesh: 1 +--- !u!1 &184364175 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 184364176} + - component: {fileID: 184364179} + - component: {fileID: 184364178} + - component: {fileID: 184364177} + m_Layer: 5 + m_Name: ResizeRight + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &184364176 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 184364175} + 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: 798021449} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 1, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0.18000007, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &184364177 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 184364175} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0b148fe25e99eb48b9724523833bab1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Delegates: + - eventID: 2 + callback: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 798021450} + m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.TimelineEventObj, Assembly-CSharp + m_MethodName: OnRightDown + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - eventID: 5 + callback: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 798021450} + m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.TimelineEventObj, Assembly-CSharp + m_MethodName: DragRight + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - eventID: 3 + callback: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 798021450} + m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.TimelineEventObj, Assembly-CSharp + m_MethodName: OnRightUp + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - eventID: 0 + callback: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 798021450} + m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.TimelineEventObj, Assembly-CSharp + m_MethodName: DragEnter + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - eventID: 1 + callback: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 798021450} + m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.TimelineEventObj, Assembly-CSharp + m_MethodName: DragExit + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &184364178 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 184364175} + 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: 1, g: 1, b: 1, a: 0} + 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: 0 + 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 &184364179 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 184364175} + m_CullTransparentMesh: 1 --- !u!1 &191459085 GameObject: m_ObjectHideFlags: 0 @@ -1228,7 +1397,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: -0.047200024, y: 0.000017166138} + m_AnchoredPosition: {x: -0.047210693, y: 0.000017166138} m_SizeDelta: {x: 36.806, y: 44.84} m_Pivot: {x: 1, y: 0.5} --- !u!114 &258006093 @@ -1496,7 +1665,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 0} - m_AnchoredPosition: {x: -0.04, y: 0} + m_AnchoredPosition: {x: -0.040008545, y: 0} m_SizeDelta: {x: -0.08, y: 4} m_Pivot: {x: 1, y: 0} --- !u!114 &321288861 @@ -3913,6 +4082,8 @@ RectTransform: - {fileID: 258006092} - {fileID: 2127582757} - {fileID: 1231936949} + - {fileID: 2046851080} + - {fileID: 184364176} m_Father: {fileID: 1838356727} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -3940,6 +4111,8 @@ MonoBehaviour: length: 0 selected: 0 mouseHovering: 0 + resizable: 0 + resizing: 0 NormalCol: {r: 0.8470589, g: 0.8470589, b: 1, a: 1} --- !u!222 &798021451 CanvasRenderer: @@ -5898,7 +6071,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: -0.04, y: 0} + m_AnchoredPosition: {x: -0.040008545, y: 0} m_SizeDelta: {x: -0.08, y: 4} m_Pivot: {x: 1, y: 1} --- !u!114 &1237250189 @@ -6831,7 +7004,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: -0.04, y: 0} + m_AnchoredPosition: {x: -0.040008545, y: 0} m_SizeDelta: {x: -0.08, y: 4} m_Pivot: {x: 1, y: 1} --- !u!114 &1474986789 @@ -8286,7 +8459,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 0} - m_AnchoredPosition: {x: -0.04, y: 0} + m_AnchoredPosition: {x: -0.040008545, y: 0} m_SizeDelta: {x: -0.08, y: 4} m_Pivot: {x: 1, y: 0} --- !u!114 &1837496589 @@ -8466,6 +8639,7 @@ MonoBehaviour: eventObjs: [] LayerCount: 4 metronomeEnabled: 0 + resizable: 0 TimelineSlider: {fileID: 770589360} TimelinePlaybackBeat: {fileID: 117889364} TimelineContent: {fileID: 1852819573} @@ -9173,6 +9347,175 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2037220113} m_CullTransparentMesh: 1 +--- !u!1 &2046851079 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2046851080} + - component: {fileID: 2046851082} + - component: {fileID: 2046851081} + - component: {fileID: 2046851083} + m_Layer: 5 + m_Name: ResizeLeft + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2046851080 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2046851079} + 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: 798021449} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 0, y: 0.000019073486} + m_SizeDelta: {x: 0.18, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &2046851081 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2046851079} + 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: 1, g: 1, b: 1, a: 0} + 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: 0 + 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 &2046851082 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2046851079} + m_CullTransparentMesh: 1 +--- !u!114 &2046851083 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2046851079} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0b148fe25e99eb48b9724523833bab1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Delegates: + - eventID: 2 + callback: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 798021450} + m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.TimelineEventObj, Assembly-CSharp + m_MethodName: OnLeftDown + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - eventID: 5 + callback: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 798021450} + m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.TimelineEventObj, Assembly-CSharp + m_MethodName: DragLeft + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - eventID: 3 + callback: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 798021450} + m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.TimelineEventObj, Assembly-CSharp + m_MethodName: OnLeftUp + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - eventID: 0 + callback: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 798021450} + m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.TimelineEventObj, Assembly-CSharp + m_MethodName: DragEnter + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - eventID: 1 + callback: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 798021450} + m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.TimelineEventObj, Assembly-CSharp + m_MethodName: DragExit + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 --- !u!1 &2047408673 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/EventCaller.cs b/Assets/Scripts/EventCaller.cs index 6e780880..99d41183 100644 --- a/Assets/Scripts/EventCaller.cs +++ b/Assets/Scripts/EventCaller.cs @@ -4,74 +4,31 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; -using RhythmHeavenMania.Util; - -using RhythmHeavenMania.Games.ForkLifter; -using RhythmHeavenMania.Games.ClappyTrio; -using RhythmHeavenMania.Games.Spaceball; -using RhythmHeavenMania.Games.KarateMan; - namespace RhythmHeavenMania { public class EventCaller : MonoBehaviour { public Transform GamesHolder; - private float currentBeat; - private float currentLength; - private float currentValA; - private string currentSwitchGame; - private int currentType; + public float currentBeat; + public float currentLength; + public float currentValA; + public string currentSwitchGame; + public int currentType; public delegate void EventCallback(); public static EventCaller instance { get; private set; } - public List minigames = new List() + public List minigames = new List() { }; - [Serializable] - public class MiniGame - { - public string name; - public string displayName; - public string color; - public GameObject holder; - public List actions = new List(); - - public MiniGame(string name, string displayName, string color, List actions) - { - this.name = name; - this.displayName = displayName; - this.color = color; - this.actions = actions; - } - } - - public class GameAction - { - public string actionName; - public EventCallback function; - public bool playerAction = false; - public float defaultLength; - public bool resizable; - - public GameAction(string actionName, EventCallback function, float defaultLength = 1, bool playerAction = false, bool resizable = false) - { - this.actionName = actionName; - this.function = function; - this.playerAction = playerAction; - this.defaultLength = defaultLength; - this.resizable = resizable; - } - } - - public MiniGame GetMinigame(string gameName) + public Minigames.Minigame GetMinigame(string gameName) { return minigames.Find(c => c.name == gameName); } - public GameAction GetGameAction(MiniGame game, string action) + public Minigames.GameAction GetGameAction(Minigames.Minigame game, string action) { return game.actions.Find(c => c.actionName == action); } @@ -79,52 +36,10 @@ namespace RhythmHeavenMania public void Init() { instance = this; - minigames = new List() - { - new MiniGame("gameManager", "Game Manager", "", new List() - { - new GameAction("end", delegate { Debug.Log("end"); }), - new GameAction("switchGame", delegate { GameManager.instance.SwitchGame(currentSwitchGame); }) - }), - new MiniGame("forkLifter", "Fork Lifter", "FFFFFF", new List() - { - new GameAction("pea", delegate { ForkLifter.instance.Flick(currentBeat, 0); }, 3, true), - new GameAction("topbun", delegate { ForkLifter.instance.Flick(currentBeat, 1); }, 3, true), - new GameAction("burger", delegate { ForkLifter.instance.Flick(currentBeat, 2); }, 3, true), - new GameAction("bottombun", delegate { ForkLifter.instance.Flick(currentBeat, 3); }, 3, true), - new GameAction("prepare", delegate { ForkLifter.instance.ForkLifterHand.Prepare(); }, 0.5f, true), - new GameAction("gulp", delegate { ForkLifterPlayer.instance.Eat(); }), - new GameAction("sigh", delegate { Jukebox.PlayOneShot("sigh"); }) - }), - new MiniGame("clappyTrio", "The Clappy Trio", "29E7FF", new List() - { - new GameAction("clap", delegate { ClappyTrio.instance.Clap(currentBeat, currentLength); }, 3, true), - new GameAction("bop", delegate { ClappyTrio.instance.Bop(currentBeat); } ), - new GameAction("prepare", delegate { ClappyTrio.instance.Prepare(0); } ), - new GameAction("prepare_alt", delegate { ClappyTrio.instance.Prepare(3); } ), - }), - new MiniGame("spaceball", "Spaceball", "00A518", new List() - { - new GameAction("shoot", delegate { Spaceball.instance.Shoot(currentBeat, false, currentType); }, 2, true), - new GameAction("shootHigh", delegate { Spaceball.instance.Shoot(currentBeat, true, currentType); }, 3, true), - new GameAction("costume", delegate { Spaceball.instance.Costume(currentType); } ), - new GameAction("alien", delegate { Spaceball.instance.alien.Show(currentBeat); } ), - new GameAction("cameraZoom", delegate { } ), - }), - new MiniGame("karateman", "Karate Man", "70A8D8", new List() - { - new GameAction("bop", delegate { KarateMan.instance.Bop(currentBeat, currentLength); }, 0.5f, true, true), - new GameAction("pot", delegate { KarateMan.instance.Shoot(currentBeat, 0); }, 2, true), - new GameAction("bulb", delegate { KarateMan.instance.Shoot(currentBeat, 1); }, 2, true), - new GameAction("rock", delegate { KarateMan.instance.Shoot(currentBeat, 2); }, 2, true), - new GameAction("ball", delegate { KarateMan.instance.Shoot(currentBeat, 3); }, 2, true), - new GameAction("kick", delegate { KarateMan.instance.Shoot(currentBeat, 4); }, 4.5f, true), - new GameAction("bgfxon", delegate { KarateMan.instance.BGFXOn(); } ), - new GameAction("bgfxoff", delegate { KarateMan.instance.BGFXOff(); }), - }) - }; - List minigamesInBeatmap = new List(); + Minigames.Init(this); + + List minigamesInBeatmap = new List(); for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++) { if (!minigamesInBeatmap.Contains(minigames.Find(c => c.name == GameManager.instance.Beatmap.entities[i].datamodel.Split('/')[0])) && GameManager.instance.Beatmap.entities[i].datamodel.Split('/')[0] != "gameManager") @@ -164,7 +79,7 @@ namespace RhythmHeavenMania public void CallEvent(string event_) { string[] details = event_.Split('/'); - MiniGame game = minigames.Find(c => c.name == details[0]); + Minigames.Minigame game = minigames.Find(c => c.name == details[0]); try { @@ -174,7 +89,7 @@ namespace RhythmHeavenMania if (details.Length > 2) currentSwitchGame = details[2]; - GameAction action = game.actions.Find(c => c.actionName == details[1]); + Minigames.GameAction action = game.actions.Find(c => c.actionName == details[1]); action.function.Invoke(); if (action.playerAction == true) diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index d6027d93..5fd4b24d 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -279,13 +279,13 @@ namespace RhythmHeavenMania preloadedGames.Add(g); } - public EventCaller.MiniGame GetGame(string name) + public Minigames.Minigame GetGame(string name) { return eventCaller.minigames.Find(c => c.name == name); } // never gonna use this - public EventCaller.MiniGame GetCurrentGame() + public Minigames.Minigame GetCurrentGame() { return eventCaller.minigames.Find(c => c.name == transform.GetComponentsInChildren()[1].name); } diff --git a/Assets/Scripts/Games/ForkLifter/ForkLifterPlayer.cs b/Assets/Scripts/Games/ForkLifter/ForkLifterPlayer.cs index 0dd93c5c..054aac21 100644 --- a/Assets/Scripts/Games/ForkLifter/ForkLifterPlayer.cs +++ b/Assets/Scripts/Games/ForkLifter/ForkLifterPlayer.cs @@ -251,12 +251,11 @@ namespace RhythmHeavenMania.Games.ForkLifter RemovePea(); } } - else - { - Jukebox.PlayOneShotGame("forkLifter/stabnohit"); - } } + if (!canHit) + Jukebox.PlayOneShotGame("forkLifter/stabnohit", false); + anim.Play("Player_Stab", 0, 0); } diff --git a/Assets/Scripts/Games/KarateMan/KarateJoe.cs b/Assets/Scripts/Games/KarateMan/KarateJoe.cs index 7c6ee4d7..ca9f14b2 100644 --- a/Assets/Scripts/Games/KarateMan/KarateJoe.cs +++ b/Assets/Scripts/Games/KarateMan/KarateJoe.cs @@ -162,15 +162,15 @@ namespace RhythmHeavenMania.Games.KarateMan p.isEligible = false; p.RemoveObject(currentHitInList); } - else - { - Jukebox.PlayOneShotGame("karateman/swingNoHit"); - } - if (punchLeft) - anim.Play("PunchLeft", 0, 0); - else - anim.Play("PunchRight", 0, 0); } + + if (!canHit) + 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/LevelEditor/EventSelector/GridGameSelector.cs b/Assets/Scripts/LevelEditor/EventSelector/GridGameSelector.cs index c56ae153..2a8141f5 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/GridGameSelector.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/GridGameSelector.cs @@ -20,7 +20,7 @@ namespace RhythmHeavenMania.Editor private RectTransform eventsParent; [Header("Properties")] - private EventCaller.MiniGame mg; + private Minigames.Minigame mg; private bool gameOpen; [SerializeField] private int currentEventIndex; private int dragTimes; diff --git a/Assets/Scripts/LevelEditor/Timeline.cs b/Assets/Scripts/LevelEditor/Timeline.cs index 5ef7dd15..9bf6df0b 100644 --- a/Assets/Scripts/LevelEditor/Timeline.cs +++ b/Assets/Scripts/LevelEditor/Timeline.cs @@ -21,6 +21,7 @@ namespace RhythmHeavenMania.Editor private bool lastFrameDrag; public int LayerCount = 4; public bool metronomeEnabled; + public bool resizable; [Header("Timeline Components")] [SerializeField] private RectTransform TimelineSlider; @@ -305,13 +306,28 @@ namespace RhythmHeavenMania.Editor else eventObj.Icon.sprite = Editor.GameIcon(eventName.Split(0)); - EventCaller.GameAction gameAction = EventCaller.instance.GetGameAction(EventCaller.instance.GetMinigame(eventName.Split(0)), eventName.Split(1)); + Minigames.GameAction gameAction = EventCaller.instance.GetGameAction(EventCaller.instance.GetMinigame(eventName.Split(0)), eventName.Split(1)); if (gameAction != null) { - g.GetComponent().sizeDelta = new Vector2(gameAction.defaultLength, LayerHeight()); - float length = gameAction.defaultLength; - eventObj.length = length; + if (gameAction.resizable == false) + { + g.GetComponent().sizeDelta = new Vector2(gameAction.defaultLength, LayerHeight()); + float length = gameAction.defaultLength; + eventObj.length = length; + } + else + { + eventObj.resizable = true; + if (gameAction.defaultLength != GameManager.instance.Beatmap.entities[entityId].length) + { + g.GetComponent().sizeDelta = new Vector2(GameManager.instance.Beatmap.entities[entityId].length, LayerHeight()); + } + else + { + g.GetComponent().sizeDelta = new Vector2(gameAction.defaultLength, LayerHeight()); + } + } } g.SetActive(true); @@ -335,7 +351,6 @@ namespace RhythmHeavenMania.Editor else { var entity = GameManager.instance.Beatmap.entities[entityId]; - var e = GameManager.instance.Beatmap.entities[entityId]; entity.eventObj = g.GetComponent(); entity.track = (int)(g.transform.localPosition.y / LayerHeight() * -1); @@ -361,7 +376,7 @@ namespace RhythmHeavenMania.Editor public bool IsEventsDragging() { - return Timeline.instance.eventObjs.FindAll(c => c.isDragging == true).Count > 0; + return eventObjs.FindAll(c => c.isDragging == true).Count > 0 || eventObjs.FindAll(c => c.resizing == true).Count > 0; } public float SnapToLayer(float y) diff --git a/Assets/Scripts/LevelEditor/TimelineEventObj.cs b/Assets/Scripts/LevelEditor/TimelineEventObj.cs index 0edc13f3..02a39631 100644 --- a/Assets/Scripts/LevelEditor/TimelineEventObj.cs +++ b/Assets/Scripts/LevelEditor/TimelineEventObj.cs @@ -15,6 +15,7 @@ namespace RhythmHeavenMania.Editor public bool isDragging; private Vector3 lastPos; + private RectTransform rectTransform; [Header("Components")] [SerializeField] private RectTransform PosPreview; @@ -28,15 +29,28 @@ namespace RhythmHeavenMania.Editor private bool lastVisible; public bool selected; public bool mouseHovering; + public bool resizable; + public bool resizing; [Header("Colors")] public Color NormalCol; + private void Start() + { + rectTransform = GetComponent(); + + if (!resizable) + { + Destroy(transform.GetChild(5).gameObject); + Destroy(transform.GetChild(6).gameObject); + } + } + private void Update() { entity = GameManager.instance.Beatmap.entities.Find(a => a.eventObj == this); - mouseHovering = RectTransformUtility.RectangleContainsScreenPoint(GetComponent(), Input.mousePosition, Camera.main); + mouseHovering = RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, Camera.main); #region Optimizations @@ -67,7 +81,25 @@ namespace RhythmHeavenMania.Editor transform.GetChild(3).gameObject.SetActive(true); for (int i = 0; i < transform.GetChild(4).childCount; i++) + { transform.GetChild(4).GetChild(i).GetComponent().color = Color.cyan; + } + + Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); + + Vector3[] v = new Vector3[4]; + rectTransform.GetWorldCorners(v); + + if (mouseHovering) + { + if (mousePos.x > transform.position.x && mousePos.x < transform.position.x + 0.1f) + { + } + else if (mousePos.x > v[3].x - 0.1f && mousePos.x < v[3].x) + { + + } + } } else { @@ -83,50 +115,143 @@ namespace RhythmHeavenMania.Editor return; } - - if (Input.GetMouseButtonDown(0) && Timeline.instance.IsMouseAboveEvents()) + if (!resizing) { - if (selected) + if (Input.GetMouseButtonDown(0) && Timeline.instance.IsMouseAboveEvents()) + { + if (selected) + { + Vector3 mousePos; + mousePos = Input.mousePosition; + mousePos = Camera.main.ScreenToWorldPoint(mousePos); + startPosX = mousePos.x - this.transform.position.x; + startPosY = mousePos.y - this.transform.position.y; + + isDragging = true; + } + } + else if (Input.GetMouseButtonUp(0)) + { + if (!mouseHovering && !isDragging && !BoxSelection.instance.selecting) + { + if (!Input.GetKey(KeyCode.LeftShift)) + { + Selections.instance.Deselect(this); + } + } + + OnUp(); + } + if (isDragging && selected) { Vector3 mousePos; mousePos = Input.mousePosition; mousePos = Camera.main.ScreenToWorldPoint(mousePos); - startPosX = mousePos.x - this.transform.position.x; - startPosY = mousePos.y - this.transform.position.y; - isDragging = true; + this.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0); + this.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(this.transform.localPosition.y)); + + if (lastPos != transform.localPosition) + OnMove(); + + lastPos = this.transform.localPosition; } } - else if (Input.GetMouseButtonUp(0)) - { - if (!mouseHovering && !isDragging && !BoxSelection.instance.selecting) - { - if (!Input.GetKey(KeyCode.LeftShift)) - { - Selections.instance.Deselect(this); - } - } - - OnUp(); - } - - if (isDragging && selected) - { - Vector3 mousePos; - mousePos = Input.mousePosition; - mousePos = Camera.main.ScreenToWorldPoint(mousePos); - - this.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0); - this.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(this.transform.localPosition.y)); - - if (lastPos != transform.localPosition) - OnMove(); - - lastPos = this.transform.localPosition; - } } + #region ResizeEvents + + public void DragEnter() + { + if (selected) + Cursor.SetCursor(Resources.Load("Cursors/horizontal_resize"), new Vector2(8, 8), CursorMode.Auto); + } + + public void DragExit() + { + if (!resizing) + Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); + } + + public void OnLeftDown() + { + if (selected) + { + SetPivot(new Vector2(1, rectTransform.pivot.y)); + resizing = true; + } + } + + public void DragLeft() + { + if (!resizing) return; + + Vector2 sizeDelta = rectTransform.sizeDelta; + + Vector2 mousePos; + RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition, Camera.main, out mousePos); + + sizeDelta = new Vector2(-mousePos.x + 0.1f, sizeDelta.y); + sizeDelta = new Vector2(Mathf.Clamp(sizeDelta.x, 0.25f, rectTransform.localPosition.x), sizeDelta.y); + + rectTransform.sizeDelta = new Vector2(Mathp.Round2Nearest(sizeDelta.x, 0.25f), sizeDelta.y); + } + + public void OnLeftUp() + { + SetPivot(new Vector2(0, rectTransform.pivot.y)); + resizing = false; + OnComplete(); + } + + public void OnRightDown() + { + if (selected) + { + SetPivot(new Vector2(0, rectTransform.pivot.y)); + resizing = true; + } + } + + public void DragRight() + { + if (!resizing) return; + // if (!mouseHovering) return; + + Vector2 sizeDelta = rectTransform.sizeDelta; + + Vector2 mousePos; + RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition, Camera.main, out mousePos); + + sizeDelta = new Vector2(mousePos.x, sizeDelta.y); + sizeDelta = new Vector2(Mathf.Clamp(sizeDelta.x, 0.25f, Mathf.Infinity), sizeDelta.y); + + rectTransform.sizeDelta = new Vector2(Mathp.Round2Nearest(sizeDelta.x, 0.25f), sizeDelta.y); + } + + public void OnRightUp() + { + resizing = false; + + OnComplete(); + } + + private void SetPivot(Vector2 pivot) + { + if (rectTransform == null) return; + + Vector2 size = rectTransform.rect.size; + Vector2 deltaPivot = rectTransform.pivot - pivot; + Vector3 deltaPosition = new Vector3(deltaPivot.x * size.x, deltaPivot.y * size.y); + rectTransform.pivot = pivot; + rectTransform.localPosition -= deltaPosition; + } + + #endregion + + #region OnEvents + private void OnMove() { if (GameManager.instance.Beatmap.entities.FindAll(c => c.beat == this.transform.localPosition.x && c.track == GetTrack()).Count > 0) @@ -141,11 +266,14 @@ namespace RhythmHeavenMania.Editor private void OnComplete() { + entity.length = rectTransform.sizeDelta.x; entity.beat = this.transform.localPosition.x; GameManager.instance.SortEventsList(); entity.track = GetTrack(); } + #endregion + #region ClickEvents public void OnDown() diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs new file mode 100644 index 00000000..816b78b9 --- /dev/null +++ b/Assets/Scripts/Minigames.cs @@ -0,0 +1,101 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +using RhythmHeavenMania.Util; + +using RhythmHeavenMania.Games.ForkLifter; +using RhythmHeavenMania.Games.ClappyTrio; +using RhythmHeavenMania.Games.Spaceball; +using RhythmHeavenMania.Games.KarateMan; + +namespace RhythmHeavenMania +{ + public class Minigames + { + public class Minigame + { + public string name; + public string displayName; + public string color; + public GameObject holder; + public List actions = new List(); + + public Minigame(string name, string displayName, string color, List actions) + { + this.name = name; + this.displayName = displayName; + this.color = color; + this.actions = actions; + } + } + + public class GameAction + { + public string actionName; + public EventCallback function; + public bool playerAction = false; + public float defaultLength; + public bool resizable; + + public GameAction(string actionName, EventCallback function, float defaultLength = 1, bool playerAction = false, bool resizable = false) + { + this.actionName = actionName; + this.function = function; + this.playerAction = playerAction; + this.defaultLength = defaultLength; + this.resizable = resizable; + } + } + + public delegate void EventCallback(); + + public static void Init(EventCaller eventCaller) + { + eventCaller.minigames = new List() + { + new Minigame("gameManager", "Game Manager", "", new List() + { + new GameAction("end", delegate { Debug.Log("end"); }), + new GameAction("switchGame", delegate { GameManager.instance.SwitchGame(eventCaller.currentSwitchGame); }) + }), + new Minigame("forkLifter", "Fork Lifter", "FFFFFF", new List() + { + new GameAction("pea", delegate { ForkLifter.instance.Flick(eventCaller.currentBeat, 0); }, 3, true), + new GameAction("topbun", delegate { ForkLifter.instance.Flick(eventCaller.currentBeat, 1); }, 3, true), + new GameAction("burger", delegate { ForkLifter.instance.Flick(eventCaller.currentBeat, 2); }, 3, true), + new GameAction("bottombun", delegate { ForkLifter.instance.Flick(eventCaller.currentBeat, 3); }, 3, true), + new GameAction("prepare", delegate { ForkLifter.instance.ForkLifterHand.Prepare(); }, 0.5f, true), + new GameAction("gulp", delegate { ForkLifterPlayer.instance.Eat(); }), + new GameAction("sigh", delegate { Jukebox.PlayOneShot("sigh"); }) + }), + new Minigame("clappyTrio", "The Clappy Trio", "29E7FF", new List() + { + new GameAction("clap", delegate { ClappyTrio.instance.Clap(eventCaller.currentBeat, eventCaller.currentLength); }, 3, true), + new GameAction("bop", delegate { ClappyTrio.instance.Bop(eventCaller.currentBeat); } ), + new GameAction("prepare", delegate { ClappyTrio.instance.Prepare(0); } ), + new GameAction("prepare_alt", delegate { ClappyTrio.instance.Prepare(3); } ), + }), + new Minigame("spaceball", "Spaceball", "00A518", new List() + { + new GameAction("shoot", delegate { Spaceball.instance.Shoot(eventCaller.currentBeat, false, eventCaller.currentType); }, 2, true), + new GameAction("shootHigh", delegate { Spaceball.instance.Shoot(eventCaller.currentBeat, true, eventCaller.currentType); }, 3, true), + new GameAction("costume", delegate { Spaceball.instance.Costume(eventCaller.currentType); } ), + new GameAction("alien", delegate { Spaceball.instance.alien.Show(eventCaller.currentBeat); } ), + new GameAction("cameraZoom", delegate { }, 4, false, true ), + }), + new Minigame("karateman", "Karate Man", "70A8D8", new List() + { + new GameAction("bop", delegate { KarateMan.instance.Bop(eventCaller.currentBeat, eventCaller.currentLength); }, 0.5f, true, true), + new GameAction("pot", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 0); }, 2, true), + new GameAction("bulb", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 1); }, 2, true), + new GameAction("rock", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 2); }, 2, true), + new GameAction("ball", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 3); }, 2, true), + new GameAction("kick", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 4); }, 4.5f, true), + new GameAction("bgfxon", delegate { KarateMan.instance.BGFXOn(); } ), + new GameAction("bgfxoff", delegate { KarateMan.instance.BGFXOff(); }), + }) + }; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Minigames.cs.meta b/Assets/Scripts/Minigames.cs.meta new file mode 100644 index 00000000..110d8959 --- /dev/null +++ b/Assets/Scripts/Minigames.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6d314b8e6c105df4b9bffa399e9c2dcd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: