Skip to content
Snippets Groups Projects
Commit 0fff99bd authored by Richard Marcus's avatar Richard Marcus
Browse files

fact creation now works without server

parent 70ccace6
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......@@ -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
{
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment