Allowed lion count and mii faces to be set before game switches and fixed some bugs from last pr

I went through every single game script to look for bugs in intialization, there shouldn't be anything else that was caused by the pr (there is a bug in Spaceball where a ball cue won't trigger correctly if it's on the same beat as the switch, but i'm not sure how to fix it)
This commit is contained in:
Slaith 2022-03-27 11:13:13 -07:00
parent d72aa964b2
commit 030837d3c9
6 changed files with 23 additions and 24 deletions

View file

@ -345,8 +345,6 @@ namespace HeavenStudio
SetGame(game);
yield return new WaitForEndOfFrame(); //this is needed so that the minigame can have Start() called before OnGameSwitch()
Minigame miniGame = currentGameO.GetComponent<Minigame>();
if (miniGame != null)
miniGame.OnGameSwitch(beat);
@ -356,7 +354,7 @@ namespace HeavenStudio
this.GetComponent<SpriteRenderer>().enabled = false;
}
private void SetGame(string game, bool onGameSwitch = true)
private void SetGame(string game)
{
Destroy(currentGameO);
@ -385,11 +383,6 @@ namespace HeavenStudio
currentGameO.transform.parent = eventCaller.GamesHolder.transform;
currentGameO.name = game;
}
/*if (onGameSwitch)
{
if (GetGame(currentGame).GetComponent<Minigame>() != null)
GetGame(game).GetComponent<Minigame>().OnGameSwitch();
}*/
SetCurrentGame(game);

View file

@ -32,6 +32,14 @@ namespace HeavenStudio.Games
instance = this;
InitLions();
}
public override void OnGameSwitch(float beat)
{
Beatmap.Entity changeLion = GameManager.instance.Beatmap.entities.FindLast(c => c.datamodel == "clappyTrio/change lion count" && c.beat <= beat);
if(changeLion != null)
{
EventCaller.instance.CallEvent(changeLion, true);
}
}
private void InitLions()
{

View file

@ -46,9 +46,13 @@ namespace HeavenStudio.Games
SetMiis();
}
public void OnGameSwitch()
public override void OnGameSwitch(float beat)
{
SetMiis();
Beatmap.Entity changeMii = GameManager.instance.Beatmap.entities.FindLast(c => c.datamodel == "drummingPractice/set mii" && c.beat <= beat);
if(changeMii != null)
{
EventCaller.instance.CallEvent(changeMii, true);
}
}
private void Update()

View file

@ -256,6 +256,7 @@ namespace HeavenStudio.Games
Jukebox.PlayOneShotGame(outSnd);
}
p.Init();
}
List<Beatmap.Entity> cuedVoices = new List<Beatmap.Entity>(); // "Hit" voices cued in advance are stored here so they aren't called multiple times in Update().

View file

@ -56,7 +56,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan
private int missTimes = 0;
private void Awake()
public void Init()
{
anim = GetComponent<Animator>();
spriteComp = Sprite.GetComponent<SpriteRenderer>();
@ -66,10 +66,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan
Sprite.transform.eulerAngles = new Vector3(0, 0, Random.Range(0, 360));
BulbLightSprite.transform.eulerAngles = Sprite.transform.eulerAngles;
if (type == 2)
hitLength = 14f;
else
hitLength = 14f;
hitLength = 14f;
if (type == 6)
CookingPotLid.SetActive(true);

View file

@ -27,7 +27,7 @@ namespace HeavenStudio.Games
bool intervalStarted;
public float wizardBeatOffset = 0f;
[NonSerialized] public int plantsLeft = 0;
[NonSerialized] public int plantsLeft = 0; //this variable is unused
public static WizardsWaltz instance;
@ -35,16 +35,12 @@ namespace HeavenStudio.Games
{
instance = this;
wizard.Init();
}
private void Start()
{
List<float> starts = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel == "wizardsWaltz/start interval").Select(c => c.beat).ToList();
Beatmap.Entity nextStart = GameManager.instance.Beatmap.entities.Find(c => c.datamodel == "wizardsWaltz/start interval" && c.beat + c.length >= Conductor.instance.songPositionInBeats);
if (starts.Count > 0)
if (nextStart != null)
{
var nextInterval = starts.IndexOf(Mathp.GetClosestInList(starts, Conductor.instance.songPositionInBeats));
wizardBeatOffset = starts[nextInterval];
EventCaller.instance.CallEvent(nextStart, true);
}
}
@ -64,7 +60,7 @@ namespace HeavenStudio.Games
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); ;
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>();