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); } }
public FunctionList(WorksheetData worksheetData) { this.worksheetData = worksheetData; functionsDict = new Dictionary <string, object>(); foreach (KeyValuePair <string, AbstractFunction> pair in BuiltinFunctions.AllFunctions) { functionsDict[pair.Key] = pair.Value; } // internal macro foreach (KeyValuePair <string, AbstractMacroData> pair in worksheetData.mapMacroData) { functionsDict[pair.Key] = pair.Value; } // external macro foreach (WorksheetData externalWorksheet in worksheetData.listExternalWorksheet) { foreach (KeyValuePair <string, AbstractMacroData> pair in externalWorksheet.mapMacroData) { functionsDict[pair.Key] = pair.Value; } } functionsArr = functionsDict.Keys.ToArray().OrderBy(item => item).ToList(); InitializeComponent(); listBox.ItemsSource = functionsArr; }
/// <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> /// Loads in rows from excel sheet and returns them as a keyvalue pair /// </summary> /// <param name="fileName"></param> /// <returns></returns> public void LoadRows(string fileName) { WorksheetData worksheetData = this.WorkbookReader.ReadWorksheet(fileName); for (int row = 0; row < worksheetData.CellData.Count; row++) { string Key = worksheetData.GetValue(row, "Type").Trim(); string Value = worksheetData.GetValue(row, "Value").Trim(); KeyValuePair <string, string> Line = new KeyValuePair <string, string>(Key, Value); Results.Add(Line); } }
public void GetAllPremiosFromWorksheet() { WorksheetData worksheetInformation = SpreadsheetsScript.instance.haribo_spreadsheet.LoadWorkSheet("premios").LoadAllWorksheetInformation(); foreach (RowData row in worksheetInformation.rows) { foreach (CellData cell in row.cells) { premios_strings.Add(cell.value); } } premioss_dropdown.AddOptions(premios_strings); }
public void SaveWorksheet(WorksheetData data, string path) { DataContractSerializer serializer = new DataContractSerializer(typeof(WorksheetData)); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.Encoding = Encoding.UTF8; XmlWriter stream = XmlWriter.Create(path, settings); serializer.WriteObject(stream, data); stream.Close(); data.currentFilePath = path; }
public WorksheetData ReadWorksheet(string fileName) { WorksheetData worksheetData = new WorksheetData(); for (int i = 0; i < ColumnHeaders.Count(); i++) { worksheetData.ColumnHeaders.Add(this.ColumnHeaders[i]); } for (int row = 0; row < ExcellData.Count(); row++) { worksheetData.CellData.Add(new List <string>()); for (int column = 0; column < ExcellData[row].Count(); column++) { worksheetData.CellData[worksheetData.CellData.Count - 1].Add(ExcellData[row][column]); } } return(worksheetData); }
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]); } } } }
public WorksheetData LoadWorksheet(string path, bool asExternal = false) { DataContractSerializer serializer = new DataContractSerializer(typeof(WorksheetData)); XmlReader stream = XmlReader.Create(path); try { WorksheetData data = serializer.ReadObject(stream) as WorksheetData; data.currentFilePath = path; data.AfterDeserialized(asExternal); return(data); } catch (Exception e) { throw new Exception("Cannot load worksheet. File not recognized"); } finally { stream.Close(); } }
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()); }
public WindowGoalseek(WorksheetData worksheetData) { this.worksheetData = worksheetData; InitializeComponent(); }
public WindowDatatable(WorksheetData worksheetData, SpreadsheetRangeData rangeData) { this.worksheetData = worksheetData; this.rangeData = rangeData; InitializeComponent(); }
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); }
public IncludeExternal(WorksheetData worksheetData) { this.worksheetData = worksheetData; InitializeComponent(); listBox.ItemsSource = worksheetData.listExternalWorksheetPaths; }