Game switching in every game

This commit is contained in:
Braedon
2022-01-15 13:46:50 -05:00
parent 0d5b938c52
commit cb25e97699
5 changed files with 68 additions and 24 deletions

View File

@ -48,7 +48,14 @@ namespace RhythmHeavenMania.Editor
if (Timeline.instance.CheckIfMouseInTimeline() && dragTimes < 1)
{
dragTimes++;
Timeline.instance.AddEventObject(mg.name + "/" + mg.actions[currentEventIndex].actionName, true, new Vector3(0, 0));
if (currentEventIndex == 0)
{
Timeline.instance.AddEventObject($"gameManager/switchGame/{mg.name}", true, new Vector3(0, 0));
}
else
{
Timeline.instance.AddEventObject(mg.name + "/" + mg.actions[currentEventIndex - 1].actionName, true, new Vector3(0, 0));
}
}
}
@ -69,9 +76,9 @@ namespace RhythmHeavenMania.Editor
if (currentEventIndex < 0)
{
currentEventIndex = mg.actions.Count - 1;
currentEventIndex = EventRef.transform.parent.childCount - 2;
}
else if (currentEventIndex > mg.actions.Count - 1)
else if (currentEventIndex > EventRef.transform.parent.childCount - 2)
{
currentEventIndex = 0;
}
@ -100,18 +107,33 @@ namespace RhythmHeavenMania.Editor
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);
}
AddEvents();
gameOpen = true;
currentEventIndex = 0;
SetColor(0);
}
private void AddEvents()
{
if (mg.name != "gameManager")
{
GameObject sg = Instantiate(EventRef, EventRef.transform.parent);
sg.GetComponent<TMP_Text>().text = "switchGame";
sg.SetActive(true);
}
for (int i = 0; i < mg.actions.Count; i++)
{
if (mg.actions[i].actionName != "switchGame")
{
GameObject e = Instantiate(EventRef, EventRef.transform.parent);
e.GetComponent<TMP_Text>().text = mg.actions[i].actionName;
e.SetActive(true);
}
}
}
private void SetColor(int ind)
{
for (int i = 0; i < EventRef.transform.parent.childCount; i++)

View File

@ -121,14 +121,16 @@ namespace RhythmHeavenMania.Editor
}
lastBeatPos = Conductor.instance.songPositionInBeats;
if (Input.GetMouseButton(1) && !Conductor.instance.isPlaying && CheckIfMouseInTimeline())
{
RectTransformUtility.ScreenPointToLocalPointInRectangle(TimelineContent, Input.mousePosition, Editor.instance.EditorCamera, out lastMousePos);
TimelineSlider.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(lastMousePos.x + 0.12f, 0.25f), 0, Mathf.Infinity), TimelineSlider.transform.localPosition.y);
Conductor.instance.SetBeat(TimelineSlider.transform.localPosition.x);
if (TimelineSlider.localPosition.x != lastBeatPos)
Conductor.instance.SetBeat(TimelineSlider.transform.localPosition.x);
lastBeatPos = TimelineSlider.localPosition.x;
}
float moveSpeed = 750;
@ -276,6 +278,10 @@ namespace RhythmHeavenMania.Editor
g.transform.GetChild(2).GetComponent<TMP_Text>().text = eventName.Split('/')[1];
TimelineEventObj eventObj = g.GetComponent<TimelineEventObj>();
if (eventName.Split(1) == "switchGame")
eventObj.Icon.sprite = Editor.GameIcon(eventName.Split(2));
else
eventObj.Icon.sprite = Editor.GameIcon(eventName.Split(0));
EventCaller.GameAction gameAction = EventCaller.instance.GetGameAction(EventCaller.instance.GetMinigame(eventName.Split(0)), eventName.Split(1));