HeavenStudioPlus/Assets/Scripts/Games/Tunnel/Tunnel.cs

159 lines
3.7 KiB
C#
Raw Normal View History

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-18 03:33:05 +00:00
new GameAction("Start", delegate { Tunnel.instance.StartCowbell(eventCaller.currentEntity.beat, eventCaller.currentEntity.toggle); }, 1, false, parameters: new List<Param>()
{
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-18 03:33:05 +00:00
2022-08-17 16:24:24 +00:00
}
//new List<string>() {"ntr", "aim"},
//"ntrcoin", "en",
//new List<string>() {}
);
}
}
}
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;
[Header("Animators")]
public Animator handAnimator;
2022-08-18 18:23:33 +00:00
[Header("Curves")]
public BezierCurve3D handCurve;
2022-08-18 03:33:05 +00:00
public PlayerActionEvent cowbell;
2022-08-18 18:23:33 +00:00
2022-08-18 03:33:05 +00:00
public int driverState;
2022-08-18 18:23:33 +00:00
public float handStart;
public float handProgress;
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-18 03:33:05 +00:00
cowbell = null;
}
private void Update()
{
2022-08-18 18:23:33 +00:00
if (PlayerInput.Pressed()) //&& !IsExpectingInputNow())
2022-08-18 03:33:05 +00:00
{
HitCowbell();
2022-08-18 18:23:33 +00:00
handStart = Conductor.instance.songPositionInBeats;
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);
frontHand.transform.position = handCurve.GetPoint(handProgress);
}
private void LateUpdate()
{
//nothing
}
2022-08-18 03:33:05 +00:00
public void HitCowbell()
{
Jukebox.PlayOneShot("count-ins/cowbell");
}
public void StartCowbell(float beat, bool audienceReacting)
{
2022-08-18 03:33:05 +00:00
//if (coin != null) return;
//Play sound and animations
2022-08-18 03:33:05 +00:00
//handAnimator.Play("Throw", 0, 0);
//Game state says the hand is throwing the coin
2022-08-18 03:33:05 +00:00
//isThrowing = true;
2022-08-18 03:33:05 +00:00
//this.audienceReacting = audienceReacting;
2022-08-18 03:33:05 +00:00
//coin = ScheduleInput(beat, 6f, InputType.STANDARD_DOWN, CatchSuccess, CatchMiss, CatchEmpty);
//cowbell = ScheduleInput(beat, 0f, InputType.STANDARD_DOWN, CowbellSuccess, CowbellMiss, CowbellEmpty);
//coin.perfectOnly = true;
}
2022-08-18 03:33:05 +00:00
public void CowbellSuccess(PlayerActionEvent caller, float state)
{
2022-08-18 03:33:05 +00:00
HitCowbell();
}
2022-08-18 03:33:05 +00:00
public void CowbellMiss(PlayerActionEvent caller)
{
//HitCowbell();
}
2022-08-18 03:33:05 +00:00
public void CowbellEmpty(PlayerActionEvent caller)
{
2022-08-18 03:33:05 +00:00
//HitCowbell();
}
2022-08-18 03:33:05 +00:00
}
}