HeavenStudioPlus/Assets/Scripts/Games/PlayerActionObject.cs

170 lines
5.3 KiB
C#
Raw Normal View History

2021-12-29 06:52:48 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Game Overlays (#280) * add accuracy display * temp BG for show * separate overlays prefab make proper shader for star effects * aim shakiness display * implement testing skill star * fully functional skill star * separate section display from editor * fully separate chart section display from timeline * add section to overlays * fix nullreference issues * start game layout settings * add game settings script * fix nonfunctioning scoring * invert y position logic on timing bar * add perfect challenge functionality * fix section not showing up in editor add perfect challenge option * add timing display minimal mode * Update PerfectAndPractice.png * show gismo for minigame bounds in editor * add ability to disable overlays in editor * prepare medals add new timing display graphic * hide screen preview * per-axis camera control added per request * section medals basic functionality * add medal get animations * fix bug with perfect icons * visual enhancements * adjust look of timing display minmode address audio ducking issues(?) * prepare overlay lyt editor add viewport pan, rotate, scale adjust audio setting * add layout editor UI elements * dynamic overlay creation * fix default single timing disp * set up overlay settings controls * start UI events * runtime uuid for component reference * layout editor affects overlay elements * show overlay element previews while editing * advanced audio settings * fix bug in drop-down creation * fallback defaults for the new stuff * fix textbox & overlay visibility bugs
2023-03-11 04:51:22 +00:00
using HeavenStudio.Editor;
2022-03-14 14:21:05 +00:00
using HeavenStudio.Editor.Track;
2022-03-14 14:21:05 +00:00
namespace HeavenStudio.Games
2021-12-29 06:52:48 +00:00
{
public class PlayerActionObject : MonoBehaviour
{
public bool inList = false;
public Minigame.Eligible state = new Minigame.Eligible();
2021-12-29 06:52:48 +00:00
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)
Game Overlays (#280) * add accuracy display * temp BG for show * separate overlays prefab make proper shader for star effects * aim shakiness display * implement testing skill star * fully functional skill star * separate section display from editor * fully separate chart section display from timeline * add section to overlays * fix nullreference issues * start game layout settings * add game settings script * fix nonfunctioning scoring * invert y position logic on timing bar * add perfect challenge functionality * fix section not showing up in editor add perfect challenge option * add timing display minimal mode * Update PerfectAndPractice.png * show gismo for minigame bounds in editor * add ability to disable overlays in editor * prepare medals add new timing display graphic * hide screen preview * per-axis camera control added per request * section medals basic functionality * add medal get animations * fix bug with perfect icons * visual enhancements * adjust look of timing display minmode address audio ducking issues(?) * prepare overlay lyt editor add viewport pan, rotate, scale adjust audio setting * add layout editor UI elements * dynamic overlay creation * fix default single timing disp * set up overlay settings controls * start UI events * runtime uuid for component reference * layout editor affects overlay elements * show overlay element previews while editing * advanced audio settings * fix bug in drop-down creation * fallback defaults for the new stuff * fix textbox & overlay visibility bugs
2023-03-11 04:51:22 +00:00
public bool isEligible = true;
private bool autoPlayEnabledOnStart; //value never used for anything
2022-02-28 08:33:11 +00:00
public bool triggersAutoplay = true;
public void PlayerActionInit(GameObject g, float createBeat)
2021-12-29 06:52:48 +00:00
{
state.gameObject = g;
state.createBeat = createBeat;
autoPlayEnabledOnStart = GameManager.instance.autoplay;
2021-12-29 06:52:48 +00:00
}
private void CheckForAce(double normalizedBeat, bool autoPlay = false)
2022-01-23 03:40:53 +00:00
{
if (aceTimes == 0)
{
if (triggersAutoplay && (GameManager.instance.autoplay || autoPlay) && GameManager.instance.canInput && normalizedBeat >= 1f - (Time.deltaTime*0.5f))
2022-01-23 03:40:53 +00:00
{
OnAce();
if (!autoPlay)
AceVisuals();
// aceTimes++;
2022-01-23 03:40:53 +00:00
}
}
}
2022-01-24 02:15:23 +00:00
public void ResetAce()
{
aceTimes = 0;
}
public void ResetState()
{
ResetAce();
2022-01-24 02:15:23 +00:00
}
2021-12-29 06:52:48 +00:00
// could possibly add support for custom early, perfect, and end times if needed.
public void StateCheck(double normalizedBeat, bool autoPlay = false)
2021-12-29 06:52:48 +00:00
{
CheckForAce(normalizedBeat, autoPlay);
if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime())
2021-12-29 06:52:48 +00:00
{
MakeEligible(true, false, false);
2021-12-29 06:52:48 +00:00
}
// Perfect State
else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime())
2021-12-29 06:52:48 +00:00
{
MakeEligible(false, true, false);
2021-12-29 06:52:48 +00:00
}
// Late State
else if (normalizedBeat > Minigame.LateTime() && normalizedBeat < Minigame.EndTime())
2021-12-29 06:52:48 +00:00
{
MakeEligible(false, false, true);
2021-12-29 06:52:48 +00:00
}
else if (normalizedBeat < Minigame.EarlyTime() || normalizedBeat > Minigame.EndTime())
{
MakeInEligible();
2021-12-29 06:52:48 +00:00
}
}
public void MakeEligible(bool early, bool perfect, bool late)
2021-12-29 06:52:48 +00:00
{
if (!inList)
{
state.early = early;
state.perfect = perfect;
state.late = late;
2021-12-29 06:52:48 +00:00
eligibleHitsList.Add(state);
2021-12-29 06:52:48 +00:00
inList = true;
}
else
{
Minigame.Eligible es = eligibleHitsList[eligibleHitsList.IndexOf(state)];
2021-12-29 06:52:48 +00:00
es.early = early;
es.perfect = perfect;
es.late = late;
}
}
public void MakeInEligible()
2021-12-29 06:52:48 +00:00
{
2022-01-23 03:40:53 +00:00
state.early = false;
state.perfect = false;
state.late = false;
2021-12-29 06:52:48 +00:00
if (!inList) return;
eligibleHitsList.Remove(state);
2021-12-29 06:52:48 +00:00
inList = false;
}
public void RemoveObject(int currentHitInList, bool destroyObject = false)
2021-12-29 06:52:48 +00:00
{
if (currentHitInList < eligibleHitsList.Count)
2021-12-29 06:52:48 +00:00
{
eligibleHitsList.Remove(eligibleHitsList[currentHitInList]);
2021-12-29 06:52:48 +00:00
currentHitInList++;
if (destroyObject) Destroy(this.gameObject);
2021-12-29 06:52:48 +00:00
}
}
// No list
public void StateCheckNoList(float normalizedBeat)
{
2022-01-23 03:40:53 +00:00
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
}
}
2022-01-23 03:40:53 +00:00
public virtual void OnAce()
{
}
private void AceVisuals()
{
Game Overlays (#280) * add accuracy display * temp BG for show * separate overlays prefab make proper shader for star effects * aim shakiness display * implement testing skill star * fully functional skill star * separate section display from editor * fully separate chart section display from timeline * add section to overlays * fix nullreference issues * start game layout settings * add game settings script * fix nonfunctioning scoring * invert y position logic on timing bar * add perfect challenge functionality * fix section not showing up in editor add perfect challenge option * add timing display minimal mode * Update PerfectAndPractice.png * show gismo for minigame bounds in editor * add ability to disable overlays in editor * prepare medals add new timing display graphic * hide screen preview * per-axis camera control added per request * section medals basic functionality * add medal get animations * fix bug with perfect icons * visual enhancements * adjust look of timing display minmode address audio ducking issues(?) * prepare overlay lyt editor add viewport pan, rotate, scale adjust audio setting * add layout editor UI elements * dynamic overlay creation * fix default single timing disp * set up overlay settings controls * start UI events * runtime uuid for component reference * layout editor affects overlay elements * show overlay element previews while editing * advanced audio settings * fix bug in drop-down creation * fallback defaults for the new stuff * fix textbox & overlay visibility bugs
2023-03-11 04:51:22 +00:00
if (Timeline.instance != null && Editor.Editor.instance != null && !Editor.Editor.instance.fullscreen)
2022-01-23 03:40:53 +00:00
{
Timeline.instance.AutoplayBTN.GetComponent<Animator>().Play("Ace", 0, 0);
2022-01-23 03:40:53 +00:00
}
}
private void ModifyState(bool early, bool perfect, bool late)
{
state.early = early;
state.perfect = perfect;
state.late = late;
}
private void OnDestroy()
{
MakeInEligible();
}
2021-12-29 06:52:48 +00:00
}
Game Overlays (#280) * add accuracy display * temp BG for show * separate overlays prefab make proper shader for star effects * aim shakiness display * implement testing skill star * fully functional skill star * separate section display from editor * fully separate chart section display from timeline * add section to overlays * fix nullreference issues * start game layout settings * add game settings script * fix nonfunctioning scoring * invert y position logic on timing bar * add perfect challenge functionality * fix section not showing up in editor add perfect challenge option * add timing display minimal mode * Update PerfectAndPractice.png * show gismo for minigame bounds in editor * add ability to disable overlays in editor * prepare medals add new timing display graphic * hide screen preview * per-axis camera control added per request * section medals basic functionality * add medal get animations * fix bug with perfect icons * visual enhancements * adjust look of timing display minmode address audio ducking issues(?) * prepare overlay lyt editor add viewport pan, rotate, scale adjust audio setting * add layout editor UI elements * dynamic overlay creation * fix default single timing disp * set up overlay settings controls * start UI events * runtime uuid for component reference * layout editor affects overlay elements * show overlay element previews while editing * advanced audio settings * fix bug in drop-down creation * fallback defaults for the new stuff * fix textbox & overlay visibility bugs
2023-03-11 04:51:22 +00:00
}