/**<summary> Get Items from server </summary>*/ public static async Task <Tuple <bool, List <ItemData> > > GetItems(string gameID) { UnityWebRequest www = UnityWebRequest.Get(App.config.apiURL + "/games/" + gameID + "/items"); www.downloadHandler = new DownloadHandlerBuffer(); www.SendWebRequest(); while (!www.isDone) { await Task.Delay(100); } if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); Debug.Log(www.downloadHandler.text); OnGetItemsResponse?.Invoke(false, null); return(new Tuple <bool, List <ItemData> >(false, null)); } else { Debug.Log(www.downloadHandler.text); List <ItemData> items = ParseItems(www.downloadHandler.text); OnGetItemsResponse?.Invoke(true, items); return(new Tuple <bool, List <ItemData> >(true, items)); } }
/**<summary> Get Items from server </summary>*/ public static async Task <Tuple <bool, List <ItemData> > > GetItemsDummy(string buildingID, string areaID) { await Task.Delay(10); List <ItemData> items = ParseItems(DummyServer.GetItems(buildingID, areaID)); OnGetItemsResponse?.Invoke(true, items); return(new Tuple <bool, List <ItemData> >(true, items)); }