mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 08:47:37 +02:00
Timeline entities added
This commit is contained in:
@ -26,8 +26,6 @@ namespace RhythmHeavenMania.Editor
|
||||
{
|
||||
instance = this;
|
||||
Initializer = GetComponent<Initializer>();
|
||||
|
||||
MainCanvas.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void Init()
|
||||
@ -36,8 +34,7 @@ namespace RhythmHeavenMania.Editor
|
||||
GameManager.instance.CursorCam.targetTexture = ScreenRenderTexture;
|
||||
Screen.texture = ScreenRenderTexture;
|
||||
|
||||
MainCanvas.gameObject.SetActive(true);
|
||||
|
||||
GameManager.instance.Init();
|
||||
Timeline.Init();
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -80
|
||||
executionOrder: -40
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
@ -4,6 +4,7 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
using TMPro;
|
||||
using Starpelly;
|
||||
|
||||
namespace RhythmHeavenMania.Editor
|
||||
{
|
||||
@ -24,10 +25,62 @@ namespace RhythmHeavenMania.Editor
|
||||
[SerializeField] private RectTransform TimelineSongPosLineRef;
|
||||
private RectTransform TimelineSongPosLine;
|
||||
|
||||
public RectTransform TestEVENTGO;
|
||||
|
||||
#region Initializers
|
||||
|
||||
public void Init()
|
||||
{
|
||||
for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++)
|
||||
{
|
||||
var entity = GameManager.instance.Beatmap.entities[i];
|
||||
|
||||
GameObject g = Instantiate(TestEVENTGO.gameObject, TestEVENTGO.parent);
|
||||
var e = GameManager.instance.Beatmap.entities[i];
|
||||
g.transform.localPosition = new Vector3(e.beat, Mathp.Round2Nearest(Random.Range(0, -205.36f), 51.34f));
|
||||
g.transform.GetChild(1).GetComponent<TMP_Text>().text = e.datamodel.Split('/')[1];
|
||||
|
||||
EventCaller.GameAction gameAction = EventCaller.instance.GetGameAction(EventCaller.instance.GetMinigame(e.datamodel.Split(0)), e.datamodel.Split(1));
|
||||
GameObject blocksHolder = g.transform.GetChild(0).gameObject;
|
||||
|
||||
if (gameAction != null)
|
||||
{
|
||||
blocksHolder.GetComponent<RectTransform>().sizeDelta = new Vector2(gameAction.defaultLength, blocksHolder.GetComponent<RectTransform>().sizeDelta.y);
|
||||
if (gameAction.eventBeats != null)
|
||||
{
|
||||
if (gameAction.eventBeats.Length > 0)
|
||||
{
|
||||
for (int k = 0; k < gameAction.eventBeats.Length; k++)
|
||||
{
|
||||
var ind = gameAction.eventBeats[k];
|
||||
if (gameAction.defaultLength > 0)
|
||||
{
|
||||
float length;
|
||||
|
||||
if (k + 1 >= gameAction.eventBeats.Length)
|
||||
length = gameAction.defaultLength - ind;
|
||||
else
|
||||
length = gameAction.eventBeats[k + 1];
|
||||
|
||||
if (gameAction.resizable)
|
||||
{
|
||||
length = entity.length;
|
||||
}
|
||||
|
||||
GameObject block = Instantiate(blocksHolder.transform.GetChild(0).gameObject, blocksHolder.transform);
|
||||
block.GetComponent<RectTransform>().sizeDelta = new Vector2(length, block.GetComponent<RectTransform>().sizeDelta.y);
|
||||
block.transform.localPosition = new Vector3(ind, block.transform.localPosition.y);
|
||||
block.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// g.GetComponent<RectTransform>().sizeDelta = new Vector2(gameAction.defaultLength, g.GetComponent<RectTransform>().sizeDelta.y);
|
||||
}
|
||||
|
||||
g.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -51,21 +104,21 @@ namespace RhythmHeavenMania.Editor
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
PlayCheck(true);
|
||||
PlayCheck(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayCheck(false);
|
||||
PlayCheck(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lastBeatPos = Conductor.instance.songPositionInBeats;
|
||||
|
||||
if (Input.GetMouseButtonDown(1) && !Conductor.instance.isPlaying)
|
||||
if (Input.GetMouseButton(1) && !Conductor.instance.isPlaying)
|
||||
{
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(TimelineContent, Input.mousePosition, Editor.instance.EditorCamera, out lastMousePos);
|
||||
TimelineSlider.localPosition = new Vector3(lastMousePos.x, TimelineSlider.transform.localPosition.y);
|
||||
TimelineSlider.localPosition = new Vector3(Mathp.Round2Nearest(lastMousePos.x + 0.12f, 0.25f), TimelineSlider.transform.localPosition.y);
|
||||
|
||||
Conductor.instance.SetBeat(TimelineSlider.transform.localPosition.x);
|
||||
}
|
||||
@ -87,16 +140,21 @@ namespace RhythmHeavenMania.Editor
|
||||
{
|
||||
if (fromStart)
|
||||
{
|
||||
if (Conductor.instance.isPlaying)
|
||||
Play(true);
|
||||
if (!Conductor.instance.isPlaying)
|
||||
{
|
||||
Play(false, TimelineSlider.transform.localPosition.x);
|
||||
}
|
||||
else
|
||||
Stop();
|
||||
{
|
||||
Stop(TimelineSlider.transform.localPosition.x);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Conductor.instance.isPlaying)
|
||||
{
|
||||
Play(false);
|
||||
Play(false, TimelineSongPosLine.transform.localPosition.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -105,9 +163,9 @@ namespace RhythmHeavenMania.Editor
|
||||
}
|
||||
}
|
||||
|
||||
public void Play(bool fromStart)
|
||||
public void Play(bool fromStart, float time)
|
||||
{
|
||||
if (fromStart) Stop();
|
||||
// if (fromStart) Stop();
|
||||
|
||||
if (!Conductor.instance.isPaused)
|
||||
{
|
||||
@ -115,7 +173,7 @@ namespace RhythmHeavenMania.Editor
|
||||
TimelineSongPosLine.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
Conductor.instance.Play();
|
||||
Conductor.instance.Play(time);
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
@ -124,7 +182,7 @@ namespace RhythmHeavenMania.Editor
|
||||
Conductor.instance.Pause();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
public void Stop(float time)
|
||||
{
|
||||
// isPaused = true;
|
||||
// timelineSlider.value = 0;
|
||||
@ -132,7 +190,7 @@ namespace RhythmHeavenMania.Editor
|
||||
if (TimelineSongPosLine != null)
|
||||
Destroy(TimelineSongPosLine.gameObject);
|
||||
|
||||
Conductor.instance.Stop();
|
||||
Conductor.instance.Stop(time);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
Reference in New Issue
Block a user