2022-01-06 00:11:33 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
using TMPro;
|
2022-01-08 16:42:48 +00:00
|
|
|
using Starpelly;
|
2022-01-06 00:11:33 +00:00
|
|
|
|
|
|
|
namespace RhythmHeavenMania.Editor
|
|
|
|
{
|
|
|
|
public class Timeline : MonoBehaviour
|
|
|
|
{
|
|
|
|
[Header("Song Positions")]
|
|
|
|
[SerializeField] private TMP_Text SongBeat;
|
|
|
|
[SerializeField] private TMP_Text SongPos;
|
|
|
|
|
|
|
|
[Header("Timeline Properties")]
|
|
|
|
private float lastBeatPos = 0;
|
2022-01-07 23:51:08 +00:00
|
|
|
private Vector2 lastMousePos;
|
2022-01-13 03:59:54 +00:00
|
|
|
public List<TimelineEventObj> eventObjs = new List<TimelineEventObj>();
|
|
|
|
private bool lastFrameDrag;
|
2022-01-14 22:46:14 +00:00
|
|
|
public int LayerCount = 4;
|
2022-01-15 17:45:08 +00:00
|
|
|
public bool metronomeEnabled;
|
2022-01-17 19:23:18 +00:00
|
|
|
public bool resizable;
|
2022-01-06 00:11:33 +00:00
|
|
|
|
|
|
|
[Header("Timeline Components")]
|
2022-01-07 11:36:23 +00:00
|
|
|
[SerializeField] private RectTransform TimelineSlider;
|
2022-01-07 23:51:08 +00:00
|
|
|
[SerializeField] private TMP_Text TimelinePlaybackBeat;
|
2022-01-07 11:36:23 +00:00
|
|
|
[SerializeField] private RectTransform TimelineContent;
|
|
|
|
[SerializeField] private RectTransform TimelineSongPosLineRef;
|
2022-01-09 23:35:55 +00:00
|
|
|
[SerializeField] private RectTransform TimelineEventObjRef;
|
2022-01-14 22:46:14 +00:00
|
|
|
[SerializeField] private RectTransform LayersRect;
|
2022-01-07 11:36:23 +00:00
|
|
|
private RectTransform TimelineSongPosLine;
|
2022-01-06 00:11:33 +00:00
|
|
|
|
2022-01-15 05:20:47 +00:00
|
|
|
[Header("Timeline Playbar")]
|
|
|
|
[SerializeField] private Button PlayBTN;
|
|
|
|
[SerializeField] private Button PauseBTN;
|
|
|
|
[SerializeField] private Button StopBTN;
|
|
|
|
[SerializeField] private Button MetronomeBTN;
|
|
|
|
|
2022-01-11 00:17:29 +00:00
|
|
|
public static Timeline instance { get; private set; }
|
2022-01-08 16:42:48 +00:00
|
|
|
|
2022-01-06 00:11:33 +00:00
|
|
|
#region Initializers
|
|
|
|
|
|
|
|
public void Init()
|
|
|
|
{
|
2022-01-11 00:17:29 +00:00
|
|
|
instance = this;
|
|
|
|
|
2022-01-08 16:42:48 +00:00
|
|
|
for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++)
|
|
|
|
{
|
2022-01-13 03:59:54 +00:00
|
|
|
var entity = GameManager.instance.Beatmap.entities[i];
|
|
|
|
var e = GameManager.instance.Beatmap.entities[i];
|
|
|
|
|
2022-01-14 22:46:14 +00:00
|
|
|
AddEventObject(e.datamodel, false, new Vector3(e.beat, Mathp.Round2Nearest(Random.Range(0, -LayersRect.rect.height), LayerHeight())), i);
|
2022-01-08 16:42:48 +00:00
|
|
|
}
|
2022-01-14 02:33:51 +00:00
|
|
|
|
|
|
|
TimelineSlider.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
|
|
|
|
TimelineSlider.GetChild(1).GetComponent<Image>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
|
|
|
|
TimelineSlider.GetChild(2).GetComponent<TMP_Text>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
|
|
|
|
TimelineSlider.GetChild(3).GetComponent<TMP_Text>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
|
|
|
|
TimelineSongPosLineRef.GetComponent<Image>().color = EditorTheme.theme.properties.CurrentTimeMarkerCol.Hex2RGB();
|
2022-01-15 05:20:47 +00:00
|
|
|
|
|
|
|
PlayBTN.onClick.AddListener(delegate
|
|
|
|
{
|
|
|
|
if (Conductor.instance.isPaused)
|
|
|
|
PlayCheck(false);
|
|
|
|
else
|
|
|
|
PlayCheck(true);
|
|
|
|
});
|
2022-01-17 02:31:49 +00:00
|
|
|
PauseBTN.onClick.AddListener(delegate
|
|
|
|
{
|
|
|
|
if (Conductor.instance.isPlaying && !Conductor.instance.isPaused)
|
|
|
|
PlayCheck(false);
|
|
|
|
});
|
|
|
|
StopBTN.onClick.AddListener(delegate
|
|
|
|
{
|
|
|
|
if (Conductor.instance.isPlaying || Conductor.instance.isPaused)
|
|
|
|
PlayCheck(true);
|
|
|
|
});
|
|
|
|
|
2022-01-15 17:45:08 +00:00
|
|
|
MetronomeBTN.onClick.AddListener(delegate
|
|
|
|
{
|
|
|
|
if (!Conductor.instance.metronome)
|
|
|
|
{
|
|
|
|
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = "009FC6".Hex2RGB();
|
|
|
|
Conductor.instance.metronome = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
|
|
|
Conductor.instance.metronome = false;
|
|
|
|
}
|
|
|
|
});
|
2022-01-15 05:20:47 +00:00
|
|
|
|
2022-01-18 00:40:23 +00:00
|
|
|
Tooltip.AddTooltip(PlayBTN.gameObject, "Play <color=#adadad>[Space]</color>");
|
|
|
|
Tooltip.AddTooltip(PauseBTN.gameObject, "Pause <color=#adadad>[Shift + Space]</color>");
|
|
|
|
Tooltip.AddTooltip(StopBTN.gameObject, "Stop <color=#adadad>[Space]</color>");
|
|
|
|
Tooltip.AddTooltip(MetronomeBTN.gameObject, "Metronome");
|
2022-01-15 05:20:47 +00:00
|
|
|
|
|
|
|
SetTimeButtonColors(true, false, false);
|
2022-01-15 17:45:08 +00:00
|
|
|
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
2022-01-06 00:11:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
2022-01-07 23:51:08 +00:00
|
|
|
if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused)
|
|
|
|
{
|
|
|
|
SongBeat.text = $"Beat {string.Format("{0:0.000}", TimelineSlider.localPosition.x)}";
|
|
|
|
SongPos.text = FormatTime(Conductor.instance.GetSongPosFromBeat(TimelineSlider.localPosition.x));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SongBeat.text = $"Beat {string.Format("{0:0.000}", Conductor.instance.songPositionInBeats)}";
|
|
|
|
SongPos.text = FormatTime(Conductor.instance.songPosition);
|
|
|
|
}
|
2022-01-06 00:11:33 +00:00
|
|
|
|
2022-01-07 23:51:08 +00:00
|
|
|
SliderControl();
|
2022-01-06 00:11:33 +00:00
|
|
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.Space))
|
|
|
|
{
|
|
|
|
if (Input.GetKey(KeyCode.LeftShift))
|
|
|
|
{
|
2022-01-08 16:42:48 +00:00
|
|
|
PlayCheck(false);
|
2022-01-06 00:11:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-08 16:42:48 +00:00
|
|
|
PlayCheck(true);
|
2022-01-06 00:11:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-15 07:08:23 +00:00
|
|
|
if (Input.GetMouseButton(1) && !Conductor.instance.isPlaying && CheckIfMouseInTimeline())
|
2022-01-07 23:51:08 +00:00
|
|
|
{
|
|
|
|
RectTransformUtility.ScreenPointToLocalPointInRectangle(TimelineContent, Input.mousePosition, Editor.instance.EditorCamera, out lastMousePos);
|
2022-01-15 07:08:23 +00:00
|
|
|
TimelineSlider.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(lastMousePos.x + 0.12f, 0.25f), 0, Mathf.Infinity), TimelineSlider.transform.localPosition.y);
|
2022-01-07 23:51:08 +00:00
|
|
|
|
2022-01-15 18:46:50 +00:00
|
|
|
if (TimelineSlider.localPosition.x != lastBeatPos)
|
|
|
|
Conductor.instance.SetBeat(TimelineSlider.transform.localPosition.x);
|
|
|
|
|
|
|
|
lastBeatPos = TimelineSlider.localPosition.x;
|
2022-01-07 23:51:08 +00:00
|
|
|
}
|
2022-01-15 05:20:47 +00:00
|
|
|
|
|
|
|
float moveSpeed = 750;
|
|
|
|
if (Input.GetKey(KeyCode.LeftShift)) moveSpeed *= 2;
|
|
|
|
|
|
|
|
if (Input.GetKey(KeyCode.LeftArrow))
|
|
|
|
{
|
|
|
|
TimelineContent.transform.localPosition += new Vector3(moveSpeed * Time.deltaTime, 0);
|
|
|
|
}
|
|
|
|
else if (Input.GetKey(KeyCode.RightArrow))
|
|
|
|
{
|
|
|
|
TimelineContent.transform.localPosition += new Vector3(-moveSpeed * Time.deltaTime, 0);
|
|
|
|
}
|
|
|
|
|
2022-01-19 05:40:49 +00:00
|
|
|
if (Conductor.instance.isPlaying)
|
|
|
|
TimelineContent.transform.localPosition = new Vector3((-Conductor.instance.songPositionInBeats * 100) + 200, TimelineContent.transform.localPosition.y);
|
|
|
|
|
2022-01-15 05:20:47 +00:00
|
|
|
TimelineContent.transform.localPosition = new Vector3(Mathf.Clamp(TimelineContent.transform.localPosition.x, Mathf.NegativeInfinity, 0), TimelineContent.transform.localPosition.y);
|
2022-01-06 00:11:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void SliderControl()
|
|
|
|
{
|
2022-01-07 23:51:08 +00:00
|
|
|
TimelinePlaybackBeat.text = $"Beat {string.Format("{0:0.000}", TimelineSlider.localPosition.x)}";
|
|
|
|
|
2022-01-07 11:36:23 +00:00
|
|
|
if (TimelineSongPosLine != null)
|
2022-01-06 00:11:33 +00:00
|
|
|
{
|
2022-01-14 22:46:14 +00:00
|
|
|
TimelineSongPosLine.transform.localPosition = new Vector3(Conductor.instance.songPositionInBeats, TimelineSongPosLine.transform.localPosition.y);
|
|
|
|
TimelineSongPosLine.transform.localScale = new Vector3(1f / TimelineContent.transform.localScale.x, TimelineSongPosLine.transform.localScale.y, 1);
|
2022-01-06 00:11:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#region PlayChecks
|
|
|
|
public void PlayCheck(bool fromStart)
|
|
|
|
{
|
|
|
|
if (fromStart)
|
|
|
|
{
|
2022-01-17 02:31:49 +00:00
|
|
|
if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused)
|
2022-01-08 16:42:48 +00:00
|
|
|
{
|
|
|
|
Play(false, TimelineSlider.transform.localPosition.x);
|
|
|
|
}
|
2022-01-06 00:11:33 +00:00
|
|
|
else
|
2022-01-08 16:42:48 +00:00
|
|
|
{
|
|
|
|
Stop(TimelineSlider.transform.localPosition.x);
|
|
|
|
}
|
|
|
|
|
2022-01-06 00:11:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-07 23:51:08 +00:00
|
|
|
if (!Conductor.instance.isPlaying)
|
2022-01-06 00:11:33 +00:00
|
|
|
{
|
2022-01-17 02:31:49 +00:00
|
|
|
if (TimelineSongPosLine == null)
|
|
|
|
{
|
|
|
|
Play(false, TimelineSlider.transform.localPosition.x);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Play(false, TimelineSongPosLine.transform.localPosition.x);
|
|
|
|
}
|
2022-01-06 00:11:33 +00:00
|
|
|
}
|
2022-01-17 02:31:49 +00:00
|
|
|
else if (!Conductor.instance.isPaused)
|
2022-01-06 00:11:33 +00:00
|
|
|
{
|
|
|
|
Pause();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-08 16:42:48 +00:00
|
|
|
public void Play(bool fromStart, float time)
|
2022-01-06 00:11:33 +00:00
|
|
|
{
|
2022-01-08 16:42:48 +00:00
|
|
|
// if (fromStart) Stop();
|
2022-01-07 11:36:23 +00:00
|
|
|
|
|
|
|
if (!Conductor.instance.isPaused)
|
|
|
|
{
|
|
|
|
TimelineSongPosLine = Instantiate(TimelineSongPosLineRef, TimelineSongPosLineRef.parent).GetComponent<RectTransform>();
|
|
|
|
TimelineSongPosLine.gameObject.SetActive(true);
|
|
|
|
}
|
|
|
|
|
2022-01-14 00:35:41 +00:00
|
|
|
GameManager.instance.Play(time);
|
2022-01-15 05:20:47 +00:00
|
|
|
|
|
|
|
SetTimeButtonColors(false, true, true);
|
2022-01-06 00:11:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Pause()
|
|
|
|
{
|
|
|
|
// isPaused = true;
|
2022-01-14 00:35:41 +00:00
|
|
|
GameManager.instance.Pause();
|
2022-01-15 05:20:47 +00:00
|
|
|
|
|
|
|
SetTimeButtonColors(true, false, true);
|
2022-01-06 00:11:33 +00:00
|
|
|
}
|
|
|
|
|
2022-01-08 16:42:48 +00:00
|
|
|
public void Stop(float time)
|
2022-01-06 00:11:33 +00:00
|
|
|
{
|
|
|
|
// isPaused = true;
|
|
|
|
// timelineSlider.value = 0;
|
2022-01-07 11:36:23 +00:00
|
|
|
|
2022-01-07 23:51:08 +00:00
|
|
|
if (TimelineSongPosLine != null)
|
2022-01-07 11:36:23 +00:00
|
|
|
Destroy(TimelineSongPosLine.gameObject);
|
|
|
|
|
2022-01-14 00:35:41 +00:00
|
|
|
GameManager.instance.Stop(time);
|
2022-01-15 05:20:47 +00:00
|
|
|
|
|
|
|
SetTimeButtonColors(true, false, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetTimeButtonColors(bool playEnabled, bool pauseEnabled, bool stopEnabled)
|
|
|
|
{
|
|
|
|
if (playEnabled)
|
|
|
|
{
|
|
|
|
PlayBTN.transform.GetChild(0).GetComponent<Image>().color = Color.green;
|
2022-01-17 05:00:26 +00:00
|
|
|
PlayBTN.enabled = true;
|
2022-01-15 05:20:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlayBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
2022-01-17 05:00:26 +00:00
|
|
|
PlayBTN.enabled = false;
|
2022-01-15 05:20:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pauseEnabled)
|
|
|
|
{
|
2022-01-17 05:00:26 +00:00
|
|
|
PauseBTN.enabled = true;
|
2022-01-15 05:20:47 +00:00
|
|
|
PauseBTN.transform.GetChild(0).GetComponent<Image>().color = Color.blue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ PauseBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
2022-01-17 05:00:26 +00:00
|
|
|
PauseBTN.enabled = false;
|
2022-01-15 05:20:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (stopEnabled)
|
|
|
|
{
|
2022-01-17 05:00:26 +00:00
|
|
|
StopBTN.enabled = true;
|
2022-01-15 05:20:47 +00:00
|
|
|
StopBTN.transform.GetChild(0).GetComponent<Image>().color = Color.red;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
StopBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
2022-01-17 05:00:26 +00:00
|
|
|
StopBTN.enabled = false;
|
2022-01-15 05:20:47 +00:00
|
|
|
}
|
2022-01-06 00:11:33 +00:00
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Extras
|
|
|
|
private string FormatTime(float time)
|
|
|
|
{
|
|
|
|
int minutes = (int)time / 60;
|
|
|
|
int seconds = (int)time - 60 * minutes;
|
|
|
|
int milliseconds = (int)(1000 * (time - minutes * 60 - seconds));
|
|
|
|
return string.Format("{0:00}:{1:00}:{2:000}", minutes, seconds, milliseconds);
|
|
|
|
}
|
2022-01-11 00:17:29 +00:00
|
|
|
|
|
|
|
public bool CheckIfMouseInTimeline()
|
|
|
|
{
|
|
|
|
return (this.gameObject.activeSelf && RectTransformUtility.RectangleContainsScreenPoint(TimelineContent.transform.parent.gameObject.GetComponent<RectTransform>(), Input.mousePosition, Camera.main));
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Functions
|
|
|
|
|
2022-01-13 03:59:54 +00:00
|
|
|
public void AddEventObject(string eventName, bool dragNDrop = false, Vector3 pos = new Vector3(), int entityId = 0)
|
2022-01-11 00:17:29 +00:00
|
|
|
{
|
|
|
|
GameObject g = Instantiate(TimelineEventObjRef.gameObject, TimelineEventObjRef.parent);
|
2022-01-13 03:59:54 +00:00
|
|
|
g.transform.localPosition = pos;
|
2022-01-17 20:08:32 +00:00
|
|
|
g.transform.GetChild(3).GetComponent<TMP_Text>().text = eventName.Split('/')[1];
|
2022-01-11 00:17:29 +00:00
|
|
|
|
|
|
|
TimelineEventObj eventObj = g.GetComponent<TimelineEventObj>();
|
2022-01-15 18:46:50 +00:00
|
|
|
|
|
|
|
if (eventName.Split(1) == "switchGame")
|
|
|
|
eventObj.Icon.sprite = Editor.GameIcon(eventName.Split(2));
|
|
|
|
else
|
2022-01-11 00:17:29 +00:00
|
|
|
eventObj.Icon.sprite = Editor.GameIcon(eventName.Split(0));
|
|
|
|
|
2022-01-17 19:23:18 +00:00
|
|
|
Minigames.GameAction gameAction = EventCaller.instance.GetGameAction(EventCaller.instance.GetMinigame(eventName.Split(0)), eventName.Split(1));
|
2022-01-11 00:17:29 +00:00
|
|
|
|
|
|
|
if (gameAction != null)
|
|
|
|
{
|
2022-01-17 19:23:18 +00:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
}
|
2022-01-11 00:17:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g.SetActive(true);
|
|
|
|
|
|
|
|
if (dragNDrop)
|
|
|
|
{
|
2022-01-14 00:35:41 +00:00
|
|
|
var mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
|
|
|
g.transform.position = new Vector3(mousePos.x, mousePos.y, 0);
|
|
|
|
|
2022-01-13 03:59:54 +00:00
|
|
|
Beatmap.Entity en = new Beatmap.Entity();
|
|
|
|
en.datamodel = eventName;
|
|
|
|
en.eventObj = eventObj;
|
|
|
|
|
|
|
|
GameManager.instance.Beatmap.entities.Add(en);
|
|
|
|
GameManager.instance.SortEventsList();
|
2022-01-14 00:35:41 +00:00
|
|
|
|
|
|
|
Selections.instance.ClickSelect(eventObj);
|
2022-01-17 23:54:25 +00:00
|
|
|
eventObj.moving = true;
|
2022-01-14 00:35:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var entity = GameManager.instance.Beatmap.entities[entityId];
|
|
|
|
|
|
|
|
entity.eventObj = g.GetComponent<TimelineEventObj>();
|
2022-01-14 22:46:14 +00:00
|
|
|
entity.track = (int)(g.transform.localPosition.y / LayerHeight() * -1);
|
2022-01-11 00:17:29 +00:00
|
|
|
}
|
2022-01-12 03:29:27 +00:00
|
|
|
|
|
|
|
Editor.EventObjs.Add(eventObj);
|
2022-01-13 03:59:54 +00:00
|
|
|
eventObjs.Add(eventObj);
|
2022-01-11 00:17:29 +00:00
|
|
|
}
|
|
|
|
|
2022-01-14 00:35:41 +00:00
|
|
|
public void DestroyEventObject(Beatmap.Entity entity)
|
2022-01-12 03:29:27 +00:00
|
|
|
{
|
2022-01-14 00:35:41 +00:00
|
|
|
Editor.EventObjs.Remove(entity.eventObj);
|
|
|
|
GameManager.instance.Beatmap.entities.Remove(entity);
|
2022-01-12 03:29:27 +00:00
|
|
|
|
2022-01-14 00:35:41 +00:00
|
|
|
Destroy(entity.eventObj.gameObject);
|
|
|
|
GameManager.instance.SortEventsList();
|
2022-01-12 03:29:27 +00:00
|
|
|
}
|
|
|
|
|
2022-01-13 03:59:54 +00:00
|
|
|
public bool IsMouseAboveEvents()
|
|
|
|
{
|
|
|
|
return Timeline.instance.eventObjs.FindAll(c => c.mouseHovering == true).Count > 0;
|
|
|
|
}
|
|
|
|
|
2022-01-17 23:54:25 +00:00
|
|
|
public bool InteractingWithEvents()
|
2022-01-13 03:59:54 +00:00
|
|
|
{
|
2022-01-17 23:54:25 +00:00
|
|
|
return eventObjs.FindAll(c => c.moving == true).Count > 0 || eventObjs.FindAll(c => c.resizing == true).Count > 0;
|
2022-01-13 03:59:54 +00:00
|
|
|
}
|
|
|
|
|
2022-01-14 22:46:14 +00:00
|
|
|
public float SnapToLayer(float y)
|
|
|
|
{
|
|
|
|
float size = LayerHeight();
|
|
|
|
return Mathf.Clamp(Mathp.Round2Nearest(y, size), -size * 3, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public float LayerHeight()
|
|
|
|
{
|
|
|
|
return LayersRect.rect.height / 4;
|
|
|
|
}
|
|
|
|
|
2022-01-12 03:29:27 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Commands
|
|
|
|
|
|
|
|
public void Move()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Undo()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-01-06 00:11:33 +00:00
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|