Merge pull request #49 from jakobwcrowe/master

BTSDS: Fine tuning for block animation timing.
This commit is contained in:
Jenny Crowe 2022-02-18 07:33:14 -07:00 committed by GitHub
commit 314f12bccb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -24,7 +24,7 @@ namespace RhythmHeavenMania.Games.BuiltToScaleDS
{
if (!moving) return;
var windupBeat = createBeat + (createLength * 3.5f);
var windupBeat = createBeat + (createLength * 4f);
var hitBeat = windupBeat + createLength;
var currentBeat = Conductor.instance.songPositionInBeats;

View file

@ -74,7 +74,7 @@ namespace RhythmHeavenMania.Games.BuiltToScaleDS
var ev = blockEvents[i];
if (spawnedBlockEvents.Contains(ev)) continue; // Don't spawn the same blocks multiple times.
var spawnBeat = ev.beat - (ev.length * 0.5f);
var spawnBeat = ev.beat - ev.length;
if (currentBeat > spawnBeat && currentBeat < ev.beat + ev.length)
{
SpawnBlocks(spawnBeat, ev.length);
@ -125,18 +125,21 @@ namespace RhythmHeavenMania.Games.BuiltToScaleDS
const int blockFramesPerSecond = 24;
const int blockHitFrame = 39;
const int blockTotalFrames = 80;
const int spawnFrameOffset = -3;
List<int> criticalFrames = new List<int> { 7, 15, 23, 31, 39, 47 };
public void SetBlockTime(Blocks blocks, float spawnBeat, float length)
{
float spawnTimeOffset = (float)spawnFrameOffset / (float)blockFramesPerSecond;
float secondsPerFrame = 1f / blockFramesPerSecond;
float secondsToHitFrame = secondsPerFrame * blockHitFrame;
float secondsPerBeat = Conductor.instance.secPerBeat;
float secondsToHitBeat = secondsPerBeat * 4.5f * length;
float secondsToHitBeat = secondsPerBeat * 5f * length + spawnTimeOffset;
float speedMult = secondsToHitFrame / secondsToHitBeat;
float secondsPastSpawnTime = secondsPerBeat * (Conductor.instance.songPositionInBeats - spawnBeat);
float secondsPastSpawnTime = secondsPerBeat * (Conductor.instance.songPositionInBeats - spawnBeat) + spawnTimeOffset;
float framesPastSpawnTime = blockFramesPerSecond * speedMult * secondsPastSpawnTime;
// The only way I could deal with Unity's interpolation shenanigans without having a stroke.