diff --git a/Assets/InteractionEngine/CommunicationEvents.cs b/Assets/InteractionEngine/CommunicationEvents.cs index ddd7481e659c5d6a63279564d0f7154a8447baec..57aed277fed5c6d5ec898b85a771bee2ad044a52 100644 --- a/Assets/InteractionEngine/CommunicationEvents.cs +++ b/Assets/InteractionEngine/CommunicationEvents.cs @@ -74,4 +74,6 @@ public class SignalEvent : UnityEvent { //Global List of Facts public static List<Fact> Facts = new List<Fact>(); + + public static bool ServerRunning = false; } diff --git a/Assets/InteractionEngine/Fact.cs b/Assets/InteractionEngine/Fact.cs index 596ae179100bd999d4288ed568b671313556a894..0129cf82f27ec83e19745f91d15ad388e32e343e 100644 --- a/Assets/InteractionEngine/Fact.cs +++ b/Assets/InteractionEngine/Fact.cs @@ -27,18 +27,24 @@ public class AddFactResponse public static AddFactResponse sendAdd(string path, string body) { + if (!CommunicationEvents.ServerRunning) + { + Debug.LogWarning("Server not running"); + return new AddFactResponse(); + } Debug.Log(body); //Put constructor parses stringbody to byteArray internally (goofy workaround) UnityWebRequest www = UnityWebRequest.Put(path, body); www.method = UnityWebRequest.kHttpVerbPOST; www.SetRequestHeader("Content-Type", "application/json"); - + www.timeout = 1; + //TODO: implement real asynchronous communication ... AsyncOperation op = www.Send(); while (!op.isDone) { } if (www.isNetworkError || www.isHttpError) { - Debug.Log(www.error); - return null; + Debug.LogWarning(www.error); + return new AddFactResponse(); } else { diff --git a/Assets/InventoryStuff/DisplayScrolls.cs b/Assets/InventoryStuff/DisplayScrolls.cs index 29475db213abc31ed41de8d22f55c061037764cf..366a6210b57aba3782661bb41a6591e186ee75bf 100644 --- a/Assets/InventoryStuff/DisplayScrolls.cs +++ b/Assets/InventoryStuff/DisplayScrolls.cs @@ -60,10 +60,11 @@ IEnumerator getScrollsfromServer() { yield return request.Send(); if (request.isNetworkError || request.isHttpError) { - Debug.LogError(request.error); + Debug.LogWarning(request.error); } else { + CommunicationEvents.ServerRunning = true; string jsonString = request.downloadHandler.text; buildScrollSelection(jsonString); } diff --git a/Assets/StartServer.cs b/Assets/StartServer.cs index 2075ea48a1dc3f4e289df64302f3c1dbd80076f6..2e7081d9d9705b82c6dd729d1bda15f0b270b6bd 100644 --- a/Assets/StartServer.cs +++ b/Assets/StartServer.cs @@ -11,7 +11,7 @@ public class StartServer : MonoBehaviour [SerializeField] TMPro.TextMeshProUGUI WaitingText; - bool ServerRunning = false; + // Start is called before the first frame update void Start() { @@ -20,7 +20,7 @@ void Start() void PrepareGame() { WaitingText.text = "Press any key to start the game"; - ServerRunning= true; + CommunicationEvents.ServerRunning= true; UnityEngine.Debug.Log("server fin"); } @@ -181,7 +181,7 @@ IEnumerator ServerRoutine() // Update is called once per frame void Update() { - if(ServerRunning && Input.anyKey) + if(CommunicationEvents.ServerRunning && Input.anyKey) { SceneManager.LoadScene(1); } diff --git a/Assets/TreeWorld_02.unity b/Assets/TreeWorld_02.unity index beb5782a220fef19777af0d38fbe0ec4069d1deb..52bd65ae3adc0f495423e7ebd1b4a17286578edc 100644 --- a/Assets/TreeWorld_02.unity +++ b/Assets/TreeWorld_02.unity @@ -28366,7 +28366,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 38cd422d38f88564e81d012b615cc77a, type: 3} m_Name: m_EditorClassIdentifier: - ToolMode: 4 + id: 0 + UiName: Sprite: {fileID: 21300000, guid: d456617ba2282854d9570dcebcc2b279, type: 3} FactManager: {fileID: 0} ignoreLayerMask: @@ -40563,6 +40564,11 @@ PrefabInstance: propertyPath: ignoreLayerMask.m_Bits value: 31232 objectReference: {fileID: 0} + - target: {fileID: 729203331, guid: 2ba8d552442ba664e8e567adee683a11, type: 3} + propertyPath: Sprite + value: + objectReference: {fileID: 21300000, guid: 644edf8b3fa05da418500a0e9dd10820, + type: 3} - target: {fileID: 1085307962, guid: 2ba8d552442ba664e8e567adee683a11, type: 3} propertyPath: GadgetUI value: