Buggy timeline object resizing

This commit is contained in:
Braedon 2022-01-17 14:23:18 -05:00
parent ce193bf572
commit 6cf529327b
13 changed files with 798 additions and 158 deletions

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ec1e8097a1b4776448cb5c472786c398
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 B

View file

@ -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:

View file

@ -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

View file

@ -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<MiniGame> minigames = new List<MiniGame>()
public List<Minigames.Minigame> minigames = new List<Minigames.Minigame>()
{
};
[Serializable]
public class MiniGame
{
public string name;
public string displayName;
public string color;
public GameObject holder;
public List<GameAction> actions = new List<GameAction>();
public MiniGame(string name, string displayName, string color, List<GameAction> 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<MiniGame>()
{
new MiniGame("gameManager", "Game Manager", "", new List<GameAction>()
{
new GameAction("end", delegate { Debug.Log("end"); }),
new GameAction("switchGame", delegate { GameManager.instance.SwitchGame(currentSwitchGame); })
}),
new MiniGame("forkLifter", "Fork Lifter", "FFFFFF", new List<GameAction>()
{
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<GameAction>()
{
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<GameAction>()
{
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<GameAction>()
{
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<MiniGame> minigamesInBeatmap = new List<MiniGame>();
Minigames.Init(this);
List<Minigames.Minigame> minigamesInBeatmap = new List<Minigames.Minigame>();
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)

View file

@ -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<Transform>()[1].name);
}

View file

@ -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);
}

View file

@ -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)

View file

@ -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;

View file

@ -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<RectTransform>().sizeDelta = new Vector2(gameAction.defaultLength, LayerHeight());
float length = gameAction.defaultLength;
eventObj.length = length;
if (gameAction.resizable == false)
{
g.GetComponent<RectTransform>().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<RectTransform>().sizeDelta = new Vector2(GameManager.instance.Beatmap.entities[entityId].length, LayerHeight());
}
else
{
g.GetComponent<RectTransform>().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<TimelineEventObj>();
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)

View file

@ -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<RectTransform>();
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<RectTransform>(), 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<Image>().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<Texture2D>("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()

101
Assets/Scripts/Minigames.cs Normal file
View file

@ -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<GameAction> actions = new List<GameAction>();
public Minigame(string name, string displayName, string color, List<GameAction> 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<Minigame>()
{
new Minigame("gameManager", "Game Manager", "", new List<GameAction>()
{
new GameAction("end", delegate { Debug.Log("end"); }),
new GameAction("switchGame", delegate { GameManager.instance.SwitchGame(eventCaller.currentSwitchGame); })
}),
new Minigame("forkLifter", "Fork Lifter", "FFFFFF", new List<GameAction>()
{
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<GameAction>()
{
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<GameAction>()
{
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<GameAction>()
{
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(); }),
})
};
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6d314b8e6c105df4b9bffa399e9c2dcd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: