HeavenStudioPlus/Assets/Scripts/Games/DogNinja/ThrowObject.cs
AstrlJelly 33253e3c27
Miscellaneous Tweaks + New Scroll Script (#350)
* meat grinder prefab + sprite cutting/naming done + icon

title :)

* Boss Bop, Miss, & Signal Anims

can you read

* Boss Call Anim

self-explanatory

* fix the z axis + new sprite

still working on getting those bops working. they're a bit weird (not the anim itself)

* Restored Meat Grinder Animations

i have no idea what just happened with github but the animations are back

* All Tack Animations Complete

just missing the meat anims

* Literally two lines changed

skull emoji (forgot to set the light meat for the miss anim to inactive by default)

* Meat Grinder Anims (should be) Done

Added the Meat Hit anims

* goodnight

* bopping every beat
* tons of sfx
* meat calls with their corresponding sfx/animations have been added
* prefunctions...

* inputs + sfx + prefunction

making swift progress here :)

* little commit

more cues and animation stuff so that i can have new animations

* Meat Toss Anims

also fixed up some of tack's hit anims to make the smear more consistent

* night night

* moved all the meat stuff to a new script
 -this should help with instantiating the meat
* animations are a bit more comprehensive
* man, barelies are way easier than i thought they were gonna be

* instantiating works now

committing to work on my pc instead of my laptop

but i have been getting a lot done with the meat! it's just that most of that stuff is learning what i can't do...

* Boss Animation Tweaks

Adjusted Boss' bop and miss animations

* woohoo animation!

hi sean this is for u. tell me anything to tweak :)

* Quick Meat Toss Anim Fix

Prevents meat from playing the toss animation twice

* meat hit animation works!

sometimes there's a frame where the first frame of its animation pops up but i should be able to fix that

also just general improvements + framework for different meats

* it's done! or at least out of wip!

* you can select which meat type is tossed (defaults to random)
* ghost meat has been busted (it looped back to its first frame of anim sometimes right before being destroyed; i just added a single frame idle.)
* overall just optimized code
* removed WIP from game name

* a few touch-ups

* change all sfx to ogg
 -also amplified toss.ogg by 4db, was hard to hear at the same time as hitting a cue
* fixed boss not bopping a beat after a signal
 -a very small bit hacky but it really works fine. will fix if any problems come up (but i added a check so that there shouldn't be)

* i have stashed changes :P

* new bg + remove references

title

* boss weird bopping fixed + game switches fixed

* final touch-ups

* random things just broke

* for whatever reason animation controller for boss got reverted, breaking an animation
* and we forgot to merge two spritesheets instead of just replacing one with the other. oops

* sfx volume lowerd

* ok cool commit time

* added superscroll (MADE BY STARPELLY)
* fixed dog ninja backwards compatibility
* fixed meat grinder's startinterval need
* added d pad controls to dog ninja and meat grinder

* oops forgot to add dpad for dog ninja

* remove d-pad from meat grinder 😢

---------

Co-authored-by: Seanski2 <seanbenedit@gmail.com>
2023-03-18 04:40:20 +00:00

158 lines
5.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using NaughtyBezierCurves;
using HeavenStudio.Util;
namespace HeavenStudio.Games.Scripts_DogNinja
{
public class ThrowObject : PlayerActionObject
{
public float startBeat;
public int type;
public string textObj;
public bool fromLeft;
public bool fromRight;
public int direction;
private Vector3 objPos;
private bool isActive = true;
private float barelyTime;
string sfxNum = "dogNinja/";
[Header("Animators")]
Animator DogAnim;
[Header("References")]
public BezierCurve3D curve;
[SerializeField] BezierCurve3D barelyCurve;
[SerializeField] BezierCurve3D BarelyLeftCurve;
[SerializeField] BezierCurve3D BarelyRightCurve;
[SerializeField] GameObject HalvesLeftBase;
[SerializeField] GameObject HalvesRightBase;
[SerializeField] Transform ObjectParent;
public Sprite[] objectLeftHalves;
public Sprite[] objectRightHalves;
private DogNinja game;
private void Awake()
{
game = DogNinja.instance;
DogAnim = game.DogAnim;
}
private void Start()
{
barelyCurve = fromLeft ? BarelyRightCurve : BarelyLeftCurve;
sfxNum += type < 7 ? "fruit" : textObj;
if (direction == 2 && fromLeft) {} else { Jukebox.PlayOneShotGame(sfxNum+"1"); }
game.ScheduleInput(startBeat, 1f, InputType.STANDARD_DOWN | InputType.DIRECTION_DOWN, Hit, Miss, Out);
DogAnim.SetBool("needPrepare", true);
}
private void Update()
{
float flyPos = Conductor.instance.GetPositionFromBeat(startBeat, 1f)+1.1f;
float flyPosBarely = Conductor.instance.GetPositionFromBeat(barelyTime, 1f)+1f;
if (isActive) {
flyPos *= 0.31f;
transform.position = curve.GetPoint(flyPos);
objPos = curve.GetPoint(flyPos);
// destroy object when it's off-screen
if (flyPos > 1f) {
GameObject.Destroy(gameObject);
}
} else {
flyPosBarely *= 0.3f;
transform.position = barelyCurve.GetPoint(flyPosBarely) + objPos;
float rot = fromLeft ? 200f : -200f;
transform.rotation = Quaternion.Euler(0, 0, transform.rotation.eulerAngles.z + (rot * Time.deltaTime));
if (flyPosBarely > 1f) {
GameObject.Destroy(gameObject);
}
}
if ((!Conductor.instance.isPlaying && !Conductor.instance.isPaused)
|| GameManager.instance.currentGame != "dogNinja") {
GameObject.Destroy(gameObject);
}
}
private void SuccessSlice()
{
string Slice = "Slice";
if (direction == 0) {
Slice += "Left";
} else if (direction == 1) {
Slice += "Right";
} else {
Slice += "Both";
}
DogAnim.DoScaledAnimationAsync(Slice, 0.5f);
if (!(direction == 2 && fromLeft)) Jukebox.PlayOneShotGame(sfxNum+"2");
game.WhichLeftHalf.sprite = objectLeftHalves[type-1];
game.WhichRightHalf.sprite = objectRightHalves[type-1];
SpawnHalves LeftHalf = Instantiate(HalvesLeftBase).GetComponent<SpawnHalves>();
LeftHalf.startBeat = startBeat;
LeftHalf.lefty = fromLeft;
LeftHalf.objPos = objPos;
SpawnHalves RightHalf = Instantiate(HalvesRightBase).GetComponent<SpawnHalves>();
RightHalf.startBeat = startBeat;
RightHalf.lefty = fromLeft;
RightHalf.objPos = objPos;
GameObject.Destroy(gameObject);
}
private void JustSlice()
{
isActive = false;
barelyTime = Conductor.instance.songPositionInBeats;
string Barely = "Barely";
if (direction == 0) {
Barely += "Left";
} else if (direction == 1) {
Barely += "Right";
} else {
Barely += "Both";
}
DogAnim.DoScaledAnimationAsync(Barely, 0.5f);
Jukebox.PlayOneShotGame("dogNinja/barely");
}
private void Hit(PlayerActionEvent caller, float state)
{
game.DogAnim.SetBool("needPrepare", false);
if (state >= 1f || state <= -1f) {
JustSlice();
} else {
SuccessSlice();
}
}
private void Miss(PlayerActionEvent caller)
{
if (!DogAnim.GetBool("needPrepare")) ;
DogAnim.DoScaledAnimationAsync("UnPrepare", 0.5f);
DogAnim.SetBool("needPrepare", false);
}
private void Out(PlayerActionEvent caller)
{
DogAnim.SetBool("needPrepare", false);
}
}
}