mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 13:37:40 +02:00
Mahou Tsukai Rework (#502)
* fixed not being able to whiff in tap trial * bored meeting fixes * more board meeting fix * ww now uses z axis instead of scale * Inputs are now reworked in mahou tsukai * Fixed the particle effect
This commit is contained in:
@ -68,6 +68,7 @@ namespace HeavenStudio.Games.Scripts_BoardMeeting
|
||||
rollLoop.KillLoop(0);
|
||||
rollLoop = null;
|
||||
}
|
||||
game.StopChairLoopSoundIfLastToStop();
|
||||
|
||||
BeatAction.New(game.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
|
@ -77,6 +77,7 @@ namespace HeavenStudio.Games.Loaders
|
||||
namespace HeavenStudio.Games
|
||||
{
|
||||
using Scripts_BoardMeeting;
|
||||
using System;
|
||||
|
||||
public class BoardMeeting : Minigame
|
||||
{
|
||||
@ -94,7 +95,7 @@ namespace HeavenStudio.Games
|
||||
bool assistantCanBop = true;
|
||||
bool executivesCanBop = true;
|
||||
public GameEvent bop = new GameEvent();
|
||||
Sound chairLoopSound = null;
|
||||
[NonSerialized] public Sound chairLoopSound = null;
|
||||
int missCounter = 0;
|
||||
private Tween shakeTween;
|
||||
|
||||
@ -106,6 +107,19 @@ namespace HeavenStudio.Games
|
||||
InitExecutives();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
foreach(var evt in scheduledInputs)
|
||||
{
|
||||
evt.Disable();
|
||||
}
|
||||
if (chairLoopSound != null)
|
||||
{
|
||||
chairLoopSound.KillLoop(0);
|
||||
chairLoopSound = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
@ -124,6 +138,10 @@ namespace HeavenStudio.Games
|
||||
SoundByte.PlayOneShotGame("boardMeeting/miss");
|
||||
SoundByte.PlayOneShot("miss");
|
||||
ScoreMiss();
|
||||
foreach (var evt in scheduledInputs)
|
||||
{
|
||||
evt.Disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -312,6 +330,16 @@ namespace HeavenStudio.Games
|
||||
}
|
||||
}
|
||||
|
||||
public void StopChairLoopSoundIfLastToStop()
|
||||
{
|
||||
if (executives.FindAll(x => x.spinning).Count > 1) return;
|
||||
if (chairLoopSound != null)
|
||||
{
|
||||
chairLoopSound.KillLoop(0);
|
||||
chairLoopSound = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void InitExecutives()
|
||||
{
|
||||
float startPos = farLeft.position.x;
|
||||
|
@ -1,33 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using HeavenStudio.Util;
|
||||
using System;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_WizardsWaltz
|
||||
{
|
||||
public class MagicFX : MonoBehaviour
|
||||
{
|
||||
public Animator animator;
|
||||
public SpriteRenderer spriteRenderer;
|
||||
public GameObject shimmer;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
int order = (int)Math.Round((transform.position.z - 2) * 1000);
|
||||
spriteRenderer.sortingOrder = order;
|
||||
shimmer.GetComponent<SpriteRenderer>().sortingOrder = order;
|
||||
animator.Play("Magic", 0, 0);
|
||||
|
||||
Rigidbody2D rb2d = gameObject.AddComponent<Rigidbody2D>();
|
||||
rb2d.gravityScale = 2.5f;
|
||||
}
|
||||
|
||||
public void Kill()
|
||||
{
|
||||
Destroy(shimmer);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b107d57be99ffe34ea2d14c49c15ff80
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -12,20 +12,20 @@ namespace HeavenStudio.Games.Scripts_WizardsWaltz
|
||||
public double createBeat;
|
||||
|
||||
private WizardsWaltz game;
|
||||
private bool hit = false;
|
||||
private bool passed = false;
|
||||
|
||||
public int order = 0;
|
||||
|
||||
private void Awake()
|
||||
public void Init(bool spawnedInactive)
|
||||
{
|
||||
game = WizardsWaltz.instance;
|
||||
spriteRenderer.sortingOrder = order;
|
||||
animator.Play("Appear", 0, 0);
|
||||
animator.Play("Appear", 0, spawnedInactive ? 1 : 0);
|
||||
}
|
||||
|
||||
private void Start() {
|
||||
game.ScheduleInput(createBeat, game.beatInterval, InputType.STANDARD_DOWN | InputType.DIRECTION_DOWN, Just, Miss, Out);
|
||||
public void StartInput(double beat, float length)
|
||||
{
|
||||
game.ScheduleInput(beat, length, InputType.STANDARD_DOWN | InputType.DIRECTION_DOWN, Just, Miss, Out);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@ -65,13 +65,11 @@ namespace HeavenStudio.Games.Scripts_WizardsWaltz
|
||||
public void Ace()
|
||||
{
|
||||
game.wizard.Magic(this, true);
|
||||
hit = true;
|
||||
}
|
||||
|
||||
public void NearMiss()
|
||||
{
|
||||
game.wizard.Magic(this, false);
|
||||
hit = true;
|
||||
}
|
||||
|
||||
private void Just(PlayerActionEvent caller, float state)
|
||||
|
@ -10,9 +10,6 @@ namespace HeavenStudio.Games.Scripts_WizardsWaltz
|
||||
public Animator animator;
|
||||
public GameObject shadow;
|
||||
|
||||
private float newBeat = 0;
|
||||
private int beats = 0;
|
||||
|
||||
private WizardsWaltz game;
|
||||
private float songPos;
|
||||
|
||||
@ -25,17 +22,20 @@ namespace HeavenStudio.Games.Scripts_WizardsWaltz
|
||||
{
|
||||
songPos = (float)(Conductor.instance.songPositionInBeatsAsDouble - game.wizardBeatOffset);
|
||||
var am = game.beatInterval / 2f;
|
||||
var x = Mathf.Sin(Mathf.PI * songPos / am) * 6;
|
||||
var y = Mathf.Cos(Mathf.PI * songPos / am);
|
||||
var scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.35f;
|
||||
|
||||
transform.position = new Vector3(x, 3f - y * 0.5f, 0);
|
||||
shadow.transform.position = new Vector3(x, -3f + y * 1.5f, 0);
|
||||
var x = Mathf.Sin(Mathf.PI * songPos / am) * game.xRange;
|
||||
var y = Mathf.Cos(Mathf.PI * songPos / am) * game.yRange;
|
||||
var z = Mathf.Cos(Mathf.PI * songPos / am) * game.zRange;
|
||||
//var scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.35f;
|
||||
|
||||
var xscale = scale;
|
||||
transform.position = new Vector3(x, 3f - y * 0.5f, z);
|
||||
shadow.transform.position = new Vector3(x, game.plantYOffset + y * 1.5f, z);
|
||||
|
||||
/*var xscale = scale;
|
||||
if (y > 0) xscale *= -1;
|
||||
transform.localScale = new Vector3(xscale, scale, 1);
|
||||
shadow.transform.localScale = new Vector3(scale, scale, 1);
|
||||
shadow.transform.localScale = new Vector3(scale, scale, 1);*/
|
||||
|
||||
transform.localScale = new Vector3((y > 0) ? -1 : 1, 1, 1);
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
|
@ -17,16 +17,24 @@ namespace HeavenStudio.Games.Loaders
|
||||
{
|
||||
new GameAction("start interval", "Start Interval")
|
||||
{
|
||||
function = delegate { WizardsWaltz.instance.SetIntervalStart(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); },
|
||||
preFunction = delegate { var e = eventCaller.currentEntity; WizardsWaltz.PreInterval(e.beat, e.length, e["auto"]); },
|
||||
defaultLength = 6f,
|
||||
resizable = true,
|
||||
priority = 1
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("auto", true, "Auto Pass Turn")
|
||||
},
|
||||
preFunctionLength = 1
|
||||
},
|
||||
new GameAction("plant", "Plant")
|
||||
{
|
||||
function = delegate { WizardsWaltz.instance.SpawnFlower(eventCaller.currentEntity.beat); },
|
||||
defaultLength = 0.5f,
|
||||
},
|
||||
new GameAction("passTurn", "Pass Turn")
|
||||
{
|
||||
preFunction = delegate { var e = eventCaller.currentEntity; WizardsWaltz.PrePassTurn(e.beat); },
|
||||
preFunctionLength = 1
|
||||
}
|
||||
},
|
||||
new List<string>() {"agb", "repeat"},
|
||||
"agbwizard", "en",
|
||||
@ -38,6 +46,7 @@ namespace HeavenStudio.Games.Loaders
|
||||
|
||||
namespace HeavenStudio.Games
|
||||
{
|
||||
using Jukebox;
|
||||
using Scripts_WizardsWaltz;
|
||||
|
||||
public class WizardsWaltz : Minigame
|
||||
@ -47,99 +56,220 @@ namespace HeavenStudio.Games
|
||||
public Girl girl;
|
||||
public GameObject plantHolder;
|
||||
public GameObject plantBase;
|
||||
public GameObject fxHolder;
|
||||
public GameObject fxBase;
|
||||
|
||||
private int timer = 0;
|
||||
public float beatInterval = 6f;
|
||||
double intervalStartBeat;
|
||||
bool intervalStarted;
|
||||
[Header("Properties")]
|
||||
[NonSerialized] public float beatInterval = 6f;
|
||||
[NonSerialized] public double intervalStartBeat;
|
||||
public double wizardBeatOffset = 0f;
|
||||
|
||||
[NonSerialized] public int plantsLeft = 0; //this variable is unused
|
||||
public float xRange = 5;
|
||||
public float zRange = 5;
|
||||
public float yRange = 0.5f;
|
||||
public float plantYOffset = -2f;
|
||||
private List<Plant> currentPlants = new();
|
||||
|
||||
public static WizardsWaltz instance;
|
||||
|
||||
private static CallAndResponseHandler crHandlerInstance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
wizard.Init();
|
||||
}
|
||||
|
||||
var nextStart = GameManager.instance.Beatmap.Entities.Find(c => c.datamodel == "wizardsWaltz/start interval" && c.beat + c.length >= Conductor.instance.songPositionInBeatsAsDouble);
|
||||
public override void OnPlay(double beat)
|
||||
{
|
||||
SetWizardOffset(beat);
|
||||
crHandlerInstance = null;
|
||||
}
|
||||
|
||||
if (nextStart != null)
|
||||
public override void OnGameSwitch(double beat)
|
||||
{
|
||||
SetWizardOffset(beat);
|
||||
if (queuedIntervals.Count > 0)
|
||||
{
|
||||
EventCaller.instance.CallEvent(nextStart, true);
|
||||
foreach (var interval in queuedIntervals)
|
||||
{
|
||||
SetIntervalStart(interval.beat, interval.interval, beat, interval.autoPassTurn);
|
||||
}
|
||||
queuedIntervals.Clear();
|
||||
}
|
||||
if (crHandlerInstance != null && crHandlerInstance.queuedEvents.Count > 0)
|
||||
{
|
||||
if (crHandlerInstance.queuedEvents.Find(x => x.beat >= beat) != null)
|
||||
{
|
||||
crHandlerInstance = null;
|
||||
return;
|
||||
}
|
||||
foreach (var crEvent in crHandlerInstance.queuedEvents)
|
||||
{
|
||||
SpawnFlower(crEvent.beat, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetWizardOffset(double beat)
|
||||
{
|
||||
var allIntervals = EventCaller.GetAllInGameManagerList("wizardsWaltz", new string[] { "start interval" });
|
||||
var tempEvents = allIntervals.FindAll(x => x.beat >= beat);
|
||||
if (tempEvents.Count > 0)
|
||||
{
|
||||
wizardBeatOffset = tempEvents[0].beat;
|
||||
beatInterval = tempEvents[0].length;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused && intervalStarted)
|
||||
if (Conductor.instance.isPlaying && !Conductor.instance.isPaused)
|
||||
{
|
||||
intervalStarted = false;
|
||||
if (passedTurns.Count > 0)
|
||||
{
|
||||
foreach (var pass in passedTurns)
|
||||
{
|
||||
PassTurnStandalone(pass);
|
||||
}
|
||||
passedTurns.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
private List<RiqEntity> GetAllPlantsBetweenBeat(double beat, double endBeat)
|
||||
{
|
||||
if (timer % 8 == 0 || UnityEngine.Random.Range(0,8) == 0)
|
||||
{
|
||||
var songPos = (float)(Conductor.instance.songPositionInBeatsAsDouble - 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) * 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, 2f + y, 0);
|
||||
magic.transform.localScale = wizard.gameObject.transform.localScale;
|
||||
magic.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
timer++;
|
||||
return EventCaller.GetAllInGameManagerList("wizardsWaltz", new string[] { "plant" }).FindAll(x => x.beat >= beat && x.beat < endBeat);
|
||||
}
|
||||
|
||||
public void SetIntervalStart(double beat, float interval = 4f)
|
||||
public void SetIntervalStart(double beat, float interval, double gameSwitchBeat, bool autoPassTurn)
|
||||
{
|
||||
// Don't do these things if the interval was already started.
|
||||
if (!intervalStarted)
|
||||
{
|
||||
plantsLeft = 0;
|
||||
intervalStarted = true;
|
||||
}
|
||||
|
||||
wizardBeatOffset = beat;
|
||||
intervalStartBeat = beat;
|
||||
beatInterval = interval;
|
||||
|
||||
CallAndResponseHandler newHandler = new();
|
||||
crHandlerInstance = newHandler;
|
||||
crHandlerInstance.StartInterval(beat, interval);
|
||||
var relevantPlantEvents = GetAllPlantsBetweenBeat(beat, beat + interval);
|
||||
foreach (var plant in relevantPlantEvents)
|
||||
{
|
||||
crHandlerInstance.AddEvent(plant.beat);
|
||||
SpawnFlower(plant.beat, plant.beat < gameSwitchBeat);
|
||||
}
|
||||
|
||||
if (autoPassTurn)
|
||||
{
|
||||
PassTurn(beat + interval, newHandler);
|
||||
}
|
||||
}
|
||||
|
||||
public void SpawnFlower(double beat)
|
||||
public static void PreInterval(double beat, float interval, bool autoPassTurn)
|
||||
{
|
||||
// If interval hasn't started, assume this is the first hair of the interval.
|
||||
if (!intervalStarted)
|
||||
SetIntervalStart(beat, beatInterval);
|
||||
if (GameManager.instance.currentGame == "wizardsWaltz")
|
||||
{
|
||||
instance.SetIntervalStart(beat, interval, beat, autoPassTurn);
|
||||
}
|
||||
else
|
||||
{
|
||||
queuedIntervals.Add(new QueuedInterval()
|
||||
{
|
||||
beat = beat,
|
||||
interval = interval,
|
||||
autoPassTurn = autoPassTurn
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
SoundByte.PlayOneShotGame("wizardsWaltz/plant", beat);
|
||||
private void PassTurnStandalone(double beat)
|
||||
{
|
||||
if (crHandlerInstance != null) PassTurn(beat, crHandlerInstance);
|
||||
}
|
||||
|
||||
public static void PrePassTurn(double beat)
|
||||
{
|
||||
if (GameManager.instance.currentGame == "wizardsWaltz")
|
||||
{
|
||||
instance.PassTurnStandalone(beat);
|
||||
}
|
||||
else
|
||||
{
|
||||
passedTurns.Add(beat);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<double> passedTurns = new();
|
||||
|
||||
private void PassTurn(double beat, CallAndResponseHandler crHandler)
|
||||
{
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat - 0.25, delegate
|
||||
{
|
||||
beatInterval = crHandler.intervalLength;
|
||||
wizardBeatOffset = beat;
|
||||
intervalStartBeat = beat;
|
||||
foreach (var plant in currentPlants)
|
||||
{
|
||||
var songPos = (float)(plant.createBeat - wizardBeatOffset);
|
||||
var am = (beatInterval / 2f);
|
||||
var x = Mathf.Sin(Mathf.PI * songPos / am) * xRange;
|
||||
var y = plantYOffset + Mathf.Cos(Mathf.PI * songPos / am) * (yRange * 1.5f);
|
||||
var z = Mathf.Cos(Mathf.PI * songPos / am) * zRange;
|
||||
/*var scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.35f;
|
||||
var xscale = scale;
|
||||
if (y > -3.5f) xscale *= -1;*/
|
||||
|
||||
plant.transform.localPosition = new Vector3(x, y, z);
|
||||
//plant.transform.localScale = new Vector3(xscale, scale, 1);
|
||||
}
|
||||
|
||||
foreach (var crEvent in crHandler.queuedEvents)
|
||||
{
|
||||
Plant plantToInput = currentPlants.Find(x => x.createBeat == crEvent.beat);
|
||||
plantToInput.StartInput(beat - 0.25, (float)crEvent.relativeBeat + 0.25f);
|
||||
}
|
||||
crHandler.queuedEvents.Clear();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
private static List<QueuedInterval> queuedIntervals = new();
|
||||
|
||||
private struct QueuedInterval
|
||||
{
|
||||
public double beat;
|
||||
public float interval;
|
||||
public bool autoPassTurn;
|
||||
}
|
||||
|
||||
public void SpawnFlower(double beat, bool spawnedInactive)
|
||||
{
|
||||
if (!spawnedInactive) SoundByte.PlayOneShotGame("wizardsWaltz/plant", beat);
|
||||
Plant plant = Instantiate(plantBase, plantHolder.transform).GetComponent<Plant>();
|
||||
|
||||
var songPos = (float)(Conductor.instance.songPositionInBeatsAsDouble - wizardBeatOffset);
|
||||
currentPlants.Add(plant);
|
||||
var songPos = (float)(beat - 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;
|
||||
var scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.35f;
|
||||
var x = Mathf.Sin(Mathf.PI * songPos / am) * xRange;
|
||||
var y = plantYOffset + Mathf.Cos(Mathf.PI * songPos / am) * (yRange * 1.5f);
|
||||
var z = Mathf.Cos(Mathf.PI * songPos / am) * zRange;
|
||||
/*var scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.35f;
|
||||
var xscale = scale;
|
||||
if (y > -3.5f) xscale *= -1;
|
||||
if (y > -3.5f) xscale *= -1;*/
|
||||
|
||||
plant.transform.localPosition = new Vector3(x, y, 0);
|
||||
plant.transform.localScale = new Vector3(xscale, scale, 1);
|
||||
plant.transform.localPosition = new Vector3(x, y, z);
|
||||
//plant.transform.localScale = new Vector3(xscale, scale, 1);
|
||||
|
||||
plant.order = (int)Math.Round((scale - 1) * 1000);
|
||||
plant.gameObject.SetActive(true);
|
||||
//plant.order = (int)Math.Round((scale - 1) * 1000);
|
||||
plant.order = (int)Math.Round(z * -1);
|
||||
|
||||
plant.createBeat = beat;
|
||||
plantsLeft++;
|
||||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate
|
||||
{
|
||||
plant.gameObject.SetActive(true);
|
||||
plant.Init(spawnedInactive);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user