示例#1
0
    // Update persisted objects fields on the cloud.
    public static void UpdateGandalf(bool runtime)
    {
        Debug.Log("<color=yellow>Updating cloud data: player called Mithrandir will be level 100.</color>");

        // Look in the 'PlayerInfo' table, for an object of name 'Mithrandir', and set its level to 100.
        CloudConnectorCore.UpdateObjects(tableName, "name", "Mithrandir", "level", "101", runtime);
    }
示例#2
0
    public IEnumerator AddWine(int index)
    {
        // Atualizar spreadsheet:
        WineInfo info = wineInfos.Find(i => i.id == index);

        info.quantity++;
        CloudConnectorCore.UpdateObjects(TABLE_NAME, ID_FIELD_NAME, info.id.ToString(), QUANTITY_FIELD_NAME, info.quantity.ToString());

        // Atualiza server no webhost por php:
        wineQuantitiesFromWebhost[index]++;
        WWW www = new WWW(WEBHOST_URL + "addWine.php?id=" + index.ToString());

        while (!www.isDone)
        {
            yield return(0);
        }

        // Atualizar server no heroku por node.js: @Heitor
        WWW wwnode = new WWW(HEROKU_URL + "addWine?id=" + index.ToString());

        while (!wwnode.isDone)
        {
            yield return(0);
        }
    }
示例#3
0
    public static void namechange(string n)
    {
        Debug.Log("<color=yellow>Updating Player name.</color>");
        bool runtime = true;

        player      = new PlayerInfo();
        playername  = n;
        player.name = playername;
        player.q11  = 0;
        player.q12  = 0;
        player.q13  = 0;
        player.q21  = 0;
        player.q22  = 0;
        player.q23  = 0;
        player.q31  = 0;
        player.q32  = 0;
        player.q33  = 0;
        player.q41  = 0;
        player.q42  = 0;
        player.q43  = 0;

        string jsonPlayer = JsonUtility.ToJson(player);

        Debug.Log("<color=yellow>Sending following player to the cloud: \n</color>" + jsonPlayer);
        //string jsonPlayer = JsonUtility.ToJson(player);


        // Save the object on the cloud, in a table called like the object type.
        CloudConnectorCore.CreateObject(jsonPlayer, tableName, runtime);
    }
示例#4
0
    //here is an example on how to update with a seperate method for every question
    public static void UpdatePlayerQuestion1(bool runtime)
    {
        Debug.Log("<color=yellow>Updating cloud data: player named " + playername + " finished question 1 in " + completetime + " seconds.</color>");

        // Look in the 'PlayerInfo' table, for an object of name 'Cameron Root, and set its level to 100.
        CloudConnectorCore.UpdateObjects(tableName, "name", playername, "q1", completetime.ToString(), runtime);
    }
示例#5
0
    /// <summary>
    /// Compares the answer <see cref="Matrix2x2"/> provided by the Player with the <see cref="solutionMatrix"/>.
    /// <para>
    ///     The <see cref="ResultText"/> will display whether or not the Player got the right answer.
    ///     This information will be recorded in the Google Sheets for Unity system (GSFU) via <see cref="CloudConnectorCore"/>.
    /// </para>
    /// <para>
    ///     Additional information can be sent to the <see cref="MatrixLogger"/> as well.
    /// </para>
    /// </summary>
    /// <param name="answerMatrix">The final answer the User submitted.</param>
    public void CheckAnswer(Matrix2x2 answerMatrix)
    {
        bool isCorrect = Matrix2x2.IsEqual(solutionMatrix, answerMatrix);

        if (isCorrect)
        {
            ResultText.text = "Correct!";
            MatrixLogger.Add("Correct! The answer was:\n" + solutionMatrix.ToString());
            SubmissionResultPanel.SetActive(true);

            answertime = Time.timeSinceLevelLoad;
            CloudConnectorCore.UpdateObjects("playerInfo", "name", Playername, q, answertime.ToString(), true);
            StopCoroutine("RemoveResultPanelAfterSomeSeconds");
            StartCoroutine("RemoveResultPanelAfterSomeSeconds");
        }
        else
        {
            MatrixLogger.Add("Incorrect! Your answer was:\n" + answerMatrix.ToString());

            ResultText.text = "Incorrect...";
            SubmissionResultPanel.SetActive(true);

            StopCoroutine("RemoveResultPanelAfterSomeSeconds");
            StartCoroutine("RemoveResultPanelAfterSomeSeconds");
        }
    }
示例#6
0
    // example update command. can either have one of these and have a way to change it for every question. Or have several.
    //This is a general use to change names. It is as simpls as
    //  (the table being changed, the first column, game object in first column to be edited, the column in which you want to edit, the change you want to make, runtime)
    public static void UpdatePlayerName(bool runtime)
    {
        Debug.Log("<color=yellow>Updating cloud data: player names " + playername + ".</color>");

        // Look in the 'PlayerInfo' table, for an object of name 'Mithrandir', and set its completion time to a given amount.
        CloudConnectorCore.UpdateObjects(tableName, "name", playername, "name", "Cameron Root", runtime);
    }
示例#7
0
    IEnumerator ExecuteRequest(Dictionary <string, string> postData)
    {
        www.Send();

        float elapsedTime = 0.0f;

        while (!www.isDone)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime >= timeOutLimit)
            {
                CloudConnectorCore.ProcessResponse("TIME_OUT", elapsedTime);
                break;
            }

            yield return(null);
        }

        if (www.isNetworkError)
        {
            CloudConnectorCore.ProcessResponse(CloudConnectorCore.MSG_CONN_ERR + "Connection error after " + elapsedTime.ToString() + " seconds: " + www.error, elapsedTime);
            yield break;
        }

        CloudConnectorCore.ProcessResponse(www.downloadHandler.text, elapsedTime);
    }
示例#8
0
    public static void CreateRequest(Dictionary <string, string> form)
    {
        form.Add("ssid", spreadsheetId);
        form.Add("pass", servicePassword);

        EditorApplication.update += EditorUpdate;

        if (usePOST)
        {
            CloudConnectorCore.UpdateStatus("Establishing Connection at URL " + webServiceUrl);
            www = UnityWebRequest.Post(webServiceUrl, form);
        }
        else         // Use GET.
        {
            string urlParams = "?";
            foreach (KeyValuePair <string, string> item in form)
            {
                urlParams += item.Key + "=" + item.Value + "&";
            }
            CloudConnectorCore.UpdateStatus("Establishing Connection at URL " + webServiceUrl + urlParams);
            www = UnityWebRequest.Get(webServiceUrl + urlParams);
        }

        startTime = EditorApplication.timeSinceStartup;
        www.Send();
    }
    // Get all player objects from the cloud.
    public static void GetAllData(bool runtime)
    {
        Debug.Log("<color=yellow>Retrieving all players from the Cloud.</color>");

        // Get all objects from table 'PlayerInfo'.
        CloudConnectorCore.GetAllTables(runtime);
    }
示例#10
0
    // Get a player object from the cloud.
    public static void RetrieveGandalf(bool runtime)
    {
        Debug.Log("<color=yellow>Retrieving player of name Mithrandir from the Cloud.</color>");

        // Get any objects from table 'PlayerInfo' with value 'Mithrandir' in the field called 'name'.
        CloudConnectorCore.GetObjectsByField(tableName, "name", "Mithrandir", runtime);
    }
示例#11
0
    // Get all player objects from the cloud.
    public static void GetAllPlayers(bool runtime)
    {
        Debug.Log("<color=yellow>Retrieving all players from the Cloud.</color>");

        tableName = "TEST";

        // Get all objects from table 'PlayerInfo'.
        CloudConnectorCore.GetTable(tableName, runtime);
    }
示例#12
0
    // Persist the example object in the cloud.
    public static void SaveGandalf(bool runtime)
    {
        // Get the json string of the object.
        string jsonPlayer = JsonUtility.ToJson(player);

        Debug.Log("<color=yellow>Sending following player to the cloud: \n</color>" + jsonPlayer);

        // Save the object on the cloud, in a table called like the object type.
        CloudConnectorCore.CreateObject(jsonPlayer, tableName, runtime);
    }
示例#13
0
    // Create a table in the cloud to store objects of type PlayerInfo.
    public static void CreatePlayerTable(bool runtime)
    {
        Debug.Log("<color=yellow>Creating a table in the cloud for players data.</color>");

        // Creting an string array for field (table headers) names.
        string[] fieldNames = new string[4];
        fieldNames[0] = "name";
        fieldNames[1] = "level";
        fieldNames[2] = "health";
        fieldNames[3] = "role";

        // Request for the table to be created on the cloud.
        CloudConnectorCore.CreateTable(fieldNames, tableName, runtime);
    }
示例#14
0
 public static void grabPlayerData()
 {
     if (!Player.init)
     {
         finished4 = true;
         CloudConnectorCore.GetObjectsByField(PLAYER, "Name", "Joe", true);
         loaded = true;
     }
     else
     {
         finished4 = true;
         loaded    = true;
         loadVal   = true;
     }
 }
示例#15
0
    // Might not include this. this is used for debugging atm. We should just have a static table created b4 hand and just update it.
    //That would be better than creating a new table everytime. Would allow us to keep progress of players.
    public static void CreatePlayerTable(bool runtime)
    {
        Debug.Log("<color=yellow>Creating a table in the cloud for players data.</color>");

        // Creting an string array for field (table headers) names.
        string[] fieldNames = new string[12];
        fieldNames[0]  = "name";
        fieldNames[1]  = "q1";
        fieldNames[2]  = "q2";
        fieldNames[3]  = "q3";
        fieldNames[4]  = "q4";
        fieldNames[5]  = "q5";
        fieldNames[6]  = "q6";
        fieldNames[7]  = "q7";
        fieldNames[8]  = "q8";
        fieldNames[9]  = "q9";
        fieldNames[10] = "q10";
        fieldNames[11] = "q11";

        // Request for the table to be created on the cloud.
        CloudConnectorCore.CreateTable(fieldNames, tableName, runtime);
    }
示例#16
0
    static void EditorUpdate()
    {
        while (!www.isDone)
        {
            elapsedTime = EditorApplication.timeSinceStartup - startTime;
            if (elapsedTime >= timeOutLimit)
            {
                CloudConnectorCore.ProcessResponse("TIME_OUT", (float)elapsedTime);
                EditorApplication.update -= EditorUpdate;
            }
            return;
        }

        if (www.isNetworkError)
        {
            CloudConnectorCore.ProcessResponse(CloudConnectorCore.MSG_CONN_ERR + "Connection error after " + elapsedTime.ToString() + " seconds: " + www.error, (float)elapsedTime);
            return;
        }

        CloudConnectorCore.ProcessResponse(www.downloadHandler.text, (float)elapsedTime);

        EditorApplication.update -= EditorUpdate;
    }
示例#17
0
    public void CreateRequest(Dictionary <string, string> form)
    {
        form.Add("ssid", spreadsheetId);
        form.Add("pass", servicePassword);

        if (usePOST)
        {
            CloudConnectorCore.UpdateStatus("Establishing Connection at URL " + webServiceUrl);
            www = UnityWebRequest.Post(webServiceUrl, form);
        }
        else         // Use GET.
        {
            string urlParams = "?";
            foreach (KeyValuePair <string, string> item in form)
            {
                urlParams += item.Key + "=" + item.Value + "&";
            }
            CloudConnectorCore.UpdateStatus("Establishing Connection at URL " + webServiceUrl + urlParams);
            www = UnityWebRequest.Get(webServiceUrl + urlParams);
        }

        StartCoroutine(ExecuteRequest(form));
    }
示例#18
0
    public IEnumerator LoadWineQuantities()
    {
        CloudConnectorCore.GetTable(TABLE_NAME);

        wineQuantitiesFromWebhost = new List <int>();
        wineQuantitiesFromHeroku  = new List <int>();
        for (int i = 0; i < 17; i++)
        {
            WWW www = new WWW(WEBHOST_URL + "getWineQuantity.php?id=" + i.ToString());
            while (!www.isDone)
            {
                yield return(0);
            }
            wineQuantitiesFromWebhost.Add(int.Parse(www.text));

            // Inserir chamada pro getWineQuantity do node por aqui @Heitor
            WWW wwnode = new WWW(HEROKU_URL + "getWineQuantity?id=" + i.ToString());
            while (!wwnode.isDone)
            {
                yield return(0);
            }
            wineQuantitiesFromHeroku.Add(int.Parse(Regex.Match(wwnode.text, @"\d+").Value));
        }
    }
示例#19
0
 public static void DoImport()
 {
     CloudConnectorCore.processedResponseCallback.AddListener(Data_Received);
     CloudConnectorCore.GetTable("Scripts", false);
 }
示例#20
0
 public static void getAbilityData()
 {
     CloudConnectorCore.GetTable(ABILITIES, true);
     finished3 = true;
 }
示例#21
0
 public static void updatePlayer(string field, string search, string field_to_change, string val)
 {
     CloudConnectorCore.UpdateObjects(PLAYER, field, search, field_to_change, val, true);
 }
示例#22
0
    public static void SavePlayer(PlayerInfo _player)
    {
        string jsonPlayer = JsonUtility.ToJson(_player);

        CloudConnectorCore.CreateObject(jsonPlayer, PLAYER, true);
    }
示例#23
0
    public static void GetVersion()
    {
        Debug.Log("<color=yellow>Retrieving Data Version from the Cloud.</color>");

        CloudConnectorCore.GetTable("Version", true);
    }
示例#24
0
 public static void GetData()
 {
     CloudConnectorCore.GetAllTables(true);
 }
示例#25
0
 public static void getEnemyData()
 {
     CloudConnectorCore.GetTable(ENEMIES, true);
     finished1 = true;
 }
示例#26
0
 public static void Version_Load()
 {
     CloudConnectorCore.GetTable("Version", true);
 }
示例#27
0
 public static void getTowerData()
 {
     CloudConnectorCore.GetTable(TOWERS, true);
     finished2 = true;
 }