mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-13 03:37:37 +02:00
Play Mode Features Part 1 (#413)
* add pause menu assets * layout and animation for pause * make play mode prefab function re-assign unused class inheritance * remove filepath * don't init medals twice * remove PlayerActionObject * initial attempt at anti-note lock TODO: circumvent inputs clearing themselves making the functionality not work * properly implement input lock prevention * fix error on editor open * functional pause menu * bugfix * make unpausing not reset current play statistics * serialize initializer components in inspector instead of procedurally generating * sanity check * note for fade * make flashes in the camera prefabs instead of in world space remove / reorganize script files address issue #411 * fix bug with perfect campaign make minigame transitions hide the game canvas adjust animation of the song credits textbox * fully functional intro scene (placeholder for future title screen) refactored entire game loading procedure re-organized some files * add interaction query to disclaimer text * reword legal * anchor section medals to section display more tempo change placement controls * operation order bugfix * prep for future ratings and stats * loading text * autoload opening scene * splash screen adjustments added setting to force enable splash screen * adjust setting entry
This commit is contained in:
@ -8,7 +8,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_BlueBear
|
||||
{
|
||||
public class Treat : PlayerActionObject
|
||||
public class Treat : MonoBehaviour
|
||||
{
|
||||
const float rotSpeed = 360f;
|
||||
|
||||
|
@ -6,7 +6,7 @@ using System;
|
||||
namespace HeavenStudio.Games.Scripts_BuiltToScaleDS
|
||||
{
|
||||
using HeavenStudio.Util;
|
||||
public class Blocks : PlayerActionObject
|
||||
public class Blocks : MonoBehaviour
|
||||
{
|
||||
public float createBeat;
|
||||
public float createLength;
|
||||
|
@ -7,7 +7,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_CatchyTune
|
||||
{
|
||||
public class Fruit : PlayerActionObject
|
||||
public class Fruit : MonoBehaviour
|
||||
{
|
||||
|
||||
public bool isPineapple;
|
||||
|
@ -6,7 +6,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_ClappyTrio
|
||||
{
|
||||
public class ClappyTrioPlayer : PlayerActionObject
|
||||
public class ClappyTrioPlayer : MonoBehaviour
|
||||
{
|
||||
ClappyTrio game;
|
||||
private float lastClapBeat;
|
||||
|
@ -6,7 +6,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_CropStomp
|
||||
{
|
||||
public class Farmer : PlayerActionObject
|
||||
public class Farmer : MonoBehaviour
|
||||
{
|
||||
public float nextStompBeat;
|
||||
|
||||
|
@ -8,7 +8,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_CropStomp
|
||||
{
|
||||
public class Veggie : PlayerActionObject
|
||||
public class Veggie : MonoBehaviour
|
||||
{
|
||||
static float pickedRotationSpeed = -1080f;
|
||||
|
||||
|
@ -9,7 +9,7 @@ using Starpelly;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_DJSchool
|
||||
{
|
||||
public class Student : PlayerActionObject
|
||||
public class Student : MonoBehaviour
|
||||
{
|
||||
public Animator anim;
|
||||
public static bool soundFX;
|
||||
|
@ -8,7 +8,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_DogNinja
|
||||
{
|
||||
public class SpawnHalves : PlayerActionObject
|
||||
public class SpawnHalves : MonoBehaviour
|
||||
{
|
||||
public float startBeat;
|
||||
public Vector3 objPos;
|
||||
|
@ -8,7 +8,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_DogNinja
|
||||
{
|
||||
public class ThrowObject : PlayerActionObject
|
||||
public class ThrowObject : MonoBehaviour
|
||||
{
|
||||
public float startBeat;
|
||||
public int type;
|
||||
|
@ -6,7 +6,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_DrummingPractice
|
||||
{
|
||||
public class DrummerHit : PlayerActionObject
|
||||
public class DrummerHit : MonoBehaviour
|
||||
{
|
||||
DrummingPractice game;
|
||||
public float startBeat;
|
||||
|
@ -9,7 +9,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_FanClub
|
||||
{
|
||||
public class NtrIdolFan : PlayerActionObject
|
||||
public class NtrIdolFan : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private GameObject motionRoot;
|
||||
|
@ -6,7 +6,7 @@ using NaughtyBezierCurves;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_Fireworks
|
||||
{
|
||||
public class FireworksBomb : PlayerActionObject
|
||||
public class FireworksBomb : MonoBehaviour
|
||||
{
|
||||
public BezierCurve3D curve;
|
||||
public bool applause;
|
||||
|
@ -6,7 +6,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_Fireworks
|
||||
{
|
||||
public class Rocket : PlayerActionObject
|
||||
public class Rocket : MonoBehaviour
|
||||
{
|
||||
[SerializeField] ParticleSystem particleBarelyEffect;
|
||||
[SerializeField] private List<ParticleSystem> particleEffects = new List<ParticleSystem>();
|
||||
|
@ -8,7 +8,7 @@ using Starpelly;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_FirstContact
|
||||
{
|
||||
public class Translator : PlayerActionObject
|
||||
public class Translator : MonoBehaviour
|
||||
{
|
||||
public Animator anim;
|
||||
|
||||
|
@ -8,7 +8,7 @@ using DG.Tweening;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_ForkLifter
|
||||
{
|
||||
public class Pea : PlayerActionObject
|
||||
public class Pea : MonoBehaviour
|
||||
{
|
||||
ForkLifter game;
|
||||
private Animator anim;
|
||||
|
@ -5,7 +5,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_GleeClub
|
||||
{
|
||||
public class GleeClubSingInput : PlayerActionObject
|
||||
public class GleeClubSingInput : MonoBehaviour
|
||||
{
|
||||
public float pitch = 1f;
|
||||
bool shouldClose = true;
|
||||
|
@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
using System.Linq;
|
||||
@ -9,49 +11,40 @@ namespace HeavenStudio.Games.Global
|
||||
{
|
||||
public class Flash : MonoBehaviour
|
||||
{
|
||||
public float startBeat;
|
||||
public float length;
|
||||
[NonSerialized] public float startBeat;
|
||||
[NonSerialized] public float length;
|
||||
|
||||
public Color startColor;
|
||||
public Color endColor;
|
||||
[NonSerialized] public Color startColor;
|
||||
[NonSerialized] public Color endColor;
|
||||
|
||||
public EasingFunction.Ease ease;
|
||||
private EasingFunction.Function func;
|
||||
[NonSerialized] public EasingFunction.Ease ease;
|
||||
[NonSerialized] private EasingFunction.Function func;
|
||||
|
||||
private SpriteRenderer spriteRenderer;
|
||||
[NonSerialized] private Image spriteRenderer;
|
||||
|
||||
[SerializeField] private Color currentCol;
|
||||
|
||||
private List<DynamicBeatmap.DynamicEntity> allFadeEvents = new List<DynamicBeatmap.DynamicEntity>();
|
||||
[NonSerialized] private List<DynamicBeatmap.DynamicEntity> allFadeEvents = new List<DynamicBeatmap.DynamicEntity>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
this.gameObject.transform.SetParent(GameManager.instance.gameObject.transform);
|
||||
gameObject.layer = LayerMask.NameToLayer("Flash");
|
||||
this.gameObject.transform.localScale = new Vector3(1, 1);
|
||||
|
||||
spriteRenderer = this.gameObject.AddComponent<SpriteRenderer>();
|
||||
|
||||
spriteRenderer.color = startColor;
|
||||
spriteRenderer.sortingOrder = 30001;
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Sprites/GeneralPurpose/Square");
|
||||
|
||||
spriteRenderer = GetComponent<Image>();
|
||||
spriteRenderer.color = currentCol;
|
||||
func = EasingFunction.GetEasingFunction(EasingFunction.Ease.Linear);
|
||||
|
||||
GameManager.instance.onBeatChanged += OnBeatChanged;
|
||||
}
|
||||
|
||||
public void OnBeatChanged(float beat)
|
||||
{
|
||||
allFadeEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "flash" });
|
||||
Test(beat);
|
||||
|
||||
// backwards-compatibility baybee
|
||||
allFadeEvents.AddRange(EventCaller.GetAllInGameManagerList("gameManager", new string[] { "flash" }));
|
||||
Test(beat);
|
||||
allFadeEvents.Sort((x, y) => x.beat.CompareTo(y.beat));
|
||||
|
||||
FindFadeFromBeat(beat);
|
||||
}
|
||||
|
||||
private void Test(float beat)
|
||||
private void FindFadeFromBeat(float beat)
|
||||
{
|
||||
Color startCol = Color.white;
|
||||
Color endCol = Color.white;
|
||||
@ -105,7 +98,7 @@ namespace HeavenStudio.Games.Global
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Test(Conductor.instance.songPositionInBeats);
|
||||
FindFadeFromBeat(Conductor.instance.songPositionInBeats);
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat, length);
|
||||
// normalizedBeat = Mathf.Clamp01(normalizedBeat);
|
||||
|
||||
|
@ -32,7 +32,7 @@ namespace HeavenStudio.Games.Global
|
||||
private List<DynamicBeatmap.DynamicEntity> idolEvents = new List<DynamicBeatmap.DynamicEntity>();
|
||||
private List<DynamicBeatmap.DynamicEntity> closedCaptionsEvents = new List<DynamicBeatmap.DynamicEntity>();
|
||||
|
||||
Textbox instance;
|
||||
public static Textbox instance { get; private set; }
|
||||
|
||||
[Header("Objects")]
|
||||
public GameObject TextboxEnabler;
|
||||
|
@ -8,7 +8,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
{
|
||||
public class KarateManPot : PlayerActionObject
|
||||
public class KarateManPot : MonoBehaviour
|
||||
{
|
||||
public float startBeat;
|
||||
public ItemType type;
|
||||
|
@ -11,7 +11,7 @@ using static HeavenStudio.EntityTypes;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_LaunchParty
|
||||
{
|
||||
public class LaunchPartyRocket : PlayerActionObject
|
||||
public class LaunchPartyRocket : MonoBehaviour
|
||||
{
|
||||
public List<float> pitches = new List<float>();
|
||||
[SerializeField] Animator anim;
|
||||
|
@ -6,7 +6,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_MarchingOrders
|
||||
{
|
||||
public class Cadet : PlayerActionObject
|
||||
public class Cadet : MonoBehaviour
|
||||
{
|
||||
public bool isSparkler;
|
||||
|
||||
|
@ -7,7 +7,7 @@ using NaughtyBezierCurves;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_MeatGrinder
|
||||
{
|
||||
public class MeatToss : PlayerActionObject
|
||||
public class MeatToss : MonoBehaviour
|
||||
{
|
||||
public float startBeat;
|
||||
public float cueLength;
|
||||
|
@ -120,7 +120,7 @@ namespace HeavenStudio.Games
|
||||
|
||||
if(closest == null)
|
||||
{
|
||||
if (input == InputType.ANY || toCompare.inputType.HasFlag(input))
|
||||
if (input == InputType.ANY || (toCompare.inputType & input) != 0)
|
||||
closest = toCompare;
|
||||
} else
|
||||
{
|
||||
@ -131,7 +131,7 @@ namespace HeavenStudio.Games
|
||||
|
||||
if (t2 < t1)
|
||||
{
|
||||
if (input == InputType.ANY || toCompare.inputType.HasFlag(input))
|
||||
if (input == InputType.ANY || (toCompare.inputType & input) != 0)
|
||||
closest = toCompare;
|
||||
}
|
||||
}
|
||||
@ -220,6 +220,14 @@ namespace HeavenStudio.Games
|
||||
|
||||
}
|
||||
|
||||
public virtual void OnStop(float beat)
|
||||
{
|
||||
foreach (var evt in scheduledInputs)
|
||||
{
|
||||
evt.Disable();
|
||||
}
|
||||
}
|
||||
|
||||
public int MultipleEventsAtOnce()
|
||||
{
|
||||
int sameTime = 0;
|
||||
|
@ -7,7 +7,7 @@ using NaughtyBezierCurves;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_MunchyMonk
|
||||
{
|
||||
public class Dumpling : PlayerActionObject
|
||||
public class Dumpling : MonoBehaviour
|
||||
{
|
||||
public Animator otherAnim;
|
||||
public float startBeat;
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@ -11,8 +12,9 @@ using HeavenStudio.Common;
|
||||
namespace HeavenStudio.Games
|
||||
{
|
||||
|
||||
public class PlayerActionEvent : PlayerActionObject
|
||||
public class PlayerActionEvent : MonoBehaviour
|
||||
{
|
||||
static List<PlayerActionEvent> allEvents = new List<PlayerActionEvent>();
|
||||
public static bool EnableAutoplayCheat = true;
|
||||
public delegate void ActionEventCallback(PlayerActionEvent caller);
|
||||
public delegate void ActionEventCallbackState(PlayerActionEvent caller, float state);
|
||||
@ -26,8 +28,12 @@ namespace HeavenStudio.Games
|
||||
public float startBeat;
|
||||
public float timer;
|
||||
|
||||
public bool isEligible = true;
|
||||
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 it's not relevant anymore
|
||||
public bool triggersAutoplay = true;
|
||||
bool lockedByEvent = false;
|
||||
bool markForDeletion = false;
|
||||
|
||||
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.
|
||||
|
||||
@ -51,43 +57,72 @@ namespace HeavenStudio.Games
|
||||
|
||||
public void Enable() { enabled = true; }
|
||||
public void Disable() { enabled = false; }
|
||||
public void QueueDeletion() { markForDeletion = true; }
|
||||
|
||||
public bool IsCorrectInput() =>
|
||||
//General inputs, both down and up
|
||||
(PlayerInput.Pressed() && inputType.HasFlag(InputType.STANDARD_DOWN)) ||
|
||||
(PlayerInput.AltPressed() && inputType.HasFlag(InputType.STANDARD_ALT_DOWN)) ||
|
||||
(PlayerInput.GetAnyDirectionDown() && inputType.HasFlag(InputType.DIRECTION_DOWN)) ||
|
||||
(PlayerInput.PressedUp() && inputType.HasFlag(InputType.STANDARD_UP)) ||
|
||||
(PlayerInput.AltPressedUp() && inputType.HasFlag(InputType.STANDARD_ALT_UP)) ||
|
||||
(PlayerInput.GetAnyDirectionUp() && inputType.HasFlag(InputType.DIRECTION_UP)) ||
|
||||
//Specific directional inputs
|
||||
(PlayerInput.GetSpecificDirectionDown(PlayerInput.DOWN) && inputType.HasFlag(InputType.DIRECTION_DOWN_DOWN)) ||
|
||||
(PlayerInput.GetSpecificDirectionDown(PlayerInput.UP) && inputType.HasFlag(InputType.DIRECTION_UP_DOWN)) ||
|
||||
(PlayerInput.GetSpecificDirectionDown(PlayerInput.LEFT) && inputType.HasFlag(InputType.DIRECTION_LEFT_DOWN)) ||
|
||||
(PlayerInput.GetSpecificDirectionDown(PlayerInput.RIGHT) && inputType.HasFlag(InputType.DIRECTION_RIGHT_DOWN)) ||
|
||||
|
||||
(PlayerInput.GetSpecificDirectionUp(PlayerInput.DOWN) && inputType.HasFlag(InputType.DIRECTION_DOWN_UP)) ||
|
||||
(PlayerInput.GetSpecificDirectionUp(PlayerInput.UP) && inputType.HasFlag(InputType.DIRECTION_UP_UP)) ||
|
||||
(PlayerInput.GetSpecificDirectionUp(PlayerInput.LEFT) && inputType.HasFlag(InputType.DIRECTION_LEFT_UP)) ||
|
||||
(PlayerInput.GetSpecificDirectionUp(PlayerInput.RIGHT) && inputType.HasFlag(InputType.DIRECTION_RIGHT_UP));
|
||||
|
||||
public void CanHit(bool canHit)
|
||||
{
|
||||
this.canHit = canHit;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
allEvents.Add(this);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if(!Conductor.instance.NotStopped()){CleanUp();} // If the song is stopped entirely in the editor, destroy itself as we don't want duplicates
|
||||
if (markForDeletion) CleanUp();
|
||||
if(!Conductor.instance.NotStopped()) CleanUp(); // If the song is stopped entirely in the editor, destroy itself as we don't want duplicates
|
||||
|
||||
if (noAutoplay && autoplayOnly) autoplayOnly = false;
|
||||
if (noAutoplay && triggersAutoplay){ triggersAutoplay = false; }
|
||||
if (noAutoplay && triggersAutoplay) triggersAutoplay = false;
|
||||
if (!enabled) return;
|
||||
|
||||
double normalizedTime = GetNormalizedTime();
|
||||
double stateProg = ((normalizedTime - Minigame.PerfectTime()) / (Minigame.LateTime() - Minigame.PerfectTime()) - 0.5f) * 2;
|
||||
StateCheck(normalizedTime);
|
||||
if (GameManager.instance.autoplay)
|
||||
{
|
||||
AutoplayInput(normalizedTime);
|
||||
return;
|
||||
}
|
||||
|
||||
//BUGFIX: ActionEvents destroyed too early
|
||||
if (normalizedTime > Minigame.EndTime()) Miss();
|
||||
|
||||
|
||||
if (IsCorrectInput() && !autoplayOnly)
|
||||
if (lockedByEvent)
|
||||
{
|
||||
if (state.perfect)
|
||||
return;
|
||||
}
|
||||
if (!CheckEventLock())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!autoplayOnly && IsCorrectInput())
|
||||
{
|
||||
if (IsExpectingInputNow())
|
||||
{
|
||||
double stateProg = ((normalizedTime - Minigame.PerfectTime()) / (Minigame.LateTime() - Minigame.PerfectTime()) - 0.5f) * 2;
|
||||
Hit(stateProg, normalizedTime);
|
||||
}
|
||||
else if (state.early && !perfectOnly)
|
||||
{
|
||||
Hit(-1f, normalizedTime);
|
||||
}
|
||||
else if (state.late && !perfectOnly)
|
||||
{
|
||||
Hit(1f, normalizedTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
Blank();
|
||||
@ -95,6 +130,60 @@ namespace HeavenStudio.Games
|
||||
}
|
||||
}
|
||||
|
||||
public void LateUpdate() {
|
||||
if (markForDeletion) {
|
||||
CleanUp();
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
foreach (PlayerActionEvent evt in allEvents)
|
||||
{
|
||||
evt.lockedByEvent = false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckEventLock()
|
||||
{
|
||||
foreach(PlayerActionEvent toCompare in allEvents)
|
||||
{
|
||||
if (toCompare == this) continue;
|
||||
if (toCompare.autoplayOnly) continue;
|
||||
if ((toCompare.inputType & this.inputType) == 0) continue;
|
||||
if (!toCompare.IsExpectingInputNow()) continue;
|
||||
|
||||
double t1 = this.startBeat + this.timer;
|
||||
double t2 = toCompare.startBeat + toCompare.timer;
|
||||
double songPos = Conductor.instance.songPositionInBeatsAsDouble;
|
||||
|
||||
// compare distance between current time and the events
|
||||
// events that happen at the exact same time with the exact same inputs will return true
|
||||
if (Math.Abs(t1 - songPos) > Math.Abs(t2 - songPos))
|
||||
return false;
|
||||
else if (t1 != t2) // if they are the same time, we don't want to lock the event
|
||||
toCompare.lockedByEvent = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void AutoplayInput(double normalizedTime, bool autoPlay = false)
|
||||
{
|
||||
if (triggersAutoplay && (GameManager.instance.autoplay || autoPlay) && GameManager.instance.canInput && normalizedTime >= 1f - (Time.deltaTime*0.5f))
|
||||
{
|
||||
AutoplayEvent();
|
||||
if (!autoPlay)
|
||||
TimelineAutoplay();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: move this to timeline code instead
|
||||
private void TimelineAutoplay()
|
||||
{
|
||||
if (Editor.Editor.instance == null) return;
|
||||
if (Editor.Track.Timeline.instance != null && !Editor.Editor.instance.fullscreen)
|
||||
{
|
||||
Editor.Track.Timeline.instance.AutoplayBTN.GetComponent<Animator>().Play("Ace", 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExpectingInputNow()
|
||||
{
|
||||
double normalizedBeat = GetNormalizedTime();
|
||||
@ -104,41 +193,15 @@ namespace HeavenStudio.Games
|
||||
double GetNormalizedTime()
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
double currTime = cond.GetSongPosFromBeat(cond.songPositionInBeatsAsDouble);
|
||||
double currTime = cond.songPositionAsDouble;
|
||||
double targetTime = cond.GetSongPosFromBeat(startBeat + timer);
|
||||
double min = targetTime - 1f;
|
||||
double max = targetTime + 1f;
|
||||
return 1f + (((currTime - min) / (max - min))-0.5f)*2;
|
||||
}
|
||||
|
||||
public bool IsCorrectInput()
|
||||
{
|
||||
// This one is a mouthful but it's an evil good to detect the correct input
|
||||
// Forgive me for those input type names
|
||||
return (
|
||||
//General inputs, both down and up
|
||||
(PlayerInput.Pressed() && inputType.HasFlag(InputType.STANDARD_DOWN)) ||
|
||||
(PlayerInput.AltPressed() && inputType.HasFlag(InputType.STANDARD_ALT_DOWN)) ||
|
||||
(PlayerInput.GetAnyDirectionDown() && inputType.HasFlag(InputType.DIRECTION_DOWN)) ||
|
||||
(PlayerInput.PressedUp() && inputType.HasFlag(InputType.STANDARD_UP)) ||
|
||||
(PlayerInput.AltPressedUp() && inputType.HasFlag(InputType.STANDARD_ALT_UP)) ||
|
||||
(PlayerInput.GetAnyDirectionUp() && inputType.HasFlag(InputType.DIRECTION_UP)) ||
|
||||
//Specific directional inputs
|
||||
(PlayerInput.GetSpecificDirectionDown(PlayerInput.DOWN) && inputType.HasFlag(InputType.DIRECTION_DOWN_DOWN)) ||
|
||||
(PlayerInput.GetSpecificDirectionDown(PlayerInput.UP) && inputType.HasFlag(InputType.DIRECTION_UP_DOWN)) ||
|
||||
(PlayerInput.GetSpecificDirectionDown(PlayerInput.LEFT) && inputType.HasFlag(InputType.DIRECTION_LEFT_DOWN)) ||
|
||||
(PlayerInput.GetSpecificDirectionDown(PlayerInput.RIGHT) && inputType.HasFlag(InputType.DIRECTION_RIGHT_DOWN)) ||
|
||||
|
||||
(PlayerInput.GetSpecificDirectionUp(PlayerInput.DOWN) && inputType.HasFlag(InputType.DIRECTION_DOWN_UP)) ||
|
||||
(PlayerInput.GetSpecificDirectionUp(PlayerInput.UP) && inputType.HasFlag(InputType.DIRECTION_UP_UP)) ||
|
||||
(PlayerInput.GetSpecificDirectionUp(PlayerInput.LEFT) && inputType.HasFlag(InputType.DIRECTION_LEFT_UP)) ||
|
||||
(PlayerInput.GetSpecificDirectionUp(PlayerInput.RIGHT) && inputType.HasFlag(InputType.DIRECTION_RIGHT_UP))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//For the Autoplay
|
||||
public override void OnAce()
|
||||
public void AutoplayEvent()
|
||||
{
|
||||
if (EnableAutoplayCheat)
|
||||
{
|
||||
@ -162,6 +225,7 @@ namespace HeavenStudio.Games
|
||||
double normalized = time - 1f;
|
||||
int offset = Mathf.CeilToInt((float)normalized * 1000);
|
||||
GameManager.instance.AvgInputOffset = offset;
|
||||
state = System.Math.Max(-1.0, System.Math.Min(1.0, state));
|
||||
OnHit(this, (float) state);
|
||||
|
||||
CleanUp();
|
||||
@ -256,9 +320,10 @@ namespace HeavenStudio.Games
|
||||
|
||||
public void CleanUp()
|
||||
{
|
||||
if (markForDeletion) return;
|
||||
allEvents.Remove(this);
|
||||
OnDestroy(this);
|
||||
Destroy(this.gameObject);
|
||||
markForDeletion = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,169 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using HeavenStudio.Editor;
|
||||
using HeavenStudio.Editor.Track;
|
||||
|
||||
namespace HeavenStudio.Games
|
||||
{
|
||||
public class PlayerActionObject : MonoBehaviour
|
||||
{
|
||||
public bool inList = false;
|
||||
public Minigame.Eligible state = new Minigame.Eligible();
|
||||
|
||||
public List<Minigame.Eligible> eligibleHitsList = new List<Minigame.Eligible>();
|
||||
|
||||
//the variables below seem to be mostly unused (they are never used in any meaningful way)
|
||||
public int aceTimes; //always set to 0 no matter what (also, the one time it's used doesn't seem to make sense)
|
||||
public bool isEligible = true;
|
||||
private bool autoPlayEnabledOnStart; //value never used for anything
|
||||
|
||||
public bool triggersAutoplay = true;
|
||||
|
||||
public void PlayerActionInit(GameObject g, float createBeat)
|
||||
{
|
||||
state.gameObject = g;
|
||||
state.createBeat = createBeat;
|
||||
|
||||
autoPlayEnabledOnStart = GameManager.instance.autoplay;
|
||||
}
|
||||
|
||||
private void CheckForAce(double normalizedBeat, bool autoPlay = false)
|
||||
{
|
||||
if (aceTimes == 0)
|
||||
{
|
||||
if (triggersAutoplay && (GameManager.instance.autoplay || autoPlay) && GameManager.instance.canInput && normalizedBeat >= 1f - (Time.deltaTime*0.5f))
|
||||
{
|
||||
OnAce();
|
||||
if (!autoPlay)
|
||||
AceVisuals();
|
||||
// aceTimes++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetAce()
|
||||
{
|
||||
aceTimes = 0;
|
||||
}
|
||||
|
||||
public void ResetState()
|
||||
{
|
||||
ResetAce();
|
||||
}
|
||||
|
||||
// could possibly add support for custom early, perfect, and end times if needed.
|
||||
public void StateCheck(double normalizedBeat, bool autoPlay = false)
|
||||
{
|
||||
CheckForAce(normalizedBeat, autoPlay);
|
||||
if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime())
|
||||
{
|
||||
MakeEligible(true, false, false);
|
||||
}
|
||||
// Perfect State
|
||||
else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime())
|
||||
{
|
||||
MakeEligible(false, true, false);
|
||||
}
|
||||
// Late State
|
||||
else if (normalizedBeat > Minigame.LateTime() && normalizedBeat < Minigame.EndTime())
|
||||
{
|
||||
MakeEligible(false, false, true);
|
||||
}
|
||||
else if (normalizedBeat < Minigame.EarlyTime() || normalizedBeat > Minigame.EndTime())
|
||||
{
|
||||
MakeInEligible();
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeEligible(bool early, bool perfect, bool late)
|
||||
{
|
||||
if (!inList)
|
||||
{
|
||||
state.early = early;
|
||||
state.perfect = perfect;
|
||||
state.late = late;
|
||||
|
||||
eligibleHitsList.Add(state);
|
||||
inList = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Minigame.Eligible es = eligibleHitsList[eligibleHitsList.IndexOf(state)];
|
||||
es.early = early;
|
||||
es.perfect = perfect;
|
||||
es.late = late;
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeInEligible()
|
||||
{
|
||||
state.early = false;
|
||||
state.perfect = false;
|
||||
state.late = false;
|
||||
if (!inList) return;
|
||||
|
||||
eligibleHitsList.Remove(state);
|
||||
inList = false;
|
||||
}
|
||||
|
||||
public void RemoveObject(int currentHitInList, bool destroyObject = false)
|
||||
{
|
||||
if (currentHitInList < eligibleHitsList.Count)
|
||||
{
|
||||
eligibleHitsList.Remove(eligibleHitsList[currentHitInList]);
|
||||
currentHitInList++;
|
||||
if (destroyObject) Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
// No list
|
||||
public void StateCheckNoList(float normalizedBeat)
|
||||
{
|
||||
CheckForAce(normalizedBeat);
|
||||
if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime())
|
||||
{
|
||||
ModifyState(true, false, false);
|
||||
}
|
||||
// Perfect State
|
||||
else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime())
|
||||
{
|
||||
ModifyState(false, true, false);
|
||||
}
|
||||
// Late State
|
||||
else if (normalizedBeat > Minigame.LateTime() && normalizedBeat < Minigame.EndTime())
|
||||
{
|
||||
ModifyState(false, false, true);
|
||||
}
|
||||
else if (normalizedBeat < Minigame.EarlyTime() || normalizedBeat > Minigame.EndTime())
|
||||
{
|
||||
// ineligible
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnAce()
|
||||
{
|
||||
}
|
||||
|
||||
private void AceVisuals()
|
||||
{
|
||||
if (Timeline.instance != null && Editor.Editor.instance != null && !Editor.Editor.instance.fullscreen)
|
||||
{
|
||||
Timeline.instance.AutoplayBTN.GetComponent<Animator>().Play("Ace", 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void ModifyState(bool early, bool perfect, bool late)
|
||||
{
|
||||
state.early = early;
|
||||
state.perfect = perfect;
|
||||
state.late = late;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
MakeInEligible();
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_RhythmRally
|
||||
{
|
||||
public class Paddlers : PlayerActionObject
|
||||
public class Paddlers : MonoBehaviour
|
||||
{
|
||||
private RhythmRally game;
|
||||
private Animator playerAnim;
|
||||
|
@ -5,7 +5,7 @@ using System;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_RhythmTweezers
|
||||
{
|
||||
public class Hair : PlayerActionObject
|
||||
public class Hair : MonoBehaviour
|
||||
{
|
||||
public float createBeat;
|
||||
public GameObject hairSprite;
|
||||
|
@ -6,7 +6,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_RhythmTweezers
|
||||
{
|
||||
public class LongHair : PlayerActionObject
|
||||
public class LongHair : MonoBehaviour
|
||||
{
|
||||
public float createBeat;
|
||||
public GameObject hairSprite;
|
||||
@ -44,7 +44,7 @@ namespace HeavenStudio.Games.Scripts_RhythmTweezers
|
||||
if (endInput == InputType.DIRECTION_UP) input = PlayerInput.GetAnyDirectionUp();
|
||||
if (input && !game.IsExpectingInputNow(endInput))
|
||||
{
|
||||
endEvent.MakeInEligible();
|
||||
endEvent.isEligible = false;
|
||||
EndEarly();
|
||||
return;
|
||||
}
|
||||
|
104
Assets/Scripts/Games/SoundEffects.cs
Normal file
104
Assets/Scripts/Games/SoundEffects.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games
|
||||
{
|
||||
public class SoundEffects : MonoBehaviour
|
||||
{
|
||||
|
||||
public enum CountNumbers { One, Two, Three, Four }
|
||||
public static string[] countNames = { "one", "two", "three", "four" };
|
||||
public static void Count(int type, bool alt)
|
||||
{
|
||||
string sound = countNames[type];
|
||||
if (!alt)
|
||||
sound += "1";
|
||||
else
|
||||
sound += "2";
|
||||
Jukebox.PlayOneShot("count-ins/" + sound);
|
||||
}
|
||||
|
||||
public enum CountInType { Normal, Alt, Cowbell }
|
||||
public static string[] GetCountInSounds(string[] sounds, CountInType type)
|
||||
{
|
||||
for (int i = 0; i < sounds.Length; i++)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CountInType.Normal:
|
||||
sounds[i] += "1";
|
||||
break;
|
||||
case CountInType.Alt:
|
||||
sounds[i] += "2";
|
||||
break;
|
||||
case CountInType.Cowbell:
|
||||
sounds[i] = "cowbell";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sounds;
|
||||
}
|
||||
public static void FourBeatCountIn(float beat, float length, int type)
|
||||
{
|
||||
string[] sounds = { "one", "two", "three", "four" };
|
||||
sounds = GetCountInSounds(sounds, (CountInType)type);
|
||||
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("count-ins/" + sounds[0], beat),
|
||||
new MultiSound.Sound("count-ins/" + sounds[1], beat + 1f * length),
|
||||
new MultiSound.Sound("count-ins/" + sounds[2], beat + 2f * length),
|
||||
new MultiSound.Sound("count-ins/" + sounds[3], beat + 3f * length)
|
||||
}, false);
|
||||
}
|
||||
|
||||
public static void EightBeatCountIn(float beat, float length, int type)
|
||||
{
|
||||
string[] sounds = { "one", "two", "one", "two", "three", "four" };
|
||||
sounds = GetCountInSounds(sounds, (CountInType)type);
|
||||
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("count-ins/" + sounds[0], beat),
|
||||
new MultiSound.Sound("count-ins/" + sounds[1], beat + 2f * length),
|
||||
new MultiSound.Sound("count-ins/" + sounds[2], beat + 4f * length),
|
||||
new MultiSound.Sound("count-ins/" + sounds[3], beat + 5f * length),
|
||||
new MultiSound.Sound("count-ins/" + sounds[4], beat + 6f * length),
|
||||
new MultiSound.Sound("count-ins/" + sounds[5], beat + 7f * length)
|
||||
}, false);
|
||||
}
|
||||
|
||||
public static void Cowbell()
|
||||
{
|
||||
Jukebox.PlayOneShot("count-ins/cowbell");
|
||||
}
|
||||
|
||||
public static void Ready(float beat, float length)
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("count-ins/ready1", beat),
|
||||
new MultiSound.Sound("count-ins/ready2", beat + 1f * length),
|
||||
}, false);
|
||||
}
|
||||
|
||||
public static void And()
|
||||
{
|
||||
Jukebox.PlayOneShot("count-ins/and");
|
||||
}
|
||||
|
||||
public static void Go(bool alt)
|
||||
{
|
||||
string sound = "count-ins/go";
|
||||
if (!alt)
|
||||
sound += "1";
|
||||
else
|
||||
sound += "2";
|
||||
Jukebox.PlayOneShot(sound);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f6efa2756faaa740b7f4f81da94a909
|
||||
guid: c2f8829b764160148b6dbf3947ea9df3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@ -6,7 +6,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_SpaceSoccer
|
||||
{
|
||||
public class Kicker : PlayerActionObject
|
||||
public class Kicker : MonoBehaviour
|
||||
{
|
||||
SpaceSoccer game;
|
||||
|
||||
@ -82,7 +82,6 @@ namespace HeavenStudio.Games.Scripts_SpaceSoccer
|
||||
public void Kick(bool hit, bool highKick = false)
|
||||
{
|
||||
if (stopBall) return;
|
||||
aceTimes = 0;
|
||||
|
||||
if (player)
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ using NaughtyBezierCurves;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_Spaceball
|
||||
{
|
||||
public class SpaceballBall : PlayerActionObject
|
||||
public class SpaceballBall : MonoBehaviour
|
||||
{
|
||||
#region Public
|
||||
|
||||
@ -46,8 +46,6 @@ namespace HeavenStudio.Games.Scripts_Spaceball
|
||||
e.gameObject = this.gameObject;
|
||||
|
||||
startRot = Random.Range(0, 360);
|
||||
|
||||
isEligible = true;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
|
@ -1,61 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_TapTrial
|
||||
{
|
||||
public class Tap : PlayerActionObject
|
||||
{
|
||||
public float startBeat;
|
||||
|
||||
public int type;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
PlayerActionInit(this.gameObject, startBeat);
|
||||
}
|
||||
|
||||
public override void OnAce()
|
||||
{
|
||||
Hit(true);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Conductor.instance.GetPositionFromBeat(startBeat, 2) >= 1)
|
||||
CleanUp();
|
||||
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat, 1f);
|
||||
StateCheck(normalizedBeat);
|
||||
|
||||
if(PlayerInput.Pressed())
|
||||
{
|
||||
if(state.perfect)
|
||||
{
|
||||
Hit(true);
|
||||
}
|
||||
else if(state.notPerfect())
|
||||
{
|
||||
Hit(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Hit(bool hit)
|
||||
{
|
||||
TapTrial.instance.player.Tap(hit, type);
|
||||
|
||||
if (hit)
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
public void CleanUp()
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01f0b70cc14be2e47998a680099e7986
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -8,7 +8,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_TrickClass
|
||||
{
|
||||
public class MobTrickObj : PlayerActionObject
|
||||
public class MobTrickObj : MonoBehaviour
|
||||
{
|
||||
public bool flyType;
|
||||
public float startBeat;
|
||||
|
@ -5,7 +5,7 @@ using System;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_WizardsWaltz
|
||||
{
|
||||
public class Plant : PlayerActionObject
|
||||
public class Plant : MonoBehaviour
|
||||
{
|
||||
public Animator animator;
|
||||
public SpriteRenderer spriteRenderer;
|
||||
|
@ -7,7 +7,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_WorkingDough
|
||||
{
|
||||
public class BGBall : PlayerActionObject
|
||||
public class BGBall : MonoBehaviour
|
||||
{
|
||||
public float startBeat;
|
||||
public float firstBeatsToTravel = 3f;
|
||||
|
@ -14,7 +14,7 @@ namespace HeavenStudio.Games.Scripts_WorkingDough
|
||||
ExitingUp = 2,
|
||||
ExitingDown = 3
|
||||
}
|
||||
public class NPCDoughBall : PlayerActionObject
|
||||
public class NPCDoughBall : MonoBehaviour
|
||||
{
|
||||
public float startBeat;
|
||||
|
||||
|
@ -7,7 +7,7 @@ using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_WorkingDough
|
||||
{
|
||||
public class PlayerEnterDoughBall : PlayerActionObject
|
||||
public class PlayerEnterDoughBall : MonoBehaviour
|
||||
{
|
||||
public float startBeat;
|
||||
public float firstBeatsToTravel = 0.5f;
|
||||
|
Reference in New Issue
Block a user