303 lines
12 KiB
C#
303 lines
12 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
using HeavenStudio.Util;
|
|
using HeavenStudio.InputSystem;
|
|
|
|
using Jukebox;
|
|
|
|
namespace HeavenStudio.Games.Loaders
|
|
{
|
|
using static Minigames;
|
|
public static class RvlHoleInOneLoader
|
|
{
|
|
public static Minigame AddGame(EventCaller eventCaller)
|
|
{
|
|
return new Minigame("holeInOne", "Hole in One", "6ab99e", false, false, new List<GameAction>()
|
|
{
|
|
new GameAction("bop", "Bop")
|
|
{
|
|
function = delegate { var e = eventCaller.currentEntity; HoleInOne.instance.ToggleBop(e.beat, e.length, e["bop"], e["autoBop"]); },
|
|
resizable = true,
|
|
parameters = new List<Param>()
|
|
{
|
|
new Param("bop", true, "Bop", "Toggle if the characters should bop for the duration of this event."),
|
|
new Param("autoBop", false, "Bop (Auto)", "Toggle if the characters should automatically bop until another Bop event is reached.")
|
|
}
|
|
},
|
|
new GameAction("monkey", "Monkey")
|
|
{
|
|
function = delegate { HoleInOne.instance.DoMonkey(eventCaller.currentEntity.beat); },
|
|
defaultLength = 3.0f,
|
|
},
|
|
new GameAction("mandrill", "Mandrill")
|
|
{
|
|
function = delegate { HoleInOne.instance.DoMandrill(eventCaller.currentEntity.beat); },
|
|
defaultLength = 4.0f,
|
|
},
|
|
new GameAction("whale", "Whale")
|
|
{
|
|
function = delegate { var e = eventCaller.currentEntity; HoleInOne.instance.Whale(e.beat, e.length, e["ease"], e["appear"]); },
|
|
parameters = new List<Param>()
|
|
{
|
|
new Param("appear", true, "Enter", "Toggle if the whale should enter or exit the scene."),
|
|
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease", "Set the easing of the action.")
|
|
},
|
|
resizable = true
|
|
},
|
|
},
|
|
new List<string>() { "rvl", "normal" },
|
|
"rvlgolf", "en",
|
|
new List<string>() {},
|
|
chronologicalSortKey: 1
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
namespace HeavenStudio.Games
|
|
{
|
|
using Scripts_HoleInOne;
|
|
public class HoleInOne : Minigame
|
|
{
|
|
[SerializeField] GameObject baseBall;
|
|
|
|
public Animator MonkeyAnim;
|
|
public Animator MonkeyHeadAnim;
|
|
public Animator MandrillAnim;
|
|
public Animator GolferAnim;
|
|
public GameObject Hole;
|
|
public Animator HoleAnim;
|
|
public Animator GrassEffectAnim;
|
|
public Animator BallEffectAnim;
|
|
|
|
double whaleStartBeat;
|
|
float whaleLength;
|
|
Util.EasingFunction.Ease lastEase;
|
|
public bool isWhale { get; private set; }
|
|
|
|
public static HoleInOne instance;
|
|
|
|
void Awake()
|
|
{
|
|
HoleInOne.instance = this;
|
|
SetupBopRegion("holeInOne", "bop", "autoBop");
|
|
isWhale = false;
|
|
Hole.SetActive(false);
|
|
}
|
|
|
|
public override void OnBeatPulse(double beat)
|
|
{
|
|
if (BeatIsInBopRegion(beat)) Bop(beat);
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (!conductor.isPlaying || conductor.isPaused) return;
|
|
|
|
if (PlayerInput.GetIsAction(InputAction_BasicPress) && !IsExpectingInputNow(InputAction_BasicPress))
|
|
{
|
|
SoundByte.PlayOneShotGame("holeInOne/hole1"); // temp should be whiff
|
|
GolferAnim.Play("GolferWhiff", 0, 0);
|
|
}
|
|
UpdateWhale(conductor.unswungSongPositionInBeatsAsDouble);
|
|
}
|
|
|
|
public void ToggleBop(double beat, float length, bool shouldBop, bool autoBop)
|
|
{
|
|
if (shouldBop)
|
|
{
|
|
for (int i = 0; i < length; i++)
|
|
{
|
|
var currentBeat = beat + i;
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
|
{
|
|
new BeatAction.Action(currentBeat, delegate { Bop(currentBeat);})
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Bop(double beat)
|
|
{
|
|
MonkeyAnim.DoScaledAnimationAsync("MonkeyBop", 1f);
|
|
MandrillAnim.DoScaledAnimationAsync("MandrillBop", 1f);
|
|
if (!GolferAnim.IsPlayingAnimationNames("GolferJust", "GolferWhiff"))
|
|
{
|
|
GolferAnim.DoScaledAnimationAsync("GolferBop", 1f);
|
|
}
|
|
}
|
|
|
|
public void Whale(double beat, float length, int ease, bool appear)
|
|
{
|
|
SoundByte.PlayOneShotGame("clappyTrio/sign");
|
|
whaleStartBeat = beat;
|
|
whaleLength = length;
|
|
lastEase = (Util.EasingFunction.Ease)ease;
|
|
isWhale = appear;
|
|
}
|
|
|
|
void UpdateWhale(double beat)
|
|
{
|
|
if (beat >= whaleStartBeat)
|
|
{
|
|
Util.EasingFunction.Function func = Util.EasingFunction.GetEasingFunction(lastEase);
|
|
float whaleProg = Conductor.instance.GetPositionFromBeat(whaleStartBeat, whaleLength, true);
|
|
whaleProg = Mathf.Clamp01(whaleProg);
|
|
// float whale = func(whaleLast, whaleNext, whaleProg);
|
|
}
|
|
}
|
|
|
|
public void DoMonkey(double beat)
|
|
{
|
|
//Monkey Multisound
|
|
// ScheduleInput(beat, 2f, InputAction_FlickPress, MonkeySuccess, MonkeyMiss, Empty);
|
|
MultiSound.Play(new MultiSound.Sound[] {
|
|
new MultiSound.Sound("holeInOne/monkey1", beat),
|
|
new MultiSound.Sound("holeInOne/monkey2", beat + 1f)
|
|
});
|
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
|
{
|
|
new BeatAction.Action(beat, delegate { MonkeyAnim.DoScaledAnimationAsync("MonkeyPrepare", 1f);}),
|
|
new BeatAction.Action(beat + 1f, delegate { MonkeyAnim.DoScaledAnimationAsync("MonkeyThrow", 1f);}),
|
|
new BeatAction.Action(beat + 1f, delegate { GolferAnim.DoScaledAnimationAsync("GolferPrepare", 1f);}),
|
|
new BeatAction.Action(beat + 2f, delegate {
|
|
if (!GolferAnim.IsPlayingAnimationNames("GolferJust", "GolferWhiff"))
|
|
{
|
|
GolferAnim.DoScaledAnimationAsync("GolferThrough", 1f);
|
|
SoundByte.PlayOneShotGame("holeInOne/hole3"); // temp
|
|
}
|
|
}),
|
|
});
|
|
SpawnBall(beat);
|
|
}
|
|
|
|
public void DoMandrill(double beat)
|
|
{
|
|
//Mandrill Multisound
|
|
ScheduleInput(beat, 3f, InputAction_FlickPress, MandrillSuccess, MandrillMiss, Empty);
|
|
MultiSound.Play(new MultiSound.Sound[] {
|
|
new MultiSound.Sound("holeInOne/mandrill1", beat),
|
|
new MultiSound.Sound("holeInOne/mandrill2", beat + 1f),
|
|
new MultiSound.Sound("holeInOne/mandrill3", beat + 2f),
|
|
new MultiSound.Sound("holeInOne/hole1", beat + 3f),
|
|
});
|
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
|
{
|
|
new BeatAction.Action(beat, delegate { MandrillAnim.DoScaledAnimationAsync("MandrillReady1", 1f);}),
|
|
new BeatAction.Action(beat + 1f, delegate { MandrillAnim.DoScaledAnimationAsync("MandrillReady2", 1f);}),
|
|
new BeatAction.Action(beat + 2f, delegate { MandrillAnim.DoScaledAnimationAsync("MandrillReady3", 1f);}),
|
|
new BeatAction.Action(beat + 2f, delegate { GolferAnim.DoScaledAnimationAsync("GolferPrepare", 1f);}),
|
|
new BeatAction.Action(beat + 3f, delegate {
|
|
if (!GolferAnim.IsPlayingAnimationNames("GolferJust", "GolferWhiff"))
|
|
{
|
|
GolferAnim.DoScaledAnimationAsync("GolferThrough", 1f);
|
|
SoundByte.PlayOneShotGame("holeInOne/hole3"); // temp
|
|
}
|
|
}),
|
|
new BeatAction.Action(beat + 3f, delegate { MandrillAnim.DoScaledAnimationAsync("MandrillPitch", 1f);}),
|
|
new BeatAction.Action(beat + 3f, delegate { MonkeyAnim.DoScaledAnimationAsync("MonkeySpin", 1f);}),
|
|
|
|
});
|
|
}
|
|
|
|
public void SpawnBall(double beat)
|
|
{
|
|
var newBall = Instantiate(baseBall, transform).GetComponent<Ball>();
|
|
newBall.startBeat = beat;
|
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
|
{
|
|
new BeatAction.Action(beat + 1f, delegate {
|
|
newBall.gameObject.SetActive(true);
|
|
newBall.Init();
|
|
}),
|
|
});
|
|
}
|
|
|
|
public void MonkeySuccess(PlayerActionEvent caller, float state)
|
|
{
|
|
if (state >= 1f || state <= -1f)
|
|
{
|
|
double beat = caller.startBeat + caller.timer;
|
|
|
|
SoundByte.PlayOneShotGame("holeInOne/mandrill1"); // temp should be barely
|
|
SoundByte.PlayOneShotGame("holeInOne/hole2", beat + 1f); // temp should be splash
|
|
|
|
MonkeyHeadAnim.DoScaledAnimationAsync("MonkeyMissHead", 1f);
|
|
GolferAnim.Play("GolferWhiff", 0, 0);
|
|
}
|
|
else
|
|
{
|
|
double beat = caller.startBeat + caller.timer;
|
|
int randomSuccess = UnityEngine.Random.Range(1,4);
|
|
|
|
MultiSound.Play(new MultiSound.Sound[] {
|
|
new MultiSound.Sound("holeInOne/monkey3", beat),
|
|
new MultiSound.Sound((isWhale) ? "holeInOne/whale" : ("holeInOne/hole" + randomSuccess), beat + 2f)
|
|
});
|
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
|
{
|
|
new BeatAction.Action(beat, delegate { MonkeyHeadAnim.DoScaledAnimationAsync("MonkeyJustHead", 1f);}),
|
|
new BeatAction.Action(beat, delegate { GolferAnim.Play("GolferJust", 0, 0);}),
|
|
new BeatAction.Action(beat + 1.5f, delegate { Hole.SetActive(true);}),
|
|
new BeatAction.Action(beat + 2f, delegate { HoleAnim.DoScaledAnimationAsync("ZoomSmall" + randomSuccess, 1f);}),
|
|
});
|
|
}
|
|
}
|
|
|
|
public void MonkeyMiss(PlayerActionEvent caller)
|
|
{
|
|
SoundByte.PlayOneShotGame("holeInOne/whale");
|
|
MonkeyHeadAnim.DoScaledAnimationAsync("MonkeySadHead", 1f);
|
|
}
|
|
|
|
public void MandrillSuccess(PlayerActionEvent caller, float state)
|
|
{
|
|
if (state >= 1f || state <= -1f)
|
|
{
|
|
double beat = caller.startBeat + caller.timer;
|
|
|
|
SoundByte.PlayOneShotGame("holeInOne/mandrill1"); // temp should be barely
|
|
SoundByte.PlayOneShotGame("holeInOne/hole2", beat + 1f); // temp should be splash
|
|
|
|
BallEffectAnim.Play("BallEffectJust");
|
|
GolferAnim.Play("GolferWhiff", 0, 0);
|
|
}
|
|
else
|
|
{
|
|
double beat = caller.startBeat + caller.timer;
|
|
|
|
MultiSound.Play(new MultiSound.Sound[] {
|
|
new MultiSound.Sound("holeInOne/mandrill4", beat),
|
|
new MultiSound.Sound((isWhale) ? "holeInOne/whale" : "holeInOne/hole4", beat + 2f)
|
|
});
|
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
|
{
|
|
new BeatAction.Action(beat, delegate { GolferAnim.DoScaledAnimationAsync("GolferJust", 1f);}),
|
|
new BeatAction.Action(beat, delegate { GolferAnim.Play("GolferJust", 0, 0);}),
|
|
new BeatAction.Action(beat + 1.5f, delegate { Hole.SetActive(true);}),
|
|
new BeatAction.Action(beat + 2f, delegate { HoleAnim.DoScaledAnimationAsync("ZoomBig", 1f);}),
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
public void MandrillMiss(PlayerActionEvent caller)
|
|
{
|
|
SoundByte.PlayOneShotGame("holeInOne/whale");
|
|
MonkeyAnim.Play("MonkeySpin");
|
|
BallEffectAnim.Play("BallEffectThrough");
|
|
GolferAnim.Play("GolferThroughMandrill");
|
|
}
|
|
|
|
public void Empty(PlayerActionEvent caller) {}
|
|
}
|
|
} |