Exemplo n.º 1
0
 /// <summary>
 /// Is this domino in a scoring position
 /// </summary>
 /// <param name="domino"></param>
 /// <returns></returns>
 public bool DominoScoresPlayer2(DominoController domino)
 {
     if (domino.IsHorizontal())
     {
         if ((domino.Column == 1 &&
              (mBoardController.HasSquareExit(domino.Row, 0, CardinalPoint.W))))
         {
             return(true);
         }
         else if ((domino.Column == (mBoardController.Size - 2) &&
                   (mBoardController.HasSquareExit(domino.Row, mBoardController.Size - 1, CardinalPoint.E))))
         {
             return(true);
         }
     }
     else //Domino Vertical
     {
         if (domino.Column == 0)
         {
             for (int row = -1; row < 2; row++)
             {
                 if (mBoardController.HasSquareExit(domino.Row + row, 0, CardinalPoint.W))
                 {
                     return(true);
                 }
             }
         }
         else if (domino.Column == mBoardController.Size - 1)
         {
             for (int row = -1; row < 2; row++)
             {
                 if (mBoardController.HasSquareExit(domino.Row + row, mBoardController.Size - 1, CardinalPoint.E))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Is this domino in a scoring position
 /// </summary>
 /// <param name="domino"></param>
 /// <returns></returns>
 public bool DominoScoresPlayer1(DominoController domino)
 {
     if (domino.IsHorizontal())
     {
         if (domino.Row == 0)
         {
             for (int col = -1; col < 2; col++)
             {
                 if (mBoardController.HasSquareExit(0, domino.Column + col, CardinalPoint.S))
                 {
                     return(true);
                 }
             }
         }
         else if (domino.Row == mBoardController.Size - 1)
         {
             for (int col = -1; col < 2; col++)
             {
                 if (mBoardController.HasSquareExit(domino.Row, domino.Column + col, CardinalPoint.N))
                 {
                     return(true);
                 }
             }
         }
     }
     else //Domino Vertical
     {
         if ((domino.Row == 1 && (mBoardController.HasSquareExit(0, domino.Column, CardinalPoint.S))))
         {
             return(true);
         }
         else if ((domino.Row == (mBoardController.Size - 2) && (mBoardController.HasSquareExit(mBoardController.Size - 1, domino.Column, CardinalPoint.N))))
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 3
0
    /// <summary>
    /// Check if the Mouse Cursor pointes at the Domino
    /// </summary>
    /// <param name="mouseX"></param>
    /// <param name="mouseY"></param>
    /// <returns></returns>
    public bool Contains(float mouseX, float mouseY)
    {
        //UnityEngine.Debug.Log("Contains?" + mouseX.ToString() + " " + mouseY.ToString());
        //UnityEngine.Debug.Log(this.X.ToString() + " " + this.Y.ToString());
        if (mController.IsHorizontal())
        {
            if ((Math.Abs(mouseX - this.X) < 1.5f * Square.kPixelSize) &&
                (Math.Abs(mouseY - this.Y) < 0.5f * Square.kPixelSize))
            {
                return(true);
            }
        }
        else
        {
            if ((Math.Abs(mouseX - this.X) < 0.5f * Square.kPixelSize) &&
                (Math.Abs(mouseY - this.Y) < 1.5f * Square.kPixelSize))
            {
                return(true);
            }
        }

        return(false);
    }
Exemplo n.º 4
0
        /// <summary>
        /// Handles spawn generation of new road chars (in the road)
        /// spwawn given the location of a domino
        /// </summary>
        /// <param name="domino">spawn in on this domino</param>
        protected void SpawnRoadCharacter(DominoController domino, float playerIndex)
        {
            List <IRoadCharacter> playerList = (playerIndex == 1) ? mPlayer1Characters : mPlayer2Characters;

            if (domino.IsHorizontal())
            {
                // spawn on small ends
                if (domino.Column == 1 &&
                    mBoardController.HasSquareExit(domino.Row, 0, CardinalPoint.W))
                {
                    playerList.Add(BuildCharacter(
                                       domino.Row,
                                       0,
                                       CardinalPoint.E,
                                       0,
                                       mBoardController.Size,
                                       false));
                }
                else if (domino.Column == (mBoardController.Size - 2) &&
                         mBoardController.HasSquareExit(domino.Row, mBoardController.Size - 1, CardinalPoint.E))
                {
                    playerList.Add(
                        BuildCharacter(domino.Row,
                                       mBoardController.Size - 1,
                                       CardinalPoint.W,
                                       0,
                                       mBoardController.Size,
                                       false));
                }

                // try spawing on bottom of board
                if (domino.Row == 0)
                {
                    for (int col = -1; col < 2; col++)
                    {
                        if (mBoardController.HasSquareExit(0, domino.Column + col, CardinalPoint.S))
                        {
                            playerList.Add(
                                BuildCharacter(0,
                                               domino.Column + col,
                                               CardinalPoint.N,
                                               0,
                                               mBoardController.Size,
                                               false));
                        }
                    }
                }
                // try spawning at top of board
                else if (domino.Row == mBoardController.Size - 1)
                {
                    for (int col = -1; col < 2; col++)
                    {
                        if (mBoardController.HasSquareExit(domino.Row, domino.Column + col, CardinalPoint.N))
                        {
                            playerList.Add(
                                BuildCharacter(
                                    mBoardController.Size - 1,
                                    domino.Column + col,
                                    CardinalPoint.S,
                                    0,
                                    mBoardController.Size,
                                    false));
                        }
                    }
                }
            }
            else //Domino Vertical
            {
                // try spawing on short ends
                if (domino.Row == 1 &&
                    mBoardController.HasSquareExit(0, domino.Column, CardinalPoint.S))
                {
                    playerList.Add(
                        BuildCharacter(
                            0,
                            domino.Column,
                            CardinalPoint.N,
                            0,
                            mBoardController.Size,
                            false));
                }
                else if (domino.Row == (mBoardController.Size - 2) &&
                         mBoardController.HasSquareExit(mBoardController.Size - 1, domino.Column, CardinalPoint.N))
                {
                    playerList.Add(
                        BuildCharacter(
                            mBoardController.Size - 1,
                            domino.Column,
                            CardinalPoint.S,
                            0,
                            mBoardController.Size,
                            false));
                }

                // try spawning along long length
                if (domino.Column == 0)
                {
                    for (int row = -1; row < 2; row++)
                    {
                        if (mBoardController.HasSquareExit(domino.Row + row, 0, CardinalPoint.W))
                        {
                            playerList.Add(
                                BuildCharacter(
                                    domino.Row + row,
                                    0,
                                    CardinalPoint.E,
                                    0,
                                    mBoardController.Size,
                                    false));
                        }
                    }
                }
                else if (domino.Column == mBoardController.Size - 1)
                {
                    for (int row = -1; row < 2; row++)
                    {
                        if (mBoardController.HasSquareExit(domino.Row + row, mBoardController.Size - 1, CardinalPoint.E))
                        {
                            playerList.Add(
                                BuildCharacter(
                                    domino.Row + row,
                                    mBoardController.Size - 1,
                                    CardinalPoint.W,
                                    0,
                                    mBoardController.Size,
                                    false));
                        }
                    }
                }
            }
        }