HeavenStudioPlus/Assets/Scripts/Games/ForkLifter/ForkLifterHand.cs
AstrlJelly 30a275da8b Collapsing Properties Update + Animation From Beat Method (#575)
* add entity to collapse function, start on new animation thingy

im gonna use fork lifter to demonstrate DoScaledAnimationFromBeatAsync() cuz it uses animations to cue the peas

also i fixed that months old bug where the fork lifter sfx wasn't playing correctly :/

* animation from beat functional, octo machine converted

this looks fantastic i can't wait to implement this into more things

* better anim function

this is more efficient AND it'll produce more consistent results when starting an animation between tempo changes :D
(it no longer iterates through a list twice)
2023-10-27 20:19:11 +00:00

47 lines
No EOL
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using HeavenStudio.Util;
using Jukebox;
using Jukebox.Legacy;
namespace HeavenStudio.Games.Scripts_ForkLifter
{
public class ForkLifterHand : MonoBehaviour
{
public SpriteRenderer fastSprite;
public Sprite[] fastSprites;
public List<RiqEntity> allFlickEntities = new List<RiqEntity>();
public int currentFlickIndex;
ForkLifter game;
private void Awake()
{
game = ForkLifter.instance;
}
public void CheckNextFlick()
{
if (allFlickEntities.Count > 0 && currentFlickIndex >= 0 && currentFlickIndex < allFlickEntities.Count)
{
int nextType = allFlickEntities[currentFlickIndex]["type"];
game.peaPreview.sprite = game.peaSprites[nextType];
fastSprite.sprite = fastSprites[nextType == (int)ForkLifter.FlickType.Burger ? 1 : 0];
} else {
game.peaPreview.sprite = null;
}
}
public void Prepare(bool mute)
{
if (!mute) SoundByte.PlayOneShotGame("forkLifter/flickPrepare");
GetComponent<Animator>().Play("Hand_Prepare", 0, 0);
}
}
}