public static void ExportGameLevels()
        {
            string path = EditorUtility.SaveFilePanel("Export Game Levels", "", "", "xls");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            using (Stream writer = File.Create(path))
            {
                ExportData exportData = new ExportData();
                foreach (GameLevelInfo gameLevel in InfoResolver.Resolve <FortInfo>().GameLevel.GameLevelInfos.Select(pair => pair.Value))
                {
                    ExportRow exportRow = new ExportRow();
                    exportRow.AddParameter("Id", new Parameter
                    {
                        Value = gameLevel.Id,
                        Type  = typeof(string)
                    });

/*                    exportRow.AddParameter("Scene", new Parameter
 *                  {
 *                      Value = gameLevel.Scene == null?null: gameLevel.Scene.Value.SceneName,
 *                      Type = typeof(string)
 *                  });*/
/*                    exportRow.AddParameter("DisplayName", new Parameter
 *                  {
 *                      Value = gameLevel.DisplayName,
 *                      Type = typeof(string)
 *                  });*/
                    exportRow.AddParameter("Name", new Parameter
                    {
                        Value = gameLevel.Name,
                        Type  = typeof(string)
                    });
                    exportRow.AddCustomExportParameter(gameLevel);
                    exportData.AddRow(exportRow);
                }
                HSSFWorkbook workbook = new HSSFWorkbook();

                HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("Game Levels");
                exportData.SerializeToSheet(sheet);
                workbook.Write(writer);
            }
        }
示例#2
0
        public static void ExportIapPackages()
        {
            string path = EditorUtility.SaveFilePanel("Export Iap packages", "", "", "xls");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            using (Stream writer = File.Create(path))
            {
                ExportData exportData = new ExportData();
                foreach (IapPackageInfo iapPackageInfo in InfoResolver.Resolve <FortInfo>().Package.Packages)
                {
                    ExportRow exportRow = new ExportRow();
                    exportRow.AddParameter("Sku", new Parameter
                    {
                        Value = iapPackageInfo.Sku,
                        Type  = typeof(string)
                    });
                    LanguageInfo[] languageInfos = EditorInfoResolver.Resolve <LanguageEditorInfo>().Languages;
                    if (languageInfos.Length == 1)
                    {
                        if (iapPackageInfo.DisplayName != null)
                        {
                            if (languageInfos[0].LanguageDatas.ContainsKey(iapPackageInfo.DisplayName.Id))
                            {
                                exportRow.AddParameter("DisplayName", new Parameter
                                {
                                    Value = languageInfos[0].LanguageDatas[iapPackageInfo.DisplayName.Id],
                                    Type  = typeof(string)
                                });
                            }
                        }
                    }
                    else
                    {
                        foreach (LanguageInfo languageInfo in EditorInfoResolver.Resolve <LanguageEditorInfo>().Languages)
                        {
                            if (iapPackageInfo.DisplayName != null)
                            {
                                if (languageInfo.LanguageDatas.ContainsKey(iapPackageInfo.DisplayName.Id))
                                {
                                    exportRow.AddParameter(string.Format("DisplayName-{0}", languageInfo.Name), new Parameter
                                    {
                                        Value = languageInfo.LanguageDatas[iapPackageInfo.DisplayName.Id],
                                        Type  = typeof(string)
                                    });
                                }
                            }
                        }
                    }
                    exportRow.AddParameter("Price", new Parameter
                    {
                        Value = iapPackageInfo.Price,
                        Type  = typeof(int)
                    });
                    exportRow.AddCustomExportParameter(iapPackageInfo);
                    exportData.AddRow(exportRow);
                }
                HSSFWorkbook workbook = new HSSFWorkbook();

                HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("Iap packages");
                exportData.SerializeToSheet(sheet);
                workbook.Write(writer);
            }
        }