Exemplo n.º 1
0
        /// <summary>
        /// 列匹配
        /// </summary>
        /// <param name="sweet">糖果本身</param>
        /// <param name="type">糖果颜色</param>
        /// <returns>匹配结果</returns>
        public List <GameSweet> FindRowSameSweet(GameSweet sweet, int currentX, int currentY, ColorType type)
        {
            int y;
            List <GameSweet> list = new List <GameSweet>();

            for (int i = 0; i <= 1; i++)
            {
                for (int yDistance = 1; yDistance < PlayerInfo.Instance.yRow; yDistance++)
                {
                    if (i == 0)
                    {
                        y = currentY - yDistance;
                    }
                    else
                    {
                        y = currentY + yDistance;
                    }
                    if (y < 0 || y >= PlayerInfo.Instance.yRow)
                    {
                        break;
                    }
                    if (sweet.IsMatch() && _sweets[currentX, y].Color == type)
                    {
                        list.Add(_sweets[currentX, y]);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            return(list);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 行匹配
        /// </summary>
        /// <param name="sweet">糖果本身</param>
        /// <param name="type">糖果颜色</param>
        /// <returns>匹配结果</returns>
        public List <GameSweet> FindColumnSameSweet(GameSweet sweet, int currentX, int currentY, ColorType type)
        {
            int x;
            List <GameSweet> list = new List <GameSweet>();

            for (int i = 0; i <= 1; i++)
            {
                for (int xDistance = 1; xDistance < PlayerInfo.Instance.xColumn; xDistance++)
                {
                    if (i == 0)
                    {
                        x = currentX - xDistance;
                    }
                    else
                    {
                        x = currentX + xDistance;
                    }
                    if (x < 0 || x >= PlayerInfo.Instance.xColumn)
                    {
                        break;
                    }
                    if (sweet.IsMatch() && _sweets[x, currentY].Color == type)
                    {
                        list.Add(_sweets[x, currentY]);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            return(list);
        }