Drag n drop begun

This commit is contained in:
Braedon 2022-01-10 19:17:29 -05:00
parent f4459c1c98
commit 8e00fa3d4c
12 changed files with 823 additions and 47 deletions

View file

@ -740,6 +740,84 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 355353077}
m_CullTransparentMesh: 1
--- !u!1 &358789043
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 358789044}
- component: {fileID: 358789045}
- component: {fileID: 358789046}
m_Layer: 5
m_Name: Content
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &358789044
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 358789043}
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: 1149103345}
m_Father: {fileID: 1056099132}
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 &358789045
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 358789043}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 45
m_Right: 0
m_Top: 30
m_Bottom: 30
m_ChildAlignment: 0
m_Spacing: 5
m_ChildForceExpandWidth: 1
m_ChildForceExpandHeight: 0
m_ChildControlWidth: 0
m_ChildControlHeight: 0
m_ChildScaleWidth: 0
m_ChildScaleHeight: 1
m_ReverseArrangement: 0
--- !u!114 &358789046
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 358789043}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3312d7739989d2b4e91e6319e9a96d76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding: {x: 0, y: 0, z: 0, w: 0}
m_Softness: {x: 0, y: 0}
--- !u!1 &424396916
GameObject:
m_ObjectHideFlags: 0
@ -2057,7 +2135,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 5, y: -5}
m_SizeDelta: {x: 32, y: 32}
m_SizeDelta: {x: 42, y: 42}
m_Pivot: {x: 0, y: 1}
--- !u!114 &781200687
MonoBehaviour:
@ -2110,6 +2188,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
GameTitlePreview: {fileID: 1047406298}
GridGameSelector: {fileID: 1154875947}
--- !u!114 &781200690
MonoBehaviour:
m_ObjectHideFlags: 0
@ -2155,6 +2234,23 @@ MonoBehaviour:
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- eventID: 4
callback:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 781200689}
m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.GridGameSelectorGame,
Assembly-CSharp
m_MethodName: OnClick
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 &798021448
GameObject:
m_ObjectHideFlags: 0
@ -2208,6 +2304,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: eb5481d804b2aec42a04ea8f659fdc5a, type: 3}
m_Name:
m_EditorClassIdentifier:
isDragging: 0
PosPreview: {fileID: 0}
PosPreviewRef: {fileID: 2142375787}
Icon: {fileID: 820032006}
@ -2667,8 +2764,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0.3137255}
m_RaycastTarget: 1
m_Color: {r: 0, g: 0, b: 0, a: 0.57254905}
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
@ -2704,6 +2801,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4ef18fa546ce78c4b9ebf77aefdec762, type: 3}
m_Name:
m_EditorClassIdentifier:
offset: {x: -1.1, y: -0.2}
--- !u!1 &1050802355
GameObject:
m_ObjectHideFlags: 0
@ -2755,6 +2853,7 @@ GameObject:
- component: {fileID: 1056099132}
- component: {fileID: 1056099134}
- component: {fileID: 1056099133}
- component: {fileID: 1056099135}
m_Layer: 5
m_Name: GameEventSelector
m_TagString: Untagged
@ -2772,7 +2871,8 @@ RectTransform:
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_Children:
- {fileID: 358789044}
m_Father: {fileID: 1050802356}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -2819,6 +2919,51 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1056099131}
m_CullTransparentMesh: 1
--- !u!114 &1056099135
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1056099131}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0b148fe25e99eb48b9724523833bab1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Delegates:
- eventID: 5
callback:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1154875947}
m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.GridGameSelector, Assembly-CSharp
m_MethodName: Drag
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: 1154875947}
m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.GridGameSelector, Assembly-CSharp
m_MethodName: Drop
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 &1110073994
GameObject:
m_ObjectHideFlags: 0
@ -2856,6 +3001,140 @@ RectTransform:
m_AnchoredPosition: {x: -382, y: 147.99997}
m_SizeDelta: {x: 515.94, y: 344}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1149103344
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1149103345}
- component: {fileID: 1149103347}
- component: {fileID: 1149103346}
m_Layer: 5
m_Name: Event
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &1149103345
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1149103344}
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: 358789044}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 205.495, y: -42.510002}
m_SizeDelta: {x: 320.99, y: 25.02}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1149103346
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1149103344}
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: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Event
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: 21.69
m_fontSizeBase: 21.69
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
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 &1149103347
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1149103344}
m_CullTransparentMesh: 1
--- !u!1 &1154875942
GameObject:
m_ObjectHideFlags: 0
@ -2866,6 +3145,7 @@ GameObject:
m_Component:
- component: {fileID: 1154875943}
- component: {fileID: 1154875945}
- component: {fileID: 1154875947}
- component: {fileID: 1154875944}
- component: {fileID: 1154875946}
m_Layer: 5
@ -2953,10 +3233,26 @@ MonoBehaviour:
m_ChildAlignment: 0
m_StartCorner: 0
m_StartAxis: 0
m_CellSize: {x: 32, y: 32}
m_CellSize: {x: 42, y: 42}
m_Spacing: {x: 5, y: 5}
m_Constraint: 0
m_ConstraintCount: 2
--- !u!114 &1154875947
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1154875942}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d9d826be8d1e71d4c971f5ed377ee873, type: 3}
m_Name:
m_EditorClassIdentifier:
SelectedMinigame:
GameEventSelector: {fileID: 1056099131}
EventRef: {fileID: 1149103344}
currentEventIndex: 0
--- !u!1 &1196204502
GameObject:
m_ObjectHideFlags: 0
@ -3582,7 +3878,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:

View file

@ -6,10 +6,12 @@ namespace RhythmHeavenMania.Common
{
public class FollowMouse : MonoBehaviour
{
public Vector2 offset;
private void Update()
{
var pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
transform.position = new Vector3(pos.x, pos.y, 0);
transform.position = new Vector3(pos.x - offset.x, pos.y - offset.y, 0);
}
}
}

View file

@ -150,5 +150,10 @@ namespace RhythmHeavenMania
else
return false;
}
public bool NotStopped()
{
return Conductor.instance.isPlaying == true || Conductor.instance.isPaused;
}
}
}

View file

@ -34,13 +34,15 @@ namespace RhythmHeavenMania
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 color, List<GameAction> actions)
public MiniGame(string name, string displayName, string color, List<GameAction> actions)
{
this.name = name;
this.displayName = displayName;
this.color = color;
this.actions = actions;
}
@ -79,12 +81,12 @@ namespace RhythmHeavenMania
instance = this;
minigames = new List<MiniGame>()
{
new MiniGame("gameManager", "", new List<GameAction>()
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", "FFFFFF", new List<GameAction>()
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),
@ -94,14 +96,14 @@ namespace RhythmHeavenMania
new GameAction("gulp", delegate { ForkLifterPlayer.instance.Eat(); }),
new GameAction("sigh", delegate { Jukebox.PlayOneShot("sigh"); })
}),
new MiniGame("clappyTrio", "29E7FF", new List<GameAction>()
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", "00A518", new List<GameAction>()
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),
@ -109,7 +111,7 @@ namespace RhythmHeavenMania
new GameAction("alien", delegate { Spaceball.instance.alien.Show(currentBeat); } ),
new GameAction("cameraZoom", delegate { } ),
}),
new MiniGame("karateman", "70A8D8", new List<GameAction>()
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),

View file

@ -43,7 +43,7 @@ namespace RhythmHeavenMania.Editor
GameObject GameIcon_ = Instantiate(GridGameSelector.GetChild(0).gameObject, GridGameSelector);
GameIcon_.GetComponent<Image>().sprite = GameIcon(EventCaller.instance.minigames[i].name);
GameIcon_.gameObject.SetActive(true);
GameIcon_.name = "GameIcon";
GameIcon_.name = EventCaller.instance.minigames[i].displayName;
}
}

View file

@ -1,20 +1,117 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
namespace RhythmHeavenMania.Editor
{
public class GridGameSelector : MonoBehaviour
{
public GameObject GameTitlePreview;
public string SelectedMinigame;
public void OnEnter()
[Header("Components")]
public GameObject GameEventSelector;
public GameObject EventRef;
[Header("Properties")]
private EventCaller.MiniGame mg;
private bool gameOpen;
[SerializeField] private int currentEventIndex;
private int dragTimes;
private void Update()
{
GameTitlePreview.GetComponent<Image>().enabled = true;
if (gameOpen)
{
if (Input.GetKeyDown(KeyCode.DownArrow))
{
UpdateIndex(1);
}
else if (Input.GetKeyDown(KeyCode.UpArrow))
{
UpdateIndex(-1);
}
}
}
public void OnExit()
#region Events
public void Drag()
{
GameTitlePreview.GetComponent<Image>().enabled = false;
if (Conductor.instance.NotStopped()) return;
if (Timeline.instance.CheckIfMouseInTimeline() && dragTimes < 1)
{
dragTimes++;
Timeline.instance.AddEventObject(mg.name + "/" + mg.actions[currentEventIndex].actionName, true);
}
}
public void Drop()
{
if (Conductor.instance.NotStopped()) return;
dragTimes = 0;
}
#endregion
#region Functions
public void UpdateIndex(int amount)
{
currentEventIndex += amount;
if (currentEventIndex < 0)
{
currentEventIndex = mg.actions.Count - 1;
}
else if (currentEventIndex > mg.actions.Count - 1)
{
currentEventIndex = 0;
}
SetColor(currentEventIndex);
}
public void SelectGame(string gameName)
{
DestroyEvents();
SelectedMinigame = gameName;
mg = EventCaller.instance.minigames.Find(c => c.displayName == gameName);
for (int i = 0; i < mg.actions.Count; i++)
{
GameObject e = Instantiate(EventRef, EventRef.transform.parent);
e.GetComponent<TMP_Text>().text = mg.actions[i].actionName;
e.SetActive(true);
}
gameOpen = true;
currentEventIndex = 0;
SetColor(0);
}
private void SetColor(int ind)
{
for (int i = 0; i < EventRef.transform.parent.childCount; i++) EventRef.transform.parent.GetChild(i).GetComponent<TMP_Text>().color = Color.white;
EventRef.transform.parent.GetChild(ind + 1).GetComponent<TMP_Text>().color = Color.cyan;
}
private void DestroyEvents()
{
for (int i = 1; i < EventRef.transform.parent.childCount; i++)
{
Destroy(EventRef.transform.parent.GetChild(i).gameObject);
}
gameOpen = false;
}
#endregion
}
}

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 0baf64619d1dc0749bfc3f9a4b8f7b47
guid: d9d826be8d1e71d4c971f5ed377ee873
MonoImporter:
externalObjects: {}
serializedVersion: 2

View file

@ -0,0 +1,30 @@
using UnityEngine;
using UnityEngine.UI;
namespace RhythmHeavenMania.Editor
{
public class GridGameSelectorGame : MonoBehaviour
{
public GameObject GameTitlePreview;
public GridGameSelector GridGameSelector;
public void OnClick()
{
GridGameSelector.SelectGame(this.gameObject.name);
}
public void OnEnter()
{
GameTitlePreview.GetComponent<Image>().enabled = true;
GameTitlePreview.transform.GetChild(0).GetComponent<TMPro.TMP_Text>().text = this.gameObject.name;
GameTitlePreview.transform.GetChild(0).gameObject.SetActive(true);
}
public void OnExit()
{
GameTitlePreview.GetComponent<Image>().enabled = false;
GameTitlePreview.transform.GetChild(0).gameObject.SetActive(false);
}
}
}

View file

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

View file

@ -26,11 +26,14 @@ namespace RhythmHeavenMania.Editor
[SerializeField] private RectTransform TimelineEventObjRef;
private RectTransform TimelineSongPosLine;
public static Timeline instance { get; private set; }
#region Initializers
public void Init()
{
instance = this;
for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++)
{
var entity = GameManager.instance.Beatmap.entities[i];
@ -178,6 +181,52 @@ namespace RhythmHeavenMania.Editor
int milliseconds = (int)(1000 * (time - minutes * 60 - seconds));
return string.Format("{0:00}:{1:00}:{2:000}", minutes, seconds, milliseconds);
}
public bool CheckIfMouseInTimeline()
{
return (this.gameObject.activeSelf && RectTransformUtility.RectangleContainsScreenPoint(TimelineContent.transform.parent.gameObject.GetComponent<RectTransform>(), Input.mousePosition, Camera.main));
}
#endregion
#region Functions
public void AddEventObject(string eventName, bool dragNDrop = false)
{
GameObject g = Instantiate(TimelineEventObjRef.gameObject, TimelineEventObjRef.parent);
g.transform.localPosition = new Vector3(0, 0);
g.transform.GetChild(1).GetComponent<TMP_Text>().text = eventName.Split('/')[1];
TimelineEventObj eventObj = g.GetComponent<TimelineEventObj>();
eventObj.Icon.sprite = Editor.GameIcon(eventName.Split(0));
EventCaller.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, g.GetComponent<RectTransform>().sizeDelta.y);
float length = gameAction.defaultLength;
eventObj.length = length;
}
g.SetActive(true);
Beatmap.Entity entity = new Beatmap.Entity();
entity.datamodel = eventName;
entity.eventObj = eventObj;
GameManager.instance.Beatmap.entities.Add(entity);
GameManager.instance.SortEventsList();
g.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition);
if (dragNDrop)
{
eventObj.OnDown();
}
// entity.eventObj = g.GetComponent<TimelineEventObj>();
// entity.track = (int)(g.transform.localPosition.y / 51.34f * -1);
}
#endregion
}
}

View file

@ -12,7 +12,7 @@ namespace RhythmHeavenMania.Editor
{
private float startPosX;
private float startPosY;
private bool isDragging;
public bool isDragging;
private Vector3 lastPos;
@ -28,7 +28,7 @@ namespace RhythmHeavenMania.Editor
private void Update()
{
if (Conductor.instance.isPlaying == true || Conductor.instance.isPaused)
if (Conductor.instance.NotStopped())
{
Cancel();
return;
@ -42,26 +42,29 @@ namespace RhythmHeavenMania.Editor
mousePos = Input.mousePosition;
mousePos = Camera.main.ScreenToWorldPoint(mousePos);
PosPreview.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0);
PosPreview.transform.localPosition = new Vector3(Mathp.Round2Nearest(PosPreview.transform.localPosition.x, 0.25f), Mathp.Round2Nearest(PosPreview.transform.localPosition.y, 51.34f));
this.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0);
this.transform.localPosition = new Vector3(Mathp.Round2Nearest(this.transform.localPosition.x, 0.25f), Mathp.Round2Nearest(this.transform.localPosition.y, 51.34f));
if (lastPos != transform.localPosition)
OnMove();
lastPos = PosPreview.transform.localPosition;
lastPos = this.transform.localPosition;
}
if (Input.GetMouseButtonUp(0))
OnUp();
}
private void OnMove()
{
if (GameManager.instance.Beatmap.entities.FindAll(c => c.beat == PosPreview.transform.localPosition.x && c.track == (int)(PosPreview.transform.localPosition.y / 51.34f * -1)).Count > 0)
if (GameManager.instance.Beatmap.entities.FindAll(c => c.beat == this.transform.localPosition.x && c.track == (int)(this.transform.localPosition.y / 51.34f * -1)).Count > 0)
{
PosPreview.GetComponent<Image>().color = Color.red;
// PosPreview.GetComponent<Image>().color = Color.red;
eligibleToMove = false;
}
else
{
PosPreview.GetComponent<Image>().color = Color.yellow;
// PosPreview.GetComponent<Image>().color = Color.yellow;
eligibleToMove = true;
}
}
@ -69,11 +72,11 @@ namespace RhythmHeavenMania.Editor
private void OnComplete()
{
var entity = GameManager.instance.Beatmap.entities[enemyIndex];
entity.beat = PosPreview.transform.localPosition.x;
entity.beat = this.transform.localPosition.x;
GameManager.instance.SortEventsList();
entity.track = (int)(PosPreview.transform.localPosition.y / 51.34f) * -1;
entity.track = (int)(this.transform.localPosition.y / 51.34f) * -1;
this.transform.localPosition = PosPreview.transform.localPosition;
// this.transform.localPosition = this.transform.localPosition;
// transform.DOLocalMove(PosPreview.transform.localPosition, 0.15f).SetEase(Ease.OutExpo);
}
@ -87,18 +90,17 @@ namespace RhythmHeavenMania.Editor
{
Vector3 mousePos;
PosPreview = Instantiate(PosPreviewRef, PosPreviewRef.transform.parent);
/*PosPreview = Instantiate(PosPreviewRef, PosPreviewRef.transform.parent);
PosPreview.sizeDelta = new Vector2(100 * transform.GetComponent<RectTransform>().sizeDelta.x, transform.GetComponent<RectTransform>().sizeDelta.y);
PosPreview.transform.localPosition = this.transform.localPosition;
PosPreview.GetComponent<Image>().enabled = true;
PosPreview.GetComponent<Image>().color = Color.yellow;
PosPreview.GetComponent<Image>().color = Color.yellow;*/
mousePos = Input.mousePosition;
mousePos = Camera.main.ScreenToWorldPoint(mousePos);
startPosX = mousePos.x - PosPreview.transform.position.x;
startPosY = mousePos.y - PosPreview.transform.position.y;
startPosX = mousePos.x - this.transform.position.x;
startPosY = mousePos.y - this.transform.position.y;
isDragging = true;
}
public void OnUp()

File diff suppressed because one or more lines are too long