Ejemplo n.º 1
0
		public void start() {
			try {
				Console.WriteLine("chess application initialization");

				Console.CancelKeyPress += (sender, e) => {
					e.Cancel = true;
					//quit();
				};

				ioController = new TEventController();

				var initHandler = new TInitHandler();
				initHandler.install();

				ui = new TUIController();
				ui.init();

				player = new TAudioPlayer();
				player.load("computermove", Config.soundPath + "computermove.wav");
				player.load("moved", Config.soundPath + "moved.wav");
				player.load("loaded", Config.soundPath + "loaded.wav");
				player.load("check", Config.soundPath + "check.wav");
				player.load("error", Config.soundPath + "error.wav");
				player.load("mate", Config.soundPath + "mate.wav");
				player.load("silence", Config.soundPath + "silence.wav");
				player.load("silence500ms", Config.soundPath + "silence500ms.wav");
				player.play("silence500ms");

				//tests
				//player.playSync("mate");
				//player.playSync("silence500ms");
				//player.playSync("check");
				//player.playSync("silence500ms");
				//player.playSync("moved");
				//player.playSync("silence500ms");
				//player.playSync("computermove");
				//player.playSync("silence500ms");

				engine = new TEngine();
				engine.start();
				//return;
				//board.newGame("k7/8/8/8/8/7p/8/K7 w - - 0 1");
				//board.newGame("k7/7P/8/8/8/8/8/K7 w - - 0 1");
				//board.newGame();
				if (!loadAutoSave()) {
					game.newGame();
				}

				var cmdHandler = new TConsoleHandler();
				cmdHandler.install();

				var dbgHandler = new TDebugHandler();
				dbgHandler.install();

				var boardHandler = new TUIBoard();
				boardHandler.install();

				var statusHandler = new TUIBoardStatusHandler();
				statusHandler.install();

				var acthandler = new TUIDefaultButtonActions();
				acthandler.install();

				var screenSaver = new TScreenSaverHandler();
				screenSaver.install();

				new TUITextInput().install();

				ui.drawAll();

				initHandler.uninstall();

				Console.WriteLine("ready");
				player.play("loaded");
				ioController.eventLoop();
			}
			catch (Exception ex) {
				Console.WriteLine(ex.ToString());
				Thread.Sleep(5000);
			}
		}
Ejemplo n.º 2
0
		public void switchTest() {
			Console.WriteLine("switch test");
			//var hw = new TIOHardware();
			//hw.init();

			//var ret = false;
			//CommandLineThread.processEvents((e) => {
			//	ret = true;
			//	onConsoleLine(e);
			//});


			//while (true) {
			//	hw.clearBoardLeds();

			//	for (var y = 0; y < 8; y++) {
			//		for (var x = 0; x < 8; x++) {
			//			if (hw.figureSwitchesNew[x, y]) {
			//				hw.ledBitArray[x, y] = true;
			//				hw.ledBitArray[x + 1, y] = true;
			//				hw.ledBitArray[x, y + 1] = true;
			//				hw.ledBitArray[x + 1, y + 1] = true;
			//			}
			//		}
			//	}

			//	if (ret) return;

			//	hw.updateLeds();
			//}

			var ec = new TEventController();
			new TSwitchTest().install(ec, 0);
			ec.eventLoop();
		}