HeavenStudioPlus/Assets/Scripts/Games/FanClub/NtrIdolFan.cs
minenice55 52ecce8c3e
Gameplay: Timing windows use a "smart" BPM scaling system (#86)
* Game: Pajama Party

* Pajama Party: bg setup, Mako jump

* Pajama Party: mako jumping

* Pajama Party: prep landing anim references

* Pajama Party: several anims, improved 3d scene

* Pajama Party: bg cleanup

* Pajama Party: Mako sleeping anims

* Pajama Party: All Mako anims, add sounds to fs

* Pajama Party: prep monkey prefab

* Pajama Party: thrown pillow, prep sequences

* Pajama Party: make embarrassed catch not loop

whoops

* Pajama Party: sound adjust, prefab work

* Pajama Party: monkey spawning, basic jumping

* Pajama Party: jump sequence

no input detection or landing yet

* Pajama Party: anims override

* Pajama Party: jump cue functional

comes with improvements and bugfixes to PlayerActionEvent

* Pajama Party: sleep cue functional

* Pajama Party: some notes

* PlayerActionEvent: more bugfixes

* Pajama Party: fully functional throw cue

* Pajama Party: start animating sleep cue

* Pajama Party: feature-complete

* Pajama Party: unfuck layering

* Pajama Party: icon

also adds Fan Club's concept icon

* Pajama Party: cues while unloaded

* inverse-scale timing windows based on speed

* Fan Club: move to new input system

* Fan Club: allow forced animations during calls

* Crop Stomp: fix camera shake regression
2022-06-03 20:15:56 -07:00

232 lines
7.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Starpelly;
using NaughtyBezierCurves;
using HeavenStudio.Util;
namespace HeavenStudio.Games.Scripts_FanClub
{
public class NtrIdolFan : PlayerActionObject
{
[Header("References")]
[SerializeField] private GameObject motionRoot;
[SerializeField] private GameObject headRoot;
public Animator animator;
public Animator headAnimator;
public ParticleSystem fanClapEffect;
public GameObject shadow;
[Header("Properties")]
[NonSerialized] public bool player = false;
public float jumpStartTime = Single.MinValue;
bool stopBeat = false;
bool stopCharge = false;
bool hasJumped = false;
float clappingStartTime = Single.MinValue;
public void AddHit(float beat, int type)
{
if (player)
{
if (type == 0) // normal clap
FanClub.instance.ScheduleInput(beat, 1f, InputType.STANDARD_DOWN, ClapJust, ClapThrough, Out);
else if (type == 1) // jump
FanClub.instance.ScheduleInput(beat, 1f, InputType.STANDARD_UP, JumpJust, JumpThrough, JumpOut);
else if (type == 2) //"kamone" charge
FanClub.instance.ScheduleInput(beat, 1f, InputType.STANDARD_DOWN, ChargeClapJust, ClapThrough, Out);
else //"kamone" long clap (first)
FanClub.instance.ScheduleInput(beat, 1f, InputType.STANDARD_DOWN, LongClapJust, ClapThrough, Out);
}
}
public void ClapJust(PlayerActionEvent caller, float state)
{
bool auto = GameManager.instance.autoplay;
ClapStart(true, false, auto ? 0.25f : 0f);
}
public void ChargeClapJust(PlayerActionEvent caller, float state)
{
bool auto = GameManager.instance.autoplay;
ClapStart(true, true, auto ? 1f : 0f);
}
public void LongClapJust(PlayerActionEvent caller, float state)
{
bool auto = GameManager.instance.autoplay;
ClapStart(true, false, auto ? 1f : 0f);
}
public void JumpJust(PlayerActionEvent caller, float state)
{
JumpStart(true);
}
public void ClapThrough(PlayerActionEvent caller) {
FanClub.instance.AngerOnMiss();
}
public void JumpThrough(PlayerActionEvent caller) {
FanClub.instance.AngerOnMiss();
}
public void Out(PlayerActionEvent caller) {}
public void JumpOut(PlayerActionEvent caller) {
var cond = Conductor.instance;
if (stopCharge)
{
caller.CanHit(false);
}
}
private void Update()
{
var cond = Conductor.instance;
if (player)
{
if (PlayerInput.Pressed())
{
if (!FanClub.instance.IsExpectingInputNow())
{
ClapStart(false);
}
}
if (PlayerInput.Pressing())
{
if (clappingStartTime != Single.MinValue && cond.songPositionInBeats > clappingStartTime + 2f && !stopCharge)
{
animator.Play("FanClapCharge", -1, 0);
stopCharge = true;
}
}
if (PlayerInput.PressedUp())
{
if (stopCharge)
{
if (!FanClub.instance.IsExpectingInputNow())
{
JumpStart(false);
}
}
else
{
animator.Play("FanFree", -1, 0);
stopBeat = false;
}
}
}
float jumpPos = cond.GetPositionFromBeat(jumpStartTime, 1f);
if (cond.songPositionInBeats >= jumpStartTime && cond.songPositionInBeats < jumpStartTime + 1f)
{
hasJumped = true;
float yMul = jumpPos * 2f - 1f;
float yWeight = -(yMul*yMul) + 1f;
motionRoot.transform.localPosition = new Vector3(0, 3f * yWeight);
shadow.transform.localScale = new Vector3((1f-yWeight*0.8f) * 1.4f, (1f-yWeight*0.8f) * 1.4f, 1f);
}
else
{
motionRoot.transform.localPosition = new Vector3(0, 0);
shadow.transform.localScale = new Vector3(1.4f, 1.4f, 1f);
if (hasJumped)
{
Jukebox.PlayOneShotGame("fanClub/landing_impact", pitch: UnityEngine.Random.Range(0.95f, 1f), volume: 1f/4);
if (player)
{
animator.Play("FanPrepare", -1, 0);
stopBeat = false;
}
}
hasJumped = false;
}
}
public void ClapStart(bool hit, bool doCharge = false, float autoplayRelease = 0f)
{
if (!hit)
{
FanClub.instance.AngerOnMiss();
}
var cond = Conductor.instance;
hasJumped = false;
stopBeat = true;
jumpStartTime = -99f;
animator.Play("FanClap", -1, 0);
Jukebox.PlayOneShotGame("fanClub/play_clap");
Jukebox.PlayOneShotGame("fanClub/crap_impact");
clappingStartTime = cond.songPositionInBeats;
if (doCharge)
BeatAction.New(this.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(cond.songPositionInBeats + 0.1f, delegate {
if (PlayerInput.Pressing() || autoplayRelease > 0f)
{
animator.Play("FanClapCharge", -1, 0);
stopCharge = true;
}
}),
});
if (autoplayRelease > 0f && !doCharge)
{
BeatAction.New(this.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(cond.songPositionInBeats + autoplayRelease, delegate {
animator.Play("FanFree", -1, 0);
stopBeat = false;
}),
});
}
}
public void JumpStart(bool hit)
{
if (!hit)
{
FanClub.instance.AngerOnMiss();
}
var cond = Conductor.instance;
animator.Play("FanJump", -1, 0);
Jukebox.PlayOneShotGame("fanClub/play_jump");
jumpStartTime = cond.songPositionInBeats;
stopCharge = false;
}
public bool IsJumping()
{
var cond = Conductor.instance;
return (cond.songPositionInBeats >= jumpStartTime && cond.songPositionInBeats < jumpStartTime + 1f);
}
public void Bop()
{
if (!stopBeat)
animator.Play("FanBeat");
}
public void ClapParticle()
{
fanClapEffect.Play();
}
public void MakeAngry(bool flip = false)
{
headAnimator.Play("FanFaceAngry", -1, 0);
if (flip)
{
headRoot.transform.localScale = new Vector3(-1f, 1f, 1f);
}
}
}
}