Better input latency, but not finalized. (weird results on low bpm's)

This commit is contained in:
Starpelly
2021-12-24 18:41:35 -05:00
parent 2c4f7bbac7
commit 58ea8d5e4c
19 changed files with 991 additions and 194 deletions

View File

@ -2,28 +2,63 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CircleCursor : MonoBehaviour
using DG.Tweening;
namespace RhythmHeavenMania
{
[SerializeField] private bool follow = false;
[SerializeField] private float mouseMoveSpeed;
private void Start()
public class CircleCursor : MonoBehaviour
{
Cursor.visible = false;
}
[SerializeField] private bool follow = false;
[SerializeField] private float mouseMoveSpeed;
private void Update()
{
Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
[Header("DSGuy")]
[SerializeField] private GameObject Eyes;
[SerializeField] private GameObject OuterCircle;
[SerializeField] private GameObject InnerCircle;
[SerializeField] private GameObject Circle;
private Tween outerCircleTween, eyesTween;
if (follow)
private void Start()
{
Vector2 direction = (pos - transform.position).normalized;
this.GetComponent<Rigidbody2D>().velocity = new Vector2(direction.x * mouseMoveSpeed, direction.y * mouseMoveSpeed);
Cursor.visible = false;
}
else
private void Update()
{
this.gameObject.transform.position = new Vector3(pos.x, pos.y, 0);
Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
if (follow)
{
Vector2 direction = (pos - transform.position).normalized;
this.GetComponent<Rigidbody2D>().velocity = new Vector2(direction.x * mouseMoveSpeed, direction.y * mouseMoveSpeed);
}
else
{
this.gameObject.transform.position = new Vector3(pos.x, pos.y, 0);
if (PlayerInput.Pressed())
{
Circle.transform.DOScale(0, 0.5f).SetEase(Ease.OutExpo);
InnerCircle.SetActive(true);
outerCircleTween.Kill();
outerCircleTween = OuterCircle.transform.DOScale(1, 0.15f).SetEase(Ease.OutExpo);
Eyes.SetActive(true);
eyesTween.Kill();
eyesTween = Eyes.transform.DOLocalMoveY(0.15f, 0.15f).SetEase(Ease.OutExpo);
}
else if (PlayerInput.PressedUp())
{
Circle.transform.DOScale(0.2f, 0.5f).SetEase(Ease.OutExpo);
InnerCircle.SetActive(false);
outerCircleTween.Kill();
outerCircleTween = OuterCircle.transform.DOScale(0, 0.15f);
eyesTween.Kill();
eyesTween = Eyes.transform.DOLocalMoveY(-0.66f, 0.15f).OnComplete(delegate { Eyes.SetActive(false); });
}
}
}
}
}
}

View File

@ -92,13 +92,13 @@ namespace RhythmHeavenMania.Games.ClappyTrio
// i spent like 25 minutes trying to figure out what was wrong with this when i forgot to subtract the currentClapLength :(
if (i == Lion.Count - 1)
minus = 0.35f;
minus = Minigame.perfectTime;
if (songPosBeat > lastClapStart + (currentClappingLength * (i) - minus) && songPosBeat < lastClapStart + (currentClappingLength * (i + 1)) && clapIndex == i)
{
if (i == Lion.Count - 1)
{
ClappyTrioPlayer.SetClapAvailability(lastClapStart + (currentClappingLength * i - 0.35f));
ClappyTrioPlayer.SetClapAvailability(lastClapStart + (currentClappingLength * i - Minigame.perfectTime));
clapIndex = 0;
isClapping = false;

View File

@ -17,8 +17,6 @@ namespace RhythmHeavenMania.Games.ClappyTrio
private int lastIndex;
private float perfectTime = 0.25f, lateTime = 0.43f;
private bool hit;
public bool clapStarted = false;
@ -38,22 +36,23 @@ namespace RhythmHeavenMania.Games.ClappyTrio
Clap();
}
if (clapVacant == true)
// if (clapVacant == true)
{
float songPosBeat = Conductor.instance.songPositionInBeats;
float normalizedBeat = (Conductor.instance.GetLoopPositionFromBeat(lastClapBeat, 1f));
print(normalizedBeat);
if (songPosBeat > lastClapBeat && songPosBeat < lastClapBeat + perfectTime && lastIndex == 0)
if (normalizedBeat > Minigame.earlyTime && normalizedBeat < Minigame.perfectTime && lastIndex == 0)
{
SetEligibility(true, false, false);
lastIndex++;
}
else if (songPosBeat > lastClapBeat + perfectTime && songPosBeat < lastClapBeat + lateTime && lastIndex == 1)
else if (normalizedBeat > Minigame.perfectTime && normalizedBeat < Minigame.lateTime && lastIndex == 1)
{
SetEligibility(false, true, false);
// Clap();
lastIndex++;
}
else if (songPosBeat > lastClapBeat + lateTime && lastIndex == 2)
else if (normalizedBeat > Minigame.lateTime && lastIndex == 2)
{
SetEligibility(false, false, true);
clapVacant = false;

View File

@ -67,7 +67,7 @@ namespace RhythmHeavenMania.Games.ForkLifter
{
Time.timeScale = timescale;
if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.Space))
if (PlayerInput.Pressed())
{
Stab();
}

View File

@ -8,11 +8,6 @@ namespace RhythmHeavenMania.Games.ForkLifter
{
public class Pea : MonoBehaviour
{
[Header("Latency")]
public float earlyTime;
public float perfectTime;
public float lateTime;
public float endTime;
private Animator anim;
@ -43,27 +38,36 @@ namespace RhythmHeavenMania.Games.ForkLifter
private void Update()
{
float normalizedBeat = (Conductor.instance.GetLoopPositionFromBeat(startBeat, 2.5f));
anim.Play("Flicked_Object", -1, normalizedBeat);
float normalizedBeatAnim = (Conductor.instance.GetLoopPositionFromBeat(startBeat, 2.5f));
anim.Play("Flicked_Object", -1, normalizedBeatAnim);
anim.speed = 0;
float normalizedBeat = (Conductor.instance.GetLoopPositionFromBeat(startBeat, 2f));
float earlyTime = Minigame.earlyTime * 2;
float perfectTime = Minigame.perfectTime * 2;
float lateTime = Minigame.lateTime * 2;
float endTime = Minigame.endTime * 2;
print(normalizedBeat + " " + perfectTime);
// Early State
if (normalizedBeat > earlyTime && normalizedBeat < perfectTime && estate <= 1)
{
estate++;
MakeEligible(true, false, false);
estate++;
}
// Perfect State
else if (normalizedBeat > perfectTime && normalizedBeat < lateTime && pstate <= 1)
{
pstate++;
MakeEligible(false, true, false);
pstate++;
}
// Late State
else if (normalizedBeat > lateTime && normalizedBeat < endTime && lstate <= 1)
{
lstate++;
MakeEligible(false, false, true);
lstate++;
}
else if (normalizedBeat < earlyTime || normalizedBeat > endTime)
{

View File

@ -6,6 +6,8 @@ namespace RhythmHeavenMania.Games
{
public class Minigame : MonoBehaviour
{
public static float earlyTime = 0.38f, perfectTime = 0.41f, lateTime = 0.535f, endTime = 1f;
public int firstEnable = 0;
public virtual void OnGameSwitch()

View File

@ -11,6 +11,11 @@ namespace RhythmHeavenMania
return (Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0));
}
public static bool PressedUp()
{
return (Input.GetKeyUp(KeyCode.Z) || Input.GetKeyUp(KeyCode.Space) || Input.GetMouseButtonUp(0));
}
public static bool Pressing()
{
return (Input.GetKey(KeyCode.Z) || Input.GetKey(KeyCode.Space) || Input.GetMouseButton(0));