public void HandleInput(string inputCommand, out int rollbackLayerCount) { if (!HandleCommand(inputCommand, out rollbackLayerCount)) { Console.WriteLine("無效的指令"); } if (editorControlHandler != null) { int editorRollbackLayerCount = 0; Console.WriteLine(editorControlHandler.ControlInformation); while (editorRollbackLayerCount == 0) { editorControlHandler.HandleInput(Console.ReadLine(), out editorRollbackLayerCount); } editorControlHandler = null; if (editorRollbackLayerCount - 1 > 0) { rollbackLayerCount = editorRollbackLayerCount - 1; } else { Console.WriteLine(ControlInformation); } } }
static void Main(string[] args) { EditorControlHandler editorControlHandler = null; while (editorControlHandler == null) { Console.Clear(); Console.WriteLine("請輸入要進入的編輯器:"); Console.WriteLine("\tstory :故事編輯器"); Console.WriteLine("\tworld :世界編輯器"); Console.WriteLine("\titem :物品編輯器"); Console.WriteLine("\tnpc :NPC編輯器"); Console.WriteLine("\tstore :商店編輯器"); Console.WriteLine("\tauto :自動設置所有遊戲資料"); Console.WriteLine("\texit :關閉編輯器"); switch (Console.ReadLine()) { case "story": editorControlHandler = new StoryEditor(); break; case "world": editorControlHandler = new WorldEditor(); break; case "item": editorControlHandler = new ItemEditor(); break; case "npc": editorControlHandler = new NPC_Editor(); break; case "store": editorControlHandler = new StoreEditor(); break; case "auto": editorControlHandler = new AutoEditor(); break; case "exit": return; default: break; } if (editorControlHandler != null) { int rollbackLayerCount = 0; Console.WriteLine(editorControlHandler.ControlInformation); while (rollbackLayerCount == 0) { editorControlHandler.HandleInput(Console.ReadLine(), out rollbackLayerCount); } editorControlHandler = null; if (rollbackLayerCount - 1 > 0) { break; } } } }