2022-05-01 18:22:00 +00:00
|
|
|
using DG.Tweening;
|
|
|
|
using NaughtyBezierCurves;
|
|
|
|
using HeavenStudio.Util;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games.Loaders
|
|
|
|
{
|
|
|
|
using static Minigames;
|
|
|
|
public static class NtrCoinLoader
|
|
|
|
{
|
|
|
|
public static Minigame AddGame(EventCaller eventCaller)
|
|
|
|
{
|
2022-05-01 21:49:55 +00:00
|
|
|
return new Minigame("coinToss", "Coin Toss \n [One coin at a time!]", "B4E6F6", false, false, new List<GameAction>()
|
2022-05-01 18:22:00 +00:00
|
|
|
{
|
2022-05-01 21:49:55 +00:00
|
|
|
new GameAction("toss", delegate { CoinToss.instance.TossCoin(eventCaller.currentEntity.beat, eventCaller.currentEntity.toggle); }, 7, false, parameters: new List<Param>()
|
|
|
|
{
|
|
|
|
new Param("toggle", false, "Audience Reaction", "Enable Audience Reaction"),
|
|
|
|
}),
|
2022-05-01 18:22:00 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games
|
|
|
|
{
|
|
|
|
using Scripts_CoinToss;
|
|
|
|
public class CoinToss : Minigame
|
|
|
|
{
|
|
|
|
|
|
|
|
public static CoinToss instance { get; set; }
|
|
|
|
public Boolean isThrowing;
|
|
|
|
|
2022-05-01 20:10:00 +00:00
|
|
|
public GameObject coin_cue;
|
|
|
|
|
2022-05-01 21:49:55 +00:00
|
|
|
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
|
|
|
|
|
2022-05-01 18:22:00 +00:00
|
|
|
[Header("Animators")]
|
|
|
|
public Animator handAnimator;
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
instance = this;
|
2022-05-01 21:49:55 +00:00
|
|
|
nbCoinThrown = 0;
|
2022-05-01 18:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
//pass
|
|
|
|
}
|
|
|
|
|
|
|
|
private void LateUpdate()
|
|
|
|
{
|
|
|
|
//pass
|
|
|
|
}
|
|
|
|
|
2022-05-01 21:49:55 +00:00
|
|
|
public void TossCoin(float beat, bool audienceReacting)
|
2022-05-01 18:22:00 +00:00
|
|
|
{
|
|
|
|
Jukebox.PlayOneShotGame("coinToss/throw");
|
|
|
|
handAnimator.Play("Throw", 0, 0);
|
|
|
|
|
|
|
|
isThrowing = true;
|
2022-05-01 20:10:00 +00:00
|
|
|
|
|
|
|
GameObject coin = Instantiate(coin_cue);
|
|
|
|
coin.SetActive(true);
|
|
|
|
Coin c = coin.GetComponent<Coin>();
|
|
|
|
c.startBeat = beat;
|
2022-05-01 21:49:55 +00:00
|
|
|
c.audienceReacting = audienceReacting;
|
|
|
|
|
|
|
|
nbCoinThrown++;
|
2022-05-01 18:22:00 +00:00
|
|
|
}
|
|
|
|
|
2022-05-01 21:49:55 +00:00
|
|
|
public void Catch_Success(bool audienceReacting)
|
2022-05-01 20:10:00 +00:00
|
|
|
{
|
|
|
|
Jukebox.PlayOneShotGame("coinToss/catch");
|
2022-05-01 21:49:55 +00:00
|
|
|
if(audienceReacting) Jukebox.PlayOneShotGame("coinToss/applause");
|
2022-05-01 20:10:00 +00:00
|
|
|
handAnimator.Play("Catch_success", 0, 0);
|
|
|
|
|
2022-05-01 21:49:55 +00:00
|
|
|
if(nbCoinThrown > 0) nbCoinThrown--;
|
|
|
|
if(nbCoinThrown == 0) isThrowing = false;
|
2022-05-01 20:10:00 +00:00
|
|
|
}
|
|
|
|
|
2022-05-01 21:49:55 +00:00
|
|
|
public void Catch_Miss(bool audienceReacting)
|
2022-05-01 20:10:00 +00:00
|
|
|
{
|
|
|
|
Jukebox.PlayOneShotGame("coinToss/miss");
|
2022-05-01 21:49:55 +00:00
|
|
|
if(audienceReacting) Jukebox.PlayOneShotGame("coinToss/disappointed");
|
|
|
|
handAnimator.Play("Pickup", 0, 0);
|
|
|
|
|
|
|
|
if (nbCoinThrown > 0) nbCoinThrown--;
|
|
|
|
if (nbCoinThrown == 0) isThrowing = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Catch_Empty()
|
|
|
|
{
|
|
|
|
handAnimator.Play("Catch_empty", 0, 0);
|
|
|
|
isThrowing = false;
|
2022-05-01 20:10:00 +00:00
|
|
|
}
|
2022-05-01 18:22:00 +00:00
|
|
|
}
|
|
|
|
}
|