Exemple #1
0
 private void OnGameStarted(ScriptEndpoint response)
 {
     if (response.IsSuccess)
     {
         GameInput.Instance.Enable();
     }
     else
     {
         Debug.Log("Error: " + response.syncanoError);
     }
 }
    private void OnPlayersDownloaded(ScriptEndpoint response)
    {
        if (!isRunning)
        {
            return;
        }

        if (response.IsSuccess)
        {
            Debug.Log(response.stdout);
        }
        //controller.UpdateCells(response.Objects);
    }
Exemple #3
0
    private void scriptEndpointCallback(ScriptEndpoint response)
    {
        if (response.IsSuccess)
        {
            IntegrationTest.Assert(response.stdout.Equals(ENDPOINT_EXPECTED_VALUE));

            IntegrationTest.Pass();
        }

        else
        {
            IntegrationTest.Fail();
        }
    }
    private void OnFoodsDownloaded(ScriptEndpoint response)
    {
        if (!isRunning)
        {
            return;
        }

        if (response.IsSuccess)
        {
            List <FoodData> food = DeserializeJson <List <FoodData> >(response.stdout);
            controller.UpdateFood(food);
        }

        GetFood();
    }
Exemple #5
0
 private void OnRoomJoined(ScriptEndpoint response)
 {
     if (response.IsSuccess)
     {
         player = Communication.DeserializeJson <PlayerData>(response.stdout);
         controller.Join(player);
         StartGame(player.id, Constants.ROOM_ID);
         menuPanel.Hide();
     }
     else
     {
         menuPanel.SetEditMode();
         Debug.Log("Error: " + response.syncanoError);
     }
 }
Exemple #6
0
    private void ScriptCallback(ScriptEndpoint endpointCallback)
    {
        if (endpointCallback.IsSuccess)
        {
            List <Record> topTenRecords = JsonConvert.DeserializeObject <List <Record> >(endpointCallback.stdout, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            DisplayTopScore(topTenRecords);
        }

        else
        {
            if (endpointCallback.IsSyncanoError)
            {
                Debug.Log(endpointCallback.syncanoError);
            }

            else
            {
                Debug.Log(endpointCallback.webError);
            }
        }
    }
Exemple #7
0
        /// <summary>
        /// Method used for calling script endpoints.
        /// </summary>
        /// <returns>The script end point.</returns>
        /// <param name="endpointId">Endpoint identifier.</param>
        /// <param name="scriptName">Script name.</param>
        /// <param name="callback">Callback.</param>
        private IEnumerator RequestScriptEndPoint(string endpointId, string scriptName, System.Action <ScriptEndpoint> callback, Dictionary <string, string> payload = null)
        {
            StringBuilder sb = new StringBuilder(string.Format(Constants.SCRIPT_ENDPOINT_URL, SyncanoClient.Instance.InstanceName, endpointId, scriptName));

            WWWForm postData = null;

            if (payload != null && payload.Count > 0)
            {
                postData = new WWWForm();

                foreach (KeyValuePair <string, string> pair in payload)
                {
                    postData.AddField(pair.Key, pair.Value);
                }
            }

            UnityWebRequest www = UnityWebRequest.Post(sb.ToString(), postData);

            yield return(www.Send());

            ScriptEndpoint response = JsonConvert.DeserializeObject <ScriptEndpoint>(www.downloadHandler.text, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });

            ReadWebRequest(response, www);

            if (response.IsSuccess)
            {
                if (string.IsNullOrEmpty(response.stderr) == false)
                {
                    response.IsSuccess = false;
                }
            }

            callback(response);
        }
 private void OnTryEatFoodFinished(ScriptEndpoint response)
 {
     foodToEat.Remove(currentlyEatenFood);
     isEatingFood = false;
     PickFoodAndEat();
 }
 private void OnTryEatCellFinished(ScriptEndpoint response)
 {
     cellsToEat.Remove(currentlyEatenCell);
     isEatingCell = false;
     PickCellAndEat();
 }