auto dispense + miss stuff
This commit is contained in:
parent
188f81b174
commit
df446d3336
|
|
@ -384,6 +384,7 @@ namespace HeavenStudio.Games.Scripts_SpaceSoccer
|
||||||
// queue normal kick input
|
// queue normal kick input
|
||||||
nextHit = game.ScheduleInput(caller.startBeat + caller.timer, ball.GetAnimLength(Ball.State.Kicked), SpaceSoccer.InputAction_BasicPress, KickJust, Miss, Out);
|
nextHit = game.ScheduleInput(caller.startBeat + caller.timer, ball.GetAnimLength(Ball.State.Kicked), SpaceSoccer.InputAction_BasicPress, KickJust, Miss, Out);
|
||||||
}
|
}
|
||||||
|
game.hitBeats.Add(caller.startBeat + caller.timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Miss(PlayerActionEvent caller)
|
private void Miss(PlayerActionEvent caller)
|
||||||
|
|
@ -407,6 +408,7 @@ namespace HeavenStudio.Games.Scripts_SpaceSoccer
|
||||||
Toe(true);
|
Toe(true);
|
||||||
nextHit = game.ScheduleInput(caller.startBeat, 3f, SpaceSoccer.InputAction_BasicPress, KickJust, Miss, Out);
|
nextHit = game.ScheduleInput(caller.startBeat, 3f, SpaceSoccer.InputAction_BasicPress, KickJust, Miss, Out);
|
||||||
ball.canKick = false;
|
ball.canKick = false;
|
||||||
|
game.hitBeats.Add(caller.startBeat + caller.timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToePrepareJust(PlayerActionEvent caller, float state)
|
private void ToePrepareJust(PlayerActionEvent caller, float state)
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,17 @@ namespace HeavenStudio.Games.Loaders
|
||||||
{
|
{
|
||||||
new GameAction("ball dispense", "Ball Dispense")
|
new GameAction("ball dispense", "Ball Dispense")
|
||||||
{
|
{
|
||||||
function = delegate { SpaceSoccer.instance.Dispense(eventCaller.currentEntity.beat, !eventCaller.currentEntity["toggle"], false, eventCaller.currentEntity["down"]); },
|
function = delegate { var e = eventCaller.currentEntity; SpaceSoccer.instance.Dispense(e.beat, !e["toggle"], false, e["down"], e["auto"], e["interval"]); },
|
||||||
defaultLength = 2f,
|
defaultLength = 2f,
|
||||||
parameters = new List<Param>()
|
parameters = new List<Param>()
|
||||||
{
|
{
|
||||||
new Param("toggle", false, "Disable Sound", "Disables the dispense sound"),
|
new Param("toggle", false, "Disable Sound", "Disables the dispense sound"),
|
||||||
new Param("down", false, "Down Sound", "Will the Down sound be played?")
|
new Param("down", false, "Down Sound", "Will the Down sound be played?"),
|
||||||
|
new Param("auto", true, "Auto Redispense", "", new()
|
||||||
|
{
|
||||||
|
new((x, _) => (bool)x, new string[] { "interval" })
|
||||||
|
}),
|
||||||
|
new("interval", new EntityTypes.Integer(2, 20, 2), "Redispense Interval")
|
||||||
},
|
},
|
||||||
inactiveFunction = delegate
|
inactiveFunction = delegate
|
||||||
{
|
{
|
||||||
|
|
@ -163,6 +168,7 @@ namespace HeavenStudio.Games
|
||||||
using HeavenStudio.Common;
|
using HeavenStudio.Common;
|
||||||
using UnityEngine.Rendering;
|
using UnityEngine.Rendering;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using System;
|
||||||
|
|
||||||
public class SpaceSoccer : Minigame
|
public class SpaceSoccer : Minigame
|
||||||
{
|
{
|
||||||
|
|
@ -214,6 +220,12 @@ namespace HeavenStudio.Games
|
||||||
float yScrollMultiplier = 0.3f;
|
float yScrollMultiplier = 0.3f;
|
||||||
[SerializeField] private float xBaseSpeed = 1;
|
[SerializeField] private float xBaseSpeed = 1;
|
||||||
[SerializeField] private float yBaseSpeed = 1;
|
[SerializeField] private float yBaseSpeed = 1;
|
||||||
|
|
||||||
|
private List<double> _highKickToeBeats = new();
|
||||||
|
private List<double> _stopBeats = new();
|
||||||
|
|
||||||
|
[NonSerialized] public List<double> hitBeats = new();
|
||||||
|
|
||||||
#region Space Kicker Position Easing
|
#region Space Kicker Position Easing
|
||||||
float easeBeat;
|
float easeBeat;
|
||||||
float easeLength;
|
float easeLength;
|
||||||
|
|
@ -234,6 +246,11 @@ namespace HeavenStudio.Games
|
||||||
instance = this;
|
instance = this;
|
||||||
colorStart = defaultBGColor;
|
colorStart = defaultBGColor;
|
||||||
colorEnd = defaultBGColor;
|
colorEnd = defaultBGColor;
|
||||||
|
var allHighKickToeEvents = EventCaller.GetAllInGameManagerList("spaceSoccer", new string[] { "high kick-toe!" });
|
||||||
|
foreach (var e in allHighKickToeEvents)
|
||||||
|
{
|
||||||
|
_highKickToeBeats.Add(e.beat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new void OnDrawGizmos()
|
new void OnDrawGizmos()
|
||||||
|
|
@ -276,6 +293,31 @@ namespace HeavenStudio.Games
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnBeatPulse(double beat)
|
||||||
|
{
|
||||||
|
if (!ballDispensed) return;
|
||||||
|
|
||||||
|
double offsetBeat = beat + (lastDispensedBeat % 1);
|
||||||
|
|
||||||
|
if (_stopBeats.Exists(x => offsetBeat >= x) || offsetBeat < lastDispensedBeat + 2) return;
|
||||||
|
|
||||||
|
if (_highKickToeBeats.Exists(x => offsetBeat >= x + 1 && offsetBeat < x + 3))
|
||||||
|
{
|
||||||
|
if (_highKickToeBeats.Exists(x => offsetBeat == x + 2) && !IsExpectingInputNow(InputAction_FlickRelease))
|
||||||
|
{
|
||||||
|
if (hitBeats.Exists(x => x == offsetBeat - 0.5)) return;
|
||||||
|
ScoreMiss();
|
||||||
|
Debug.Log("Miss toe");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!IsExpectingInputNow(InputAction_BasicPress))
|
||||||
|
{
|
||||||
|
if (hitBeats.Exists(x => offsetBeat == x)) return;
|
||||||
|
ScoreMiss();
|
||||||
|
Debug.Log("Miss");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void StopBall(bool stop)
|
public void StopBall(bool stop)
|
||||||
{
|
{
|
||||||
foreach (var kicker in kickers)
|
foreach (var kicker in kickers)
|
||||||
|
|
@ -329,12 +371,12 @@ namespace HeavenStudio.Games
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bool isOnGameSwitchBeat = entity.beat == beat;
|
bool isOnGameSwitchBeat = entity.beat == beat;
|
||||||
Debug.Log(isOnGameSwitchBeat);
|
Dispense(entity.beat, isOnGameSwitchBeat && !entity["toggle"], false, isOnGameSwitchBeat && entity["down"], entity["auto"], entity["interval"]);
|
||||||
Dispense(entity.beat, isOnGameSwitchBeat && !entity["toggle"], false, isOnGameSwitchBeat && entity["down"]);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PersistColor(beat);
|
PersistColor(beat);
|
||||||
|
AddStopEvents(beat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SuperCurveObject.Path GetPath(string name)
|
public SuperCurveObject.Path GetPath(string name)
|
||||||
|
|
@ -349,6 +391,8 @@ namespace HeavenStudio.Games
|
||||||
return default(SuperCurveObject.Path);
|
return default(SuperCurveObject.Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region VisualInterpolation
|
||||||
|
|
||||||
public void UpdateScrollSpeed(float scrollSpeedX, float scrollSpeedY)
|
public void UpdateScrollSpeed(float scrollSpeedX, float scrollSpeedY)
|
||||||
{
|
{
|
||||||
xScrollMultiplier = scrollSpeedX;
|
xScrollMultiplier = scrollSpeedX;
|
||||||
|
|
@ -452,10 +496,35 @@ namespace HeavenStudio.Games
|
||||||
kickers.Add(spawnedKicker);
|
kickers.Add(spawnedKicker);
|
||||||
kickerHolder.gameObject.SetActive(true);
|
kickerHolder.gameObject.SetActive(true);
|
||||||
}
|
}
|
||||||
if (ballDispensed) Dispense(lastDispensedBeat, false, true);
|
if (ballDispensed) Dispense(lastDispensedBeat, false, true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispense(double beat, bool playSound = true, bool ignorePlayer = false, bool playDown = false)
|
#endregion
|
||||||
|
|
||||||
|
public void Dispense(double beat, bool playSound = true, bool ignorePlayer = false, bool playDown = false, bool autoDispense = true, int autoInterval = 2)
|
||||||
|
{
|
||||||
|
DispenseExec(beat, playSound, ignorePlayer, playDown);
|
||||||
|
|
||||||
|
if (!autoDispense) return;
|
||||||
|
|
||||||
|
DispenseRecursion(beat + 2, autoInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DispenseRecursion(double beat, int interval)
|
||||||
|
{
|
||||||
|
double dispenseBeat = beat + interval;
|
||||||
|
if (_stopBeats.Exists(x => dispenseBeat + 2 >= x)) return;
|
||||||
|
BeatAction.New(this, new()
|
||||||
|
{
|
||||||
|
new(dispenseBeat, delegate
|
||||||
|
{
|
||||||
|
if (!_highKickToeBeats.Exists(x => dispenseBeat + 2 > x && dispenseBeat + 2 < x + 3)) DispenseExec(dispenseBeat);
|
||||||
|
DispenseRecursion(dispenseBeat + 2, interval);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DispenseExec(double beat, bool playSound = true, bool ignorePlayer = false, bool playDown = false)
|
||||||
{
|
{
|
||||||
if (!ballDispensed) lastDispensedBeat = beat;
|
if (!ballDispensed) lastDispensedBeat = beat;
|
||||||
ballDispensed = true;
|
ballDispensed = true;
|
||||||
|
|
@ -496,6 +565,15 @@ namespace HeavenStudio.Games
|
||||||
}, forcePlay:true);
|
}, forcePlay:true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddStopEvents(double beat)
|
||||||
|
{
|
||||||
|
var allStopEvents = EventCaller.GetAllInGameManagerList("spaceSoccer", new string[] { "stopBall" }).FindAll(x => x.beat >= beat);
|
||||||
|
foreach (var e in allStopEvents)
|
||||||
|
{
|
||||||
|
_stopBeats.Add(e.beat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private double colorStartBeat = -1;
|
private double colorStartBeat = -1;
|
||||||
private float colorLength = 0f;
|
private float colorLength = 0f;
|
||||||
private Color colorStart; //obviously put to the default color of the game
|
private Color colorStart; //obviously put to the default color of the game
|
||||||
|
|
@ -550,6 +628,7 @@ namespace HeavenStudio.Games
|
||||||
public override void OnPlay(double beat)
|
public override void OnPlay(double beat)
|
||||||
{
|
{
|
||||||
PersistColor(beat);
|
PersistColor(beat);
|
||||||
|
AddStopEvents(beat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue