/// <summary> /// 更换两张牌的位置 /// </summary> public void ExchangePokersPosition(PokerCard poker1, PokerCard poker2) { if (poker1 == null || poker2 == null) { return; } Facade.Instance <MusicManager>().Play("select"); Vector3 tempPos = poker1.transform.localPosition; poker1.MoveTo(poker1.transform.localPosition, poker2.transform.localPosition); poker2.MoveTo(poker2.transform.localPosition, tempPos); }
/// <summary> /// 将牌变为选择的方案牌型 /// </summary> /// <param name="intList"></param> void ChoisePlane(List <int> intList) { //第一次选择的时候不用换牌,直接赋值 if (_lastList == null || _lastList.Count == 0) { for (int i = 0; i < intList.Count; i++) { PokerCard ca = CardsList[i].GetComponent <PokerCard>(); ca.SetCardId(intList[i]); ca.SetCardFront(); } return; } List <int> tempList = _lastList.GetRange(0, 13); if (intList.Count != tempList.Count) { YxDebug.LogError("码牌数据错误"); return; } bool change = false; for (int i = 0; i < tempList.Count; i++) { int index = i; var tempObj = CardsList[i]; if (intList[i] != tempList[i]) { index = tempList.IndexOf(intList[i]); CardsList[i] = CardsList[index]; CardsList[index] = tempObj; int tempInt = tempList[i]; tempList[i] = tempList[index]; tempList[index] = tempInt; --i; change = true; } PokerCard card = tempObj.GetComponent <PokerCard>(); card.MoveTo(CardsList[index].transform.localPosition, RepositionCard(index)); } if (change) { Facade.Instance <MusicManager>().Play("select"); } _lastList = tempList; ResetSelectedCards(); }