mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 08:47:37 +02:00
Event colors
This commit is contained in:
@ -21,6 +21,8 @@ namespace RhythmHeavenMania.Editor
|
||||
[Header("Components")]
|
||||
[SerializeField] private Timeline Timeline;
|
||||
|
||||
public static List<TimelineEventObj> EventObjs = new List<TimelineEventObj>();
|
||||
|
||||
public static Editor instance { get; private set; }
|
||||
|
||||
private void Start()
|
||||
|
@ -112,7 +112,10 @@ namespace RhythmHeavenMania.Editor
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
@ -223,10 +223,36 @@ namespace RhythmHeavenMania.Editor
|
||||
{
|
||||
eventObj.OnDown();
|
||||
}
|
||||
|
||||
Editor.EventObjs.Add(eventObj);
|
||||
|
||||
// entity.eventObj = g.GetComponent<TimelineEventObj>();
|
||||
// entity.track = (int)(g.transform.localPosition.y / 51.34f * -1);
|
||||
}
|
||||
|
||||
public void DestroyEventObject(TimelineEventObj eventObj)
|
||||
{
|
||||
var e = GameManager.instance.Beatmap.entities.Find(c => c.eventObj == eventObj);
|
||||
GameManager.instance.Beatmap.entities.Remove(e);
|
||||
GameManager.instance.SortEventsList();
|
||||
Destroy(eventObj.gameObject);
|
||||
|
||||
Editor.EventObjs.Remove(eventObj);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
|
||||
public void Move()
|
||||
{
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -25,9 +25,31 @@ namespace RhythmHeavenMania.Editor
|
||||
private int enemyIndex;
|
||||
public float length;
|
||||
private bool eligibleToMove = false;
|
||||
private bool lastVisible;
|
||||
|
||||
[Header("Colors")]
|
||||
public Color NormalCol;
|
||||
public Color SelectedCol;
|
||||
public Color DeleteCol;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// Optimizations
|
||||
|
||||
bool visible = GetComponent<RectTransform>().IsVisibleFrom(Camera.main);
|
||||
|
||||
if (visible != lastVisible)
|
||||
{
|
||||
for (int i = 0; i < this.transform.childCount; i++)
|
||||
{
|
||||
this.transform.GetChild(i).gameObject.SetActive(visible);
|
||||
}
|
||||
}
|
||||
|
||||
lastVisible = visible;
|
||||
|
||||
// -------------
|
||||
|
||||
if (Conductor.instance.NotStopped())
|
||||
{
|
||||
Cancel();
|
||||
@ -43,16 +65,25 @@ namespace RhythmHeavenMania.Editor
|
||||
mousePos = Camera.main.ScreenToWorldPoint(mousePos);
|
||||
|
||||
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));
|
||||
this.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.y, 51.34f), -51.34f * 3, 0));
|
||||
|
||||
if (lastPos != transform.localPosition)
|
||||
OnMove();
|
||||
|
||||
lastPos = this.transform.localPosition;
|
||||
|
||||
SetColor(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetColor(0);
|
||||
}
|
||||
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
OnUp();
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Delete))
|
||||
Timeline.instance.DestroyEventObject(this);
|
||||
}
|
||||
|
||||
private void OnMove()
|
||||
@ -110,5 +141,24 @@ namespace RhythmHeavenMania.Editor
|
||||
if (eligibleToMove) OnComplete();
|
||||
Cancel();
|
||||
}
|
||||
|
||||
public void SetColor(int type)
|
||||
{
|
||||
Color c = Color.white;
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
c = NormalCol;
|
||||
break;
|
||||
case 1:
|
||||
c = SelectedCol;
|
||||
break;
|
||||
case 2:
|
||||
c = DeleteCol;
|
||||
break;
|
||||
}
|
||||
|
||||
transform.GetChild(0).GetComponent<Image>().color = c;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user