Custom snap interval, but not in the editor (yet)

This commit is contained in:
Braedon
2022-02-11 20:15:36 -05:00
parent 75e25ceac0
commit c04f994d1b
19 changed files with 1037 additions and 1109 deletions

View File

@ -92,14 +92,13 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
if (pluckState == 1)
{
var hairDirection = tweezers.tweezerSpriteTrans.position - holder.transform.position;
Vector3 tst = tweezers.tweezerSpriteTrans.position;
var hairDirection = new Vector3(tst.x + 0.173f, tst.y) - holder.transform.position;
holder.transform.rotation = Quaternion.FromToRotation(Vector3.down, hairDirection);
float normalizedBeat = Conductor.instance.GetPositionFromBeat(createBeat + game.tweezerBeatOffset + game.beatInterval, 0.5f);
anim.Play("LoopPull", 0, normalizedBeat);
tweezers.anim.Play("Tweezers_LongPluck", 0, normalizedBeat);
// float angleBetweenTweezersAndHair = angleBtw2Points(tweezers.transform.position, holder.transform.position);
// holder.transform.rotation = Quaternion.Euler(new Vector3(0, 0, angleBetweenTweezersAndHair));
// Auto-release if holding at release time.
if (normalizedBeat >= 1f)
@ -109,12 +108,6 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
loop.transform.localScale = Vector2.one / holder.transform.localScale;
}
float angleBtw2Points(Vector3 a, Vector3 b)
{
return Mathf.Atan2(a.y - b.y, a.x - b.x) * Mathf.Rad2Deg;
}
public void Ace()
{
tweezers.LongPluck(true, this);

View File

@ -182,7 +182,7 @@ namespace RhythmHeavenMania.Editor
{
if (Input.GetKeyDown(KeyCode.S))
{
SaveRemix(false);
// SaveRemix(false);
}
}
}

View File

@ -83,7 +83,7 @@ namespace RhythmHeavenMania.Editor.Track
if (create == true)
{
tempoChange.transform.position = new Vector3(Editor.instance.EditorCamera.ScreenToWorldPoint(Input.mousePosition).x + 0.08f, tempoChange.transform.position.y);
tempoChange.transform.localPosition = new Vector3(Starpelly.Mathp.Round2Nearest(tempoChange.transform.localPosition.x, 0.25f), tempoChange.transform.localPosition.y);
tempoChange.transform.localPosition = new Vector3(Starpelly.Mathp.Round2Nearest(tempoChange.transform.localPosition.x, Timeline.SnapInterval()), tempoChange.transform.localPosition.y);
Beatmap.TempoChange tempoC = new Beatmap.TempoChange();
tempoC.beat = tempoChange.transform.localPosition.x;

View File

@ -71,7 +71,7 @@ namespace RhythmHeavenMania.Editor.Track
Vector3 mousePos = Editor.instance.EditorCamera.ScreenToWorldPoint(Input.mousePosition);
transform.position = new Vector3(mousePos.x - startPosX, transform.position.y, 0);
transform.localPosition = new Vector3(Mathf.Clamp(Starpelly.Mathp.Round2Nearest(transform.localPosition.x, 0.25f), 0, Mathf.Infinity), transform.localPosition.y);
transform.localPosition = new Vector3(Mathf.Clamp(Starpelly.Mathp.Round2Nearest(transform.localPosition.x, Timeline.SnapInterval()), 0, Mathf.Infinity), transform.localPosition.y);
}
if (Input.GetMouseButtonUp(0))
{

View File

@ -26,6 +26,9 @@ namespace RhythmHeavenMania.Editor.Track
public bool resizable;
private bool movingPlayback;
public CurrentTimelineState timelineState = new CurrentTimelineState();
public float snapInterval = 0.25f; // 4/4
public static float SnapInterval() { return instance.snapInterval; }
public class CurrentTimelineState
{
@ -256,7 +259,7 @@ namespace RhythmHeavenMania.Editor.Track
if (movingPlayback)
{
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);
TimelineSlider.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(lastMousePos.x + 0.12f, Timeline.SnapInterval()), 0, Mathf.Infinity), TimelineSlider.transform.localPosition.y);
if (TimelineSlider.localPosition.x != lastBeatPos)
Conductor.instance.SetBeat(TimelineSlider.transform.localPosition.x);
@ -576,7 +579,7 @@ namespace RhythmHeavenMania.Editor.Track
public void SetPlaybackSpeed(float speed)
{
float spd = Mathp.Round2Nearest(speed, 0.25f);
float spd = Mathp.Round2Nearest(speed, Timeline.SnapInterval());
PlaybackSpeed.transform.GetChild(3).GetComponent<TMP_Text>().text = $"Playback Speed: {spd}x";
Conductor.instance.musicSource.pitch = spd;
PlaybackSpeed.value = spd;

View File

@ -149,7 +149,7 @@ namespace RhythmHeavenMania.Editor.Track
lastPos_ = transform.localPosition;
this.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0);
this.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(this.transform.localPosition.y));
this.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.x, Timeline.SnapInterval()), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(this.transform.localPosition.y));
// moveTemp.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0);
// moveTemp.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(moveTemp.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(moveTemp.transform.localPosition.y));
@ -171,9 +171,9 @@ namespace RhythmHeavenMania.Editor.Track
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition, Editor.instance.EditorCamera, out mousePos);
sizeDelta = new Vector2(-mousePos.x + 0.15f, sizeDelta.y);
sizeDelta = new Vector2(Mathf.Clamp(sizeDelta.x, 0.25f, rectTransform.localPosition.x), sizeDelta.y);
sizeDelta = new Vector2(Mathf.Clamp(sizeDelta.x, Timeline.SnapInterval(), rectTransform.localPosition.x), sizeDelta.y);
rectTransform.sizeDelta = new Vector2(Mathp.Round2Nearest(sizeDelta.x, 0.25f), sizeDelta.y);
rectTransform.sizeDelta = new Vector2(Mathp.Round2Nearest(sizeDelta.x, Timeline.SnapInterval()), sizeDelta.y);
SetPivot(new Vector2(0, rectTransform.pivot.y));
OnComplete(false);
}
@ -185,9 +185,9 @@ namespace RhythmHeavenMania.Editor.Track
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition, Editor.instance.EditorCamera, out mousePos);
sizeDelta = new Vector2(mousePos.x + 0.15f, sizeDelta.y);
sizeDelta = new Vector2(Mathf.Clamp(sizeDelta.x, 0.25f, Mathf.Infinity), sizeDelta.y);
sizeDelta = new Vector2(Mathf.Clamp(sizeDelta.x, Timeline.SnapInterval(), Mathf.Infinity), sizeDelta.y);
rectTransform.sizeDelta = new Vector2(Mathp.Round2Nearest(sizeDelta.x, 0.25f), sizeDelta.y);
rectTransform.sizeDelta = new Vector2(Mathp.Round2Nearest(sizeDelta.x, Timeline.SnapInterval()), sizeDelta.y);
SetPivot(new Vector2(0, rectTransform.pivot.y));
OnComplete(false);
}

View File

@ -204,12 +204,12 @@ namespace RhythmHeavenMania
new GameAction("set tweezer delay", delegate { RhythmTweezers.instance.tweezerBeatOffset = eventCaller.currentEntity.length; }, 1f, true),
new GameAction("reset tweezer delay", delegate { RhythmTweezers.instance.tweezerBeatOffset = 0f; }, 0.5f),
}),
/*
new Minigame("rhythmRally", "Rhythm Rally", "B888F8", true, false, new List<GameAction>()
{
}),
new Minigame("spaceDance", "Space Dance", "B888F8", new List<GameAction>()
/*new Minigame("spaceDance", "Space Dance", "B888F8", new List<GameAction>()
{
}),
new Minigame("tapTrial", "Tap Trial", "B888F8", new List<GameAction>()