HeavenStudio/Assets/Scripts/Games/Cannery/Can.cs
AstrlJelly a1f872ef4f
The Cannery (#730)
* everything!

conveyor belt is lined up with cans, ive got the blackout in, everythings good. i might add in some recoloring, tho

* rename to cannery and The Cannery, respectively

* ColorEase struct, new spritesheet

* a few anims, uninstancing start

compiler errors! just wanna get mannequin factory done

* a singular semicolon

good job me

* update: revoked semicolon and A privileges

* The: fix

mwuahahhaha

* started working on anims

* restore lost anims and some new ones

* add new anims

* add icon, remove colorease

adding colorease in a different pr

* BG stuffs

* Cannery Visual Overhaul

Yeah!

* ok for some reason this animation was not in the changes list until i closed unity yeah ok fuck you

* make bg controlled by code

simple ease + speed modifier and it's controlled by delta time
and that's cannery finished!! it truly looks amazing now.

---------

Co-authored-by: Seanski2 <seanbenedit@gmail.com>
Co-authored-by: saladplainzone <chocolate2890mail@gmail.com>
2024-03-04 03:50:43 +00:00

49 lines
1.5 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
namespace HeavenStudio.Games.Scripts_Cannery
{
public class Can : MonoBehaviour
{
public double startBeat;
[Header("Components")]
[SerializeField] Animator anim;
public Cannery game;
private void Awake()
{
if (Random.Range(0, 1f) >= 0.5f) anim.Play("Flip", 0);
game.ScheduleInput(startBeat, 1, Minigame.InputAction_BasicPress, Hit, null, null);
}
private void Update()
{
float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat, 2);
if (normalizedBeat > 1) Destroy(gameObject);
anim.DoNormalizedAnimation("Move", normalizedBeat, 0);
}
private void Hit(PlayerActionEvent caller, float state)
{
SoundByte.PlayOneShotGame("cannery/can");
anim.DoScaledAnimationAsync("Can", 0.5f, 0, 1);
if (state is >= 1 or <= -1) {
SoundByte.PlayOneShot("miss");
game.cannerAnim.DoScaledAnimationAsync("CanBarely", 0.5f);
double beat = caller.startBeat + caller.timer;
BeatAction.New(this, new() {
new(beat + 0.35f, () => anim.DoScaledAnimationAsync("Reopen", 0.5f, 0, 1))
});
} else {
game.cannerAnim.DoScaledAnimationAsync("Can", 0.5f);
}
}
}
}