Think everything is here functionality wise other than the automation of connect…
…ing as client / server, and the swipe up motion to start video
Showing
39 changed files
with
322 additions
and
16 deletions
Assets/Packages/GlobaTools.meta
0 → 100644
Assets/Packages/GlobaTools/Utility.meta
0 → 100644
No preview for this file type
No preview for this file type
| ... | @@ -5,33 +5,42 @@ public class AppManager : Singleton<AppManager> | ... | @@ -5,33 +5,42 @@ public class AppManager : Singleton<AppManager> |
| 5 | { | 5 | { |
| 6 | public AVProWindowsMediaMovie movieScript; | 6 | public AVProWindowsMediaMovie movieScript; |
| 7 | public Canvas serverCanvas; | 7 | public Canvas serverCanvas; |
| 8 | - public CanvasGroup inactiveCanvas; | 8 | + public CanvasGroup inUseCanvas; |
| 9 | + public CanvasGroup timeoutCanvas; | ||
| 10 | + public CanvasGroup videoCanvas; | ||
| 11 | + public float tweenTime; | ||
| 9 | public float appTimeout; | 12 | public float appTimeout; |
| 10 | 13 | ||
| 11 | - void Start () | 14 | + public void Initialize() |
| 12 | { | 15 | { |
| 13 | - inactiveCanvas.alpha = 1; | 16 | + inUseCanvas.alpha = 1; |
| 17 | + timeoutCanvas.alpha = 0; | ||
| 18 | + videoCanvas.alpha = 0; | ||
| 14 | StartCoroutine(AppTimeout()); | 19 | StartCoroutine(AppTimeout()); |
| 15 | - } | 20 | + } |
| 16 | 21 | ||
| 17 | private bool _videoPlaying = false; | 22 | private bool _videoPlaying = false; |
| 23 | + private float _timeout = 0; | ||
| 24 | + private bool _didTimeout = false; | ||
| 18 | 25 | ||
| 19 | private IEnumerator AppTimeout() | 26 | private IEnumerator AppTimeout() |
| 20 | { | 27 | { |
| 21 | while(true) | 28 | while(true) |
| 22 | { | 29 | { |
| 23 | - float timeout = 0; | 30 | + _timeout = 0; |
| 24 | - bool didTimeout = false; | 31 | + _didTimeout = false; |
| 25 | 32 | ||
| 26 | while (!_videoPlaying) | 33 | while (!_videoPlaying) |
| 27 | { | 34 | { |
| 28 | - timeout += Time.deltaTime; | 35 | + if (!_didTimeout) |
| 29 | - print(timeout); | 36 | + _timeout += Time.deltaTime; |
| 30 | 37 | ||
| 31 | - if (timeout >= appTimeout && ! didTimeout) | 38 | + if (_timeout >= appTimeout && !_didTimeout) |
| 32 | { | 39 | { |
| 33 | - didTimeout = true; | 40 | + _didTimeout = true; |
| 34 | - print("timeout"); | 41 | + |
| 42 | + TweenCanvasGroup(inUseCanvas, 0, tweenTime); | ||
| 43 | + TweenCanvasGroup(timeoutCanvas, 1, tweenTime); | ||
| 35 | } | 44 | } |
| 36 | 45 | ||
| 37 | yield return null; | 46 | yield return null; |
| ... | @@ -41,9 +50,21 @@ public class AppManager : Singleton<AppManager> | ... | @@ -41,9 +50,21 @@ public class AppManager : Singleton<AppManager> |
| 41 | } | 50 | } |
| 42 | } | 51 | } |
| 43 | 52 | ||
| 53 | + public void ResetTimer() | ||
| 54 | + { | ||
| 55 | + if (_videoPlaying) return; | ||
| 56 | + | ||
| 57 | + TweenCanvasGroup(inUseCanvas, 1, tweenTime); | ||
| 58 | + TweenCanvasGroup(timeoutCanvas, 0, tweenTime); | ||
| 59 | + | ||
| 60 | + _timeout = 0; | ||
| 61 | + _didTimeout = false; | ||
| 62 | + } | ||
| 63 | + | ||
| 44 | public void DestroyServerCanvas() | 64 | public void DestroyServerCanvas() |
| 45 | { | 65 | { |
| 46 | - Destroy(serverCanvas.gameObject); | 66 | + if (serverCanvas != null) |
| 67 | + Destroy(serverCanvas.gameObject); | ||
| 47 | } | 68 | } |
| 48 | 69 | ||
| 49 | private Coroutine movieCoroutine; | 70 | private Coroutine movieCoroutine; |
| ... | @@ -55,8 +76,6 @@ public class AppManager : Singleton<AppManager> | ... | @@ -55,8 +76,6 @@ public class AppManager : Singleton<AppManager> |
| 55 | movieScript._filename = filename; | 76 | movieScript._filename = filename; |
| 56 | movieScript.LoadMovie(true); | 77 | movieScript.LoadMovie(true); |
| 57 | 78 | ||
| 58 | - TweenCanvasGroup(inactiveCanvas, 0, 1); | ||
| 59 | - | ||
| 60 | if (movieCoroutine != null) | 79 | if (movieCoroutine != null) |
| 61 | StopCoroutine(movieCoroutine); | 80 | StopCoroutine(movieCoroutine); |
| 62 | 81 | ||
| ... | @@ -65,11 +84,26 @@ public class AppManager : Singleton<AppManager> | ... | @@ -65,11 +84,26 @@ public class AppManager : Singleton<AppManager> |
| 65 | 84 | ||
| 66 | private IEnumerator MoviePlaying() | 85 | private IEnumerator MoviePlaying() |
| 67 | { | 86 | { |
| 87 | + StopCoroutine("AppTimeout"); | ||
| 88 | + | ||
| 68 | _videoPlaying = true; | 89 | _videoPlaying = true; |
| 69 | - while (movieScript.MovieInstance.IsPlaying) | 90 | + TweenCanvasGroup(videoCanvas, 1, tweenTime); |
| 70 | - yield return null; | 91 | + //TweenCanvasGroup(inUseCanvas, 0, tweenTime); |
| 92 | + //TweenCanvasGroup(timeoutCanvas, 0, tweenTime); | ||
| 93 | + | ||
| 94 | + float holdTime = movieScript.MovieInstance.DurationSeconds - tweenTime; | ||
| 95 | + | ||
| 96 | + yield return new WaitForSeconds(holdTime); | ||
| 97 | + | ||
| 98 | + TweenCanvasGroup(videoCanvas, 0, tweenTime); | ||
| 99 | + TweenCanvasGroup(inUseCanvas, 1, tweenTime); | ||
| 100 | + | ||
| 101 | + yield return new WaitForSeconds(tweenTime); | ||
| 71 | 102 | ||
| 72 | _videoPlaying = false; | 103 | _videoPlaying = false; |
| 104 | + movieScript.UnloadMovie(); | ||
| 105 | + | ||
| 106 | + StartCoroutine("AppTimeout"); | ||
| 73 | } | 107 | } |
| 74 | 108 | ||
| 75 | public void TweenCanvasGroup(CanvasGroup group, float alpha, float time) | 109 | public void TweenCanvasGroup(CanvasGroup group, float alpha, float time) |
| ... | @@ -79,6 +113,8 @@ public class AppManager : Singleton<AppManager> | ... | @@ -79,6 +113,8 @@ public class AppManager : Singleton<AppManager> |
| 79 | 113 | ||
| 80 | public void TweenCanvasGroup(CanvasGroup group, float alpha, float time, System.Action onComplete) | 114 | public void TweenCanvasGroup(CanvasGroup group, float alpha, float time, System.Action onComplete) |
| 81 | { | 115 | { |
| 116 | + iTween.Stop(group.gameObject); | ||
| 117 | + | ||
| 82 | Hashtable hash = new Hashtable() | 118 | Hashtable hash = new Hashtable() |
| 83 | { | 119 | { |
| 84 | { "from", group.alpha }, | 120 | { "from", group.alpha }, | ... | ... |
| ... | @@ -18,6 +18,8 @@ public class NetworkUser : NetworkBehaviour | ... | @@ -18,6 +18,8 @@ public class NetworkUser : NetworkBehaviour |
| 18 | } | 18 | } |
| 19 | else | 19 | else |
| 20 | { | 20 | { |
| 21 | + AppManager.Instance.Initialize(); | ||
| 22 | + | ||
| 21 | string path = Application.streamingAssetsPath + "/videoSettings.json"; | 23 | string path = Application.streamingAssetsPath + "/videoSettings.json"; |
| 22 | if (!File.Exists(path)) | 24 | if (!File.Exists(path)) |
| 23 | { | 25 | { |
| ... | @@ -66,6 +68,9 @@ public class NetworkUser : NetworkBehaviour | ... | @@ -66,6 +68,9 @@ public class NetworkUser : NetworkBehaviour |
| 66 | 68 | ||
| 67 | void Update () | 69 | void Update () |
| 68 | { | 70 | { |
| 71 | + if (Input.touchCount > 0) | ||
| 72 | + CmdResetTimer(); | ||
| 73 | + | ||
| 69 | if (Input.GetKeyDown(KeyCode.Alpha1)) | 74 | if (Input.GetKeyDown(KeyCode.Alpha1)) |
| 70 | { | 75 | { |
| 71 | var thisDict = _files[0]; | 76 | var thisDict = _files[0]; |
| ... | @@ -80,6 +85,12 @@ public class NetworkUser : NetworkBehaviour | ... | @@ -80,6 +85,12 @@ public class NetworkUser : NetworkBehaviour |
| 80 | } | 85 | } |
| 81 | 86 | ||
| 82 | [Command] | 87 | [Command] |
| 88 | + private void CmdResetTimer() | ||
| 89 | + { | ||
| 90 | + AppManager.Instance.ResetTimer(); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + [Command] | ||
| 83 | public void CmdLoadVideo(string file) | 94 | public void CmdLoadVideo(string file) |
| 84 | { | 95 | { |
| 85 | AppManager.Instance.LoadMovie(file); | 96 | AppManager.Instance.LoadMovie(file); | ... | ... |
-
Please register or sign in to post a comment