Ejemplo n.º 1
0
 protected void OnRectCompleted(LogicRectangle logicRectangle)
 {
     Players[ActivePlayerId].AddRect();
     UIController.Instance.ActivateSigh(Players[ActivePlayerId].Sign, logicRectangle);
     if ((Players[0].ActivatedRects + Players[1].ActivatedRects) == RectsCount)
     {
         if (Players[0].ActivatedRects > Players[1].ActivatedRects)
         {
             MessageBox.Show(
                 string.Format("{0} won with {1} rects.", Players[0].Name, Players[0].ActivatedRects),
                 "Game Over", MessageBoxButton.OK, MessageBoxImage.Information);
             return;
         }
         if (Players[0].ActivatedRects < Players[1].ActivatedRects)
         {
             MessageBox.Show(
                 string.Format("{0} won with {1} rects.", Players[1].Name, Players[1].ActivatedRects),
                 "Game Over", MessageBoxButton.OK, MessageBoxImage.Information);
             return;
         }
         if (Players[0].ActivatedRects == Players[1].ActivatedRects)
         {
             MessageBox.Show("Draw in this game", "Game Over", MessageBoxButton.OK, MessageBoxImage.Information);
             return;
         }
     }
     TurnAgain = true;
 }
Ejemplo n.º 2
0
        public void GenerateField(LogicRectangle[][] gameField)
        {
            fieldSize = gameField.Length;
            int  num     = sideWidth;
            int  index   = 0;
            int  counter = 0;
            bool back    = false;

            //Generate arrays and Rectangles
            do
            {
                gameField[index] = new LogicRectangle[num];
                for (int i = 0; i < num; i++)
                {
                    gameField[index][i] =
                        new LogicRectangle(new LogicRectangle.LineState(), new LogicRectangle.LineState(), new LogicRectangle.LineState(), new LogicRectangle.LineState());
                    gameField[index][i].SetPosition(index, i);
                }
                if (num == fieldSize)
                {
                    ++counter;
                }
                if (num < fieldSize && !back)
                {
                    num += 2;
                }

                if (counter == sideWidth)
                {
                    back = true;
                }

                if (back)
                {
                    num -= 2;
                }
                ++index;
            } while (num >= sideWidth);
        }