HeavenStudio/Assets/Scripts/UI/Overlays/GoForAPerfect.cs
minenice55 d5ae99d8ba
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

123 lines
3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
namespace HeavenStudio.Common
{
public class GoForAPerfect : MonoBehaviour
{
public static GoForAPerfect instance { get; set; }
[SerializeField] Animator texAnim;
[SerializeField] Animator pAnim;
private bool active = false;
private bool hiddenActive = false;
public bool perfect;
Conductor cond;
float lastReportedBeat = 0f;
float currentBeat = 0f;
long currentBlink = 0;
private void Awake()
{
instance = this;
}
private void Start()
{
perfect = true;
cond = Conductor.instance;
}
private void Update() {
gameObject.SetActive(hiddenActive);
if (!active) return;
if (!OverlaysManager.OverlaysEnabled) return;
if (cond == null || !cond.isPlaying) return;
if (cond.ReportBeat(ref lastReportedBeat))
{
currentBeat = lastReportedBeat;
if (currentBlink != 0)
{
currentBlink++;
if (currentBlink % 2 == 0)
{
texAnim.Play("GoForAPerfect_Blink", -1, 0);
}
else
{
texAnim.Play("GoForAPerfect_Blink2", -1, 0);
}
}
else
{
currentBlink++;
}
}
else if (cond.songPositionInBeats < lastReportedBeat)
{
lastReportedBeat = Mathf.Round(cond.songPositionInBeats);
}
}
public void Hit()
{
if (!active) return;
if (!OverlaysManager.OverlaysEnabled) return;
pAnim.Play("PerfectIcon_Hit", 0, 0);
}
public void Miss()
{
perfect = false;
if (!active) return;
SetInactive();
if (!OverlaysManager.OverlaysEnabled)
{
hiddenActive = false;
return;
}
GameProfiler.instance.perfect = false;
texAnim.Play("GoForAPerfect_Miss");
pAnim.Play("PerfectIcon_Miss", -1, 0);
Jukebox.PlayOneShot("perfectMiss");
}
public void Enable(double startBeat)
{
SetActive();
gameObject.SetActive(true);
pAnim.gameObject.SetActive(true);
texAnim.gameObject.SetActive(true);
texAnim.Play("GoForAPerfect_Idle");
currentBlink = 0;
}
public void Disable()
{
SetInactive();
gameObject.SetActive(false);
}
public void SetActive()
{
hiddenActive = true;
active = true;
}
public void SetInactive()
{
active = false;
}
}
}