2022-03-15 00:54:54 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using System;
|
|
|
|
using Starpelly;
|
2022-03-15 22:43:13 +00:00
|
|
|
using NaughtyBezierCurves;
|
2022-03-15 00:54:54 +00:00
|
|
|
|
|
|
|
using HeavenStudio.Util;
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games.Scripts_FanClub
|
|
|
|
{
|
2022-03-16 21:41:46 +00:00
|
|
|
public class NtrIdolFan : PlayerActionObject
|
2022-03-15 00:54:54 +00:00
|
|
|
{
|
|
|
|
[Header("References")]
|
2022-03-15 22:43:13 +00:00
|
|
|
[SerializeField] private GameObject motionRoot;
|
|
|
|
[SerializeField] private GameObject headRoot;
|
2022-03-15 00:54:54 +00:00
|
|
|
public Animator animator;
|
|
|
|
public Animator headAnimator;
|
|
|
|
public ParticleSystem fanClapEffect;
|
2022-03-15 22:43:13 +00:00
|
|
|
public GameObject shadow;
|
2022-03-15 00:54:54 +00:00
|
|
|
|
2022-03-15 22:43:13 +00:00
|
|
|
[Header("Properties")]
|
|
|
|
[NonSerialized] public bool player = false;
|
2022-03-17 20:43:35 +00:00
|
|
|
public float jumpStartTime = Single.MinValue;
|
2022-03-15 00:54:54 +00:00
|
|
|
bool stopBeat = false;
|
2022-03-15 22:43:13 +00:00
|
|
|
bool stopCharge = false;
|
|
|
|
bool hasJumped = false;
|
|
|
|
|
2022-06-04 03:15:56 +00:00
|
|
|
float clappingStartTime = Single.MinValue;
|
2022-03-15 22:43:13 +00:00
|
|
|
|
2022-06-09 03:35:15 +00:00
|
|
|
public void AddHit(float beat, int type = 0)
|
2022-03-16 21:41:46 +00:00
|
|
|
{
|
|
|
|
if (player)
|
2022-06-04 03:15:56 +00:00
|
|
|
{
|
2022-06-09 03:35:15 +00:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
FanClub.instance.ScheduleInput(beat, 1f, InputType.STANDARD_DOWN, ClapJust, ClapThrough, Out);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
FanClub.instance.ScheduleInput(beat, 1f, InputType.STANDARD_UP, JumpJust, JumpThrough, JumpOut);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
FanClub.instance.ScheduleInput(beat, 1f, InputType.STANDARD_DOWN, ChargeClapJust, ClapThrough, Out);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FanClub.instance.ScheduleInput(beat, 1f, InputType.STANDARD_DOWN, LongClapJust, ClapThrough, Out);
|
|
|
|
break;
|
|
|
|
}
|
2022-06-04 03:15:56 +00:00
|
|
|
}
|
2022-03-16 21:41:46 +00:00
|
|
|
}
|
|
|
|
|
2022-06-04 03:15:56 +00:00
|
|
|
public void ClapJust(PlayerActionEvent caller, float state)
|
2022-03-16 21:41:46 +00:00
|
|
|
{
|
2022-06-04 03:15:56 +00:00
|
|
|
bool auto = GameManager.instance.autoplay;
|
2022-08-19 21:08:58 +00:00
|
|
|
ClapStart(true, false, auto ? 0.1f : 0f);
|
2022-03-16 21:41:46 +00:00
|
|
|
}
|
|
|
|
|
2022-06-04 03:15:56 +00:00
|
|
|
public void ChargeClapJust(PlayerActionEvent caller, float state)
|
2022-03-16 21:41:46 +00:00
|
|
|
{
|
2022-06-04 03:15:56 +00:00
|
|
|
bool auto = GameManager.instance.autoplay;
|
|
|
|
ClapStart(true, true, auto ? 1f : 0f);
|
2022-03-16 21:41:46 +00:00
|
|
|
}
|
|
|
|
|
2022-06-04 03:15:56 +00:00
|
|
|
public void LongClapJust(PlayerActionEvent caller, float state)
|
2022-03-16 21:41:46 +00:00
|
|
|
{
|
2022-06-04 03:15:56 +00:00
|
|
|
bool auto = GameManager.instance.autoplay;
|
|
|
|
ClapStart(true, false, auto ? 1f : 0f);
|
2022-03-16 21:41:46 +00:00
|
|
|
}
|
|
|
|
|
2022-06-04 03:15:56 +00:00
|
|
|
public void JumpJust(PlayerActionEvent caller, float state)
|
2022-03-15 22:43:13 +00:00
|
|
|
{
|
2022-06-04 03:15:56 +00:00
|
|
|
JumpStart(true);
|
|
|
|
}
|
2022-03-16 21:41:46 +00:00
|
|
|
|
2022-06-04 03:15:56 +00:00
|
|
|
public void ClapThrough(PlayerActionEvent caller) {
|
|
|
|
FanClub.instance.AngerOnMiss();
|
|
|
|
}
|
2022-04-28 20:01:07 +00:00
|
|
|
|
2022-06-04 03:15:56 +00:00
|
|
|
public void JumpThrough(PlayerActionEvent caller) {
|
|
|
|
FanClub.instance.AngerOnMiss();
|
|
|
|
}
|
2022-03-16 21:41:46 +00:00
|
|
|
|
2022-06-04 03:15:56 +00:00
|
|
|
public void Out(PlayerActionEvent caller) {}
|
2022-03-16 21:41:46 +00:00
|
|
|
|
2022-06-04 03:15:56 +00:00
|
|
|
public void JumpOut(PlayerActionEvent caller) {
|
|
|
|
var cond = Conductor.instance;
|
|
|
|
if (stopCharge)
|
2022-03-16 21:41:46 +00:00
|
|
|
{
|
2022-06-04 03:15:56 +00:00
|
|
|
caller.CanHit(false);
|
2022-03-16 21:41:46 +00:00
|
|
|
}
|
2022-06-04 03:15:56 +00:00
|
|
|
}
|
2022-03-16 21:41:46 +00:00
|
|
|
|
2022-06-04 03:15:56 +00:00
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
var cond = Conductor.instance;
|
2022-03-16 21:41:46 +00:00
|
|
|
|
2022-03-15 22:43:13 +00:00
|
|
|
if (player)
|
|
|
|
{
|
2022-06-04 03:15:56 +00:00
|
|
|
if (PlayerInput.Pressed())
|
2022-03-16 21:41:46 +00:00
|
|
|
{
|
2022-06-04 03:15:56 +00:00
|
|
|
if (!FanClub.instance.IsExpectingInputNow())
|
2022-03-16 21:41:46 +00:00
|
|
|
{
|
2022-06-04 03:15:56 +00:00
|
|
|
ClapStart(false);
|
2022-03-16 21:41:46 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-15 22:43:13 +00:00
|
|
|
if (PlayerInput.Pressing())
|
|
|
|
{
|
2022-06-04 03:15:56 +00:00
|
|
|
if (clappingStartTime != Single.MinValue && cond.songPositionInBeats > clappingStartTime + 2f && !stopCharge)
|
2022-03-15 22:43:13 +00:00
|
|
|
{
|
2022-03-27 23:05:08 +00:00
|
|
|
animator.Play("FanClapCharge", -1, 0);
|
2022-03-15 22:43:13 +00:00
|
|
|
stopCharge = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (PlayerInput.PressedUp())
|
|
|
|
{
|
2022-06-09 03:35:15 +00:00
|
|
|
if (clappingStartTime != Single.MinValue && cond.songPositionInBeats > clappingStartTime + 2f && stopCharge && !FanClub.instance.IsExpectingInputNow())
|
2022-03-15 22:43:13 +00:00
|
|
|
{
|
2022-06-09 03:35:15 +00:00
|
|
|
JumpStart(false);
|
2022-03-15 22:43:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-03-27 23:05:08 +00:00
|
|
|
animator.Play("FanFree", -1, 0);
|
2022-03-15 22:43:13 +00:00
|
|
|
stopBeat = false;
|
2022-07-24 02:24:07 +00:00
|
|
|
clappingStartTime = Single.MinValue;
|
2022-03-15 22:43:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2022-09-18 20:48:14 +00:00
|
|
|
animator.Play("FanJump", -1, 0);
|
2022-03-15 22:43:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
motionRoot.transform.localPosition = new Vector3(0, 0);
|
|
|
|
shadow.transform.localScale = new Vector3(1.4f, 1.4f, 1f);
|
2022-03-17 21:01:26 +00:00
|
|
|
if (hasJumped)
|
2022-03-15 22:43:13 +00:00
|
|
|
{
|
2022-03-17 21:01:26 +00:00
|
|
|
Jukebox.PlayOneShotGame("fanClub/landing_impact", pitch: UnityEngine.Random.Range(0.95f, 1f), volume: 1f/4);
|
|
|
|
if (player)
|
|
|
|
{
|
2022-03-27 23:05:08 +00:00
|
|
|
animator.Play("FanPrepare", -1, 0);
|
2022-03-17 21:01:26 +00:00
|
|
|
stopBeat = false;
|
|
|
|
}
|
2022-03-15 22:43:13 +00:00
|
|
|
}
|
|
|
|
hasJumped = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-04 03:15:56 +00:00
|
|
|
public void ClapStart(bool hit, bool doCharge = false, float autoplayRelease = 0f)
|
2022-03-15 22:43:13 +00:00
|
|
|
{
|
2022-06-04 03:15:56 +00:00
|
|
|
if (!hit)
|
2022-03-15 22:43:13 +00:00
|
|
|
{
|
|
|
|
FanClub.instance.AngerOnMiss();
|
|
|
|
}
|
2022-06-04 03:15:56 +00:00
|
|
|
|
|
|
|
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)
|
2022-03-15 22:43:13 +00:00
|
|
|
BeatAction.New(this.gameObject, new List<BeatAction.Action>()
|
|
|
|
{
|
|
|
|
new BeatAction.Action(cond.songPositionInBeats + 0.1f, delegate {
|
2022-06-04 03:15:56 +00:00
|
|
|
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 {
|
2022-03-27 23:05:08 +00:00
|
|
|
animator.Play("FanFree", -1, 0);
|
2022-03-15 22:43:13 +00:00
|
|
|
stopBeat = false;
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-04 03:15:56 +00:00
|
|
|
public void JumpStart(bool hit)
|
2022-03-15 22:43:13 +00:00
|
|
|
{
|
2022-06-04 03:15:56 +00:00
|
|
|
if (!hit)
|
2022-03-15 22:43:13 +00:00
|
|
|
{
|
|
|
|
FanClub.instance.AngerOnMiss();
|
|
|
|
}
|
2022-06-04 03:15:56 +00:00
|
|
|
|
|
|
|
var cond = Conductor.instance;
|
|
|
|
animator.Play("FanJump", -1, 0);
|
|
|
|
Jukebox.PlayOneShotGame("fanClub/play_jump");
|
|
|
|
jumpStartTime = cond.songPositionInBeats;
|
2022-07-24 02:24:07 +00:00
|
|
|
clappingStartTime = Single.MinValue;
|
2022-06-04 03:15:56 +00:00
|
|
|
stopCharge = false;
|
2022-03-15 22:43:13 +00:00
|
|
|
}
|
2022-03-15 00:54:54 +00:00
|
|
|
|
2022-03-17 19:13:48 +00:00
|
|
|
public bool IsJumping()
|
|
|
|
{
|
|
|
|
var cond = Conductor.instance;
|
|
|
|
return (cond.songPositionInBeats >= jumpStartTime && cond.songPositionInBeats < jumpStartTime + 1f);
|
|
|
|
}
|
|
|
|
|
2022-03-15 00:54:54 +00:00
|
|
|
public void Bop()
|
|
|
|
{
|
2022-03-15 22:43:13 +00:00
|
|
|
if (!stopBeat)
|
2022-03-17 19:13:48 +00:00
|
|
|
animator.Play("FanBeat");
|
2022-03-15 00:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void ClapParticle()
|
|
|
|
{
|
|
|
|
fanClapEffect.Play();
|
|
|
|
}
|
2022-03-15 22:43:13 +00:00
|
|
|
|
|
|
|
public void MakeAngry(bool flip = false)
|
|
|
|
{
|
2022-03-27 23:05:08 +00:00
|
|
|
headAnimator.Play("FanFaceAngry", -1, 0);
|
2022-03-15 22:43:13 +00:00
|
|
|
if (flip)
|
|
|
|
{
|
|
|
|
headRoot.transform.localScale = new Vector3(-1f, 1f, 1f);
|
|
|
|
}
|
|
|
|
}
|
2022-03-15 00:54:54 +00:00
|
|
|
}
|
2022-03-15 22:43:13 +00:00
|
|
|
}
|