public static bool IsCenter(this GetRangeType type) { switch (type) { case GetRangeType.CenterAll: case GetRangeType.CenterLeft: case GetRangeType.CenterRight: return(true); default: return(false); } }
public static IList <GameCard> GetRangeCard(this GameCard card, int range, GetRangeType type = GetRangeType.CenterAll) {//按照从左到右的顺序,选中卡牌 var rowList = card.GetRowList(); var centerIndex = card.GetRowIndex(); var result = new List <GameCard>(); for (var i = centerIndex - range; i <= centerIndex + range; i++) { if ((i >= 0 && (i < rowList.Count())) && ((i < centerIndex && type.IsLeft()) || (i == centerIndex && type.IsCenter()) || (i > centerIndex && type.IsRight()))) { result.Add(rowList[i]); } } return(result); }