/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // initialization logic initPosition(); currentBoardVsGoat = new Board(); currentBoardVsTiger = new Board(); currentBoardTwoPlayer = new Board(); fetchSavedState(); fetchSavedSettings(); currentBoard = currentBoardVsGoat; goatsCaptured = currentBoard.mGoatsIntoBoard - getGoatCount(); gameStateVsGoat = new GameState(); gameStateVsTiger = new GameState(); gameStateTwoPlayer = new GameState(); winner = nodeState.none; newMoveDone = false; puckTouched = false; currentMode = gameMode.vsTiger; currentScreen = gameScreens.mainMenuScreen; //currentMode = gameMode.vsGoat; helpSection = new ScrollContainer(); creditsection = new CreditsSection(); onePlayerBtnGoat = new gButton(470, 97); onePlayerBtnTiger = new gButton(485, 197); twoPlayerBtn = new gButton(475,297); settingsBtn = new gButton(555,20); helpBtn = new gButton(480, 20); creditsBtn = new gButton(630, 20); rateBtn = new gButton(465, 400); sfxOnBtn = new gButton(380,175); sfxOffBtn = new gButton(380,175); undoBtn = new gButton(648, 403); //level levelBtn1 = new gButton(378, 265); levelBtn2 = new gButton(458, 265); levelBtn3 = new gButton(538, 265); menuBtn = new gButton(280,240); newGameBtn = new gButton(440, 240); resumeBtn = new gButton(440,240); okBtn = new gButton(552,320); //settings level switch (level) { case 1: levelBtn1.pressed = true; break; case 2: levelBtn2.pressed = true; break; case 3: levelBtn3.pressed = true; break; default: levelBtn1.pressed = true; break; } base.Initialize(); }
void mainScreenTouchHanlder() { TouchCollection touches = TouchPanel.GetState(); if (/*!touching &&*/ touches.Count > 0) { touching = true; TouchLocation touch = touches.First(); System.Diagnostics.Debug.WriteLine("X" + touch.Position.X + "Y" + touch.Position.Y); //make a move by computer // twoPlayerBtn.setPos(400,200); twoPlayerBtn.handeTouch(touch); onePlayerBtnGoat.handeTouch(touch); onePlayerBtnTiger.handeTouch(touch); settingsBtn.handeTouch(touch); helpBtn.handeTouch(touch); creditsBtn.handeTouch(touch); rateBtn.handeTouch(touch); } else { if (twoPlayerBtn.pressed) { twoPlayerBtn.pressed = false; currentMode = gameMode.twoPlayers; gameState = gameStateTwoPlayer; currentBoard = currentBoardTwoPlayer; goatsCaptured = currentBoard.mGoatsIntoBoard - getGoatCount(); newMoveDone = true;//to check who won switchToGamePlayScreen(); } if (onePlayerBtnGoat.pressed) { onePlayerBtnGoat.pressed = false; currentMode = gameMode.vsGoat; System.Diagnostics.Debug.WriteLine("current screen" + currentMode); gameState = gameStateVsGoat; currentBoard = currentBoardVsGoat; goatsCaptured = currentBoard.mGoatsIntoBoard - getGoatCount(); newMoveDone = true;//to check who won switchToGamePlayScreen(); } if (onePlayerBtnTiger.pressed) { onePlayerBtnTiger.pressed = false; currentMode = gameMode.vsTiger; gameState = gameStateVsTiger; currentBoard = currentBoardVsTiger; goatsCaptured = currentBoard.mGoatsIntoBoard - getGoatCount(); newMoveDone = true;//to check who won switchToGamePlayScreen(); } if (settingsBtn.pressed) { System.Diagnostics.Debug.WriteLine("settings press"); settingsBtn.pressed = false; showSettingsOverlay(); } if(helpBtn.pressed){ System.Diagnostics.Debug.WriteLine("help button press"); helpBtn.pressed = false; showHelpScreen(); } if (creditsBtn.pressed) { System.Diagnostics.Debug.WriteLine("credits button press"); creditsBtn.pressed = false; showCreditsScreen(); } if (rateBtn.pressed) { System.Diagnostics.Debug.WriteLine("credits button press"); rateBtn.pressed = false; showRateScreen(); } } }