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.
123 lines
2.8 KiB
123 lines
2.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;
|
|
public CanvasGroup s_grp;
|
|
|
|
int loop_count;
|
|
float h_lerp_val;
|
|
float s_lerp_val;
|
|
|
|
void Start()
|
|
{
|
|
h_grp.alpha = 0f;
|
|
loop_count = 0;
|
|
h_lerp_val = 0f;
|
|
s_lerp_val = 1f;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if(h_player.IsPlaying == false){
|
|
if (idle_player.Frame == idle_player.TotalNumFrames)
|
|
{
|
|
loop_count += 1;
|
|
//Debug.Log(loop_count);
|
|
}
|
|
if (loop_count >= loop_to_trigger)
|
|
{
|
|
Debug.Log("horse fade in");
|
|
h_player.Play();
|
|
StartCoroutine("h_fade_in");
|
|
loop_count = 0;
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
if(h_player.GetCurrentTime == 18f)
|
|
{
|
|
Debug.Log("snow out");
|
|
StartCoroutine("s_fade_out");
|
|
}
|
|
|
|
else if(h_player.GetCurrentTime == 27f)
|
|
{
|
|
Debug.Log("snow in");
|
|
StartCoroutine("s_fade_in");
|
|
}
|
|
|
|
if(h_player.Frame == h_player.TotalNumFrames - fade_sec * 30)
|
|
{
|
|
idle_player.Frame = 0;
|
|
Debug.Log("horse fade out");
|
|
StartCoroutine("h_fade_out");
|
|
}
|
|
}
|
|
}
|
|
|
|
IEnumerator h_fade_in()
|
|
{
|
|
h_lerp_val = 0f;
|
|
while (h_grp.alpha < 1f)
|
|
{
|
|
h_lerp_val += Time.deltaTime / fade_sec;
|
|
h_grp.alpha = Mathf.Lerp(0f, 1f, h_lerp_val);
|
|
yield return null;
|
|
}
|
|
yield break;
|
|
}
|
|
|
|
IEnumerator h_fade_out()
|
|
{
|
|
h_lerp_val = 1f;
|
|
while (h_grp.alpha > 0f)
|
|
{
|
|
h_lerp_val -= Time.deltaTime / fade_sec;
|
|
h_grp.alpha = Mathf.Lerp(0f, 1f, h_lerp_val);
|
|
yield return null;
|
|
}
|
|
yield break;
|
|
}
|
|
|
|
IEnumerator s_fade_in()
|
|
{
|
|
s_lerp_val = 0f;
|
|
while (s_grp.alpha < 1f)
|
|
{
|
|
s_lerp_val += Time.deltaTime*2f;
|
|
s_grp.alpha = Mathf.Lerp(0f, 1f, s_lerp_val);
|
|
yield return null;
|
|
}
|
|
yield break;
|
|
}
|
|
|
|
IEnumerator s_fade_out()
|
|
{
|
|
s_lerp_val = 1f;
|
|
while (s_grp.alpha > 0f)
|
|
{
|
|
s_lerp_val -= Time.deltaTime*2f;
|
|
s_grp.alpha = Mathf.Lerp(0f, 1f, s_lerp_val);
|
|
yield return null;
|
|
}
|
|
yield break;
|
|
}
|
|
}
|
|
|