d83900fe5b
* Begun * horizon * Added animators and attention company voiceline * Success Inputs and audio done * some flipper flop anims * Icon + Flipper roll improvements + anim implementation * Code cleanified * Begun work on missing logic and sounds and faces * Faces fixing * Barely faces and sound * forgort this * Miss faces for the player implemented * flippers done * a few fixes * Gave captain tuck's head an animator * mirrored anims * more anim stuff * Implemented some anims and shit * more anim stufff * Implemented dem anims * captain tuck anims * More implementations * reverse rolls * captain tuck walk * more animation nonsense * more tweaks lol * camera and move stuff, buggy though * I hate this bug ! * Implemented more anims! WOw! * Walking * Grrr * More stuff implemented yippee * roll fixes * anim stuff 2 * oops * new anim scaling * Fixed stuff * fixing past mistakes * Exposed roll distance in inspector * anim nonsense * Lots of fixes and tweaks and small additions * Fixes!!!!!! * Changed to an uh slider instead of tickbox * animation adjustments * snow particles * implemented snow particle * Miss sound improved and whiffs added * miss anims * Updated bop and ability to mute attention company voice line * Impact fixes --------- Co-authored-by: ev <85412919+evdial@users.noreply.github.com>
159 lines
5.6 KiB
C#
159 lines
5.6 KiB
C#
using HeavenStudio.Util;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace HeavenStudio.Games.Scripts_FlipperFlop
|
|
{
|
|
public class FlipperFlopFlipper : MonoBehaviour
|
|
{
|
|
[SerializeField] Animator anim;
|
|
[SerializeField] Animator faceAnim;
|
|
[SerializeField] GameObject leftImpact;
|
|
[SerializeField] GameObject rightImpact;
|
|
public bool player;
|
|
public bool left;
|
|
bool up;
|
|
bool canBlink = true;
|
|
private FlipperFlop game;
|
|
|
|
private void Awake()
|
|
{
|
|
faceAnim.Play("FaceNormal", 0, 0);
|
|
game = FlipperFlop.instance;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (UnityEngine.Random.Range(1, 600) == 1 && canBlink && !isPlaying(faceAnim, "FlipperBlink"))
|
|
{
|
|
faceAnim.DoScaledAnimationAsync("FlipperBlink", 0.5f);
|
|
}
|
|
}
|
|
|
|
public void Impact(bool enableRight)
|
|
{
|
|
if (enableRight)
|
|
{
|
|
rightImpact.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
leftImpact.SetActive(true);
|
|
}
|
|
faceAnim.Play("FaceAngry", 0, 0);
|
|
BeatAction.New(game.gameObject, new List<BeatAction.Action>()
|
|
{
|
|
new BeatAction.Action(Conductor.instance.songPositionInBeats + 0.1f, delegate { leftImpact.SetActive(false); rightImpact.SetActive(false); }),
|
|
new BeatAction.Action(Conductor.instance.songPositionInBeats + 0.3f, delegate { faceAnim.Play("FaceAnnoyed", 0, 0); })
|
|
});
|
|
}
|
|
|
|
public void PrepareFlip()
|
|
{
|
|
anim.DoScaledAnimationAsync("PrepareFlop", 0.5f);
|
|
}
|
|
|
|
public void Flip(bool roll, bool hit, bool barely = false, bool dontSwitch = false)
|
|
{
|
|
if (roll)
|
|
{
|
|
if (player && hit && !barely)
|
|
{
|
|
Jukebox.PlayOneShotGame("flipperFlop/roll" + (left ? "L" : "R"));
|
|
faceAnim.Play("FaceNormal", 0, 0);
|
|
canBlink = true;
|
|
}
|
|
else if (player && barely && hit)
|
|
{
|
|
Jukebox.PlayOneShotGame("flipperFlop/tink");
|
|
faceAnim.Play("FaceBarely", 0, 0);
|
|
canBlink = false;
|
|
}
|
|
else if (player && !hit)
|
|
{
|
|
faceAnim.Play("FaceOw");
|
|
canBlink = false;
|
|
Jukebox.PlayOneShotGame("flipperFlop/failgroan");
|
|
game.BumpIntoOtherSeal(!left);
|
|
BeatAction.New(this.gameObject, new List<BeatAction.Action>()
|
|
{
|
|
new BeatAction.Action(Conductor.instance.songPositionInBeats + 0.3f, delegate { faceAnim.Play("FaceGoofy"); }),
|
|
});
|
|
}
|
|
|
|
up = !up;
|
|
}
|
|
else
|
|
{
|
|
if (player && hit)
|
|
{
|
|
if (up && !barely)
|
|
{
|
|
faceAnim.Play("FaceNormal", 0, 0);
|
|
Jukebox.PlayOneShotGame($"flipperFlop/flipB{UnityEngine.Random.Range(1, 3)}");
|
|
canBlink = true;
|
|
}
|
|
else if (!barely)
|
|
{
|
|
Jukebox.PlayOneShotGame($"flipperFlop/flip{UnityEngine.Random.Range(1, 3)}");
|
|
faceAnim.Play("FaceNormal", 0, 0);
|
|
canBlink = true;
|
|
}
|
|
else
|
|
{
|
|
Jukebox.PlayOneShotGame("flipperFlop/tink");
|
|
faceAnim.Play("FaceBarely", 0, 0);
|
|
canBlink = false;
|
|
}
|
|
}
|
|
else if (player)
|
|
{
|
|
faceAnim.Play("FaceOw");
|
|
canBlink = false;
|
|
string shouldReverse = up ? "Reverse" : "";
|
|
string leftOrRight = left ? "Left" : "Right";
|
|
|
|
Jukebox.PlayOneShotGame("flipperFlop/failgroan", -1, 1, 0.5f);
|
|
Jukebox.PlayOneShotGame("flipperFlop/punch", -1, 1, 0.5f);
|
|
anim.DoScaledAnimationAsync(shouldReverse + "MissFlop" + leftOrRight, 0.5f);
|
|
game.BumpIntoOtherSeal(!left);
|
|
BeatAction.New(this.gameObject, new List<BeatAction.Action>()
|
|
{
|
|
new BeatAction.Action(Conductor.instance.songPositionInBeats + 0.3f, delegate { faceAnim.Play("FaceGoofy"); }),
|
|
});
|
|
}
|
|
}
|
|
if (hit || barely || roll)
|
|
{
|
|
string shouldReverse = up ? "Reverse" : "";
|
|
if (roll) shouldReverse = !up ? "Reverse" : "";
|
|
string leftOrRight = left ? "Left" : "Right";
|
|
string rollOrFlop = roll ? "Roll" : "Flop";
|
|
|
|
anim.DoScaledAnimationAsync(shouldReverse + rollOrFlop + leftOrRight, roll ? 0.8f : 0.5f);
|
|
}
|
|
|
|
if (!dontSwitch) left = !left;
|
|
}
|
|
|
|
public void Bop()
|
|
{
|
|
anim.DoScaledAnimationAsync("FlipperBop", 0.5f);
|
|
faceAnim.Play("FaceNormal", 0, 0);
|
|
canBlink = true;
|
|
}
|
|
|
|
bool isPlaying(Animator anim, string stateName)
|
|
{
|
|
if (anim.GetCurrentAnimatorStateInfo(0).IsName(stateName) &&
|
|
anim.GetCurrentAnimatorStateInfo(0).normalizedTime < 1.0f)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
|