void Test()
 {
     if (spreadSheet == null)
     {
         spreadSheet = new SpreadSheetManager();
     }
 }
    static void UpdateAnimals()
    {
        //load the animal container from resources
        AnimalContainer container = Resources.Load <AnimalContainer>("AnimalContainer");

        //load the revelant spreadsheet
        SpreadSheetManager manager   = new SpreadSheetManager();
        GS2U_Worksheet     worksheet = manager.LoadSpreadSheet("Animal Stats").LoadWorkSheet("Stats");
        WorksheetData      data      = worksheet.LoadAllWorksheetInformation();

        //loop through all the animals on the spreadsheet, if an animal is found then update their stats
        for (int i = 0; i < data.rows.Count; i++)
        {
            Animal animal = container.allAnimals.Find(x => x.name == data.rows[i].rowTitle);

            //if an animal can not be found then create an asset for that animal
            if (animal == null)
            {
                animal      = new Animal();
                animal.name = data.rows[i].rowTitle;
                AssetDatabase.CreateAsset(animal, "Assets/Animal Example/Animal Stats/" + animal.name + ".asset");
                container.allAnimals.Add(animal);

                Debug.Log("Creating animal asset for " + animal.name);
            }

            //update the animals stats
            animal.UpdateStats(data.rows[i]);
            Debug.Log("Updating Stats for " + animal.name);
        }
    }
Пример #3
0
    IEnumerator LoadGoogleSheetData()
    {
        Debug.Log("LOADING DATA");
        spreadSheetManager = new SpreadSheetManager();
        yield return(null);

        spreadSheetFromName = spreadSheetManager.LoadSpreadSheet("Chef Dolores VR");
        worksheetFromName   = spreadSheetFromName.LoadWorkSheet("RemConfig");
        CellData cellData      = worksheetFromName.GetCellData("B", 2);
        CellData versionNumber = worksheetFromName.GetCellData("B", 3);

        Debug.Log(cellData.value.ToString());

        switch (cellData.value)
        {
        case "1":
            hasBeenPaid      = true;
            messageText.text = "Cargando datos...";
            versionText.text = "Ver. " + versionNumber.value;
            break;

        case "Yes":
            hasBeenPaid      = true;
            messageText.text = "Cargando datos...";
            versionText.text = "Ver. " + versionNumber.value;
            break;

        default:
            hasBeenPaid      = false;
            messageText.text = "Error: C0D_05";
            versionText.text = "Ver. " + versionNumber.value;
            break;
        }
    }
Пример #4
0
    /// <summary>
    /// Loads the revelant sheet and searches for the information for this asset
    /// if you want to access a different sheet replace "Animal Stats" and "Stats" with the revelant spreadsheet title and sheet name
    /// </summary>
    void UpdateStats()
    {
        SpreadSheetManager manager   = new SpreadSheetManager();
        GS2U_Worksheet     worksheet = manager.LoadSpreadSheet("Animal Stats").LoadWorkSheet("Stats");
        WorksheetData      data      = worksheet.LoadAllWorksheetInformation();

        RowData rData = null;

        for (int i = 0; i < data.rows.Count; i++)
        {
            if (data.rows[i].rowTitle == animal.name
                )
            {
                rData = data.rows[i];
                break;
            }
        }

        if (rData != null)
        {
            animal.UpdateStats(rData);
        }
        else
        {
            Debug.Log("no found data");
        }

        EditorUtility.SetDirty(target);
    }
 public void ReloadWorksheets()
 {
     CheckConnection();
     ClearOldSheetInfo();
     manager = new SpreadSheetManager();
     GetSpreadsheets();
     GetWorksheets();
 }
Пример #6
0
    /// <summary>
    /// Adds the new animal to the spreadsheet online
    /// if you want to access a different sheet replace "Animal Stats" and "Stats" with the revelant spreadsheet title and sheet name
    /// all title names must be in lowercase and contain no spaces
    /// </summary>
    void SendAnimalDataToSheet()
    {
        SpreadSheetManager manager   = new SpreadSheetManager();
        GS2U_Worksheet     worksheet = manager.LoadSpreadSheet("Animal Stats").LoadWorkSheet("Stats");

        worksheet.AddRowData(new Dictionary <string, string>
        {
            //NOTE: all data names are in lower case
            { "name", animal.name },
            { "health", animal.health.ToString() },
            { "attack", animal.health.ToString() },
            { "defence", animal.health.ToString() },
        });
    }
Пример #7
0
    void Awake()
    {
        //if true will update all animals in the animal container, this can be expensive to do at runtime but will always ensure the most updated values.
        //recomend to use behind a loading screen.
        if (updateOnPlay)
        {
            SpreadSheetManager manager   = new SpreadSheetManager();
            GS2U_Worksheet     worksheet = manager.LoadSpreadSheet("Animal Stats").LoadWorkSheet("Stats");
            WorksheetData      data      = worksheet.LoadAllWorksheetInformation();

            for (int i = 0; i < data.rows.Count; i++)
            {
                Animal animal = container.allAnimals.Find(x => x.name == data.rows[i].rowTitle);

                if (animal != null)
                {
                    animal.UpdateStats(data.rows[i]);
                }
            }
        }
    }
    void Start()
    {
        //Update on play here is used as an example of real time data retreval, it is not recomended to do a lot of calls on begin, if needed group it to one larger call
        //See the UpdateAllAnimals.cs on how to do a batch update in the editor or AnimalManager.cs for a runtime example
        if (updateOnPlay)
        {
            SpreadSheetManager manager   = new SpreadSheetManager();
            GS2U_Worksheet     worksheet = manager.LoadSpreadSheet("Animal Stats").LoadWorkSheet("Stats");
            WorksheetData      data      = worksheet.LoadAllWorksheetInformation();
            RowData            rData     = null;

            for (int i = 0; i < data.rows.Count; i++)
            {
                if (data.rows[i].rowTitle == animal.name)
                {
                    rData = data.rows[i];
                    break;
                }
            }

            if (rData != null)
            {
                Debug.Log("updating animal stats " + animal.name);
                animal.UpdateStats(rData);
            }
            else
            {
                Debug.Log("no found data");
            }
        }

        //show the stats on the canvas
        animalName.text    = animal.name;
        animalHealth.text  = string.Format(animalHealth.text, animal.health.ToString());
        animalAttack.text  = string.Format(animalAttack.text, animal.attack.ToString());
        animalDefence.text = string.Format(animalDefence.text, animal.defence.ToString());
    }
Пример #9
0
        void UpdateStats()
        {
            SpreadSheetManager manager   = new SpreadSheetManager();
            GS2U_Worksheet     worksheet = manager.LoadSpreadSheet("Character Data").LoadWorkSheet(c.charName);
            WorksheetData      data      = worksheet.LoadAllWorksheetInformation();

            Debug.Log("Starting nW.Dam = " + c.nW.damage);
            RowData rData = null;

            for (int i = 0; i < data.rows.Count; i++)
            {
                rData = data.rows[i];
                switch (data.rows[i].rowTitle)
                {
                case "Neutral Weak":
                {
                    c.nW = SetAttack(rData, c.nW);
                    break;
                }

                case "Neutral Strong":
                {
                    c.nS = SetAttack(rData, c.nS);
                    break;
                }

                case "Forward Weak":
                {
                    c.fW = SetAttack(rData, c.fW);
                    break;
                }

                case "Forward Strong":
                {
                    c.fS = SetAttack(rData, c.fS);
                    break;
                }

                case "Side Weak":
                {
                    c.sW = SetAttack(rData, c.sW);
                    break;
                }

                case "Side Strong":
                {
                    c.sS = SetAttack(rData, c.sS);
                    break;
                }

                case "Back Weak":
                {
                    c.bW = SetAttack(rData, c.bW);
                    break;
                }

                case "Back Strong":
                {
                    c.bS = SetAttack(rData, c.bS);
                    break;
                }

                case "Neutral Weak Air":
                {
                    c.nWA = SetAttack(rData, c.nWA);
                    break;
                }

                case "Neutral Strong Air":
                {
                    c.nSA = SetAttack(rData, c.nSA);
                    break;
                }

                case "Forward Weak Air":
                {
                    c.fWA = SetAttack(rData, c.fWA);
                    break;
                }

                case "Forward Strong Air":
                {
                    c.fSA = SetAttack(rData, c.fSA);
                    break;
                }

                case "Side Weak Air":
                {
                    c.sWA = SetAttack(rData, c.sWA);
                    break;
                }

                case "Side Strong Air":
                {
                    c.sSA = SetAttack(rData, c.sSA);
                    break;
                }

                case "Back Weak Air":
                {
                    c.bWA = SetAttack(rData, c.bWA);
                    break;
                }

                case "Back Strong Air":
                {
                    c.bSA = SetAttack(rData, c.bSA);
                    break;
                }

                case "Neutral Special":
                {
                    c.nSp = SetAttack(rData, c.nSp);
                    break;
                }

                case "Forward Special":
                {
                    c.fSp = SetAttack(rData, c.fSp);
                    break;
                }

                case "Side Special":
                {
                    c.sSp = SetAttack(rData, c.sSp);
                    break;
                }

                case "Back Special":
                {
                    c.bSp = SetAttack(rData, c.bSp);
                    break;
                }

                case "Neutral Air Special":
                {
                    c.nASp = SetAttack(rData, c.nASp);
                    break;
                }

                case "Forward Air Special":
                {
                    c.fASp = SetAttack(rData, c.fASp);
                    break;
                }

                case "Side Air Special":
                {
                    c.sASp = SetAttack(rData, c.sASp);
                    break;
                }

                case "Back Air Special":
                {
                    c.bASp = SetAttack(rData, c.bASp);
                    break;
                }
                }
            }
            EditorUtility.SetDirty(target);
        }
        void OnGUI()
        {
            tabID = GUILayout.Toolbar(tabID, new string[] { "Private", "Public" });

            if (config == null)
            {
                Debug.LogError("Error: no config file");
                return;
            }

            switch (tabID)
            {
            case 0:
            {
                config.CLIENT_ID = EditorGUILayout.TextField("Client ID", config.CLIENT_ID);

                GUILayout.BeginHorizontal();
                if (showSecret)
                {
                    config.CLIENT_SECRET = EditorGUILayout.TextField("Client Secret Code", config.CLIENT_SECRET);
                }
                else
                {
                    config.CLIENT_SECRET = EditorGUILayout.PasswordField("Client Secret Code", config.CLIENT_SECRET);
                }
                showSecret = GUILayout.Toggle(showSecret, "Show");
                GUILayout.EndHorizontal();

                if (GUILayout.Button("Get Access Code"))
                {
                    string authUrl = oAuth2.GetAuthURL();
                    Application.OpenURL(authUrl);
                }

                config.ACCESS_TOKEN = EditorGUILayout.TextField("Access Code", config.ACCESS_TOKEN);

                if (GUILayout.Button("Authentication with Acceess Code"))
                {
                    SecurityPolicy.Instate();
                    config.REFRESH_TOKEN = oAuth2.AuthWithAccessCode(config.ACCESS_TOKEN);
                }

                if (GUILayout.Button("Debug Information (WARNING: This may take some time)"))
                {
                    isDebugOn = true;

                    if (config.REFRESH_TOKEN != "")
                    {
                        if (spreadSheet == null)
                        {
                            spreadSheet = new SpreadSheetManager();
                        }

                        var tempData = spreadSheet.GetAllSheets();
                        for (int i = 0; i < tempData.Count; i++)
                        {
                            knownData.Add(new KnownData(tempData[i], tempData[i].GetAllWorkSheetsNames()));
                            spreadsheetNames.Add(tempData[i].spreadsheetEntry.Title.Text);
                        }
                    }
                }

                if (isDebugOn)
                {
                    DrawPreview();
                }
                break;
            }

            case 1:
            {
                config.API_Key = EditorGUILayout.TextField("API Key", config.API_Key);
                break;
            }
            }


            EditorUtility.SetDirty(config);
        }
 void ListToSheet()
 {
     SpreadSheetManager manager = new SpreadSheetManager();
 }