HeavenStudioPlus/Assets/Scripts/Games/NailCarpenter/Nail.cs
フマジメ 2d42699a0d
Nail Carpenter (WIP) (#739)
* 1

* sfx

* NailCarpenter(WIP)

* Nail Carpenter(WIP) #set anim to sweets

* Nail Carpenter(WIP) #Fixed audio bugs in an unbeautiful implementation.
2024-03-04 05:58:22 +00:00

75 lines
No EOL
2.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using NaughtyBezierCurves;
using DG.Tweening;
using HeavenStudio.Util;
namespace HeavenStudio.Games.Scripts_NailCarpenter
{
public class Nail : MonoBehaviour
{
public double targetBeat;
public Animator nailAnim;
private NailCarpenter game;
public void Init()
{
game = NailCarpenter.instance;
game.ScheduleInput(targetBeat, 0, NailCarpenter.InputAction_BasicPress, HammmerJust, HammmerMiss, Empty);
game.ScheduleUserInput(targetBeat, 0, NailCarpenter.InputAction_AltFinish, strongHammmerJust, Empty, Empty);
}
private void HammmerJust(PlayerActionEvent caller, float state)
{
game.Carpenter.DoScaledAnimationAsync("carpenterHit", 0.5f);
if (state >= 1f || state <= -1f)
{
nailAnim.DoScaledAnimationAsync(
(state >= 1f ? "nailBendRight" : "nailBendLeft"), 0.5f);
SoundByte.PlayOneShot("miss");
return;
}
SoundByte.PlayOneShotGame("nailCarpenter/HammerWeak");
nailAnim.DoScaledAnimationAsync("nailHammered", 0.5f);
}
private void strongHammmerJust(PlayerActionEvent caller, float state)
{
game.ScoreMiss();
game.Carpenter.DoScaledAnimationAsync("carpenterHit", 0.5f);
if (state >= 1f || state <= -1f)
{
nailAnim.DoScaledAnimationAsync(
(state >= 1f ? "nailBendRight" : "nailBendLeft"), 0.5f);
SoundByte.PlayOneShot("miss");
return;
}
SoundByte.PlayOneShotGame("nailCarpenter/HammerStrong");
nailAnim.DoScaledAnimationAsync("nailStrongHammered", 0.5f);
}
private void HammmerMiss(PlayerActionEvent caller)
{
game.EyeAnim.DoScaledAnimationAsync("eyeBlink", 0.5f);
}
private void Empty(PlayerActionEvent caller) { }
private void Update()
{
var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused)
{
double beat = cond.songPositionInBeats;
if (targetBeat != double.MinValue)
{
if (beat >= targetBeat + 9) Destroy(gameObject);
}
}
}
}
}