mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 11:45:09 +00:00
Bug Fixing
This commit is contained in:
parent
70dd10c646
commit
94b688dbc6
2 changed files with 24 additions and 8 deletions
|
@ -24,6 +24,9 @@ namespace HeavenStudio.Games.Scripts_CoinToss
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
//Make sure there's no overlapping coin cues.
|
||||||
|
if (CoinToss.instance.current_coin != this.gameObject) Destroy(this.gameObject);
|
||||||
|
|
||||||
if (Conductor.instance.GetPositionFromBeat(startBeat, 1f) >= 6.3f)
|
if (Conductor.instance.GetPositionFromBeat(startBeat, 1f) >= 6.3f)
|
||||||
MissCoin();
|
MissCoin();
|
||||||
|
|
||||||
|
|
|
@ -29,12 +29,17 @@ namespace HeavenStudio.Games
|
||||||
public class CoinToss : Minigame
|
public class CoinToss : Minigame
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//Right now, you can only throw one coin at a time.
|
||||||
|
//..Which makes sense, you only have one coin in the original game
|
||||||
|
|
||||||
|
//Though it would need a bit of code rewrite to make it work with multiple coins
|
||||||
|
|
||||||
public static CoinToss instance { get; set; }
|
public static CoinToss instance { get; set; }
|
||||||
public Boolean isThrowing;
|
public Boolean isThrowing;
|
||||||
|
|
||||||
public GameObject coin_cue;
|
public GameObject coin_cue;
|
||||||
|
|
||||||
private int nbCoinThrown; //Variable used if multiple coins are thrown. But it's pretty buggy at the moment and should not be used at the moment
|
public GameObject current_coin;
|
||||||
|
|
||||||
[Header("Animators")]
|
[Header("Animators")]
|
||||||
public Animator handAnimator;
|
public Animator handAnimator;
|
||||||
|
@ -42,7 +47,8 @@ namespace HeavenStudio.Games
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
instance = this;
|
instance = this;
|
||||||
nbCoinThrown = 0;
|
isThrowing = false;
|
||||||
|
current_coin = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
|
@ -57,18 +63,27 @@ namespace HeavenStudio.Games
|
||||||
|
|
||||||
public void TossCoin(float beat, bool audienceReacting)
|
public void TossCoin(float beat, bool audienceReacting)
|
||||||
{
|
{
|
||||||
|
//Play sound and animations
|
||||||
Jukebox.PlayOneShotGame("coinToss/throw");
|
Jukebox.PlayOneShotGame("coinToss/throw");
|
||||||
handAnimator.Play("Throw", 0, 0);
|
handAnimator.Play("Throw", 0, 0);
|
||||||
|
//Game state says the hand is throwing the coin
|
||||||
isThrowing = true;
|
isThrowing = true;
|
||||||
|
|
||||||
|
//Delete the current coin to clean up overlapping instances
|
||||||
|
if(current_coin != null)
|
||||||
|
{
|
||||||
|
Destroy(current_coin);
|
||||||
|
current_coin = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create a new coin to throw
|
||||||
GameObject coin = Instantiate(coin_cue);
|
GameObject coin = Instantiate(coin_cue);
|
||||||
coin.SetActive(true);
|
coin.SetActive(true);
|
||||||
Coin c = coin.GetComponent<Coin>();
|
Coin c = coin.GetComponent<Coin>();
|
||||||
c.startBeat = beat;
|
c.startBeat = beat;
|
||||||
c.audienceReacting = audienceReacting;
|
c.audienceReacting = audienceReacting;
|
||||||
|
|
||||||
nbCoinThrown++;
|
current_coin = coin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Catch_Success(bool audienceReacting)
|
public void Catch_Success(bool audienceReacting)
|
||||||
|
@ -77,8 +92,7 @@ namespace HeavenStudio.Games
|
||||||
if(audienceReacting) Jukebox.PlayOneShotGame("coinToss/applause");
|
if(audienceReacting) Jukebox.PlayOneShotGame("coinToss/applause");
|
||||||
handAnimator.Play("Catch_success", 0, 0);
|
handAnimator.Play("Catch_success", 0, 0);
|
||||||
|
|
||||||
if(nbCoinThrown > 0) nbCoinThrown--;
|
isThrowing = false;
|
||||||
if(nbCoinThrown == 0) isThrowing = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Catch_Miss(bool audienceReacting)
|
public void Catch_Miss(bool audienceReacting)
|
||||||
|
@ -87,8 +101,7 @@ namespace HeavenStudio.Games
|
||||||
if(audienceReacting) Jukebox.PlayOneShotGame("coinToss/disappointed");
|
if(audienceReacting) Jukebox.PlayOneShotGame("coinToss/disappointed");
|
||||||
handAnimator.Play("Pickup", 0, 0);
|
handAnimator.Play("Pickup", 0, 0);
|
||||||
|
|
||||||
if (nbCoinThrown > 0) nbCoinThrown--;
|
isThrowing = false;
|
||||||
if (nbCoinThrown == 0) isThrowing = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Catch_Empty()
|
public void Catch_Empty()
|
||||||
|
|
Loading…
Reference in a new issue