|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
using UltraCombos;
|
|
|
|
|
|
|
|
|
|
|
|
public class movieController : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
DShowMoviePlayer player;
|
|
|
|
|
|
AudioSource aud;
|
|
|
|
|
|
public int id;
|
|
|
|
|
|
public int stat;
|
|
|
|
|
|
public float fade_speed;
|
|
|
|
|
|
public bool force_destroy;
|
|
|
|
|
|
public float destroy_timer;
|
|
|
|
|
|
public float wait_sec = 2f;
|
|
|
|
|
|
public float volume = 1f;
|
|
|
|
|
|
public DShowClip snow_01;
|
|
|
|
|
|
public DShowClip snow_02;
|
|
|
|
|
|
public DShowClip snow_03;
|
|
|
|
|
|
public DShowClip snow_04;
|
|
|
|
|
|
|
|
|
|
|
|
public AudioClip step1;
|
|
|
|
|
|
public AudioClip step2;
|
|
|
|
|
|
public AudioClip step3;
|
|
|
|
|
|
public AudioClip step4;
|
|
|
|
|
|
|
|
|
|
|
|
bool playAud;
|
|
|
|
|
|
float alpha;
|
|
|
|
|
|
|
|
|
|
|
|
void Awake()
|
|
|
|
|
|
{
|
|
|
|
|
|
player = GetComponent<DShowMoviePlayer>();
|
|
|
|
|
|
//aud = GetComponent<AudioSource>();
|
|
|
|
|
|
stat = 0;
|
|
|
|
|
|
force_destroy = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
//player = GetComponent<DShowMoviePlayer>();
|
|
|
|
|
|
GetComponent<RawImage>().color = Color.clear;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
aud.volume = volume;
|
|
|
|
|
|
if (playAud && aud.clip != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.Log(aud.clip.name);
|
|
|
|
|
|
aud.Play();
|
|
|
|
|
|
playAud = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(stat == 0){
|
|
|
|
|
|
alpha = 0;
|
|
|
|
|
|
if (player.IsPlaying)
|
|
|
|
|
|
stat = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (stat == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
alpha += fade_speed * 5f;
|
|
|
|
|
|
if (alpha >= 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
alpha = 1;
|
|
|
|
|
|
stat = 2;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
if (stat == 2 && force_destroy)
|
|
|
|
|
|
{
|
|
|
|
|
|
stat = 3;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (stat == 3)
|
|
|
|
|
|
{
|
|
|
|
|
|
float t = Time.time;
|
|
|
|
|
|
if (t - destroy_timer > wait_sec)
|
|
|
|
|
|
{
|
|
|
|
|
|
//Debug.Log("fade");
|
|
|
|
|
|
alpha -= fade_speed;
|
|
|
|
|
|
if (alpha < 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Destroy(this.gameObject);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
GetComponent<RawImage>().color = new Color(1f, 1f, 1f, alpha);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OnEnable()
|
|
|
|
|
|
{
|
|
|
|
|
|
aud = gameObject.AddComponent<AudioSource>();
|
|
|
|
|
|
int seed = Random.Range(0, 4);
|
|
|
|
|
|
switch (seed){
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
player.VideoAsset = snow_01;
|
|
|
|
|
|
aud.clip = step1;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
player.VideoAsset = snow_02;
|
|
|
|
|
|
aud.clip = step2;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
player.VideoAsset = snow_03;
|
|
|
|
|
|
aud.clip = step3;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
player.VideoAsset = snow_04;
|
|
|
|
|
|
aud.clip = step4;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
//aud.Play();
|
|
|
|
|
|
playAud = true;
|
|
|
|
|
|
|
|
|
|
|
|
if (name != "RawImage") {
|
|
|
|
|
|
|
|
|
|
|
|
GetComponent<RawImage>().enabled = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
//Debug.Log("Hi");
|
|
|
|
|
|
|
|
|
|
|
|
stat = 0;
|
|
|
|
|
|
alpha = 0f;
|
|
|
|
|
|
rotateImg();
|
|
|
|
|
|
player.Play();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OnDestroy()
|
|
|
|
|
|
{
|
|
|
|
|
|
//Debug.Log("Bye");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void rotateImg()
|
|
|
|
|
|
{
|
|
|
|
|
|
Vector3 rot_axis = new Vector3(0, 0, 1);
|
|
|
|
|
|
Vector3 mid_pt = new Vector3(GetComponent<RectTransform>().position.x, GetComponent<RectTransform>().position.y, 0);
|
|
|
|
|
|
float rand_deg = Random.Range(0, 360);
|
|
|
|
|
|
GetComponent<RectTransform>().Rotate(rot_axis, rand_deg);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|