HeavenStudio/Assets/Scripts/Games/MunchyMonk/Dumpling.cs
minenice55 caf7d9465f
Play Mode Features Part 1 (#413)
* add pause menu assets

* layout and animation for pause

* make play mode prefab function

re-assign unused class inheritance

* remove filepath

* don't init medals twice

* remove PlayerActionObject

* initial attempt at anti-note lock

TODO: circumvent inputs clearing themselves making the functionality not work

* properly implement input lock prevention

* fix error on editor open

* functional pause menu

* bugfix

* make unpausing not reset current play statistics

* serialize initializer components in inspector instead of procedurally generating

* sanity check

* note for fade

* make flashes in the camera prefabs instead of in world space

remove / reorganize script files
address issue #411

* fix bug with perfect campaign

make minigame transitions hide the game canvas
adjust animation of the song credits textbox

* fully functional intro scene (placeholder for future title screen)

refactored entire game loading procedure
re-organized some files

* add interaction query to disclaimer text

* reword legal

* anchor section medals to section display

more tempo change placement controls

* operation order bugfix

* prep for future ratings and stats

* loading text

* autoload opening scene

* splash screen adjustments

added setting to force enable splash screen

* adjust setting entry
2023-05-07 20:33:15 +00:00

101 lines
3.5 KiB
C#

using HeavenStudio.Util;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using NaughtyBezierCurves;
namespace HeavenStudio.Games.Scripts_MunchyMonk
{
public class Dumpling : MonoBehaviour
{
public Animator otherAnim;
public float startBeat;
public float type;
const string sfxName = "munchyMonk/";
private bool canDestroy;
[Header("References")]
[SerializeField] Animator smearAnim;
[SerializeField] Animator anim;
private MunchyMonk game;
private void Awake()
{
game = MunchyMonk.instance;
game.firstTwoMissed = false;
}
private void Start()
{
if (type == 1f || type == 3f) {
game.ScheduleInput(startBeat, 1f, InputType.STANDARD_DOWN, Hit, Miss, Early);
} else if (type >= 3.5f) {
game.ScheduleInput(startBeat, 0.75f, InputType.STANDARD_DOWN, Hit, Miss, Early);
} else {
game.ScheduleInput(startBeat, type == 2f ? 1.5f : 2f, InputType.STANDARD_DOWN, Hit, Miss, Early);
}
}
private void Update()
{
if ((!Conductor.instance.isPlaying && !Conductor.instance.isPaused) || GameManager.instance.currentGame != "munchyMonk") {
GameObject.Destroy(gameObject);
}
if (canDestroy && anim.IsAnimationNotPlaying()) GameObject.Destroy(gameObject);
}
private void Hit(PlayerActionEvent caller, float state)
{
if (!canDestroy) {
game.MonkArmsAnim.DoScaledAnimationAsync("WristSlap", 0.5f);
Jukebox.PlayOneShotGame(sfxName+"slap");
game.isStaring = false;
if (state >= 1f || state <= -1f)
{
game.MonkAnim.DoScaledAnimationAsync("Barely", 0.5f);
anim.DoScaledAnimationAsync("HitHead", 0.5f);
Jukebox.PlayOneShotGame(sfxName+"barely");
canDestroy = true;
} else {
game.MonkAnim.DoScaledAnimationAsync("Eat", 0.4f);
if (type == 2) otherAnim.DoScaledAnimationAsync("FollowHand", 0.5f);
smearAnim.Play("SmearAppear", 0, 0);
game.needBlush = true;
Jukebox.PlayOneShotGame(sfxName+"gulp");
if (game.forceGrow) game.growLevel += 1;
GameObject.Destroy(gameObject);
}
}
}
private void Miss(PlayerActionEvent caller)
{
if (!canDestroy) {
anim.DoScaledAnimationAsync("FallOff", 0.5f);
canDestroy = true;
}
}
private void Early(PlayerActionEvent caller)
{
if (!(type == 2.5f) || game.firstTwoMissed) {
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[] {
new MultiSound.Sound(sfxName+"slap", game.lastReportedBeat),
new MultiSound.Sound(sfxName+"miss", game.lastReportedBeat),
});
canDestroy = true;
game.needBlush = false;
game.firstTwoMissed = true;
}
}
}
}