You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
1.8 KiB
83 lines
1.8 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UltraCombos;
|
|
using UltraCombos.Configuration;
|
|
|
|
|
|
public class StatManager : MonoBehaviour
|
|
{
|
|
[Config]
|
|
[Range(0.1f, 3f)]
|
|
public float fade_sec = 1f;
|
|
|
|
[Config]
|
|
[Range(1, 10)]
|
|
public int loop_to_trigger = 1;
|
|
|
|
public DShowMoviePlayer idle_player;
|
|
public DShowMoviePlayer h_player;
|
|
public CanvasGroup h_grp;
|
|
|
|
int loop_count;
|
|
float lerp_val = 1f;
|
|
|
|
void Start()
|
|
{
|
|
h_grp.alpha = 0f;
|
|
loop_count = 0;
|
|
lerp_val = 0;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if(h_player.IsPlaying == false){
|
|
if (idle_player.Frame == idle_player.TotalNumFrames)
|
|
{
|
|
loop_count += 1;
|
|
}
|
|
if (loop_count >= loop_to_trigger)
|
|
{
|
|
Debug.Log("horse fade in");
|
|
h_player.Play();
|
|
StartCoroutine("fade_in");
|
|
loop_count = 0;
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
if(h_player.Frame == h_player.TotalNumFrames - fade_sec * 30)
|
|
{
|
|
idle_player.Frame = 0;
|
|
Debug.Log("horse fade out");
|
|
StartCoroutine("fade_out");
|
|
}
|
|
}
|
|
}
|
|
|
|
IEnumerator fade_in()
|
|
{
|
|
lerp_val = 0f;
|
|
while (h_grp.alpha <= 1f)
|
|
{
|
|
lerp_val += Time.deltaTime / fade_sec;
|
|
h_grp.alpha = Mathf.Lerp(0f, 1f, lerp_val);
|
|
yield return null;
|
|
}
|
|
yield break;
|
|
}
|
|
|
|
IEnumerator fade_out()
|
|
{
|
|
lerp_val = 1f;
|
|
while (h_grp.alpha >= 0f)
|
|
{
|
|
lerp_val -= Time.deltaTime / fade_sec;
|
|
h_grp.alpha = Mathf.Lerp(0f, 1f, lerp_val);
|
|
yield return null;
|
|
}
|
|
yield break;
|
|
}
|
|
}
|
|
|