2022-08-17 02:12:48 +00:00
|
|
|
using DG.Tweening;
|
|
|
|
using NaughtyBezierCurves;
|
|
|
|
using HeavenStudio.Util;
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
return new Minigame("tunnel", "Tunnel", "B4E6F6", false, false, new List<GameAction>()
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2022-08-19 03:47:40 +00:00
|
|
|
new GameAction("Cowbell", delegate { Tunnel.instance.StartCowbell(eventCaller.currentEntity.beat, eventCaller.currentEntity.toggle, eventCaller.currentEntity.length); }, 1f, true, parameters: new List<Param>()
|
2022-08-17 02:12:48 +00:00
|
|
|
{
|
2022-08-18 03:33:05 +00:00
|
|
|
new Param("toggle", false, "Driver can stop", "Lets the driver stop if the player makes too many mistakes"),
|
|
|
|
}),
|
2022-08-17 02:12:48 +00:00
|
|
|
|
2022-08-19 04:19:08 +00:00
|
|
|
new GameAction("Count In", delegate { Tunnel.instance.CountIn(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 1f, true),
|
|
|
|
|
|
|
|
|
2022-08-17 16:24:24 +00:00
|
|
|
}
|
|
|
|
//new List<string>() {"ntr", "aim"},
|
|
|
|
//"ntrcoin", "en",
|
|
|
|
//new List<string>() {}
|
2022-08-17 02:12:48 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games
|
|
|
|
{
|
|
|
|
//using Scripts_CoinToss;
|
|
|
|
public class Tunnel : Minigame
|
|
|
|
{
|
|
|
|
|
|
|
|
//Right now, you can only throw one coin at a time.
|
|
|
|
//..Which makes sense, you only have one coin in the original game
|
|
|
|
|
|
|
|
//Though it would need a bit of code rewrite to make it work with multiple coins
|
|
|
|
|
|
|
|
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;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
if (cond.ReportBeat(ref cowbell.lastReportedBeat, cowbell.startBeat % 1))
|
|
|
|
{
|
|
|
|
if (cond.songPositionInBeats >= cowbell.startBeat && cond.songPositionInBeats < cowbell.startBeat + cowbell.length)
|
|
|
|
{
|
|
|
|
ScheduleInput(cond.songPositionInBeats, 1, InputType.STANDARD_DOWN, CowbellSuccess, CowbellMiss, CowbellEmpty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
2022-08-18 18:23:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
//update hand position
|
|
|
|
handProgress = Math.Min(Conductor.instance.songPositionInBeats - handStart, 1);
|
|
|
|
|
2022-08-18 23:28:23 +00:00
|
|
|
|
|
|
|
frontHand.transform.position = handCurve.GetPoint(EasingFunction.EaseOutQuad(0, 1, handProgress));
|
2022-08-18 18:23:33 +00:00
|
|
|
|
2022-08-17 02:12:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void LateUpdate()
|
|
|
|
{
|
|
|
|
//nothing
|
|
|
|
}
|
|
|
|
|
2022-08-18 03:33:05 +00:00
|
|
|
|
|
|
|
public void HitCowbell()
|
|
|
|
{
|
|
|
|
Jukebox.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
|
|
|
}
|
|
|
|
|
2022-08-19 04:19:08 +00:00
|
|
|
public void StartCowbell(float beat, bool driverStops, float length)
|
2022-08-17 02:12:48 +00:00
|
|
|
{
|
2022-08-19 03:47:40 +00:00
|
|
|
started = true;
|
|
|
|
|
2022-08-20 18:45:54 +00:00
|
|
|
cowbell.length = length;
|
|
|
|
cowbell.startBeat = beat;
|
2022-08-19 03:47:40 +00:00
|
|
|
|
2022-08-18 03:33:05 +00:00
|
|
|
|
2022-08-20 18:45:54 +00:00
|
|
|
//for (int i = 1; i <= length; i++)
|
|
|
|
//{
|
|
|
|
//ScheduleInput(beat, i, InputType.STANDARD_DOWN, CowbellSuccess, CowbellMiss, CowbellEmpty);
|
|
|
|
//}
|
2022-08-17 02:12:48 +00:00
|
|
|
|
2022-08-20 18:45:54 +00:00
|
|
|
|
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);
|
|
|
|
if(Math.Abs(state) >= 0.5)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2022-08-19 04:19:08 +00:00
|
|
|
public void CountIn(float beat, float length)
|
|
|
|
{
|
|
|
|
for (int i = 0; i <= length; i++)
|
|
|
|
{
|
|
|
|
if(i % 2 == 0)
|
|
|
|
{
|
|
|
|
Jukebox.PlayOneShotGame("tunnel/en/one", beat+i);
|
|
|
|
print("cueing one at " + (beat + i));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Jukebox.PlayOneShotGame("tunnel/en/two", beat+i);
|
|
|
|
print("cueing two at " + (beat + i));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-08-19 03:47:40 +00:00
|
|
|
|
2022-08-17 02:12:48 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|