static bool RecipeCheck(Workbench workbench) { switch (workbench.WorkbenchTable) { case InstrumentsRecipe.WoodShovelFirstRecipe: break; } return(false); }
static void WorkbenchPrint(Workbench workbench) { for (int i = 0; i < workbench.WorkbenchTableWidth; i++) { for (int j = 0; j < workbench.WorkbenchTableLenth; j++) { if (i == Cursor.cursorYPosition && j == Cursor.cursorXPosition) { Console.ForegroundColor = ConsoleColor.Red; Console.Write(workbench[i, j]); } else { Console.ForegroundColor = ConsoleColor.White; Console.Write(workbench[i, j]); } } Console.WriteLine(); } }
public static void WorkbenchPrint(Workbench workbench) { for (int i = 0, a = 0; i < Constants.FRAME_TOP_WIDTH; i++) { Console.SetCursorPosition(Constants.STANDART_CURSOR_X_POSITION, Constants.STANDART_CURSOR_Y_POSITION + i); for (int j = 0, b = 0; j < Constants.FRAME_TOP_LENTH; j++) { if (i % Constants.TWO != Constants.NULL) { Console.ForegroundColor = ConsoleColor.White; Console.Write('-'); } else if (i % Constants.TWO == Constants.NULL && j % Constants.TWO != Constants.NULL) { Console.ForegroundColor = ConsoleColor.White; Console.Write('|'); } else if ((a == Cursor.cursorYPosition && b == Cursor.cursorXPosition) && (i % Constants.TWO == Constants.NULL && j % Constants.TWO == Constants.NULL)) { Console.ForegroundColor = ConsoleColor.Red; Console.Write(workbench[a, b]); Console.ForegroundColor = ConsoleColor.White; b++; } else if (i % Constants.TWO == Constants.NULL && j % Constants.TWO == Constants.NULL) { Console.ForegroundColor = ConsoleColor.White; Console.Write(workbench[a, b]); b++; } } if (i % Constants.TWO != Constants.NULL) { a++; } Console.WriteLine(); } }
static void Main(string[] args) { Workbench workbench = new Workbench(); bool isFinish = false; WorkbenchPrint(workbench); while (true) { ConsoleKeyInfo info; info = Console.ReadKey(); switch (info.Key) { case ConsoleKey.LeftArrow: if (Cursor.cursorXPosition != Constants.NULL) { Cursor.cursorXPosition = Cursor.cursorXPosition - Constants.LENTH_TO_INDEX; Console.Clear(); WorkbenchPrint(workbench); } else { Console.Clear(); WorkbenchPrint(workbench); } break; case ConsoleKey.RightArrow: if (Cursor.cursorXPosition != workbench.WorkbenchTableLenth - Constants.LENTH_TO_INDEX) { Cursor.cursorXPosition = Cursor.cursorXPosition + Constants.LENTH_TO_INDEX; Console.Clear(); WorkbenchPrint(workbench); } else { Console.Clear(); WorkbenchPrint(workbench); } break; case ConsoleKey.UpArrow: if (Cursor.cursorYPosition != Constants.NULL) { Cursor.cursorYPosition = Cursor.cursorYPosition - Constants.LENTH_TO_INDEX; Console.Clear(); WorkbenchPrint(workbench); } else { Console.Clear(); WorkbenchPrint(workbench); } break; case ConsoleKey.DownArrow: if (Cursor.cursorYPosition != workbench.WorkbenchTableWidth - Constants.LENTH_TO_INDEX) { Cursor.cursorYPosition = Cursor.cursorYPosition + Constants.LENTH_TO_INDEX; Console.Clear(); WorkbenchPrint(workbench); } else { Console.Clear(); WorkbenchPrint(workbench); } break; case ConsoleKey.Enter: isFinish = true; break; case ConsoleKey.D0: workbench[Cursor.cursorYPosition, Cursor.cursorXPosition] = '0'; Console.Clear(); WorkbenchPrint(workbench); break; case ConsoleKey.D1: workbench[Cursor.cursorYPosition, Cursor.cursorXPosition] = '1'; Console.Clear(); WorkbenchPrint(workbench); break; case ConsoleKey.D2: workbench[Cursor.cursorYPosition, Cursor.cursorXPosition] = '2'; Console.Clear(); WorkbenchPrint(workbench); break; case ConsoleKey.D3: workbench[Cursor.cursorYPosition, Cursor.cursorXPosition] = '3'; Console.Clear(); WorkbenchPrint(workbench); break; case ConsoleKey.D4: workbench[Cursor.cursorYPosition, Cursor.cursorXPosition] = '4'; Console.Clear(); WorkbenchPrint(workbench); break; case ConsoleKey.D5: workbench[Cursor.cursorYPosition, Cursor.cursorXPosition] = '5'; Console.Clear(); WorkbenchPrint(workbench); break; default: Console.Clear(); WorkbenchPrint(workbench); break; } if (isFinish == true) { break; } } }
public static string CheckRecipe(Workbench workbench) { bool isEqual = false; #region WoodInstrument for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == WoodSwordFirstRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали деревянный меч"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == WoodSwordSecondRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали деревянный меч"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == WoodSwordThirdRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали деревянный меч"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == WoodShovelFirstRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали деревянную лопату"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == WoodShovelSecondRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали деревянную лопату"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == WoodShovelThirdRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали деревянную лопату"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == WoodPickaxe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали деревянную кирку"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == WoodAxe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали деревянный топор"); } #endregion #region StoneInstrument for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == StoneSwordFirstRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали каменный меч"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == StoneSwordSecondRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали каменный меч"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == StoneSwordThirdRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали каменный меч"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == StoneShovelFirstRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали каменную лопату"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == StoneShovelSecondRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали каменную лопату"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == StoneShovelThirdRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали каменную лопату"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == StonePickaxe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали каменную кирку"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == StoneAxe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали каменный топор"); } #endregion #region IronInstrument for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == IronSwordFirstRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали железыный меч"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == IronSwordSecondRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали железыный меч"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == IronSwordThirdRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали железыный меч"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == IronShovelFirstRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали железную лопату"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == IronShovelSecondRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали железную лопату"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == IronShovelThirdRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали железную лопату"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == IronPickaxe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали железную кирку"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == IronAxe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали железный топор"); } #endregion #region GoldInstrument for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == GoldSwordFirstRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали золотой меч"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == GoldSwordSecondRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали золотой меч"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == GoldSwordThirdRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали золотой меч"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == GoldShovelFirstRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали золотую лопату"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == GoldShovelSecondRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали золотую лопату"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == GoldShovelThirdRecipe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали золотую лопату"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == GoldPickaxe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали золотую кирку"); } for (int i = 0; i < Constants.STANDART_WORKBENCH_SIZE; i++) { for (int j = 0; j < Constants.STANDART_WORKBENCH_SIZE; j++) { if (workbench[i, j] == GoldAxe[i, j]) { isEqual = true; } else { isEqual = false; break; } } if (isEqual == false) { break; } } if (isEqual == true) { return("Вы создали золотой топор"); } else { return("Такого рецепта еще нет..."); } #endregion }
static void Main(string[] args) { Console.CursorVisible = false; Workbench workbench = new Workbench(); bool isFinish = false, isEnd = false; ConsoleKeyInfo info; while (true) { switch (Choice()) { case Constants.FIRST_CHOISE: Console.Clear(); Console.Write(" Workbench \n"); WorkbenchPrint(workbench); while (true) { isFinish = false; info = Console.ReadKey(true); switch (info.Key) { case ConsoleKey.LeftArrow: if (Cursor.cursorXPosition != Constants.NULL) { Cursor.cursorXPosition--; WorkbenchPrint(workbench); } break; case ConsoleKey.RightArrow: if (Cursor.cursorXPosition != workbench.WorkbenchTableLenth - Constants.LENTH_TO_INDEX) { Cursor.cursorXPosition++; WorkbenchPrint(workbench); } break; case ConsoleKey.UpArrow: if (Cursor.cursorYPosition != Constants.NULL) { Cursor.cursorYPosition = Cursor.cursorYPosition - Constants.LENTH_TO_INDEX; WorkbenchPrint(workbench); } break; case ConsoleKey.DownArrow: if (Cursor.cursorYPosition != workbench.WorkbenchTableWidth - Constants.LENTH_TO_INDEX) { Cursor.cursorYPosition = Cursor.cursorYPosition + Constants.LENTH_TO_INDEX; WorkbenchPrint(workbench); } break; case ConsoleKey.Enter: Console.SetCursorPosition(Constants.MESSAGE_X_POSITION, Constants.MESSAGE_Y_POSITION); Console.Write(InstrumentsRecipe.CheckRecipe(workbench)); while (true) { info = Console.ReadKey(true); if (info.Key == ConsoleKey.Escape || info.Key == ConsoleKey.Enter) { break; } } isFinish = true; workbench.Clear(); Console.Clear(); break; case ConsoleKey.D0: workbench = workbench + Materials.NULL; WorkbenchPrint(workbench); break; case ConsoleKey.D1: workbench += Materials.WOOD; WorkbenchPrint(workbench); break; case ConsoleKey.D2: workbench = workbench + Materials.STONE; WorkbenchPrint(workbench); break; case ConsoleKey.D3: workbench = workbench + Materials.IRON; WorkbenchPrint(workbench); break; case ConsoleKey.D4: workbench = workbench + Materials.GOLD; WorkbenchPrint(workbench); break; case ConsoleKey.D5: workbench = workbench + Materials.STICK; WorkbenchPrint(workbench); break; case ConsoleKey.Escape: isFinish = true; Console.Clear(); break; default: WorkbenchPrint(workbench); break; } if (isFinish == true) { break; } } break; case Constants.SECOND_CHOISE: Console.Clear(); Instruction(); break; case Constants.THIRD_CHOISE: Console.Clear(); InstrumentsRecipe.RecipeShow(); Console.Clear(); break; case Constants.FOURTH_CHOISE: Console.Clear(); isEnd = true; break; } if (isEnd == true) { break; } } }