private void AddExtraCommand(List <AdvCommand> commandList, AdvSettingDataManager dataManager) { int index = 0; while (index < commandList.Count) { AdvCommand command = commandList[index]; AdvCommand next = ((index + 1) >= commandList.Count) ? null : commandList[index + 1]; index++; string[] extraCommandIdArray = command.GetExtraCommandIdArray(next); if (extraCommandIdArray != null) { foreach (string str in extraCommandIdArray) { AdvCommand item = AdvCommandParser.CreateCommand(str, command.RowData, dataManager); if (command.IsEntityType) { item.EntityData = command.EntityData; } commandList.Insert(index, item); index++; } } } }
/// <summary> /// 選択肢終了などの特別なコマンドを自動解析して追加 /// </summary> /// <param name="continuousCommand">連続しているコマンド</param> /// <param name="currentCommand">現在のコマンド</param> void AddExtraCommand(List <AdvCommand> commandList, AdvSettingDataManager dataManager) { int index = 0; while (index < commandList.Count) { AdvCommand current = commandList[index]; AdvCommand next = index + 1 < commandList.Count ? commandList[index + 1] : null; ++index; string[] idArray = current.GetExtraCommandIdArray(next); if (idArray != null) { foreach (string id in idArray) { AdvCommand extraCommand = AdvCommandParser.CreateCommand(id, current.RowData, dataManager); if (current.IsEntityType) { extraCommand.EntityData = current.EntityData; } commandList.Insert(index, extraCommand); ++index; } } } }
public bool TryParseMacro(StringGridRow row, AdvSettingDataManager dataManager, out List<AdvCommand> commnadList) { commnadList = null; string commandName = AdvParser.ParseCellOptional<string>(row, AdvColumnName.Command,""); AdvMacroData data; if( macroDataTbl.TryGetValue(commandName, out data ) ) { commnadList = new List<AdvCommand>(); List<StringGridRow> macroRows = data.MakeMacroRows(row); foreach( StringGridRow macroRow in macroRows ) { List<AdvCommand> list; if( TryParseMacro( macroRow, dataManager, out list ) ) { commnadList.AddRange(list); } else { commnadList.Add(AdvCommandParser.CreateCommand(macroRow, dataManager)); } } return true; } else { return false; } }
public List <AdvCommand> CreateCommandList(AdvSettingDataManager dataManager) { List <AdvCommand> commandList = new List <AdvCommand>(); foreach (StringGridRow row in Rows) { if (row.RowIndex < DataTopRow) { continue; //データの行じゃない } if (row.IsEmptyOrCommantOut) { continue; //データがない } Profiler.BeginSample("コマンド作成"); AdvCommand command = AdvCommandParser.CreateCommand(row, dataManager); Profiler.EndSample(); //エンティティ処理がある Profiler.BeginSample("GetEntityIndex"); int entityIndex = GetEntityIndex(row.RowIndex); Profiler.EndSample(); if (entityIndex >= 0) { command.EntityData = entityDataList[entityIndex]; } if (null != command) { commandList.Add(command); } } return(commandList); }
//コマンドデータの解析・初期化 void ParseFromStringGrid(StringGrid grid, AdvSettingDataManager dataManager) { AddCommandBegin(); AdvCommand continuousCommand = null; //連続的なコマンド処理 foreach (StringGridRow row in grid.Rows) { if (row.RowIndex < grid.DataTopRow) { continue; //データの行じゃない } if (row.IsEmpty) { continue; //データがない } AdvCommand command = AdvCommandParser.CreateCommand(row, dataManager); if (null != command) { //連続するコマンドの場合は、連続が途切れたら終了コマンドを追加 TryAddContinusCommand(continuousCommand, command); //コマンド追加 AddCommand(command); //連続するコマンドの場合は、連続が途切れたら終了コマンドを追加 continuousCommand = GetNextContinusCommand(continuousCommand, command); } } //連続するコマンドの場合は、連続が途切れたら終了コマンドを追加 TryAddContinusCommand(continuousCommand, null); AddCommandEnd(); }
//今のコマンドから、エンティティ処理したコマンドを作成 public static AdvCommand CreateEntityCommand(AdvCommand original, AdvEngine engine, AdvScenarioPageData pageData) { StringGridRow row = new StringGridRow(original.RowData.Grid, original.RowData.RowIndex); row.DebugIndex = original.RowData.DebugIndex; string[] strings = original.EntityData.CreateCommandStrings(engine.Param.GetParameter); row.InitFromStringArray(strings); AdvCommand entityCommand = AdvCommandParser.CreateCommand(original.Id, row, engine.DataManager.SettingDataManager); if (entityCommand is AdvCommandText) { AdvCommandText textCommand = entityCommand as AdvCommandText; textCommand.InitOnCreateEntity(original as AdvCommandText); } return(entityCommand); }
//今のコマンドから、エンティティ処理したコマンドを作成 public AdvCommand CreateEntityCommand(AdvEngine engine, AdvScenarioPageData pageData) { StringGridRow row; if (!TryParseRowDataEntity(this.OriginalRowData, engine.Param.GetParameter, out row)) { return(this); } AdvCommand command = AdvCommandParser.CreateCommand(row, engine.DataManager.SettingDataManager); if (this.TextDataInPage != null) { command.InitTextDataInPage(this.TextDataInPage); this.TextDataInPage.Command = command; } return(command); }
//シナリオデータとして解析 public void Init(AdvSettingDataManager dataManager, AdvMacroManager macroManger) { isInit = false; List <AdvCommand> commandList = new List <AdvCommand>(); foreach (StringGridRow row in DataGrid.Rows) { if (row.RowIndex < DataGrid.DataTopRow) { continue; //データの行じゃない } if (row.IsEmptyOrCommantOut) { continue; //データがない } List <AdvCommand> macroCommnadList; AdvCommand.StartCheckEntity(dataManager.DefaultParam.GetParameter); bool isMacro = macroManger.TryParseMacro(row, dataManager, out macroCommnadList); AdvCommand.EndCheckEntity(); if (isMacro) { //マクロの場合 commandList.AddRange(macroCommnadList); } else { //通常コマンド AdvCommand command = AdvCommandParser.CreateCommand(row, dataManager); if (null != command) { commandList.Add(command); } } } //選択肢終了などの特別なコマンドを自動解析して追加 AddExtraCommand(commandList, dataManager); //シナリオラベルデータを作成 MakeScanerioLabelData(commandList); isInit = true; }
public List <AdvCommand> CreateCommandList(AdvSettingDataManager dataManager) { List <AdvCommand> list = new List <AdvCommand>(); foreach (StringGridRow row in base.Rows) { if ((row.RowIndex >= base.DataTopRow) && !row.IsEmptyOrCommantOut) { AdvCommand item = AdvCommandParser.CreateCommand(row, dataManager); int entityIndex = this.GetEntityIndex(row.RowIndex); if (entityIndex >= 0) { item.EntityData = this.entityDataList[entityIndex]; } if (item != null) { list.Add(item); } } } return(list); }
/* * /// <summary> * /// 指定インデックスのコマンドを取得 * /// </summary> * /// <param name="index">インデックス</param> * /// <returns>コマンド</returns> * public AdvCommand GetCommand(int index) * { * return null; * } * * /// <summary> * /// 指定シナリオラベルの指定ページのコマンドインデックスを取得 * /// </summary> * /// <param name="scenarioLabel">シナリオラベル</param> * /// <param name="page">ページ</param> * /// <returns>ページのコマンドインデックス</returns> * public int SeekPageIndex(string scenarioLabel, int page) * { * int index = 0; * * if (Name == scenarioLabel) * { * //シナリオ名そのものだった場合は一番最初から * index = 0; * } * else * { * //シナリオラベルをシーク * while (true) * { * AdvCommand command = GetCommand(index); * if (null == GetCommand(index)) * { * Debug.LogError(LanguageAdvErrorMsg.LocalizeTextFormat(AdvErrorMsg.NotFoundScnarioLabel,scenarioLabel)); * return 0; * } * * if ( command.GetScenarioLabel() == scenarioLabel) * { * break; * } ++index; * } * } * if (page < 0) * { //シナリオラベル冒頭 * return index; * } * * int pageCount = 0; * //シナリオラベルからの指定のページまでシーク * while (true) * { * AdvCommand command = GetCommand(index); * if (null == command) * { * //指定のページ数がなかったので、ここまでで終了 * return index-1; * } * if (command.IsTypePageEnd()) * { * if (pageCount >= page) * { * return index; * } ++pageCount; * } ++index; * } * } */ //コマンドデータの解析・初期化 void ParseFromStringGrid(StringGrid grid, AdvSettingDataManager dataManager) { isInit = false; List <AdvCommand> commandList = new List <AdvCommand>(); AdvCommand continuousCommand = null; //連続的なコマンド処理 foreach (StringGridRow row in grid.Rows) { if (row.RowIndex < grid.DataTopRow) { continue; //データの行じゃない } if (row.IsEmpty) { continue; //データがない } AdvCommand command = AdvCommandParser.CreateCommand(row, dataManager); if (null != command) { //連続するコマンドの場合は、連続が途切れたら終了コマンドを追加 TryAddContinusCommand(continuousCommand, command, commandList, dataManager); //コマンド追加 if (null != command) { commandList.Add(command); } //連続するコマンドの場合は、連続が途切れたら終了コマンドを追加 continuousCommand = command.IsContinusCommand ? command : null;; } } //連続するコマンドの場合は、連続が途切れたら終了コマンドを追加 TryAddContinusCommand(continuousCommand, null, commandList, dataManager); MakeScanerioLabelData(commandList); isInit = true; }