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.

167 lines
4.0 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;
public AudioClip horse_clip;
AudioSource aud;
int loop_count;
float h_lerp_val;
float s_lerp_val;
float h_total_time = 30f;
float i_total_time = 8f;
float trigger_time;
float m_timer;
void Start()
{
h_grp.alpha = 0f;
loop_count = 0;
h_lerp_val = 0f;
s_lerp_val = 1f;
// m_timer = h_total_time;
m_timer = 0f;
}
void Update()
{
trigger_time = i_total_time * loop_to_trigger;
//if(h_player.IsPlaying == falss)
m_timer += Time.deltaTime;
//Debug.Log(m_timer);
//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)
//if (h_player.IsPlaying)
/*if (false)
{
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.GetCurrentTime > h_total_time - fade_sec)
{
//idle_player.Frame = 0;
Debug.Log("horse fade out");
StartCoroutine("h_fade_out");
}
}*/
if(m_timer > trigger_time + h_total_time)
{
m_timer = 0f;
}
else if (m_timer > trigger_time + h_total_time - fade_sec)
{
Debug.Log("horse fade out");
StartCoroutine("h_fade_out");
}
else if (m_timer > trigger_time + 27f)
{
Debug.Log("snow in");
StartCoroutine("s_fade_in");
}
else if (m_timer > trigger_time + 18f)
{
Debug.Log("snow out");
StartCoroutine("s_fade_out");
}
else if (m_timer > trigger_time)
{
aud = gameObject.AddComponent<AudioSource>();
aud.loop = false;
aud.playOnAwake = false;
aud.clip = horse_clip;
aud.Play();
h_player.Play();
//m_timer = 0f;
Debug.Log("horse fade in");
StartCoroutine("h_fade_in");
loop_count = 0;
}
}
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;
}
Destroy(aud);
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;
}
}