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

@ -1018,7 +1018,7 @@ SpriteRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 848710030467426981, guid: 27e9694e644a6914d9047c1029955365, type: 3}
m_Color: {r: 0.8679245, g: 0.6164698, b: 0, a: 1}
m_Color: {r: 0.78431374, g: 0.5882353, b: 0, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
@ -2182,7 +2182,8 @@ MonoBehaviour:
EligibleHits: []
firstEnable: 0
VegetableHolder: {fileID: 2852202173104472746}
Vegetable: {fileID: 3177931334588542204}
Vegetable: {fileID: 6331401567023014501}
VegetableDupe: {fileID: 9096051369561297840}
VegetableAnimator: {fileID: 3603513546661280919}
Tweezers: {fileID: 3391455012319192365}
hairBase: {fileID: 4104508031135416673}
@ -2194,6 +2195,8 @@ MonoBehaviour:
tweezerBeatOffset: 0
pluckedHairSprite: {fileID: 3562159510210354730, guid: 8b24cfccb5b27054bbfccc7d7a912b73, type: 3}
missedHairSprite: {fileID: -2343768176336248091, guid: 8b24cfccb5b27054bbfccc7d7a912b73, type: 3}
onionSprite: {fileID: 848710030467426981, guid: 27e9694e644a6914d9047c1029955365, type: 3}
potatoSprite: {fileID: -6820761741098029108, guid: 27e9694e644a6914d9047c1029955365, type: 3}
--- !u!1 &5813499711658895222
GameObject:
m_ObjectHideFlags: 0
@ -2632,7 +2635,7 @@ SpriteRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 848710030467426981, guid: 27e9694e644a6914d9047c1029955365, type: 3}
m_Color: {r: 0.8679245, g: 0.6164698, b: 0, a: 1}
m_Color: {r: 0.78431374, g: 0.5882353, b: 0, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0

View file

@ -249,7 +249,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6234653028453841298}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 618b0e3f6c65dd247a4a016150006c57, type: 3}
m_Name:

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),
}),