mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 03:35:10 +00:00
Cleanup + new Shedule methods
This commit is contained in:
parent
0b79779b9b
commit
71bbefb764
3 changed files with 46 additions and 25 deletions
|
@ -75,24 +75,20 @@ namespace HeavenStudio.Games
|
|||
this.audienceReacting = audienceReacting;
|
||||
|
||||
coin = ScheduleInput(beat, 6f, InputType.STANDARD_DOWN, CatchSuccess, CatchMiss, CatchEmpty);
|
||||
//coin.perfectOnly = true;
|
||||
}
|
||||
|
||||
public void CatchSuccess(float state)
|
||||
public void CatchSuccess(PlayerActionEvent caller, float state)
|
||||
{
|
||||
if (state != 0)
|
||||
{
|
||||
CatchMiss();
|
||||
return;
|
||||
}
|
||||
|
||||
Jukebox.PlayOneShotGame("coinToss/catch");
|
||||
if(this.audienceReacting) Jukebox.PlayOneShotGame("coinToss/applause");
|
||||
handAnimator.Play("Catch_success", 0, 0);
|
||||
|
||||
Debug.Log(state);
|
||||
isThrowing = false;
|
||||
}
|
||||
|
||||
public void CatchMiss()
|
||||
public void CatchMiss(PlayerActionEvent caller)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("coinToss/miss");
|
||||
if(this.audienceReacting) Jukebox.PlayOneShotGame("coinToss/disappointed");
|
||||
|
@ -101,7 +97,7 @@ namespace HeavenStudio.Games
|
|||
isThrowing = false;
|
||||
}
|
||||
|
||||
public void CatchEmpty()
|
||||
public void CatchEmpty(PlayerActionEvent caller)
|
||||
{
|
||||
handAnimator.Play("Catch_empty", 0, 0);
|
||||
isThrowing = false;
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace HeavenStudio.Games
|
|||
{
|
||||
public class Minigame : MonoBehaviour
|
||||
{
|
||||
public static float earlyTime = 0.84f, perfectTime = 0.91f, lateTime = 1.09f, endTime = 1.15f;
|
||||
public static float earlyTime = 0.90f, perfectTime = 0.93f, lateTime = 1.06f, endTime = 1.10f;
|
||||
public List<Minigame.Eligible> EligibleHits = new List<Minigame.Eligible>();
|
||||
|
||||
[System.Serializable]
|
||||
|
@ -68,6 +68,32 @@ namespace HeavenStudio.Games
|
|||
return evt;
|
||||
}
|
||||
|
||||
public PlayerActionEvent ScheduleAutoplayInput(float startBeat,
|
||||
float timer,
|
||||
InputType inputType,
|
||||
PlayerActionEvent.ActionEventCallbackState OnHit,
|
||||
PlayerActionEvent.ActionEventCallback OnMiss,
|
||||
PlayerActionEvent.ActionEventCallback OnBlank)
|
||||
{
|
||||
PlayerActionEvent evt = ScheduleInput(startBeat, timer, inputType, OnHit, OnMiss, OnBlank);
|
||||
evt.autoplayOnly = true;
|
||||
return evt;
|
||||
}
|
||||
|
||||
public PlayerActionEvent ScheduleUserInput(float startBeat,
|
||||
float timer,
|
||||
InputType inputType,
|
||||
PlayerActionEvent.ActionEventCallbackState OnHit,
|
||||
PlayerActionEvent.ActionEventCallback OnMiss,
|
||||
PlayerActionEvent.ActionEventCallback OnBlank)
|
||||
{
|
||||
PlayerActionEvent evt = ScheduleInput(startBeat, timer, inputType, OnHit, OnMiss, OnBlank);
|
||||
evt.noAutoplay = true;
|
||||
return evt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Clean up method used whenever a PlayerActionEvent has finished
|
||||
public void RemoveScheduledInput(PlayerActionEvent evt)
|
||||
{
|
||||
|
|
|
@ -11,30 +11,28 @@ namespace HeavenStudio.Games
|
|||
|
||||
public class PlayerActionEvent : PlayerActionObject
|
||||
{
|
||||
public delegate void ActionEventCallback();
|
||||
public delegate void ActionEventCallbackState(float state);
|
||||
|
||||
public delegate void ActionEventCallbackSelf(PlayerActionEvent evt);
|
||||
public delegate void ActionEventCallback(PlayerActionEvent caller);
|
||||
public delegate void ActionEventCallbackState(PlayerActionEvent caller, float state);
|
||||
|
||||
public ActionEventCallbackState OnHit; //Function to trigger when an input has been done perfectly
|
||||
public ActionEventCallback OnMiss; //Function to trigger when an input has been missed
|
||||
public ActionEventCallback OnBlank; //Function to trigger when an input has been recorded while this is pending
|
||||
|
||||
public ActionEventCallbackSelf OnDestroy; //Function to trigger whenever this event gets destroyed. /!\ Shouldn't be used for a minigame! Use OnMiss instead /!\
|
||||
public ActionEventCallback OnDestroy; //Function to trigger whenever this event gets destroyed. /!\ Shouldn't be used for a minigame! Use OnMiss instead /!\
|
||||
|
||||
public float startBeat;
|
||||
public float timer;
|
||||
|
||||
public bool canHit = true; //Indicates if you can still hit the cue or not. If set to false, it'll guarantee a miss
|
||||
public bool enabled = true; //Indicates if the PlayerActionEvent is enabled. If set to false, it'll not trigger any events and destroy itself AFTER the event
|
||||
public bool enabled = true; //Indicates if the PlayerActionEvent is enabled. If set to false, it'll not trigger any events and destroy itself AFTER it's not relevant anymore
|
||||
|
||||
public bool autoplayOnly = false; //Indicates if the input event only triggers when it's autoplay. If set to true, NO Miss or Blank events will be triggered when you're not autoplaying.
|
||||
|
||||
public bool noAutoplay = false; //Indicates if this PlayerActionEvent is recognized by the autoplay. /!\ Overrides autoPlayOnly /!\
|
||||
|
||||
// I don't know why we would ever need the noAutoplay setting, but we never know!
|
||||
public InputType inputType; //The type of input. Check the InputType class to see a list of all of them
|
||||
|
||||
public InputType inputType;
|
||||
public bool perfectOnly = false; //Indicates that the input only recognize perfect inputs.
|
||||
|
||||
public void setHitCallback(ActionEventCallbackState OnHit)
|
||||
{
|
||||
|
@ -64,6 +62,7 @@ namespace HeavenStudio.Games
|
|||
float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat,timer);
|
||||
StateCheck(normalizedBeat);
|
||||
|
||||
|
||||
if (normalizedBeat > Minigame.LateTime()) Miss();
|
||||
|
||||
|
||||
|
@ -71,13 +70,14 @@ namespace HeavenStudio.Games
|
|||
{
|
||||
if (state.perfect)
|
||||
{
|
||||
Debug.Log(normalizedBeat);
|
||||
Hit(0f);
|
||||
}
|
||||
else if (state.early)
|
||||
else if (state.early && !perfectOnly)
|
||||
{
|
||||
Hit(-1f);
|
||||
}
|
||||
else if (state.late)
|
||||
else if (state.late && !perfectOnly)
|
||||
{
|
||||
Hit(1f);
|
||||
}
|
||||
|
@ -133,13 +133,12 @@ namespace HeavenStudio.Games
|
|||
{
|
||||
if(canHit)
|
||||
{
|
||||
OnHit(state);
|
||||
OnHit(this, state);
|
||||
CleanUp();
|
||||
} else
|
||||
{
|
||||
OnBlank();
|
||||
Blank();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -148,7 +147,7 @@ namespace HeavenStudio.Games
|
|||
{
|
||||
if (OnMiss != null && enabled && !autoplayOnly)
|
||||
{
|
||||
OnMiss();
|
||||
OnMiss(this);
|
||||
}
|
||||
|
||||
CleanUp();
|
||||
|
@ -158,7 +157,7 @@ namespace HeavenStudio.Games
|
|||
{
|
||||
if(OnBlank != null && enabled && !autoplayOnly)
|
||||
{
|
||||
OnBlank();
|
||||
OnBlank(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue