diff --git a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Prefabs/RawImage.prefab b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Prefabs/RawImage.prefab index 27e5695..694f9a5 100644 --- a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Prefabs/RawImage.prefab +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Prefabs/RawImage.prefab @@ -38,7 +38,7 @@ RectTransform: m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 300, y: 300} + m_SizeDelta: {x: 200, y: 200} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &2142686115215515799 CanvasRenderer: @@ -88,6 +88,9 @@ MonoBehaviour: id: 0 fade_speed: 0.05 stat: 0 + alpha: 0 + destroy_timer: 0 + CanDsetroy: 0 --- !u!114 &1996081109 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/movieController.cs b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/movieController.cs index 17269ad..21cbba0 100644 --- a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/movieController.cs +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/movieController.cs @@ -9,68 +9,38 @@ public class movieController : MonoBehaviour { DShowMoviePlayer player; public int id; - //public tuio_event tuio_event; public float fade_speed = 0.02f; public int stat; - float c; + public float alpha; public float destroy_timer; - float wait_sec = 3f; - //Vector2 pos, pre_pos; - //public Transform trans; + public bool CanDsetroy; + float wait_sec = 2f; void Awake() { player = GetComponent(); - //trans = GetComponent(); + CanDsetroy = true; + stat = 1; } void Start() { //player = GetComponent(); GetComponent().color = Color.clear; - //pos = Vector2.zero; } - // Update is called once per frame void Update() { -#if false - transform.gameObject.SetActive(true); - - trans = GetComponent(); - //Debug.Log(stat); - pre_pos = pos; - - if (tuio_event.tuio_input.touchCount > 0 && id != -1) - { - - transform.gameObject.SetActive(true); - ////////////////////// - /// - /* - int t_c = tuio_event.tuio_input.touchCount; - if (id == t_c) - { - //id -= 1; - Debug.Log("error"); - } - //Debug.Log("id = " + id + " / touch count = " + t_c); - if (id >= 0) - { - pos = tuio_event.tuio_input.GetTouch(id).position; - } - else - pos = pre_pos; - GetComponent().position = new Vector3(pos.x, pos.y, 0); - */ + if(stat == 0){ + alpha = 0; + stat = 1; } -#endif - if (stat == 1) + else if (stat == 1) { - c += fade_speed; - if (c > 1) + alpha += fade_speed; + if (alpha >= 1) { - c = 1; + alpha = 1; stat = 2; } @@ -80,17 +50,16 @@ public class movieController : MonoBehaviour float t = Time.time; if (t - destroy_timer > wait_sec) { - Debug.Log("fade"); - c -= fade_speed; - if (c < 0) + //Debug.Log("fade"); + alpha -= fade_speed; + if (alpha < 0 && CanDsetroy) { Destroy(this.gameObject); } } } - - GetComponent().color = new Color(1f, 1f, 1f, c); + GetComponent().color = new Color(1f, 1f, 1f, alpha); } void OnEnable() @@ -100,17 +69,22 @@ public class movieController : MonoBehaviour GetComponent().enabled = true; } //Debug.Log("Hi"); - //Debug.Log(id.ToString()); + stat = 1; - c = 0f; - Vector3 rot_axis = new Vector3(0, 0, 1); - Vector3 mid_pt = new Vector3(GetComponent().position.x, GetComponent().position.y, 0); - float rand_deg = Random.Range(0, 360); - GetComponent().Rotate(rot_axis, rand_deg); + alpha = 0f; + rotateImg(); } void OnDestroy() { //Debug.Log("Bye"); } + + public void rotateImg() + { + Vector3 rot_axis = new Vector3(0, 0, 1); + Vector3 mid_pt = new Vector3(GetComponent().position.x, GetComponent().position.y, 0); + float rand_deg = Random.Range(0, 360); + GetComponent().Rotate(rot_axis, rand_deg); + } } diff --git a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/tuio_event.cs b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/tuio_event.cs index 4dea273..326208d 100644 --- a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/tuio_event.cs +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/tuio_event.cs @@ -9,6 +9,8 @@ public class tuio_event : MonoBehaviour public Transform canvas; //public UltraCombos.GlobalMKHookInput tuio_input; Dictionary movies = new Dictionary(); + Dictionary pre_pos = new Dictionary(); + void Update() { var touches = TUIOManager.Instance.touches; @@ -24,10 +26,42 @@ public class tuio_event : MonoBehaviour movie.id = id; movies.Add(id, movie); movie.transform.position = touches[id].position; + pre_pos.Add(id, touches[id].position); } else //update { - movie = movies[id]; + if (Time.frameCount % 10 == 0) + { + float delta_pos = Vector2.Distance(pre_pos[id], touches[id].position); + if (delta_pos > 200) + { + Debug.Log("generate new one"); + GameObject g = Instantiate(img, canvas); + int clone_id = id + Random.Range(5000, 10000); + g.name = clone_id.ToString(); + movie = g.AddComponent(); + movie.id = clone_id; + movies.Add(clone_id, movie); + movie.transform.position = pre_pos[id]; + movie.transform.localRotation = movies[id].transform.localRotation; + movie.alpha = 0.9f; + + movies[id].stat = 0; + movies[id].transform.position = touches[id].position; + movies[id].CanDsetroy = false; + movies[id].rotateImg(); + + pre_pos[id] = touches[id].position; + } + else + { + //movies[id].transform.position = touches[id].position; + } + } + else + { + movie = movies[id]; + } } //update or after adding //Debug.Log("Update"); @@ -45,92 +79,16 @@ public class tuio_event : MonoBehaviour } foreach (var id in removes) { - if (movies[id].stat == 2) + if (movies[id].stat == 2 || movies[id].stat == 3) { movies[id].stat = 3; movies[id].destroy_timer = Time.time; + movies[id].CanDsetroy = true; movies.Remove(id); Debug.Log("Remove"); } //movies[id].destroy_timer = Time.time; } - //movies.Remove(id); - } -#else - // Start is called before the first frame update - public GameObject img; - public GameObject canvas; - public UltraCombos.GlobalMKHookInput tuio_input; - - List cur_ids = new List(); - List pre_ids = new List(); - - int pre_count; - int cur_count; - - void Start() - { - cur_count = 0; - } - - void Update() - { - reset_id(); - pre_count = cur_count; - pre_ids.Clear(); - cur_ids.ForEach(i => pre_ids.Add(i)); - - cur_count = tuio_input.touchCount; - cur_ids.Clear(); - - for (int i = 0; i < cur_count; i++) - { - cur_ids.Add(tuio_input.GetTouch(i).fingerId); - } - - if (cur_count > pre_count) // Add - { - //Debug.Log("Add"); - for (int i = 0; i < cur_count; i++) - { - int f_id = tuio_input.GetTouch(i).fingerId; - bool isOldTouch = pre_ids.Contains(f_id); - if (isOldTouch == false) - { - GameObject g = Instantiate(img, canvas.GetComponent()); - g.name = f_id.ToString(); - //g.GetComponent().id = i; - } - } - } - else if (cur_count < pre_count) // Remove - { - //Debug.Log("Remove"); - int exit_id; - for (int i = 0; i < pre_count; i++) - { - int _id = pre_ids[i]; - bool isExitTouch = !cur_ids.Contains(_id); - if (isExitTouch) - { - exit_id = _id; - //GameObject.Find(_id.ToString()).GetComponent().stat = 2; - Destroy(GameObject.Find(_id.ToString())); - } - } - } - reset_id(); - } - - void reset_id() - { - GameObject[] objs = GameObject.FindGameObjectsWithTag("onFoot"); - //Debug.Log(objs.Length); - for (int i = 0; i < objs.Length; i++) - { - objs[i].GetComponent().id = i - 1; - Debug.Log(objs[i].name + " / id = " + objs[i].GetComponent().id.ToString()); - } } #endif } diff --git a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Videos/New UltraCombos.DShowClip.asset b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Videos/New UltraCombos.DShowClip.asset index 8514bad..8ac65e0 100644 --- a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Videos/New UltraCombos.DShowClip.asset +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Videos/New UltraCombos.DShowClip.asset @@ -13,5 +13,5 @@ MonoBehaviour: m_Name: New UltraCombos.DShowClip m_EditorClassIdentifier: m_VideoLocation: 1 - m_VideoPath: ..\..\..\..\_Deploy_PC\08_DarkSea\Material\1928-01-D.avi + m_VideoPath: ..\..\..\..\_Deploy_PC\08_DarkSea\Material\Video_buttombracket.avi animationClip: {fileID: 0}