Wizard's Waltz is feature complete

Just missing 90% of the visual assets
This commit is contained in:
Carson Kompon
2022-03-03 22:30:08 -05:00
parent a97fd43ec3
commit ef300057a7
26 changed files with 1109 additions and 23 deletions

View File

@ -0,0 +1,91 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
namespace RhythmHeavenMania.Games.WizardsWaltz
{
public class Plant : PlayerActionObject
{
public Animator animator;
public float createBeat;
private WizardsWaltz game;
private bool hit = false;
private bool passed = false;
private void Awake()
{
game = WizardsWaltz.instance;
}
private void Start()
{
animator.Play("Appear", 0, 0);
}
private void Update()
{
if (!passed && Conductor.instance.songPositionInBeats > createBeat + game.beatInterval)
{
StartCoroutine(FadeOut());
passed = true;
}
if (hit) return;
float stateBeat = Conductor.instance.GetPositionFromMargin(createBeat + game.beatInterval, 1f);
StateCheck(stateBeat);
if (PlayerInput.Pressed(true))
{
if (state.perfect)
{
Ace();
} else if (state.notPerfect())
{
Miss();
}
}
}
public void Bloom()
{
animator.Play("Hit", 0, 0);
}
public void Eat()
{
animator.Play("Eat", 0, 0);
}
public void EatLoop()
{
animator.Play("EatLoop", 0, 0);
}
public void Ace()
{
game.wizard.Magic(this, true);
hit = true;
}
public void Miss()
{
game.wizard.Magic(this, false);
hit = true;
}
public override void OnAce()
{
Ace();
}
public IEnumerator FadeOut()
{
yield return new WaitForSeconds(Conductor.instance.secPerBeat * game.beatInterval / 2f);
Destroy(gameObject);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b62617c2e80c5e2488da3c603bc21022
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,24 +7,51 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
{
public class Wizard : MonoBehaviour
{
public GameObject shadow;
private WizardsWaltz game;
private float songPos;
// Start is called before the first frame update
void Start()
private void Awake()
{
game = WizardsWaltz.instance;
}
// Update is called once per frame
void Update()
{
songPos = Conductor.instance.songPositionInBeats;
var x = Mathf.Sin(Mathf.PI * songPos / 2) * 6;
var y = 2 + Mathf.Cos(Mathf.PI * songPos / 2) * 1.5f;
var scale = 1 - Mathf.Cos(Mathf.PI * songPos / 2) * 0.25f;
transform.position = new Vector3(x, y, 0);
transform.localScale = new Vector3(scale, scale, 1);
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 scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.25f;
transform.position = new Vector3(x, 2 + y, -scale);
shadow.transform.position = new Vector3(x, -2.5f + y, -scale + 0.1f);
var xscale = scale;
if (y > 0) xscale *= -1;
transform.localScale = new Vector3(xscale, scale, 1);
shadow.transform.localScale = new Vector3(scale, scale, 1);
}
public void Magic(Plant plant, bool hit)
{
if(plant == null)
{
// TODO: Play empty A press sound
return;
}
if (hit)
{
Jukebox.PlayOneShotGame("wizardsWaltz/grow");
plant.Bloom();
}
else
{
Jukebox.PlayOneShot("miss");
plant.Eat();
}
}
}
}

View File

@ -1,6 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Starpelly;
using RhythmHeavenMania.Util;
@ -8,8 +10,17 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
{
public class WizardsWaltz : Minigame
{
[Header("References")]
public Wizard wizard;
public GameObject plantHolder;
public GameObject plantBase;
public float beatInterval = 4f;
float intervalStartBeat;
bool intervalStarted;
public float wizardBeatOffset = 0f;
[NonSerialized] public int plantsLeft = 0;
public static WizardsWaltz instance;
@ -18,16 +29,52 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
instance = this;
}
// Start is called before the first frame update
void Start()
private void Update()
{
if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused && intervalStarted)
{
intervalStarted = false;
}
}
// Update is called once per frame
void Update()
public void SetIntervalStart(float beat, float interval = 4f)
{
// Don't do these things if the interval was already started.
if (!intervalStarted)
{
plantsLeft = 0;
intervalStarted = true;
}
intervalStartBeat = beat;
beatInterval = interval;
}
public void SpawnFlower(float beat)
{
// If interval hasn't started, assume this is the first hair of the interval.
if (!intervalStarted)
SetIntervalStart(beat, beatInterval);
Jukebox.PlayOneShotGame("wizardsWaltz/plant", beat);
Plant plant = Instantiate(plantBase, plantHolder.transform).GetComponent<Plant>();
var songPos = Conductor.instance.songPositionInBeats;
var am = (beatInterval / 2f);
var x = Mathf.Sin(Mathf.PI * songPos / am) * 6;
var y = -2.5f + Mathf.Cos(Mathf.PI * songPos / am) * 1.5f;
var scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.25f;
var xscale = scale;
if (y > -2.5f) xscale *= -1;
plant.transform.localPosition = new Vector3(x, y, -scale);
plant.transform.localScale = new Vector3(xscale, scale, 1);
plant.gameObject.SetActive(true);
plant.createBeat = beat;
plantsLeft++;
}
}
}

View File

@ -370,7 +370,8 @@ namespace RhythmHeavenMania
}),
new Minigame("wizardsWaltz", "Wizard's Waltz \n<color=#adadad>(Mahou Tsukai)</color>", "FFEF9C", false, false, new List<GameAction>()
{
// new GameAction("plant flower", delegate { }, 2f, false),
new GameAction("start interval", delegate { WizardsWaltz.instance.SetIntervalStart(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 4f, true),
new GameAction("plant flower", delegate { WizardsWaltz.instance.SpawnFlower(eventCaller.currentEntity.beat); }, 0.5f, false),
}),
/*new Minigame("spaceDance", "Space Dance", "B888F8", new List<GameAction>()
{