Dave Boyle

Needs some design updates here and there but this is pretty much done at this point

...@@ -5,34 +5,37 @@ using UnityEngine.Networking; ...@@ -5,34 +5,37 @@ using UnityEngine.Networking;
5 5
6 public class AppSettings : Singleton<AppSettings> 6 public class AppSettings : Singleton<AppSettings>
7 { 7 {
8 - public bool server;
9 public CanvasGroup splash; 8 public CanvasGroup splash;
10 [Header("Settings")] 9 [Header("Settings")]
11 public CanvasGroup settings; 10 public CanvasGroup settings;
12 public InputField serverIp; 11 public InputField serverIp;
13 - public Toggle isServer; 12 + //public Toggle isServer;
14 13
15 void Awake () 14 void Awake ()
16 { 15 {
17 splash.alpha = 1; 16 splash.alpha = 1;
18 } 17 }
19 18
19 + public bool isServer { get; private set; }
20 +
20 void Start() 21 void Start()
21 { 22 {
22 settings.blocksRaycasts = false; 23 settings.blocksRaycasts = false;
24 + isServer = !Application.isMobilePlatform;
25 + //isServer = !Application.isEditor;
23 26
24 - //if (Application.isMobilePlatform) 27 + if (!isServer)
25 - //{ 28 + {
26 - // if (!PlayerPrefs.HasKey("serverIp")) 29 + if (!PlayerPrefs.HasKey("serverIp"))
27 - // ShowSettings(); 30 + ShowSettings();
28 - // else 31 + else
29 - // { 32 + {
30 - // string ip = PlayerPrefs.GetString("serverIp"); 33 + string ip = PlayerPrefs.GetString("serverIp");
31 - // Finalize(false, ip); 34 + Finalize(false, ip);
32 - // } 35 + }
33 - //} 36 + }
34 - //else 37 + else
35 - // Finalize(true, string.Empty); 38 + Finalize(true, string.Empty);
36 39
37 //if (server) 40 //if (server)
38 // Finalize(true, string.Empty); 41 // Finalize(true, string.Empty);
...@@ -48,27 +51,27 @@ public class AppSettings : Singleton<AppSettings> ...@@ -48,27 +51,27 @@ public class AppSettings : Singleton<AppSettings>
48 51
49 //} 52 //}
50 53
51 - if (!PlayerPrefs.HasKey("isServer")) 54 + //if (!PlayerPrefs.HasKey("isServer"))
52 - { 55 + //{
53 - ShowSettings(); 56 + // ShowSettings();
54 - } 57 + //}
55 - else 58 + //else
56 - { 59 + //{
57 - bool server = PlayerPrefs.GetString("isServer").ToLower() == "true" ? true : false; 60 + // bool server = PlayerPrefs.GetString("isServer").ToLower() == "true" ? true : false;
58 - string ip = string.Empty; 61 + // string ip = string.Empty;
59 62
60 - if (!server && !PlayerPrefs.HasKey("serverIp")) 63 + // if (!server && !PlayerPrefs.HasKey("serverIp"))
61 - { 64 + // {
62 - ShowSettings(); 65 + // ShowSettings();
63 - } 66 + // }
64 - else if (!server) 67 + // else if (!server)
65 - { 68 + // {
66 - ip = PlayerPrefs.GetString("serverIp"); 69 + // ip = PlayerPrefs.GetString("serverIp");
67 - Finalize(server, ip); 70 + // Finalize(server, ip);
68 - } 71 + // }
69 - else 72 + // else
70 - Finalize(server, ip); 73 + // Finalize(server, ip);
71 - } 74 + //}
72 75
73 Invoke("HideSplash", 3); 76 Invoke("HideSplash", 3);
74 } 77 }
...@@ -81,10 +84,10 @@ public class AppSettings : Singleton<AppSettings> ...@@ -81,10 +84,10 @@ public class AppSettings : Singleton<AppSettings>
81 84
82 public void SaveSettings() 85 public void SaveSettings()
83 { 86 {
84 - bool server = isServer.isOn; 87 + //bool server = isServer.isOn;
85 string ip = serverIp.text; 88 string ip = serverIp.text;
86 89
87 - Finalize(server, ip); 90 + Finalize(isServer, ip);
88 } 91 }
89 92
90 private void Finalize(bool server, string ip) 93 private void Finalize(bool server, string ip)
...@@ -101,7 +104,7 @@ public class AppSettings : Singleton<AppSettings> ...@@ -101,7 +104,7 @@ public class AppSettings : Singleton<AppSettings>
101 } 104 }
102 105
103 PlayerPrefs.SetString("serverIp", ip); 106 PlayerPrefs.SetString("serverIp", ip);
104 - PlayerPrefs.SetString("isServer", server.ToString()); 107 + //PlayerPrefs.SetString("isServer", server.ToString());
105 108
106 settings.blocksRaycasts = false; 109 settings.blocksRaycasts = false;
107 AppManager.Instance.TweenCanvasGroup(settings, 0, 1); 110 AppManager.Instance.TweenCanvasGroup(settings, 0, 1);
...@@ -115,16 +118,16 @@ public class AppSettings : Singleton<AppSettings> ...@@ -115,16 +118,16 @@ public class AppSettings : Singleton<AppSettings>
115 { 118 {
116 if (_inSettings) return; 119 if (_inSettings) return;
117 120
118 - bool server = false; 121 + //bool server = false;
119 string ip = string.Empty; 122 string ip = string.Empty;
120 123
121 - if (PlayerPrefs.HasKey("isServer")) 124 + //if (PlayerPrefs.HasKey("isServer"))
122 - server = PlayerPrefs.GetString("isServer").ToLower() == "true" ? true : false; 125 + //server = PlayerPrefs.GetString("isServer").ToLower() == "true" ? true : false;
123 if (PlayerPrefs.HasKey("serverIp")) 126 if (PlayerPrefs.HasKey("serverIp"))
124 ip = PlayerPrefs.GetString("serverIp"); 127 ip = PlayerPrefs.GetString("serverIp");
125 128
126 serverIp.text = ip; 129 serverIp.text = ip;
127 - isServer.isOn = server; 130 + //isServer.isOn = server;
128 131
129 _inSettings = true; 132 _inSettings = true;
130 settings.blocksRaycasts = true; 133 settings.blocksRaycasts = true;
......
...@@ -48,6 +48,7 @@ public class MoviePlayNode : MonoBehaviour ...@@ -48,6 +48,7 @@ public class MoviePlayNode : MonoBehaviour
48 48
49 public void Drag(UnityEngine.EventSystems.BaseEventData test) 49 public void Drag(UnityEngine.EventSystems.BaseEventData test)
50 { 50 {
51 + print ("dragging");
51 _isDragging = true; 52 _isDragging = true;
52 _canReset = false; 53 _canReset = false;
53 54
...@@ -74,6 +75,8 @@ public class MoviePlayNode : MonoBehaviour ...@@ -74,6 +75,8 @@ public class MoviePlayNode : MonoBehaviour
74 { 75 {
75 _arrow.CrossFadeColor(_arrowStart, 0.4f, true, false); 76 _arrow.CrossFadeColor(_arrowStart, 0.4f, true, false);
76 _highlight.CrossFadeAlpha(0, 0.4f, true); 77 _highlight.CrossFadeAlpha(0, 0.4f, true);
78 +
79 + _canPlay = true;
77 } 80 }
78 81
79 private bool _canReset = false; 82 private bool _canReset = false;
......
1 +using UnityEngine;
2 +using System.Collections;
3 +using UnityEngine.Networking;
4 +
5 +public class NetworkManager : UnityEngine.Networking.NetworkManager
6 +{
7 + public override void OnClientDisconnect(NetworkConnection conn)
8 + {
9 + base.OnClientDisconnect(conn);
10 +
11 + StopCoroutine("Reconnect");
12 + StartCoroutine(Reconnect());
13 + }
14 +
15 + private IEnumerator Reconnect()
16 + {
17 + while (client == null)
18 + {
19 + Debug.Log("Lost connection to server. Trying to reconnect...");
20 + StartClient();
21 + yield return new WaitForSeconds(3);
22 + }
23 + }
24 +}
1 +fileFormatVersion: 2
2 +guid: 813f3b235c0e8f54d81e60d419523fbe
3 +timeCreated: 1467903377
4 +licenseType: Pro
5 +MonoImporter:
6 + serializedVersion: 2
7 + defaultReferences: []
8 + executionOrder: 0
9 + icon: {instanceID: 0}
10 + userData:
11 + assetBundleName:
12 + assetBundleVariant:
...@@ -7,9 +7,17 @@ using UnityEngine.Networking; ...@@ -7,9 +7,17 @@ using UnityEngine.Networking;
7 public class NetworkUser : NetworkBehaviour 7 public class NetworkUser : NetworkBehaviour
8 { 8 {
9 public Transform buttonParent; 9 public Transform buttonParent;
10 - public GameObject canvas; 10 + public GameObject clientCanvas;
11 + public CanvasGroup timeoutCanvas;
11 public List<MoviePlayNode> movieButtonNodes; 12 public List<MoviePlayNode> movieButtonNodes;
12 13
14 + void Awake()
15 + {
16 + timeoutCanvas.alpha = 0;
17 + timeoutCanvas.interactable = false;
18 + timeoutCanvas.blocksRaycasts = false;
19 + }
20 +
13 void Start() 21 void Start()
14 { 22 {
15 if (!isServer) 23 if (!isServer)
...@@ -18,7 +26,7 @@ public class NetworkUser : NetworkBehaviour ...@@ -18,7 +26,7 @@ public class NetworkUser : NetworkBehaviour
18 } 26 }
19 else 27 else
20 { 28 {
21 - Destroy(canvas); 29 + Destroy(clientCanvas);
22 string path = Application.streamingAssetsPath + "/videoSettings.json"; 30 string path = Application.streamingAssetsPath + "/videoSettings.json";
23 if (!File.Exists(path)) 31 if (!File.Exists(path))
24 { 32 {
...@@ -55,11 +63,7 @@ public class NetworkUser : NetworkBehaviour ...@@ -55,11 +63,7 @@ public class NetworkUser : NetworkBehaviour
55 continue; 63 continue;
56 } 64 }
57 65
58 - //MoviePlayNode mpn = Instantiate<MoviePlayNode>(thisNode);
59 thisNode.Initialize(dict["filename"], this); 66 thisNode.Initialize(dict["filename"], this);
60 - //mpn.transform.SetParent(buttonParent);
61 - //mpn.transform.localPosition = Vector3.zero;
62 - //mpn.transform.localScale = Vector3.one;
63 } 67 }
64 } 68 }
65 69
...@@ -79,11 +83,37 @@ public class NetworkUser : NetworkBehaviour ...@@ -79,11 +83,37 @@ public class NetworkUser : NetworkBehaviour
79 _files.Add(thisDict); 83 _files.Add(thisDict);
80 } 84 }
81 } 85 }
86 +
87 + private bool _isTimedOut = true;
88 +
89 + [ClientRpc]
90 + public void RpcTimeout()
91 + {
92 + _isTimedOut = true;
93 +
94 + AppManager.Instance.TweenCanvasGroup(timeoutCanvas, 1, 0.5f);
95 + timeoutCanvas.interactable = true;
96 + timeoutCanvas.blocksRaycasts = true;
97 + }
98 +
99 + private void HideTimeout()
100 + {
101 + if (!_isTimedOut) return;
102 +
103 + AppManager.Instance.TweenCanvasGroup(timeoutCanvas, 0, 0.5f);
104 + timeoutCanvas.interactable = false;
105 + timeoutCanvas.blocksRaycasts = false;
106 +
107 + _isTimedOut = false;
108 + }
82 109
83 void Update () 110 void Update ()
84 { 111 {
85 if (Input.touchCount > 0) 112 if (Input.touchCount > 0)
113 + {
86 CmdResetTimer(); 114 CmdResetTimer();
115 + HideTimeout();
116 + }
87 117
88 if (Input.GetKeyDown(KeyCode.Alpha1)) 118 if (Input.GetKeyDown(KeyCode.Alpha1))
89 { 119 {
......
1 +using UnityEngine;
2 +using System.Collections;
3 +
4 +public class Reconnection : MonoBehaviour
5 +{
6 +
7 + void Start () {
8 +
9 + }
10 +
11 + void Update () {
12 +
13 + }
14 +}
1 +fileFormatVersion: 2
2 +guid: 9bd24722c46f081429864245b5dcc901
3 +timeCreated: 1467903468
4 +licenseType: Pro
5 +MonoImporter:
6 + serializedVersion: 2
7 + defaultReferences: []
8 + executionOrder: 0
9 + icon: {instanceID: 0}
10 + userData:
11 + assetBundleName:
12 + assetBundleVariant:
...@@ -43,6 +43,9 @@ public class ServerCanvasManager : Singleton<ServerCanvasManager> ...@@ -43,6 +43,9 @@ public class ServerCanvasManager : Singleton<ServerCanvasManager>
43 AppManager.Instance.TweenCanvasGroup(inUseCanvas, 0, tweenTime); 43 AppManager.Instance.TweenCanvasGroup(inUseCanvas, 0, tweenTime);
44 AppManager.Instance.TweenCanvasGroup(timeoutCanvas, 1, tweenTime); 44 AppManager.Instance.TweenCanvasGroup(timeoutCanvas, 1, tweenTime);
45 45
46 + foreach (NetworkUser user in FindObjectsOfType<NetworkUser>())
47 + user.RpcTimeout();
48 +
46 movieScript.UnloadMovie(); 49 movieScript.UnloadMovie();
47 timeoutMovie.UnloadMovie(); 50 timeoutMovie.UnloadMovie();
48 timeoutMovie.LoadMovie(true); 51 timeoutMovie.LoadMovie(true);
......