示例#1
0
    private static void MakeData(StringGridDictionary SGD, int index)
    {
        Dictionary <string, StringGridDictionaryKeyValue> .ValueCollection vc = SGD.Values;
        //Debug.LogError(vc);
        Dictionary <string, StringGridDictionaryKeyValue> .ValueCollection.Enumerator en = vc.GetEnumerator();
        while (en.MoveNext())
        {
            StringGridDictionaryKeyValue kv = en.Current;
            StringGrid           sg         = kv.Grid;
            List <StringGridRow> list       = sg.Rows;
            switch (index)
            {
            case 0:
                AddCastle(list);
                break;

            case 1:
                AddChar(list);
                break;

            case 2:
                AddCastleConnection(list);
                break;

            default:
                break;
            }
        }
    }
示例#2
0
    static void MakeCastleConnectionData()
    {
        StringGridDictionary SGD = ExcelParser.Read(Application.dataPath + "//G_Excel//CastleConnection.xlsx");

        MakeData(SGD, 2);
        Object obj = AssetDatabase.LoadAssetAtPath <Object>(GetSO_Path(2));

        Selection.activeObject = obj;
    }
		//ブックの読み込み
		static void ReadBook(IWorkbook book, string path, StringGridDictionary gridDictionary)
		{
			for (int i = 0; i < book.NumberOfSheets; ++i)
			{
				ISheet sheet = book.GetSheetAt(i);
				StringGrid grid = ReadSheet(sheet, path);
				gridDictionary.Add(new StringGridDictionaryKeyValue(sheet.SheetName, grid));
			}
		}
示例#4
0
    static void MakeCharData()
    {
        StringGridDictionary SGD = ExcelParser.Read(Application.dataPath + "//G_Excel//CharData.xlsx");

        MakeData(SGD, 1);
        //Debug.LogError(SGD);
        Object obj = AssetDatabase.LoadAssetAtPath <Object>(GetSO_Path(1));

        Selection.activeObject = obj;
    }
		//ファイルの読み込み
		public static StringGridDictionary Read( string path )
		{
			StringGridDictionary gridDictionary = new StringGridDictionary();
			if ( IsExcelFile(path) )
			{
				string ext = Path.GetExtension(path);
				using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
				{
					if (ext == ExtXls)
					{
						ReadBook(new HSSFWorkbook(fs), path, gridDictionary);
					}
					else if (ext == ExtXlsx)
					{
						ReadBook(new XSSFWorkbook(fs), path, gridDictionary);
					}
				}
			}
			return gridDictionary;
		}
		/// <summary>
		/// コンバートする
		/// </summary>
		/// <param name="folderPath">出力先パス</param>
		/// <param name="assetPathList">読み込むエクセルファイルのリスト</param>
		/// <returns>コンバートしたらtrue。失敗したらfalse</returns>
		public bool Convert(string folderPath, List<string> assetPathList, int version )
		{
			scenarioSheetDictionary.Clear();
			if (!string.IsNullOrEmpty(folderPath) && assetPathList.Count > 0)
			{
				//対象のエクセルファイルを全て読み込み
				StringGridDictionary readSheet = new StringGridDictionary();
				foreach (string assetPath in assetPathList)
				{
					if (!string.IsNullOrEmpty(assetPath))
					{
						StringGridDictionary dictionary = ExcelParser.Read(assetPath);
						foreach (var sheet in dictionary.List )
						{
							readSheet.Add(sheet);
						}
					}
				}

				if (readSheet.List.Count <= 0) return false;

				//各シートをコンバート
				foreach (var sheet in readSheet.List)
				{
					ConvertSheet(sheet, folderPath);
				}
				//シナリオ設定シートは個別にコンバート
				WriteScenarioSetting(folderPath, version);

				///起動用CSVをコンバート
				WriteBootSetting(folderPath, version);

				return true;
			}
			return false;
		}
		//設定データをインポート
		void ImportSettingBook(StringGridDictionary book, string path)
		{
			//インポート後のスクリプタブルオブジェクトを作成
			string assetPath = Path.GetDirectoryName(path) + "/" + Path.GetFileNameWithoutExtension(path) + SettingAssetExt;
			foreach (var sheet in book.List )
			{
				StringGrid grid = sheet.Grid;
				//設定データか、シナリオデータかチェック
				if (AdvSettingDataManager.IsBootSheet(sheet.Name) || AdvSettingDataManager.IsSettingsSheet(sheet.Name))
				{
					//設定データのアセットを作成
					if (assetSetting == null)
					{
						assetSetting = UtageEditorToolKit.GetImportedAssetCreateIfMissing<AdvSettingDataManager>(assetPath);
						assetSetting.Clear();
					}
					assetSetting.hideFlags = HideFlags.NotEditable;
					assetSetting.ParseFromExcel(sheet.Name, grid);
				}
			}

			if (assetSetting != null)
			{
				assetSetting.EditorTestInit();
				Debug.Log( LanguageAdvErrorMsg.LocalizeTextFormat(AdvErrorMsg.Import,assetPath));
				//変更を反映
				EditorUtility.SetDirty(assetSetting);
			}
		}
		//ブックのインポート
		void ImportScenarioBook(StringGridDictionary book, string path)
		{
			//シナリオデータ用のスクリプタブルオブジェクトを宣言
			string scenarioAssetPath = Path.ChangeExtension(path, ScenarioAssetExt);
			AdvScenarioDataExported assetScenario = null;

			foreach (var sheet in book.List)
			{
				StringGrid grid = sheet.Grid;
				//設定データか、シナリオデータかチェック
				if (!AdvSettingDataManager.IsBootSheet(sheet.Name) && !AdvSettingDataManager.IsSettingsSheet(sheet.Name))
				{
					//シナリオデータのアセットを作成
					if (assetScenario == null)
					{
						assetScenario = UtageEditorToolKit.GetImportedAssetCreateIfMissing<AdvScenarioDataExported>(scenarioAssetPath);
						assetScenario.Clear();
					}
					assetScenario.hideFlags = HideFlags.NotEditable;
					assetScenario.ParseFromExcel(sheet.Name, grid);
					if (assetSetting != null)
					{
						AdvScenarioData scenarioData = assetScenario.ErrorCheck(sheet.Name, grid, assetSetting);
						scenarioDataTbl.Add(sheet.Name, scenarioData);
					}
				}
			}

			//変更を反映
			if (assetScenario != null)
			{
				Debug.Log(LanguageAdvErrorMsg.LocalizeTextFormat(AdvErrorMsg.Import, scenarioAssetPath));
				EditorUtility.SetDirty(assetScenario);
			}
		}