public void Setup(CharacterType charType) { List <CardAssetList> cardAssetLists = cardConfigObject.GetCardAssetList(charType); cardList.DetachChildren(); foreach (var cardAssetList in cardAssetLists) { CardCell cardCellObject = Instantiate(CardPrefab, cardList, false).GetComponent <CardCell>(); cardCellObject.Setup(cardAssetList); } }
void GrabReferences() { string nameItem; _linesPrize = new bool[NumRow]; _allCells = new CardCell[NumRow][]; /* Search all SpriteRenderer references for each cellNum of this card table * for _allSpriteInCards, and prepare _allNumbersInCards. */ for (int i = 0; i < NumRow; i++) { _allCells[i] = new CardCell[NumCols]; for (int j = 0; j < NumCols; j++) { nameItem = "c[" + i + "," + j + "]/cellNum"; _allCells[i][j] = new CardCell(_transformThisCard.Find(nameItem).GetComponent <SpriteRenderer>()); } } }
/// <summary> /// 设置跟随推荐接口 /// 有 使用消息配置卡券(cardCellData) 和 使用消息配置URL(urlCellData) 两种方式 /// 注意:cardCellData和urlCellData必须也只能选择一个,不可同时为空 /// </summary> /// <param name="cardId">卡券ID</param> /// <param name="cardCellData">使用消息配置卡券数据</param> /// <param name="urlCellData">使用消息配置URL数据</param> /// <param name="timeOut"></param> /// <returns></returns> public JsonResult RecommendSet(string cardId, CardCell cardCellData = null, UrlCell urlCellData = null, int timeOut = Config.TIME_OUT) { var accessToken = _api.GetAccessToken(); var url = string.Format("https://api.weixin.qq.com/card/update?access_token={0}", accessToken); var data = new { card_id = cardId, member_card = new { base_info = new { modify_msg_operation = new { card_cell = cardCellData, url_cell = urlCellData } } } }; return(Post <JsonResult>(url, data, timeOut)); }
/// <summary> /// 设置跟随推荐接口 /// 有 使用消息配置卡券(cardCellData) 和 使用消息配置URL(urlCellData) 两种方式 /// 注意:cardCellData和urlCellData必须也只能选择一个,不可同时为空 /// </summary> /// <param name="accessTokenOrAppId"></param> /// <param name="cardId">卡券ID</param> /// <param name="cardCellData">使用消息配置卡券数据</param> /// <param name="urlCellData">使用消息配置URL数据</param> /// <param name="timeOut"></param> /// <returns></returns> public static WxJsonResult RecommendSet(string accessTokenOrAppId, string cardId, CardCell cardCellData = null, UrlCell urlCellData = null, int timeOut = Config.TIME_OUT) { return(ApiHandlerWapper.TryCommonApi(accessToken => { var urlFormat = string.Format("https://api.weixin.qq.com/card/update?access_token={0}", accessToken); var data = new { card_id = cardId, member_card = new { base_info = new { modify_msg_operation = new { card_cell = cardCellData, url_cell = urlCellData } } } }; return CommonJsonSend.Send <WxJsonResult>(null, urlFormat, data, timeOut: timeOut); }, accessTokenOrAppId)); }
public void GetBIngoLinesTest() { var cardCells = new CardCell[] { new CardCell() { CardId = 0, Index = 0, IsOpen = true, Number = 1 }, new CardCell() { CardId = 0, Index = 1, IsOpen = true, Number = 2 }, new CardCell() { CardId = 0, Index = 2, IsOpen = false, Number = 3 }, new CardCell() { CardId = 0, Index = 3, IsOpen = false, Number = 4 }, new CardCell() { CardId = 0, Index = 4, IsOpen = true, Number = 5 }, new CardCell() { CardId = 0, Index = 5, IsOpen = false, Number = 6 }, new CardCell() { CardId = 0, Index = 6, IsOpen = true, Number = 7 }, new CardCell() { CardId = 0, Index = 7, IsOpen = false, Number = 8 }, new CardCell() { CardId = 0, Index = 8, IsOpen = true, Number = 9 }, new CardCell() { CardId = 0, Index = 9, IsOpen = false, Number = 10 }, new CardCell() { CardId = 0, Index = 10, IsOpen = false, Number = 11 }, new CardCell() { CardId = 0, Index = 11, IsOpen = true, Number = 12 }, new CardCell() { CardId = 0, Index = 12, IsOpen = true, Number = 13 }, new CardCell() { CardId = 0, Index = 13, IsOpen = false, Number = 14 }, new CardCell() { CardId = 0, Index = 14, IsOpen = false, Number = 15 }, new CardCell() { CardId = 0, Index = 15, IsOpen = true, Number = 16 }, new CardCell() { CardId = 0, Index = 16, IsOpen = true, Number = 17 }, new CardCell() { CardId = 0, Index = 17, IsOpen = true, Number = 18 }, new CardCell() { CardId = 0, Index = 18, IsOpen = true, Number = 19 }, new CardCell() { CardId = 0, Index = 19, IsOpen = true, Number = 20 }, new CardCell() { CardId = 0, Index = 20, IsOpen = true, Number = 21 }, new CardCell() { CardId = 0, Index = 21, IsOpen = true, Number = 22 }, new CardCell() { CardId = 0, Index = 22, IsOpen = false, Number = 23 }, new CardCell() { CardId = 0, Index = 23, IsOpen = false, Number = 24 }, new CardCell() { CardId = 0, Index = 24, IsOpen = false, Number = 25 }, }; var bingo = cardCells.GetBingoLines(); Assert.AreEqual(3, bingo.Count); CollectionAssert.AreEquivalent( bingo.ToArray(), new[] { BingoLineType.Row4, BingoLineType.Col2, BingoLineType.Slash }); }
public void GetLizhiLinesTest() { var cardCells = new CardCell[] { new CardCell() { CardId = 0, Index = 0, IsOpen = true, Number = 1 }, new CardCell() { CardId = 0, Index = 1, IsOpen = true, Number = 2 }, new CardCell() { CardId = 0, Index = 2, IsOpen = true, Number = 3 }, new CardCell() { CardId = 0, Index = 3, IsOpen = true, Number = 4 }, new CardCell() { CardId = 0, Index = 4, IsOpen = false, Number = 5 }, new CardCell() { CardId = 0, Index = 5, IsOpen = false, Number = 6 }, new CardCell() { CardId = 0, Index = 6, IsOpen = true, Number = 7 }, new CardCell() { CardId = 0, Index = 7, IsOpen = true, Number = 8 }, new CardCell() { CardId = 0, Index = 8, IsOpen = false, Number = 9 }, new CardCell() { CardId = 0, Index = 9, IsOpen = false, Number = 10 }, new CardCell() { CardId = 0, Index = 10, IsOpen = false, Number = 11 }, new CardCell() { CardId = 0, Index = 11, IsOpen = false, Number = 12 }, new CardCell() { CardId = 0, Index = 12, IsOpen = true, Number = 13 }, new CardCell() { CardId = 0, Index = 13, IsOpen = false, Number = 14 }, new CardCell() { CardId = 0, Index = 14, IsOpen = false, Number = 15 }, new CardCell() { CardId = 0, Index = 15, IsOpen = false, Number = 16 }, new CardCell() { CardId = 0, Index = 16, IsOpen = false, Number = 17 }, new CardCell() { CardId = 0, Index = 17, IsOpen = false, Number = 18 }, new CardCell() { CardId = 0, Index = 18, IsOpen = true, Number = 19 }, new CardCell() { CardId = 0, Index = 19, IsOpen = false, Number = 20 }, new CardCell() { CardId = 0, Index = 20, IsOpen = false, Number = 21 }, new CardCell() { CardId = 0, Index = 21, IsOpen = false, Number = 22 }, new CardCell() { CardId = 0, Index = 22, IsOpen = true, Number = 23 }, new CardCell() { CardId = 0, Index = 23, IsOpen = false, Number = 24 }, new CardCell() { CardId = 0, Index = 24, IsOpen = false, Number = 25 }, }; var lizhi = cardCells.GetLizhiLines(); Assert.AreEqual(3, lizhi.Count); CollectionAssert.AreEquivalent( lizhi.Select(x => x.LineType).ToArray(), new[] { BingoLineType.Row1, BingoLineType.Col3, BingoLineType.BackSlash }); CollectionAssert.AreEquivalent( lizhi.Select(x => x.WaitingNumber).ToArray(), new[] { 5, 18, 25 }); }
private PayloadItem[] MapResponseToItem(InternalModels.Response source, PayloadItem[] destinations, ResolutionContext context) { var itemWithBubble = new PayloadItem { Bubble = { Text = source.Text } }; var buttons = source.Buttons?.Where(b => !b.IsQuickReply).ToList(); var cardItems = buttons?.Select(b => { var cardItem = new CardCell { Type = CellTypeValues.GreetingGridItem, TopText = new CardCellText { Type = CellTypeValues.TextCellView, Text = string.Empty, Typeface = TypefaceValues.Caption, TextColor = TextColorValues.Default }, BottomText = new CardCellText { Type = CellTypeValues.LeftRightCellView, Text = b.Text, Typeface = TypefaceValues.Button1, TextColor = TextColorValues.Default, MaxLines = 2, Margins = new Margins { Top = IndentValues.X0 } }, Paddings = new Paddings { Top = IndentValues.X0, Left = IndentValues.X6, Right = IndentValues.X6, Bottom = IndentValues.X16 } }; var action = context.Mapper.Map <SberModels.Action>(b); cardItem.Actions = new[] { action }; return(cardItem); }).ToArray(); var card = new Card { Type = CardTypeValues.GridCard, Items = cardItems, Columns = 2, ItemWidth = ItemWidthValues.Resizable }; var itemWithCard = new PayloadItem { Card = card }; return(new[] { itemWithBubble, itemWithCard }); }