2023-03-27 02:26:11 +00:00
|
|
|
using HeavenStudio.Util;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
using NaughtyBezierCurves;
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games.Scripts_MunchyMonk
|
|
|
|
{
|
2023-05-07 20:33:15 +00:00
|
|
|
public class Dumpling : MonoBehaviour
|
2023-03-27 02:26:11 +00:00
|
|
|
{
|
2023-05-23 04:09:46 +00:00
|
|
|
public Color dumplingColor;
|
2023-06-10 19:17:06 +00:00
|
|
|
public double startBeat;
|
2023-05-23 04:09:46 +00:00
|
|
|
|
2023-03-27 02:26:11 +00:00
|
|
|
const string sfxName = "munchyMonk/";
|
2023-05-23 04:09:46 +00:00
|
|
|
public bool canDestroy;
|
2023-03-27 02:26:11 +00:00
|
|
|
|
|
|
|
[Header("References")]
|
|
|
|
[SerializeField] Animator smearAnim;
|
|
|
|
[SerializeField] Animator anim;
|
2023-05-23 04:09:46 +00:00
|
|
|
[SerializeField] SpriteRenderer smearSr;
|
|
|
|
public SpriteRenderer sr;
|
2023-03-27 02:26:11 +00:00
|
|
|
|
|
|
|
private MunchyMonk game;
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
game = MunchyMonk.instance;
|
2023-05-23 04:09:46 +00:00
|
|
|
sr = GetComponent<SpriteRenderer>();
|
2023-03-27 02:26:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
2023-05-23 04:09:46 +00:00
|
|
|
sr.color = dumplingColor;
|
|
|
|
if (game.dumplings.Count > 1) {
|
|
|
|
anim.Play("IdleOnTop", 0, 0);
|
|
|
|
game.dumplings[0].anim.DoScaledAnimationAsync("Squish", 0.5f);
|
2023-03-27 02:26:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
if (canDestroy && anim.IsAnimationNotPlaying()) GameObject.Destroy(gameObject);
|
|
|
|
}
|
|
|
|
|
2023-05-23 04:09:46 +00:00
|
|
|
public void HitFunction(float state)
|
2023-03-27 02:26:11 +00:00
|
|
|
{
|
2023-05-23 04:09:46 +00:00
|
|
|
smearSr.color = dumplingColor;
|
|
|
|
game.MonkArmsAnim.DoScaledAnimationAsync("WristSlap", 0.5f);
|
2023-06-10 19:17:06 +00:00
|
|
|
SoundByte.PlayOneShotGame(sfxName+"slap");
|
2023-05-23 04:09:46 +00:00
|
|
|
game.isStaring = false;
|
|
|
|
|
|
|
|
if (state >= 1f || state <= -1f)
|
|
|
|
{
|
|
|
|
game.MonkAnim.DoScaledAnimationAsync("Barely", 0.5f);
|
|
|
|
anim.DoScaledAnimationAsync("HitHead", 0.5f);
|
2023-06-10 19:17:06 +00:00
|
|
|
SoundByte.PlayOneShotGame(sfxName+"barely");
|
2023-05-23 04:09:46 +00:00
|
|
|
canDestroy = true;
|
|
|
|
game.needBlush = false;
|
|
|
|
} else {
|
|
|
|
game.MonkAnim.DoScaledAnimationAsync("Eat", 0.4f);
|
|
|
|
game.dumplings[0].anim.DoScaledAnimationAsync("FollowHand", 0.5f);
|
|
|
|
smearAnim.Play("SmearAppear", 0, 0);
|
|
|
|
game.needBlush = true;
|
2023-06-10 19:17:06 +00:00
|
|
|
SoundByte.PlayOneShotGame(sfxName+"gulp");
|
2023-05-23 04:09:46 +00:00
|
|
|
MunchyMonk.howManyGulps++;
|
|
|
|
for (int i = 1; i <= 4; i++)
|
2023-03-27 02:26:11 +00:00
|
|
|
{
|
2023-05-23 04:09:46 +00:00
|
|
|
if (MunchyMonk.howManyGulps == MunchyMonk.inputsTilGrow*i) {
|
|
|
|
MunchyMonk.growLevel = i;
|
|
|
|
}
|
2023-03-27 02:26:11 +00:00
|
|
|
}
|
2023-05-23 04:09:46 +00:00
|
|
|
GameObject.Destroy(gameObject);
|
2023-03-27 02:26:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-23 04:09:46 +00:00
|
|
|
public void MissFunction()
|
2023-03-27 02:26:11 +00:00
|
|
|
{
|
|
|
|
if (!canDestroy) {
|
|
|
|
anim.DoScaledAnimationAsync("FallOff", 0.5f);
|
|
|
|
canDestroy = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-23 04:09:46 +00:00
|
|
|
public void EarlyFunction()
|
|
|
|
{
|
|
|
|
game.MonkArmsAnim.DoScaledAnimationAsync("WristSlap", 0.5f);
|
|
|
|
game.MonkAnim.DoScaledAnimationAsync("Miss", 0.5f);
|
|
|
|
smearAnim.Play("SmearAppear", 0, 0);
|
|
|
|
anim.DoScaledAnimationAsync("HitHead", 0.5f);
|
|
|
|
MultiSound.Play(new MultiSound.Sound[] {
|
2023-06-10 19:17:06 +00:00
|
|
|
new MultiSound.Sound(sfxName+"slap", Conductor.instance.songPositionInBeatsAsDouble),
|
|
|
|
new MultiSound.Sound(sfxName+"miss", Conductor.instance.songPositionInBeatsAsDouble),
|
2023-05-23 04:09:46 +00:00
|
|
|
});
|
|
|
|
canDestroy = true;
|
|
|
|
game.needBlush = false;
|
2023-03-27 02:26:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|