HeavenStudioPlus/Assets/Scripts/Games/ForkLifter/Pea.cs

50 lines
1.4 KiB
C#
Raw Normal View History

2021-12-21 01:10:49 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RhythmHeavenMania.Util;
namespace RhythmHeavenMania.Games.ForkLifter
{
public class Pea : PlayerActionObject
2021-12-21 01:10:49 +00:00
{
private Animator anim;
public float startBeat;
public int type;
private void Start()
{
anim = GetComponent<Animator>();
2021-12-23 22:39:03 +00:00
Jukebox.PlayOneShotGame("forkLifter/zoom");
2021-12-21 01:10:49 +00:00
GetComponentInChildren<SpriteRenderer>().sprite = ForkLifter.instance.peaSprites[type];
for (int i = 0; i < transform.GetChild(0).childCount; i++)
{
transform.GetChild(0).GetChild(i).GetComponent<SpriteRenderer>().sprite = transform.GetChild(0).GetComponent<SpriteRenderer>().sprite;
}
PlayerActionInit(this.gameObject, startBeat, ForkLifter.instance.EligibleHits);
isEligible = true;
2021-12-21 01:10:49 +00:00
}
private void Update()
{
2021-12-25 02:37:03 +00:00
float normalizedBeatAnim = Conductor.instance.GetLoopPositionFromBeat(startBeat, 2.5f);
anim.Play("Flicked_Object", -1, normalizedBeatAnim);
2021-12-21 01:10:49 +00:00
anim.speed = 0;
2021-12-25 02:37:03 +00:00
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, 2f);
StateCheck(normalizedBeat);
2021-12-21 01:10:49 +00:00
if (normalizedBeat > 1.35f)
{
Jukebox.PlayOneShot("audience/disappointed");
2021-12-21 01:10:49 +00:00
Destroy(this.gameObject);
}
}
}
}