2023-05-19 22:21:02 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using HeavenStudio.Util;
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games.Scripts_TossBoys
|
|
|
|
{
|
|
|
|
public class TossKid : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField] ParticleSystem _hitEffect;
|
|
|
|
[SerializeField] GameObject arrow;
|
|
|
|
Animator anim;
|
|
|
|
[SerializeField] string prefix;
|
|
|
|
TossBoys game;
|
|
|
|
public bool crouch;
|
|
|
|
bool preparing;
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
anim = GetComponent<Animator>();
|
|
|
|
game = TossBoys.instance;
|
|
|
|
DoAnimationScaledAsync("Idle", 20f);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void HitBall(bool hit = true)
|
|
|
|
{
|
|
|
|
if (hit)
|
|
|
|
{
|
|
|
|
ParticleSystem spawnedEffect = Instantiate(_hitEffect, transform);
|
|
|
|
spawnedEffect.Play();
|
|
|
|
DoAnimationScaledAsync(crouch ? "CrouchHit" : "Hit", 0.5f);
|
|
|
|
}
|
2023-12-06 01:59:36 +00:00
|
|
|
else if (!anim.IsPlayingAnimationNames(prefix + "Whiff", prefix + "Miss"))
|
2023-05-19 22:21:02 +00:00
|
|
|
{
|
|
|
|
DoAnimationScaledAsync("Whiff", 0.5f);
|
2023-06-10 19:13:29 +00:00
|
|
|
SoundByte.PlayOneShotGame("tossBoys/whiff");
|
2023-05-19 22:21:02 +00:00
|
|
|
}
|
2023-10-29 19:44:47 +00:00
|
|
|
preparing = false;
|
2023-05-19 22:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Bop()
|
|
|
|
{
|
2023-12-06 01:59:36 +00:00
|
|
|
if (crouch || preparing || (!anim.IsAnimationNotPlaying() && !anim.IsPlayingAnimationNames(prefix + "Idle"))) return;
|
2023-05-19 22:21:02 +00:00
|
|
|
DoAnimationScaledAsync("Bop", 0.5f);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Crouch()
|
|
|
|
{
|
|
|
|
DoAnimationScaledAsync("Crouch", 0.5f);
|
|
|
|
crouch = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void PopBall()
|
|
|
|
{
|
|
|
|
DoAnimationScaledAsync("Slap", 0.5f);
|
|
|
|
preparing = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void PopBallPrepare()
|
|
|
|
{
|
|
|
|
if (preparing) return;
|
|
|
|
DoAnimationScaledAsync("PrepareHand", 0.5f);
|
|
|
|
preparing = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Miss()
|
|
|
|
{
|
|
|
|
DoAnimationScaledAsync("Miss", 0.5f);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Barely()
|
|
|
|
{
|
|
|
|
DoAnimationScaledAsync("Barely", 0.5f);
|
|
|
|
}
|
|
|
|
|
2023-06-10 19:13:29 +00:00
|
|
|
public void ShowArrow(double startBeat, float length)
|
2023-05-19 22:21:02 +00:00
|
|
|
{
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(game, new List<BeatAction.Action>(){
|
2023-05-19 22:21:02 +00:00
|
|
|
new BeatAction.Action(startBeat, delegate { arrow.SetActive(true); }),
|
|
|
|
new BeatAction.Action(startBeat + length, delegate { arrow.SetActive(false); }),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoAnimationScaledAsync(string name, float time)
|
|
|
|
{
|
|
|
|
anim.DoScaledAnimationAsync(prefix + name, time);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|