public static string Build(Recipes recipes, Table table) { if (table == recipes.goldenAxe) { return("Золотой топор"); } if (table == recipes.goldenMattock) { return("Золотая мотыга"); } if (table == recipes.goldenPickaxe) { return("Золотая кирка"); } if (table == recipes.goldenShovel) { return("Золотая лопата"); } if (table == recipes.goldenSword) { return("Золотой меч"); } if (table == recipes.ironAxe) { return("Железный топор"); } if (table == recipes.ironSword) { return("Железный меч"); } if (table == recipes.ironMattock) { return("Железная мотыга"); } if (table == recipes.ironPickaxe) { return("Железная кирка"); } if (table == recipes.ironShovel) { return("Железная лопата"); } if (table == recipes.stoneAxe) { return("Каменный топор"); } if (table == recipes.stoneSword) { return("Каменный меч"); } if (table == recipes.stoneMattock) { return("Каменная мотыга"); } if (table == recipes.stonePickaxe) { return("Каменная кирка"); } if (table == recipes.stoneShovel) { return("Каменная лопата"); } if (table == recipes.woodenAxe) { return("Деревянный топор"); } if (table == recipes.woodenSword) { return("Деревянный меч"); } if (table == recipes.woodenMattock) { return("Деревенная мотыга"); } if (table == recipes.woodenPickaxe) { return("Деревенная кирка"); } if (table == recipes.woodenShovel) { return("Деревенная лопата"); } if (table == recipes.stove) { return("Печка"); } return("Ничего"); }
static void Main(string[] args) { Recipes recipes = new Recipes(); Table userTable = new Table(); string tableFence = "#######"; string tableCells = "# # # #"; while (true) { Clear(); WriteLine("Верстак майнкрафта: "); for (int j = 0; j < 3; j++) { WriteLine(tableFence); WriteLine(tableCells); } WriteLine(tableFence); for (int i = 0, y = 2, x = 1; i < Constants.TABLE_SIZE; i++) { SetCursorPosition(x, y); x += Constants.CURSOR_STEP; if (x > Constants.MAX_POS_X) { y += Constants.CURSOR_STEP; x = Constants.DEFAULT_POS_X; } ConsoleKeyInfo key = ReadKey(); char keyChar = key.KeyChar; if (keyChar == 27) { break; } else if (keyChar == 'Д' || keyChar == 'д' || keyChar == 'L' || keyChar == 'l') { userTable[i] = Constants.WOOD; Write("\bД\b"); } else if (keyChar == 'К' || keyChar == 'к' || keyChar == 'R' || keyChar == 'r') { userTable[i] = Constants.STONE; Write("\bК\b"); } else if (keyChar == 'З' || keyChar == 'з' || keyChar == 'P' || keyChar == 'p') { userTable[i] = Constants.GOLD; Write("\bЗ\b"); } else if (keyChar == 'П' || keyChar == 'п' || keyChar == 'G' || keyChar == 'g') { userTable[i] = Constants.STICK; Write("\bП\b"); } else if (keyChar == 'Ж' || keyChar == 'ж' || keyChar == ';' || keyChar == ':') { userTable[i] = Constants.IRON; Write("\bЖ\b"); } else { userTable[i] = Constants.NOTHING; Write("\b \b"); } } SetCursorPosition(0, Constants.TABLE_SIZE); string builtedItem = Recipes.Build(recipes, userTable); WriteLine("Вы получили: \"{0}\"", builtedItem); ReadLine(); } }