2022-08-17 02:12:48 +00:00
|
|
|
using DG.Tweening;
|
|
|
|
using NaughtyBezierCurves;
|
2022-08-20 20:27:20 +00:00
|
|
|
using HeavenStudio.Util;
|
2022-08-17 02:12:48 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games.Loaders
|
|
|
|
{
|
|
|
|
using static Minigames;
|
|
|
|
public static class NtrTunnelLoader
|
|
|
|
{
|
|
|
|
public static Minigame AddGame(EventCaller eventCaller)
|
|
|
|
{
|
2023-04-02 02:28:23 +00:00
|
|
|
return new Minigame("tunnel", "Tunnel \n<color=#eb5454>[WIP]</color>", "c00000", false, false, new List<GameAction>()
|
2022-08-17 02:12:48 +00:00
|
|
|
{
|
2022-09-04 17:23:43 +00:00
|
|
|
new GameAction("cowbell", "Cowbell")
|
2022-08-17 02:12:48 +00:00
|
|
|
{
|
2023-02-21 21:56:01 +00:00
|
|
|
preFunction = delegate { Tunnel.PreStartCowbell(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); },
|
|
|
|
defaultLength = 4f,
|
2022-09-04 17:23:43 +00:00
|
|
|
resizable = true,
|
2022-08-19 04:19:08 +00:00
|
|
|
|
2022-09-04 17:23:43 +00:00
|
|
|
},
|
|
|
|
new GameAction("countin", "Count In")
|
|
|
|
{
|
2023-02-21 21:56:01 +00:00
|
|
|
preFunction = delegate { Tunnel.CountIn(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); },
|
|
|
|
defaultLength = 4f,
|
2022-09-04 17:23:43 +00:00
|
|
|
resizable = true,
|
|
|
|
}
|
2023-05-28 17:34:44 +00:00
|
|
|
},
|
|
|
|
new List<string>() {"ntr", "keep"},
|
|
|
|
"ntrtunnel", "en",
|
|
|
|
new List<string>() {"en"}
|
|
|
|
);
|
2022-08-17 02:12:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games
|
|
|
|
{
|
|
|
|
public class Tunnel : Minigame
|
|
|
|
{
|
|
|
|
public static Tunnel instance { get; set; }
|
|
|
|
|
|
|
|
[Header("Backgrounds")]
|
|
|
|
public SpriteRenderer fg;
|
|
|
|
public SpriteRenderer bg;
|
|
|
|
|
|
|
|
Tween bgColorTween;
|
|
|
|
Tween fgColorTween;
|
|
|
|
|
2022-08-18 18:23:33 +00:00
|
|
|
|
|
|
|
[Header("References")]
|
|
|
|
public GameObject frontHand;
|
|
|
|
|
|
|
|
|
2022-08-17 02:12:48 +00:00
|
|
|
[Header("Animators")]
|
2022-08-18 23:28:23 +00:00
|
|
|
public Animator cowbellAnimator;
|
2022-08-20 01:01:29 +00:00
|
|
|
public Animator driverAnimator;
|
2022-08-17 02:12:48 +00:00
|
|
|
|
2022-08-18 18:23:33 +00:00
|
|
|
[Header("Curves")]
|
|
|
|
public BezierCurve3D handCurve;
|
|
|
|
|
|
|
|
|
2022-08-20 18:45:54 +00:00
|
|
|
public GameEvent cowbell = new GameEvent();
|
2022-08-18 18:23:33 +00:00
|
|
|
|
|
|
|
|
2022-08-18 03:33:05 +00:00
|
|
|
public int driverState;
|
2022-08-17 02:12:48 +00:00
|
|
|
|
2022-08-18 18:23:33 +00:00
|
|
|
public float handStart;
|
|
|
|
public float handProgress;
|
2022-08-19 03:47:40 +00:00
|
|
|
public bool started;
|
2023-02-21 21:56:01 +00:00
|
|
|
public struct QueuedCowbell
|
|
|
|
{
|
2023-06-10 19:13:29 +00:00
|
|
|
public double beat;
|
2023-02-21 21:56:01 +00:00
|
|
|
public float length;
|
|
|
|
}
|
|
|
|
static List<QueuedCowbell> queuedInputs = new List<QueuedCowbell>();
|
2022-08-18 18:23:33 +00:00
|
|
|
|
2022-08-17 02:12:48 +00:00
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
instance = this;
|
2022-08-18 03:33:05 +00:00
|
|
|
}
|
|
|
|
|
2023-02-21 21:56:01 +00:00
|
|
|
void OnDestroy()
|
|
|
|
{
|
|
|
|
if (queuedInputs.Count > 0) queuedInputs.Clear();
|
2023-06-03 23:30:17 +00:00
|
|
|
foreach (var evt in scheduledInputs)
|
|
|
|
{
|
|
|
|
evt.Disable();
|
|
|
|
}
|
2023-02-21 21:56:01 +00:00
|
|
|
}
|
2022-08-18 03:33:05 +00:00
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
driverState = 0;
|
2022-08-18 18:23:33 +00:00
|
|
|
handStart = -1f;
|
2022-08-17 02:12:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
2022-08-20 18:45:54 +00:00
|
|
|
|
|
|
|
var cond = Conductor.instance;
|
2023-02-21 21:56:01 +00:00
|
|
|
//update hand position
|
|
|
|
handProgress = Math.Min(Conductor.instance.songPositionInBeats - handStart, 1);
|
2022-08-20 18:45:54 +00:00
|
|
|
|
|
|
|
|
2023-02-21 21:56:01 +00:00
|
|
|
frontHand.transform.position = handCurve.GetPoint(EasingFunction.EaseOutQuad(0, 1, handProgress));
|
|
|
|
if (!cond.isPlaying || cond.isPaused)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2022-08-19 03:47:40 +00:00
|
|
|
if (PlayerInput.Pressed() && !IsExpectingInputNow())
|
2022-08-18 03:33:05 +00:00
|
|
|
{
|
|
|
|
HitCowbell();
|
2022-08-20 01:01:29 +00:00
|
|
|
//print("unexpected input");
|
|
|
|
driverAnimator.Play("Angry1", -1, 0);
|
2022-08-18 03:33:05 +00:00
|
|
|
}
|
2023-02-21 21:56:01 +00:00
|
|
|
if (queuedInputs.Count > 0)
|
|
|
|
{
|
|
|
|
foreach (var input in queuedInputs)
|
|
|
|
{
|
|
|
|
StartCowbell(input.beat, input.length);
|
|
|
|
}
|
|
|
|
queuedInputs.Clear();
|
|
|
|
}
|
2022-08-18 18:23:33 +00:00
|
|
|
|
2022-08-17 02:12:48 +00:00
|
|
|
}
|
|
|
|
|
2022-08-18 03:33:05 +00:00
|
|
|
|
|
|
|
public void HitCowbell()
|
|
|
|
{
|
2023-06-10 19:13:29 +00:00
|
|
|
SoundByte.PlayOneShot("count-ins/cowbell");
|
2022-08-18 23:28:23 +00:00
|
|
|
|
|
|
|
handStart = Conductor.instance.songPositionInBeats;
|
|
|
|
|
|
|
|
cowbellAnimator.Play("Shake",-1,0);
|
2022-08-18 03:33:05 +00:00
|
|
|
}
|
|
|
|
|
2023-06-10 19:13:29 +00:00
|
|
|
public static void PreStartCowbell(double beat, float length)
|
2022-08-17 02:12:48 +00:00
|
|
|
{
|
2023-02-21 21:56:01 +00:00
|
|
|
if (GameManager.instance.currentGame == "tunnel")
|
|
|
|
{
|
|
|
|
instance.StartCowbell(beat, length);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
queuedInputs.Add(new QueuedCowbell { beat = beat, length = length });
|
|
|
|
}
|
|
|
|
}
|
2022-08-17 02:12:48 +00:00
|
|
|
|
2023-06-10 19:13:29 +00:00
|
|
|
public void StartCowbell(double beat, float length)
|
2023-02-21 21:56:01 +00:00
|
|
|
{
|
|
|
|
started = true;
|
|
|
|
for(int i = 0; i < length; i++)
|
|
|
|
{
|
|
|
|
ScheduleInput(beat, i, InputType.STANDARD_DOWN, CowbellSuccess, CowbellMiss, CowbellEmpty);
|
|
|
|
}
|
2022-08-17 02:12:48 +00:00
|
|
|
}
|
|
|
|
|
2022-08-18 03:33:05 +00:00
|
|
|
public void CowbellSuccess(PlayerActionEvent caller, float state)
|
2022-08-17 02:12:48 +00:00
|
|
|
{
|
2022-08-18 03:33:05 +00:00
|
|
|
HitCowbell();
|
2022-08-20 01:01:29 +00:00
|
|
|
//print(state);
|
2023-02-21 21:56:01 +00:00
|
|
|
if(Math.Abs(state) >= 1f)
|
2022-08-20 01:01:29 +00:00
|
|
|
{
|
|
|
|
driverAnimator.Play("Disturbed", -1, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
driverAnimator.Play("Idle", -1, 0);
|
|
|
|
}
|
|
|
|
|
2022-08-17 02:12:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-18 03:33:05 +00:00
|
|
|
public void CowbellMiss(PlayerActionEvent caller)
|
|
|
|
{
|
|
|
|
//HitCowbell();
|
2022-08-20 01:01:29 +00:00
|
|
|
|
|
|
|
driverAnimator.Play("Angry1", -1, 0);
|
2022-08-17 02:12:48 +00:00
|
|
|
}
|
|
|
|
|
2022-08-18 03:33:05 +00:00
|
|
|
public void CowbellEmpty(PlayerActionEvent caller)
|
2022-08-17 02:12:48 +00:00
|
|
|
{
|
2022-08-18 03:33:05 +00:00
|
|
|
//HitCowbell();
|
2022-08-17 02:12:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-19 03:47:40 +00:00
|
|
|
|
2023-06-10 19:13:29 +00:00
|
|
|
public static void CountIn(double beat, float length)
|
2022-08-19 04:19:08 +00:00
|
|
|
{
|
2022-08-20 19:48:56 +00:00
|
|
|
|
|
|
|
List<MultiSound.Sound> cuelist = new List<MultiSound.Sound>();
|
|
|
|
|
|
|
|
|
2023-02-21 21:56:01 +00:00
|
|
|
for (int i = 0; i < length; i++)
|
2022-08-19 04:19:08 +00:00
|
|
|
{
|
|
|
|
if(i % 2 == 0)
|
|
|
|
{
|
2022-08-20 19:48:56 +00:00
|
|
|
//Jukebox.PlayOneShotGame("tunnel/en/one", beat+i);
|
|
|
|
//print("cueing one at " + (beat + i));
|
|
|
|
cuelist.Add(new MultiSound.Sound("tunnel/en/one", beat + i));
|
2022-08-19 04:19:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-08-20 19:48:56 +00:00
|
|
|
//Jukebox.PlayOneShotGame("tunnel/en/two", beat+i);
|
|
|
|
//print("cueing two at " + (beat + i));
|
|
|
|
cuelist.Add(new MultiSound.Sound("tunnel/en/two", beat + i));
|
2022-08-19 04:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2023-02-21 21:56:01 +00:00
|
|
|
MultiSound.Play(cuelist.ToArray(), forcePlay: true);
|
2022-08-19 04:19:08 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-08-19 03:47:40 +00:00
|
|
|
|
2022-08-17 02:12:48 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|