Example #1
0
    Tile CheckScoreTile(Tile source, int targetRow, int targetColumn)
    {
        Tile target = m_Tiles[targetRow, targetColumn];

        BallFactory.BallType sourceType = source.GetBall().GetBallType();
        Ball targetBall = target.GetBall();

        if (targetBall == null)
        {
            target = null;
        }
        else if (target.GetBall().GetBallMode() == BallFactory.BallMode.Scale)
        {
            target = null;
        }
        else
        {
            BallFactory.BallType targetType = target.GetBall().GetBallType();
            if (!(sourceType == BallFactory.BallType.Ghost ||
                  targetType == BallFactory.BallType.Ghost ||
                  sourceType == targetType))
            {
                target = null;
            }
        }


        return(target);
    }
Example #2
0
    bool CheckScoreTiles()
    {
        // var firstTile = m_ScoreTiles[0];
        m_GhostTiles.Clear();
        m_ErrorTiles.Clear();

        int  total   = m_ScoreTiles.Count;
        bool isValid = false;

        if (total < m_LeastBallsToScore)
        {
            isValid = false;
        }
        else
        {
            BallFactory.BallType type = BallFactory.BallType.None;

            foreach (var item in m_ScoreTiles)
            {
                if (item.GetBall().GetBallType() != BallFactory.BallType.Ghost)
                {
                    if (type == BallFactory.BallType.None)
                    {
                        type = item.GetBall().GetBallType();
                    }
                    else
                    {
                        if (type != item.GetBall().GetBallType())
                        {
                            m_ErrorTiles.Add(item);
                        }
                    }
                }
                else
                {
                    m_GhostTiles.Add(item);
                }
            }

            if (total - m_ErrorTiles.Count >= m_LeastBallsToScore)
            {
                isValid = true;
                if (m_ErrorTiles.Count > 0)
                {
                    foreach (var item in m_ErrorTiles)
                    {
                        m_ScoreTiles.Remove(item);
                    }
                }
            }
            else
            {
                if (m_ErrorTiles.Count + m_GhostTiles.Count >= m_LeastBallsToScore)
                {
                    isValid = true;

                    m_ScoreTiles.Clear();
                    foreach (var item in m_GhostTiles)
                    {
                        m_ScoreTiles.Add(item);
                    }
                    foreach (var item in m_ErrorTiles)
                    {
                        m_ScoreTiles.Add(item);
                    }
                }
            }
        }

        return(isValid);
    }
Example #3
0
 public void SetBallType(BallFactory.BallType type)
 {
     m_Type = type;
 }