Wizard's Waltz height fix + position based on start interval

Based on megaminerjenny's suggestions :)
This commit is contained in:
Carson Kompon 2022-03-06 11:35:23 -05:00
parent a5164ddcbe
commit 2eda6c0d45
2 changed files with 19 additions and 8 deletions

View file

@ -23,14 +23,14 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
void Update()
{
songPos = Conductor.instance.songPositionInBeats;
songPos = Conductor.instance.songPositionInBeats - game.wizardBeatOffset;
var am = game.beatInterval / 2f;
var x = Mathf.Sin(Mathf.PI * songPos / am) * 6;
var y = Mathf.Cos(Mathf.PI * songPos / am) * 1.5f;
var y = Mathf.Cos(Mathf.PI * songPos / am);
var scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.35f;
transform.position = new Vector3(x, 1.5f + y, 0);
shadow.transform.position = new Vector3(x, -3f + y, 0);
transform.position = new Vector3(x, 3f - y * 0.5f, 0);
shadow.transform.position = new Vector3(x, -3f + y * 1.5f, 0);
var xscale = scale;
if (y > 0) xscale *= -1;

View file

@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using System;
using Starpelly;
@ -33,6 +34,15 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
instance = this;
}
private void Start()
{
List<float> starts = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel == "wizardsWaltz/start interval").Select(c => c.beat).ToList();
var nextInterval = starts.IndexOf(Mathp.GetClosestInList(starts, Conductor.instance.songPositionInBeats));
wizardBeatOffset = starts[nextInterval];
Debug.Log(wizardBeatOffset);
}
private void Update()
{
if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused && intervalStarted)
@ -45,15 +55,15 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
{
if (timer % 8 == 0 || UnityEngine.Random.Range(0,8) == 0)
{
var songPos = Conductor.instance.songPositionInBeats;
var songPos = Conductor.instance.songPositionInBeats - wizardBeatOffset;
var am = beatInterval / 2f;
var x = Mathf.Sin(Mathf.PI * songPos / am) * 6 + UnityEngine.Random.Range(-0.5f, 0.5f);
var y = Mathf.Cos(Mathf.PI * songPos / am) * 2f + UnityEngine.Random.Range(-0.5f, 0.5f); ;
var y = Mathf.Cos(Mathf.PI * songPos / am) * 0.5f + UnityEngine.Random.Range(-0.5f, 0.5f);
var scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.35f + UnityEngine.Random.Range(-0.2f, 0.2f); ;
MagicFX magic = Instantiate(fxBase, fxHolder.transform).GetComponent<MagicFX>();
magic.transform.position = new Vector3(x, 0.5f + y, 0);
magic.transform.position = new Vector3(x, 2f + y, 0);
magic.transform.localScale = wizard.gameObject.transform.localScale;
magic.gameObject.SetActive(true);
}
@ -70,6 +80,7 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
intervalStarted = true;
}
wizardBeatOffset = beat;
intervalStartBeat = beat;
beatInterval = interval;
}
@ -83,7 +94,7 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
Jukebox.PlayOneShotGame("wizardsWaltz/plant", beat);
Plant plant = Instantiate(plantBase, plantHolder.transform).GetComponent<Plant>();
var songPos = Conductor.instance.songPositionInBeats;
var songPos = Conductor.instance.songPositionInBeats - wizardBeatOffset;
var am = (beatInterval / 2f);
var x = Mathf.Sin(Mathf.PI * songPos / am) * 6;
var y = -3f + Mathf.Cos(Mathf.PI * songPos / am) * 1.5f;