Merge pull request #65 from Slaith12/main

Allowed lion count and mii faces to be set before game switches and f…
This commit is contained in:
Jenny Crowe 2022-03-28 11:55:03 -07:00 committed by GitHub
commit ec8517dffa
7 changed files with 25 additions and 25 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

@ -20,7 +20,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan
public GameObject shadow;
private void Awake()
public void Init()
{
SpriteRenderer = this.gameObject.GetComponent<SpriteRenderer>();
SpriteRenderer.sprite = KarateMan.instance.BarrelSprites[spriteIndex];

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);
@ -413,6 +410,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan
bde.spriteIndex = 4;
break;
}
bde.Init();
}
}
}

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>();