mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-09 19:25:10 +00:00
Time hopping improvements although still a bit buggy
This commit is contained in:
parent
0686697150
commit
75c98a87fb
8 changed files with 111 additions and 131 deletions
|
@ -4074,7 +4074,7 @@ Canvas:
|
|||
m_RenderMode: 0
|
||||
m_Camera: {fileID: 2047408675}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
m_PixelPerfect: 1
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
|
@ -4767,7 +4767,7 @@ RectTransform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1791483799}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 90}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0.013888889, y: 0.013888889, z: 0.013888889}
|
||||
m_Children:
|
||||
- {fileID: 1110073995}
|
||||
|
|
|
@ -92,19 +92,6 @@ namespace RhythmHeavenMania
|
|||
if (!Conductor.instance.isPlaying)
|
||||
return;
|
||||
|
||||
/*if (Input.GetKeyDown(KeyCode.A))
|
||||
{
|
||||
Conductor.instance.SetBeat(Conductor.instance.songPositionInBeats + 3);
|
||||
|
||||
GetGame(currentGame).holder.GetComponent<Minigame>().OnTimeChange();
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
Conductor.instance.SetBeat(Conductor.instance.songPositionInBeats - 3);
|
||||
|
||||
GetGame(currentGame).holder.GetComponent<Minigame>().OnTimeChange();
|
||||
}*/
|
||||
|
||||
List<float> entities = Beatmap.entities.Select(c => c.beat).ToList();
|
||||
|
||||
if (currentEvent < Beatmap.entities.Count && currentEvent >= 0)
|
||||
|
@ -117,11 +104,18 @@ namespace RhythmHeavenMania
|
|||
|
||||
// GameManager entities should ALWAYS execute before gameplay entities
|
||||
for (int i = 0; i < gameManagerEntities.Count; i++)
|
||||
{
|
||||
var gameManagerEntity = gameManagerEntities[i];
|
||||
if ((gameManagerEntity.beat + eventCaller.GetGameAction(eventCaller.GetMinigame(gameManagerEntity.datamodel.Split(0)), gameManagerEntity.datamodel.Split(1)).defaultLength) > Conductor.instance.songPositionInBeats)
|
||||
{
|
||||
eventCaller.CallEvent(gameManagerEntities[i].datamodel);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < entitesAtSameBeat.Count; i++)
|
||||
{
|
||||
var entity = entitesAtSameBeat[i];
|
||||
if ((entity.beat + eventCaller.GetGameAction(eventCaller.GetMinigame(entity.datamodel.Split(0)), entity.datamodel.Split(1)).defaultLength) > Conductor.instance.songPositionInBeats)
|
||||
{
|
||||
// if game isn't loaded, preload game so whatever event that would be called will still run outside if needed
|
||||
if (entitesAtSameBeat[i].datamodel.Split('/')[0] != currentGame && !preloadedGames.Contains(preloadedGames.Find(c => c.name == entitesAtSameBeat[i].datamodel.Split('/')[0])))
|
||||
|
@ -130,12 +124,42 @@ namespace RhythmHeavenMania
|
|||
}
|
||||
eventCaller.CallEvent(entitesAtSameBeat[i].datamodel);
|
||||
}
|
||||
}
|
||||
|
||||
currentEvent += entitesAtSameBeat.Count + gameManagerEntities.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Play Events
|
||||
|
||||
public void Play(float beat)
|
||||
{
|
||||
StartCoroutine(PlayCo(beat));
|
||||
}
|
||||
|
||||
private IEnumerator PlayCo(float beat)
|
||||
{
|
||||
yield return null;
|
||||
Conductor.instance.Play(beat);
|
||||
SetCurrentEventToClosest(beat);
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
Conductor.instance.Pause();
|
||||
}
|
||||
|
||||
public void Stop(float beat)
|
||||
{
|
||||
Conductor.instance.Stop(beat);
|
||||
SetCurrentEventToClosest(beat);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region List Functions
|
||||
|
||||
public void SortEventsList()
|
||||
{
|
||||
Beatmap.entities.Sort((x, y) => x.beat.CompareTo(y.beat));
|
||||
|
@ -165,14 +189,13 @@ namespace RhythmHeavenMania
|
|||
newGame = Beatmap.entities[entities.IndexOf(Mathp.GetClosestInList(Beatmap.entities.FindAll(c => c.datamodel != "gameManager" && c.beat < Conductor.instance.songPositionInBeats).ToList().Select(c => c.beat).ToList(), beat))].datamodel.Split('/')[0];
|
||||
}
|
||||
|
||||
if (newGame != currentGame)
|
||||
{
|
||||
SwitchGame(newGame);
|
||||
}
|
||||
SetGame(newGame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void SwitchGame(string game)
|
||||
{
|
||||
if (currentGameSwitchIE != null) StopCoroutine(currentGameSwitchIE);
|
||||
|
|
|
@ -55,6 +55,8 @@ namespace RhythmHeavenMania.Games.Spaceball
|
|||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
try
|
||||
{
|
||||
var allPlayerActions = EventCaller.GetAllPlayerEntities("spaceball");
|
||||
int currentPlayerEvent = GameManager.instance.currentPlayerEvent - EventCaller.GetAllPlayerEntitiesExceptBeforeBeat("spaceball", Conductor.instance.songPositionInBeats).Count;
|
||||
|
@ -95,6 +97,11 @@ namespace RhythmHeavenMania.Games.Spaceball
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
// this technically isn't game breaking so oh well
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateCameraZoom()
|
||||
{
|
||||
|
|
|
@ -116,7 +116,6 @@ namespace RhythmHeavenMania.Editor
|
|||
TimelineEventObj e = GameManager.instance.Beatmap.entities[i].eventObj;
|
||||
if (selectionBox.Contains(Camera.main.WorldToScreenPoint(e.transform.position)))
|
||||
{
|
||||
print(RectTransformToScreenSpace(e.GetComponent<RectTransform>()));
|
||||
Selections.instance.DragSelect(e);
|
||||
selected++;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace RhythmHeavenMania.Editor
|
|||
if (Timeline.instance.CheckIfMouseInTimeline() && dragTimes < 1)
|
||||
{
|
||||
dragTimes++;
|
||||
Timeline.instance.AddEventObject(mg.name + "/" + mg.actions[currentEventIndex].actionName, true);
|
||||
Timeline.instance.AddEventObject(mg.name + "/" + mg.actions[currentEventIndex].actionName, true, new Vector3(0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,39 +14,5 @@ namespace RhythmHeavenMania.Editor
|
|||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
/*if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
if (!Timeline.instance.IsDraggingEvent())
|
||||
{
|
||||
if (clicked == false)
|
||||
{
|
||||
if (!Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
print('a');
|
||||
Selections.instance.DeselectAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clicked = false;*/
|
||||
}
|
||||
|
||||
public void Click(TimelineEventObj eventObj)
|
||||
{
|
||||
/*if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
Selections.instance.ShiftClickSelect(eventObj);
|
||||
}
|
||||
else
|
||||
{
|
||||
Selections.instance.ClickSelect(eventObj);
|
||||
}
|
||||
|
||||
clicked = true;*/
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,29 +38,6 @@ namespace RhythmHeavenMania.Editor
|
|||
|
||||
for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++)
|
||||
{
|
||||
/*var entity = GameManager.instance.Beatmap.entities[i];
|
||||
var e = GameManager.instance.Beatmap.entities[i];
|
||||
|
||||
EventCaller.GameAction gameAction = EventCaller.instance.GetGameAction(EventCaller.instance.GetMinigame(e.datamodel.Split(0)), e.datamodel.Split(1));
|
||||
|
||||
GameObject g = Instantiate(TimelineEventObjRef.gameObject, TimelineEventObjRef.parent);
|
||||
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];
|
||||
|
||||
TimelineEventObj eventObj = g.GetComponent<TimelineEventObj>();
|
||||
eventObj.Icon.sprite = Editor.GameIcon(e.datamodel.Split(0));
|
||||
|
||||
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);
|
||||
entity.eventObj = g.GetComponent<TimelineEventObj>();
|
||||
entity.track = (int)(g.transform.localPosition.y / 51.34f * -1);*/
|
||||
|
||||
var entity = GameManager.instance.Beatmap.entities[i];
|
||||
var e = GameManager.instance.Beatmap.entities[i];
|
||||
|
||||
|
@ -158,13 +135,13 @@ namespace RhythmHeavenMania.Editor
|
|||
TimelineSongPosLine.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
Conductor.instance.Play(time);
|
||||
GameManager.instance.Play(time);
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
// isPaused = true;
|
||||
Conductor.instance.Pause();
|
||||
GameManager.instance.Pause();
|
||||
}
|
||||
|
||||
public void Stop(float time)
|
||||
|
@ -175,7 +152,7 @@ namespace RhythmHeavenMania.Editor
|
|||
if (TimelineSongPosLine != null)
|
||||
Destroy(TimelineSongPosLine.gameObject);
|
||||
|
||||
Conductor.instance.Stop(time);
|
||||
GameManager.instance.Stop(time);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -217,16 +194,11 @@ namespace RhythmHeavenMania.Editor
|
|||
|
||||
g.SetActive(true);
|
||||
|
||||
var entity = GameManager.instance.Beatmap.entities[entityId];
|
||||
var e = GameManager.instance.Beatmap.entities[entityId];
|
||||
|
||||
entity.eventObj = g.GetComponent<TimelineEventObj>();
|
||||
entity.track = (int)(g.transform.localPosition.y / 51.34f * -1);
|
||||
|
||||
if (dragNDrop)
|
||||
{
|
||||
g.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
eventObj.OnDown();
|
||||
var mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
g.transform.position = new Vector3(mousePos.x, mousePos.y, 0);
|
||||
|
||||
|
||||
Beatmap.Entity en = new Beatmap.Entity();
|
||||
en.datamodel = eventName;
|
||||
|
@ -234,20 +206,30 @@ namespace RhythmHeavenMania.Editor
|
|||
|
||||
GameManager.instance.Beatmap.entities.Add(en);
|
||||
GameManager.instance.SortEventsList();
|
||||
|
||||
Selections.instance.ClickSelect(eventObj);
|
||||
eventObj.isDragging = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var entity = GameManager.instance.Beatmap.entities[entityId];
|
||||
var e = GameManager.instance.Beatmap.entities[entityId];
|
||||
|
||||
entity.eventObj = g.GetComponent<TimelineEventObj>();
|
||||
entity.track = (int)(g.transform.localPosition.y / 51.34f * -1);
|
||||
}
|
||||
|
||||
Editor.EventObjs.Add(eventObj);
|
||||
eventObjs.Add(eventObj);
|
||||
}
|
||||
|
||||
public void DestroyEventObject(TimelineEventObj eventObj)
|
||||
public void DestroyEventObject(Beatmap.Entity entity)
|
||||
{
|
||||
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(entity.eventObj);
|
||||
GameManager.instance.Beatmap.entities.Remove(entity);
|
||||
|
||||
Editor.EventObjs.Remove(eventObj);
|
||||
Destroy(entity.eventObj.gameObject);
|
||||
GameManager.instance.SortEventsList();
|
||||
}
|
||||
|
||||
public bool IsMouseAboveEvents()
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace RhythmHeavenMania.Editor
|
|||
[SerializeField] public Image Icon;
|
||||
|
||||
[Header("Properties")]
|
||||
private int enemyIndex;
|
||||
private Beatmap.Entity entity;
|
||||
public float length;
|
||||
private bool eligibleToMove = false;
|
||||
private bool lastVisible;
|
||||
|
@ -36,6 +36,8 @@ namespace RhythmHeavenMania.Editor
|
|||
|
||||
private void Update()
|
||||
{
|
||||
entity = GameManager.instance.Beatmap.entities.Find(a => a.eventObj == this);
|
||||
|
||||
mouseHovering = RectTransformUtility.RectangleContainsScreenPoint(GetComponent<RectTransform>(), Input.mousePosition, Camera.main);
|
||||
|
||||
#region Optimizations
|
||||
|
@ -57,6 +59,12 @@ namespace RhythmHeavenMania.Editor
|
|||
if (selected)
|
||||
{
|
||||
SetColor(1);
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Delete))
|
||||
{
|
||||
Selections.instance.Deselect(this);
|
||||
Timeline.instance.DestroyEventObject(entity);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -69,7 +77,6 @@ namespace RhythmHeavenMania.Editor
|
|||
return;
|
||||
}
|
||||
|
||||
enemyIndex = GameManager.instance.Beatmap.entities.FindIndex(a => a.eventObj == this);
|
||||
|
||||
if (Input.GetMouseButtonDown(0) && Timeline.instance.IsMouseAboveEvents())
|
||||
{
|
||||
|
@ -112,9 +119,6 @@ namespace RhythmHeavenMania.Editor
|
|||
lastPos = this.transform.localPosition;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Delete))
|
||||
Timeline.instance.DestroyEventObject(this);
|
||||
|
||||
}
|
||||
|
||||
private void OnMove()
|
||||
|
@ -131,7 +135,6 @@ namespace RhythmHeavenMania.Editor
|
|||
|
||||
private void OnComplete()
|
||||
{
|
||||
var entity = GameManager.instance.Beatmap.entities[enemyIndex];
|
||||
entity.beat = this.transform.localPosition.x;
|
||||
GameManager.instance.SortEventsList();
|
||||
entity.track = (int)(this.transform.localPosition.y / 51.34f) * -1;
|
||||
|
@ -216,7 +219,7 @@ namespace RhythmHeavenMania.Editor
|
|||
private void OnDestroy()
|
||||
{
|
||||
// better safety net than canada's healthcare system
|
||||
GameManager.instance.Beatmap.entities.Remove(GameManager.instance.Beatmap.entities.Find(c => c.eventObj = this));
|
||||
// GameManager.instance.Beatmap.entities.Remove(GameManager.instance.Beatmap.entities.Find(c => c.eventObj = this));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in a new issue