private void StartGame()
 {
     TicTacToeScreen theAwesomeGame = new TicTacToeScreen();
     //    ScreenManager.AddScreen(theAwesomeGame);
     //    ScreenManager.Screens[ScreenManager.Screens.Count() - 1].LoadContent();
     IsExiting = true;
     LoadingScreen loadingScreen = new LoadingScreen(new GameScreen[] { theAwesomeGame }, true, ScreenManager);
 }
Beispiel #2
0
 public int CheckWin(out TicTacToeScreen.DrawStrike strikeDecision, out char winningCharacter)
 {
     // Returns Row Win
     for(int i = 0; i <=6; i+=3)
     {
         if(boxes[i].Character == boxes[i + 1].Character && boxes[i+1].Character == boxes[i + 2].Character && ((boxes[i].Character == 'X') || (boxes[i].Character =='O')))
         {
             strikeDecision = TicTacToeScreen.DrawStrike.Row;
             winningCharacter = boxes[i].Character;
             return i;
         }
     }
     for (int i = 0; i < 3; i++ )
     {
         if((boxes[i].Character == boxes[i + 3].Character) && (boxes[i + 3].Character == boxes[i + 6].Character) && (boxes[i].Character.Equals('X') || (boxes[i].Character.Equals('O'))))
         {
             strikeDecision = TicTacToeScreen.DrawStrike.Column;
             winningCharacter = boxes[i].Character;
             return i;
         }
      //           Debug.WriteLine("characters are: {0}, {1}, {2}", boxes[i].Character, boxes[i + 3].Character, boxes[i + 6].Character);
         Debug.WriteLine("");
     }
     if(boxes[0].Character == boxes[4].Character && boxes[4].Character == boxes[8].Character && ((boxes[0].Character == 'X') || (boxes[0].Character == 'O')))
     {
         strikeDecision = TicTacToeScreen.DrawStrike.Diagonal;
     // could be 0, 4, 8
         Debug.WriteLine("Diagonal forward win!!!");
         winningCharacter = boxes[0].Character;
         return 1;
     }
     if(boxes[2].Character == boxes[4].Character  && boxes[4].Character== boxes[6].Character && ((boxes[2].Character == 'X' )||( boxes[2].Character == 'O')))
     {
         strikeDecision = TicTacToeScreen.DrawStrike.Diagonal;
     // could be 2, 4, 6
         winningCharacter = boxes[2].Character;
         return 2;
     }
     strikeDecision = TicTacToeScreen.DrawStrike.NoDecision;
     winningCharacter = '\0';
         return -1;
 }
Beispiel #3
0
 public void DrawStrike(int number, TicTacToeScreen.DrawStrike strikeDecision,SpriteBatch spriteBatch, GameTime gameTime,Texture2D strikingPixel)
 {
     // To draw the highlighting
     if (gameTime.TotalGameTime.TotalMilliseconds > nextBlinkTime)
     {
         if (color == Color.Yellow)
         {
             color = Color.Red;
         }
         else
         {
             color = Color.Yellow;
         }
         nextBlinkTime = gameTime.TotalGameTime.TotalMilliseconds + 1000f;
     }
     Color[] drawingColor = new Color[9];
     System.Diagnostics.Debug.WriteLine("Row number is: {0}", number);
     strikingPixel.GetData<Color>(0,new Rectangle(0,0,1,1),drawingColor,0,1);
     float i = 0;
     Vector2 drawingVector = Vector2.Zero;
     if(strikeDecision == TicTacToeScreen.DrawStrike.Row)
     {
         i = boxes[number].currentPosition.X - 15;
         for(; i < boxes[number + 2].currentPosition.X + BoxDimension + 15; i++)
         {
             spriteBatch.Draw(strikingPixel, new Vector2(i, boxes[number].currentPosition.Y + BoxDimension / 2), drawingColor[0]);
         }
        for(int j = number; j <= number + 2; j++)
        {
            boxes[j].Highlight(gameTime, spriteBatch, TicTacToeScreen.GetTextureForHighlighting(color, 5));
        }
     }
     else if(strikeDecision == TicTacToeScreen.DrawStrike.Column)
     {
         System.Diagnostics.Debug.WriteLine("Column Win!!!!, at number {0}", number);
         i = boxes[number].currentPosition.Y - 15;
         for(; i < boxes[number + 6].currentPosition.Y + BoxDimension + 15; i++)
         {
             spriteBatch.Draw(strikingPixel, new Vector2(boxes[number].currentPosition.X+BoxDimension/2, i),drawingColor[0]);
         }
         for (int j = number; j < 9; j += 3)
         {
             boxes[j].Highlight(gameTime, spriteBatch, TicTacToeScreen.GetTextureForHighlighting(color, 5));
         }
     }
     else if (strikeDecision == TicTacToeScreen.DrawStrike.Diagonal)
     {
         if (number == 1)
         {
             float y = boxes[0].currentPosition.Y;
             for (i = boxes[0].currentPosition.X; i < boxes[8].currentPosition.X + BoxDimension; i++)
             {
                 spriteBatch.Draw(strikingPixel, new Vector2(i, y), drawingColor[0]);
                 ++y;
             }
             for(int j = 0; j < 9; j+=4)
             {
                 boxes[j].Highlight(gameTime, spriteBatch, TicTacToeScreen.GetTextureForHighlighting(color, 5));
             }
         }
         else if(number == 2)
         {
             float y = boxes[2].currentPosition.Y;
             for (i = boxes[2].currentPosition.X + BoxDimension; i >= boxes[6].currentPosition.X; i--)
             {
                 spriteBatch.Draw(strikingPixel, new Vector2(i, y), drawingColor[0]);
                 y++;
             }
             for(int j = 2; j < 9; j +=2)
             {
                 boxes[j].Highlight(gameTime, spriteBatch, TicTacToeScreen.GetTextureForHighlighting(color, 5));
             }
         }
     }
 }