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);
        }
    }
Beispiel #2
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;
        }
    }
    /// <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);
    }
    /// <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() },
        });
    }
    public void AddResultsToSheet()
    {
        int            myRandom           = Random.Range(0, 30);
        GS2U_Worksheet gameplaysWorksheet = haribo_spreadsheet.LoadWorkSheet("gameplays");

        gameplaysWorksheet.AddRowData(new Dictionary <string, string>
        {
            { "nombre", GameDataScript.instance.nombre },
            { "paterno", GameDataScript.instance.apellido_paterno },
            { "materno", GameDataScript.instance.apellido_materno },
            { "tiros", "30" },
            { "detenidos", myRandom.ToString() },
            { "goles", (30 - myRandom).ToString() },
            { "puntos", GameDataScript.instance.puntos.ToString() },
            { "fecha", System.DateTime.Now.ToString("dd/MM/yyyy") },
            { "hora", System.DateTime.Now.TimeOfDay.ToString() }
        });

        Boot_Script.instance.test_int++;
    }
Beispiel #6
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());
    }
Beispiel #8
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);
        }