Tweezers: Added vegetable type and properties to "Next Vegetable" event. Added "Change Vegetable" event

This commit is contained in:
Jenny Crowe
2022-02-13 07:02:55 -07:00
parent 9268a38f2f
commit 51db8b53ba
4 changed files with 69 additions and 7 deletions

View File

@ -12,8 +12,10 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
// use PlayerActionObject for the actual tweezers but this isn't playable rn so IDC
public class RhythmTweezers : Minigame
{
[Header("References")]
public Transform VegetableHolder;
public GameObject Vegetable;
public SpriteRenderer Vegetable;
public SpriteRenderer VegetableDupe;
public Animator VegetableAnimator;
public Tweezers Tweezers;
public GameObject hairBase;
@ -24,19 +26,43 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
public GameObject DroppedHairsHolder;
[NonSerialized] public int hairsLeft = 0;
[Header("Variables")]
public float beatInterval = 4f;
float intervalStartBeat;
bool intervalStarted;
public float tweezerBeatOffset = 0f;
[Header("Sprites")]
public Sprite pluckedHairSprite;
public Sprite missedHairSprite;
public Sprite onionSprite;
public Sprite potatoSprite;
[NonSerialized] public int eyeSize = 0;
Tween transitionTween;
bool transitioning = false;
private static Color _defaultOnionColor;
public static Color defaultOnionColor
{
get
{
ColorUtility.TryParseHtmlString("#C89600", out _defaultOnionColor);
return _defaultOnionColor;
}
}
private static Color _defaultPotatoColor;
public static Color defaultPotatoColor
{
get
{
ColorUtility.TryParseHtmlString("#FFDC00", out _defaultPotatoColor);
return _defaultPotatoColor;
}
}
public static RhythmTweezers instance { get; set; }
private void Awake()
@ -102,12 +128,18 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
}
const float vegDupeOffset = 16.7f;
public void NextVegetable(float beat)
public void NextVegetable(float beat, int type, Color onionColor, Color potatoColor)
{
transitioning = true;
Jukebox.PlayOneShotGame("rhythmTweezers/register", beat);
Sprite nextVeggieSprite = type == 0 ? onionSprite : potatoSprite;
Color nextColor = type == 0 ? onionColor : potatoColor;
VegetableDupe.sprite = nextVeggieSprite;
VegetableDupe.color = nextColor;
// Move both vegetables to the left by vegDupeOffset, then reset their positions.
// On position reset, reset state of core vegetable.
transitionTween = VegetableHolder.DOLocalMoveX(-vegDupeOffset, Conductor.instance.secPerBeat * 0.5f)
@ -116,6 +148,9 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
var holderPos = VegetableHolder.localPosition;
VegetableHolder.localPosition = new Vector3(0f, holderPos.y, holderPos.z);
Vegetable.sprite = nextVeggieSprite;
Vegetable.color = nextColor;
ResetVegetable();
transitioning = false;
intervalStarted = false;
@ -123,6 +158,19 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
}).SetEase(Ease.InOutSine);
}
public void ChangeVegetableImmediate(int type, Color onionColor, Color potatoColor)
{
StopTransitionIfActive();
Sprite newSprite = type == 0 ? onionSprite : potatoSprite;
Color newColor = type == 0 ? onionColor : potatoColor;
Vegetable.sprite = newSprite;
Vegetable.color = newColor;
VegetableDupe.sprite = newSprite;
VegetableDupe.color = newColor;
}
private void Update()
{
if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused && intervalStarted)

View File

@ -201,7 +201,18 @@ namespace RhythmHeavenMania
new GameAction("start interval", delegate { RhythmTweezers.instance.SetIntervalStart(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 4f, true),
new GameAction("short hair", delegate { RhythmTweezers.instance.SpawnHair(eventCaller.currentEntity.beat); }, 0.5f),
new GameAction("long hair", delegate { RhythmTweezers.instance.SpawnLongHair(eventCaller.currentEntity.beat); }, 0.5f),
new GameAction("next vegetable", delegate { RhythmTweezers.instance.NextVegetable(eventCaller.currentEntity.beat); }, 0.5f),
new GameAction("next vegetable", delegate { var e = eventCaller.currentEntity; RhythmTweezers.instance.NextVegetable(e.beat, e.type, e.colorA, e.colorB); }, 0.5f, false, new List<Param>()
{
new Param("type", new EntityTypes.Integer(0, 1), "Type"),
new Param("colorA", RhythmTweezers.defaultOnionColor, "Onion Color"),
new Param("colorB", RhythmTweezers.defaultPotatoColor, "Potato Color")
} ),
new GameAction("change vegetable", delegate { var e = eventCaller.currentEntity; RhythmTweezers.instance.ChangeVegetableImmediate(e.type, e.colorA, e.colorB); }, 0.5f, false, new List<Param>()
{
new Param("type", new EntityTypes.Integer(0, 1), "Type"),
new Param("colorA", RhythmTweezers.defaultOnionColor, "Onion Color"),
new Param("colorB", RhythmTweezers.defaultPotatoColor, "Potato Color")
} ),
new GameAction("set tweezer delay", delegate { RhythmTweezers.instance.tweezerBeatOffset = eventCaller.currentEntity.length; }, 1f, true),
new GameAction("reset tweezer delay", delegate { RhythmTweezers.instance.tweezerBeatOffset = 0f; }, 0.5f),
}),