Пример #1
0
    /// <summary>
    /// Raises the show button click event.
    /// </summary>
    private void OnShowButtonClick()
    {
        showButton.enabled = false;

        if (demoBatchObjects.Count > 0)
        {
            string    data = null;
            MoBackRow t    = new MoBackRow(DemoBatchTableName);
            for (int i = 0; i < demoBatchObjects.Count; i++)
            {
                string val = demoBatchObjects[i].GetString("Value").ToString();
                if (!string.IsNullOrEmpty(data))
                {
                    data += ", " + val;
                }
                else
                {
                    data += val;
                }
            }
            Display(data);
        }
        else
        {
            Display("No data to display.");
        }

        showButton.enabled = true;
    }
Пример #2
0
    /// <summary>
    /// Start this instance.
    /// </summary>
    /// <returns>A Unity coroutine IEnumerator.</returns>
    public IEnumerator Start()
    {
        nArray = new MoBackArray();
        MoBackRow newRow1 = new MoBackRow("TestMoback");

        // Create a new row for a new user with a score of 0 to start.
        newRow1.SetValue("Name", "MoBackUser");
        newRow1.SetValue("Score", 0);

        // Send the data to the table and wait for a response.
        MoBackRequest response = newRow1.Save();

        yield return(response.Run());

        // If the response to the request is an error, output the error details.
        if (response.State == MoBackRequest.RequestState.ERROR)
        {
            Debug.LogError(response.errorDetails);
        }

        if (menuHandler == null)
        {
            menuHandler = FindObjectOfType <DemoMenuHandler>();
        }
    }
Пример #3
0
    /// <summary>
    /// Raises the add item button click event.
    /// </summary>
    private void OnAddItemButtonClick()
    {
        MoBackRow t = new MoBackRow(ChildRelationTableName);

        t.SetValue(ItemTypeColumn, childInput.text);
        items.Add(t);
        Display(childInput.text + " has been added to child array");
        childInput.text = string.Empty;
        if (items.Count >= 1)
        {
            createRelationButton.gameObject.SetActive(true);
        }
    }
Пример #4
0
    IEnumerator UpdateRow()
    {
        MoBackRow newRow = new MoBackRow("PlayersData");

        newRow.SetValue("IDcode", currentID);
        newRow.SetValue("aValue", GameObject.Find("Main").GetComponent <scene2script>().userData.a);
        newRow.SetValue("bValue", GameObject.Find("Main").GetComponent <scene2script>().userData.b);
        newRow.SetValue("xValue", GameObject.Find("Main").GetComponent <scene2script>().userData.x);
        newRow.SetValue("yValue", GameObject.Find("Main").GetComponent <scene2script>().userData.y);
        newRow.SetValue("maxScene", maxScene);
        MoBackRequest response = newRow.Save();

        yield return(response.Run());
    }
Пример #5
0
    /// <summary>
    /// Raises the add button click event.
    /// </summary>
    private void OnAddButtonClick()
    {
        addButton.enabled = false;

        if (!string.IsNullOrEmpty(valueInput.text))
        {
            MoBackRow row = new MoBackRow(DemoBatchTableName);
            row.SetValue("Value", valueInput.text.ToString());
            demoBatchObjects.Add(row);
            Display(valueInput.text + " Added successfully ");
            valueInput.text = string.Empty;
        }
        else
        {
            Display("Field Cannot be Blank");
        }

        addButton.enabled = true;
    }
Пример #6
0
    /// <summary>
    /// Updates an existing row with a new score and notifies the user when successful.
    /// </summary>
    /// <returns>A Unity coroutine IEnumerator.</returns>
    /// <param name="score">Score to submit.</param>
    public IEnumerator SubmitScore(int score)
    {
        // Create a new table called "TestMoBack" if it hasn't already been created; otherwise, specify which table you want to work with.
        table = new MoBackTableInterface("TestMoback");

        // Send a request for data to the server with a specific set of parameters.
        MoBackRequest <List <MoBackRow> > tableContentsFetch = table.GetRows(new MoBackRequestParameters().EqualTo("Name", "MoBackUser"));

        yield return(tableContentsFetch.Run());

        // Once the request has been completed, manipulate the fetched data.
        if (tableContentsFetch.State == MoBackRequest.RequestState.COMPLETED)
        {
            List <MoBackRow> rows = tableContentsFetch.ResponseValue;

            // Update the last item in the table to a new score and send to the server.
            MoBackRow newRow = rows[rows.Count - 1];
            newRow.SetValue("Score", score);
            MoBackRequest response = newRow.Save();

            // Wait for a response before displaying that the request was successful.
            yield return(response.Run());

            if (response.State == MoBackRequest.RequestState.COMPLETED)
            {
                menuHandler.Display("Score submitted successfully.");
            }
            else
            {
                menuHandler.Display("Request was not successful. Please double check your app ID and/or environment key.");

                // Display an error should one occur.
                Debug.Log(response.errorDetails);
            }
        }
        else
        {
            // Display an error should one occur.
            Debug.Log(tableContentsFetch.errorDetails);
        }
    }