HeavenStudioPlus/Assets/Scripts/Games/RhythmTweezers/LongHair.cs

115 lines
3.7 KiB
C#
Raw Normal View History

2022-02-10 08:13:54 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2022-03-14 14:21:05 +00:00
using HeavenStudio.Util;
Rockers + Rhythm Tweezers Call and Response API (#444) * rock hers * Rockers is a real game and also color maps have been added * little more set up * anims and mor sprites * First version of CallAndResponseHandler added * You can mute now wow * Got some stuff working * anim city * Fixed Inputs * Visual goodies * Changed how some events work * Rockers is now stack proof * Fixed a bug * Bend early stages * bendbendbendbendbendover * bend fully implemented * Removed "noise" * pain * Many animation * Bend anims implemented * strum effect implemented * Made bends work way better * dfgdfsgsdffsd * Implemented strumstart and countin * hi * Made strumstart transition into strumidle * Implemented samples * All of the btsds samples are in now too * many anim2 * A buggy version of the custom together system has been implemented * Ok now it's unbuggified * fixed a small thing * lightning eff * anim fixes * oops * you can now mute voiceline and also put in a standalone voiceline block * Tweaks to dropdowns * more tiny anim thing * more animation stuff * Bug fixes * implemented mute and gotomiddle sliders for custom together event * Default cmon and last one added * You can chain last ones and cmons now * Applause sounds added * Fixed some bugs * Made it so you can disable camera movement * fixed an inconsistency * Rhythm tweezers is actually kinda playable now, not finished though, i need to make beat offset work with this * Rhythm tweezers now works between game switches * Beat offset eradication * Made eye size work properly * Camera quad ease rather than quint * Inactive intervals added * Rockers works inactively too now * Bug fix * No peeking! No way! * Alt smile added for tweezers * early and late riff * jj miss anim * icon and miss * Long hair works properly now * Miss anims implemented for rockers --------- Co-authored-by: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Co-authored-by: minenice55 <star.elementa@gmail.com>
2023-05-29 20:09:34 +00:00
using UnityEngine.UIElements;
2022-03-14 14:21:05 +00:00
namespace HeavenStudio.Games.Scripts_RhythmTweezers
2022-02-10 08:13:54 +00:00
{
public class LongHair : MonoBehaviour
2022-02-10 08:13:54 +00:00
{
public double createBeat;
public GameObject hairSprite;
public GameObject stubbleSprite;
2022-02-10 08:13:54 +00:00
private RhythmTweezers game;
private Tweezers tweezers;
2022-02-11 07:21:43 +00:00
private Animator anim;
private int pluckState = 0;
public GameObject holder;
2022-02-11 07:21:43 +00:00
public GameObject loop;
2022-03-10 03:59:48 +00:00
private Sound pullSound;
private double inputBeat;
Rockers + Rhythm Tweezers Call and Response API (#444) * rock hers * Rockers is a real game and also color maps have been added * little more set up * anims and mor sprites * First version of CallAndResponseHandler added * You can mute now wow * Got some stuff working * anim city * Fixed Inputs * Visual goodies * Changed how some events work * Rockers is now stack proof * Fixed a bug * Bend early stages * bendbendbendbendbendover * bend fully implemented * Removed "noise" * pain * Many animation * Bend anims implemented * strum effect implemented * Made bends work way better * dfgdfsgsdffsd * Implemented strumstart and countin * hi * Made strumstart transition into strumidle * Implemented samples * All of the btsds samples are in now too * many anim2 * A buggy version of the custom together system has been implemented * Ok now it's unbuggified * fixed a small thing * lightning eff * anim fixes * oops * you can now mute voiceline and also put in a standalone voiceline block * Tweaks to dropdowns * more tiny anim thing * more animation stuff * Bug fixes * implemented mute and gotomiddle sliders for custom together event * Default cmon and last one added * You can chain last ones and cmons now * Applause sounds added * Fixed some bugs * Made it so you can disable camera movement * fixed an inconsistency * Rhythm tweezers is actually kinda playable now, not finished though, i need to make beat offset work with this * Rhythm tweezers now works between game switches * Beat offset eradication * Made eye size work properly * Camera quad ease rather than quint * Inactive intervals added * Rockers works inactively too now * Bug fix * No peeking! No way! * Alt smile added for tweezers * early and late riff * jj miss anim * icon and miss * Long hair works properly now * Miss anims implemented for rockers --------- Co-authored-by: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Co-authored-by: minenice55 <star.elementa@gmail.com>
2023-05-29 20:09:34 +00:00
PlayerActionEvent endEvent;
public void StartInput(double beat, double length, Tweezers tweezer)
2022-02-10 08:13:54 +00:00
{
game = RhythmTweezers.instance;
2022-02-11 07:21:43 +00:00
anim = GetComponent<Animator>();
tweezers = tweezer;
Rockers + Rhythm Tweezers Call and Response API (#444) * rock hers * Rockers is a real game and also color maps have been added * little more set up * anims and mor sprites * First version of CallAndResponseHandler added * You can mute now wow * Got some stuff working * anim city * Fixed Inputs * Visual goodies * Changed how some events work * Rockers is now stack proof * Fixed a bug * Bend early stages * bendbendbendbendbendover * bend fully implemented * Removed "noise" * pain * Many animation * Bend anims implemented * strum effect implemented * Made bends work way better * dfgdfsgsdffsd * Implemented strumstart and countin * hi * Made strumstart transition into strumidle * Implemented samples * All of the btsds samples are in now too * many anim2 * A buggy version of the custom together system has been implemented * Ok now it's unbuggified * fixed a small thing * lightning eff * anim fixes * oops * you can now mute voiceline and also put in a standalone voiceline block * Tweaks to dropdowns * more tiny anim thing * more animation stuff * Bug fixes * implemented mute and gotomiddle sliders for custom together event * Default cmon and last one added * You can chain last ones and cmons now * Applause sounds added * Fixed some bugs * Made it so you can disable camera movement * fixed an inconsistency * Rhythm tweezers is actually kinda playable now, not finished though, i need to make beat offset work with this * Rhythm tweezers now works between game switches * Beat offset eradication * Made eye size work properly * Camera quad ease rather than quint * Inactive intervals added * Rockers works inactively too now * Bug fix * No peeking! No way! * Alt smile added for tweezers * early and late riff * jj miss anim * icon and miss * Long hair works properly now * Miss anims implemented for rockers --------- Co-authored-by: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Co-authored-by: minenice55 <star.elementa@gmail.com>
2023-05-29 20:09:34 +00:00
inputBeat = beat + length;
game.ScheduleInput(beat, length, RhythmTweezers.InputAction_Press, StartJust, StartMiss, Out);
}
2022-02-10 08:13:54 +00:00
private void Update()
{
2022-02-11 07:21:43 +00:00
if (pluckState == 1)
{
Vector3 tst = tweezers.tweezerSpriteTrans.position;
var hairDirection = new Vector3(tst.x + 0.173f, tst.y) - holder.transform.position;
2022-02-11 07:21:43 +00:00
holder.transform.rotation = Quaternion.FromToRotation(Vector3.down, hairDirection);
float normalizedBeat = Conductor.instance.GetPositionFromBeat(inputBeat, 0.5f, ignoreSwing: false);
2022-02-11 07:21:43 +00:00
anim.Play("LoopPull", 0, normalizedBeat);
tweezers.anim.Play("Tweezers_LongPluck", 0, normalizedBeat);
if (!game.IsExpectingInputNow(RhythmTweezers.InputAction_Release) && PlayerInput.GetIsAction(RhythmTweezers.InputAction_Release) && normalizedBeat < 1f)
Rockers + Rhythm Tweezers Call and Response API (#444) * rock hers * Rockers is a real game and also color maps have been added * little more set up * anims and mor sprites * First version of CallAndResponseHandler added * You can mute now wow * Got some stuff working * anim city * Fixed Inputs * Visual goodies * Changed how some events work * Rockers is now stack proof * Fixed a bug * Bend early stages * bendbendbendbendbendover * bend fully implemented * Removed "noise" * pain * Many animation * Bend anims implemented * strum effect implemented * Made bends work way better * dfgdfsgsdffsd * Implemented strumstart and countin * hi * Made strumstart transition into strumidle * Implemented samples * All of the btsds samples are in now too * many anim2 * A buggy version of the custom together system has been implemented * Ok now it's unbuggified * fixed a small thing * lightning eff * anim fixes * oops * you can now mute voiceline and also put in a standalone voiceline block * Tweaks to dropdowns * more tiny anim thing * more animation stuff * Bug fixes * implemented mute and gotomiddle sliders for custom together event * Default cmon and last one added * You can chain last ones and cmons now * Applause sounds added * Fixed some bugs * Made it so you can disable camera movement * fixed an inconsistency * Rhythm tweezers is actually kinda playable now, not finished though, i need to make beat offset work with this * Rhythm tweezers now works between game switches * Beat offset eradication * Made eye size work properly * Camera quad ease rather than quint * Inactive intervals added * Rockers works inactively too now * Bug fix * No peeking! No way! * Alt smile added for tweezers * early and late riff * jj miss anim * icon and miss * Long hair works properly now * Miss anims implemented for rockers --------- Co-authored-by: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Co-authored-by: minenice55 <star.elementa@gmail.com>
2023-05-29 20:09:34 +00:00
{
EndEarly();
endEvent.Disable();
}
2022-02-11 07:21:43 +00:00
// Auto-release if holding at release time.
if (normalizedBeat >= 1f)
endEvent.Hit(0, 1);
}
2022-02-11 07:21:43 +00:00
loop.transform.localScale = Vector2.one / holder.transform.localScale;
}
public void EndAce()
2022-02-10 08:13:54 +00:00
{
Rockers + Rhythm Tweezers Call and Response API (#444) * rock hers * Rockers is a real game and also color maps have been added * little more set up * anims and mor sprites * First version of CallAndResponseHandler added * You can mute now wow * Got some stuff working * anim city * Fixed Inputs * Visual goodies * Changed how some events work * Rockers is now stack proof * Fixed a bug * Bend early stages * bendbendbendbendbendover * bend fully implemented * Removed "noise" * pain * Many animation * Bend anims implemented * strum effect implemented * Made bends work way better * dfgdfsgsdffsd * Implemented strumstart and countin * hi * Made strumstart transition into strumidle * Implemented samples * All of the btsds samples are in now too * many anim2 * A buggy version of the custom together system has been implemented * Ok now it's unbuggified * fixed a small thing * lightning eff * anim fixes * oops * you can now mute voiceline and also put in a standalone voiceline block * Tweaks to dropdowns * more tiny anim thing * more animation stuff * Bug fixes * implemented mute and gotomiddle sliders for custom together event * Default cmon and last one added * You can chain last ones and cmons now * Applause sounds added * Fixed some bugs * Made it so you can disable camera movement * fixed an inconsistency * Rhythm tweezers is actually kinda playable now, not finished though, i need to make beat offset work with this * Rhythm tweezers now works between game switches * Beat offset eradication * Made eye size work properly * Camera quad ease rather than quint * Inactive intervals added * Rockers works inactively too now * Bug fix * No peeking! No way! * Alt smile added for tweezers * early and late riff * jj miss anim * icon and miss * Long hair works properly now * Miss anims implemented for rockers --------- Co-authored-by: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Co-authored-by: minenice55 <star.elementa@gmail.com>
2023-05-29 20:09:34 +00:00
if (pluckState != 1) return;
2022-02-10 08:13:54 +00:00
tweezers.LongPluck(true, this);
tweezers.hitOnFrame++;
2022-02-11 07:21:43 +00:00
if (pullSound != null)
pullSound.KillLoop();
2022-02-11 07:21:43 +00:00
pluckState = -1;
}
public void EndEarly()
2022-02-11 07:21:43 +00:00
{
var normalized = Conductor.instance.GetPositionFromBeat(inputBeat, 0.5f, ignoreSwing: false);
anim.Play("LoopPullReverse", 0, normalized);
Rockers + Rhythm Tweezers Call and Response API (#444) * rock hers * Rockers is a real game and also color maps have been added * little more set up * anims and mor sprites * First version of CallAndResponseHandler added * You can mute now wow * Got some stuff working * anim city * Fixed Inputs * Visual goodies * Changed how some events work * Rockers is now stack proof * Fixed a bug * Bend early stages * bendbendbendbendbendover * bend fully implemented * Removed "noise" * pain * Many animation * Bend anims implemented * strum effect implemented * Made bends work way better * dfgdfsgsdffsd * Implemented strumstart and countin * hi * Made strumstart transition into strumidle * Implemented samples * All of the btsds samples are in now too * many anim2 * A buggy version of the custom together system has been implemented * Ok now it's unbuggified * fixed a small thing * lightning eff * anim fixes * oops * you can now mute voiceline and also put in a standalone voiceline block * Tweaks to dropdowns * more tiny anim thing * more animation stuff * Bug fixes * implemented mute and gotomiddle sliders for custom together event * Default cmon and last one added * You can chain last ones and cmons now * Applause sounds added * Fixed some bugs * Made it so you can disable camera movement * fixed an inconsistency * Rhythm tweezers is actually kinda playable now, not finished though, i need to make beat offset work with this * Rhythm tweezers now works between game switches * Beat offset eradication * Made eye size work properly * Camera quad ease rather than quint * Inactive intervals added * Rockers works inactively too now * Bug fix * No peeking! No way! * Alt smile added for tweezers * early and late riff * jj miss anim * icon and miss * Long hair works properly now * Miss anims implemented for rockers --------- Co-authored-by: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Co-authored-by: minenice55 <star.elementa@gmail.com>
2023-05-29 20:09:34 +00:00
tweezers.anim.Play("Tweezers_Idle", 0, 0);
if (pullSound != null)
pullSound.KillLoop();
pluckState = -1;
game.ScoreMiss();
}
private void StartJust(PlayerActionEvent caller, float state)
{
// don't count near misses
if (state >= 1f || state <= -1f) {
pluckState = -1;
return;
}
pullSound = SoundByte.PlayOneShotGame($"rhythmTweezers/longPull{UnityEngine.Random.Range(1, 5)}");
pluckState = 1;
endEvent = game.ScheduleInput(inputBeat, 0.5f, RhythmTweezers.InputAction_Release, EndJust, Out, Out);
}
private void StartMiss(PlayerActionEvent caller)
{
// this is where perfect challenge breaks
}
private void Out(PlayerActionEvent caller) {}
private void EndJust(PlayerActionEvent caller, float state)
{
if (state <= -1f) {
EndEarly();
return;
2022-02-11 07:21:43 +00:00
}
EndAce();
2022-02-10 08:13:54 +00:00
}
}
}