/// <summary> /// 每回合增加手牌 /// </summary> /// <param name="cardlist"></param> private void addCard(List <CardDto> cardlist) { int index = myCardList.Count; foreach (var item in cardlist) { myCardList.Add(item); } //对手牌进行排序 //CardWeight.SortCard(ref myCardList); //复用先前创建的牌 for (int i = 0; i < index; i++) { CardCtrllist[i].gameObject.SetActive(true); CardCtrllist[i].Init(myCardList[i], true, i); } for (int i = index; i < myCardList.Count; i++) { GameObject card = GameObject.Instantiate(cardPrefab, cardTransformParent); card.transform.localPosition = new Vector3(0, index * 0.01f, index * -1f); //card.name = myCardList[i].Name; CardCtrl cardCtrl = card.GetComponent <CardCtrl>(); cardCtrl.CardMouseDownEvent = IsCanSelece; cardCtrl.Init(myCardList[i], true, index); CardCtrllist.Add(cardCtrl); index++; } }
/// <summary> /// 初始阶段创建手牌 /// </summary> /// <param name="cardDto"></param> /// <param name="index"></param> private void createCard(CardDto cardDto, int index) { GameObject card = GameObject.Instantiate(cardPrefab, cardTransformParent); //card.transform.localPosition = new Vector2(index * 1f, 0); card.transform.localPosition = new Vector3(0, index * 0.01f, index * -1f); //card.name = cardDto.Name; CardCtrl cardCtrl = card.GetComponent <CardCtrl>(); cardCtrl.CardMouseDownEvent = IsCanSelece; cardCtrl.Init(cardDto, true, index); myCardList.Add(cardDto); CardCtrllist.Add(cardCtrl); }