/// <summary> /// 玩家出牌的类型 /// </summary> /// <param name="payload"></param> private void OnPlayerPlayCard() { List <Card> cardsList = characterView.m_player.FindCards();//获取被选中牌的集合 CardType pcardType; if (Rulers.CanPOp(cardsList, out pcardType))//判断能否出牌,并返回出牌的类型 { //把数据封装,让外界处理选择牌能否出成功 PlayCardArgs play = new PlayCardArgs() { characterType = CharacterType.Player, length = cardsList.Count, weight = ToolsManager.GetWeight(cardsList, pcardType), cardType = pcardType }; dispatcher.Dispatch(CommandEvent.PlayCard, play);//派发判断能否出牌成功的命令 } }
/// <summary> /// 电脑玩家出牌的方法 /// </summary> /// <param name="obj"></param> /// <returns></returns> IEnumerator DePlay(ComputerSmartArgs obj) { yield return(new WaitForSeconds(2)); bool can = false; switch (obj.currentCharacter) { case CharacterType.ComputerRight: //清空桌面 characterView.m_Desk.ClearList(ShowPoint.ComputerRight); can = characterView.m_ComputerRight.SmartSelectCards(obj.cardType, obj.weight, obj.Length, CharacterType.ComputerRight == obj.isBiggest); //获取电脑玩家出牌的集合 List <Card> Rightcards = characterView.m_ComputerRight.SelectedCard; //获取出牌的类型 CardType RightcardType = characterView.m_ComputerRight.cardType; if (can) { //桌面添加出的牌 foreach (var item in Rightcards) { characterView.m_Desk.AddCard(item, false, ShowPoint.ComputerRight); } //封装玩家出牌后的传递数据 PlayCardArgs play = new PlayCardArgs() { cardType = RightcardType, length = Rightcards.Count, weight = ToolsManager.GetWeight(Rightcards, RightcardType), characterType = CharacterType.ComputerRight }; //删除手牌 //在调用SmartSelectCards方法时,出牌成功,就自动删除 //出牌成功 if (!characterView.m_ComputerRight.IHasCard) //判断牌是否有剩余 { //游戏结束 Identity p = characterView.m_player.PlayerIdentity; Identity Left = characterView.m_ComputerLeft.PlayerIdentity; Identity Right = characterView.m_ComputerRight.PlayerIdentity; CharacterType gg = CharacterType.Player; if (p == Identity.Landlord) { gg = CharacterType.Player; } else if (Left == Identity.Landlord) { gg = CharacterType.ComputerLeft; } else if (Right == Identity.Landlord) { gg = CharacterType.ComputerRight; } GameOverArgs e = new GameOverArgs() { ComputerRigh = true, ComputerLeft = Right == Left ? true : false, PlayerWin = p == Right ? true : false, type = gg, isLand = p == Identity.Landlord ? true : false }; dispatcher.Dispatch(CommandEvent.GameOver, e); } else { dispatcher.Dispatch(CommandEvent.PlayCard, play); //下家出牌 } } else { //不出牌 dispatcher.Dispatch(CommandEvent.PassCard); } break; case CharacterType.ComputerLeft: //清空桌面 characterView.m_Desk.ClearList(ShowPoint.ComputerLeft); can = characterView.m_ComputerLeft.SmartSelectCards(obj.cardType, obj.weight, obj.Length, CharacterType.ComputerLeft == obj.isBiggest); //获取电脑玩家出牌的集合 List <Card> cards = characterView.m_ComputerLeft.SelectedCard; //获取出牌的类型 CardType cardType = characterView.m_ComputerLeft.cardType; if (can) { //桌面添加出的牌 foreach (var item in cards) { characterView.m_Desk.AddCard(item, false, ShowPoint.ComputerLeft); } //封装玩家出牌后的传递数据 PlayCardArgs play = new PlayCardArgs() { cardType = cardType, length = cards.Count, weight = ToolsManager.GetWeight(cards, cardType), characterType = CharacterType.ComputerLeft }; //删除手牌 //在调用SmartSelectCards方法时,出牌成功,就自动删除 //出牌成功 if (!characterView.m_ComputerLeft.IHasCard) //判断牌是否有剩余 { //游戏结束 Identity p = characterView.m_player.PlayerIdentity; Identity Left = characterView.m_ComputerLeft.PlayerIdentity; Identity Right = characterView.m_ComputerRight.PlayerIdentity; CharacterType gg = CharacterType.Player; if (p == Identity.Landlord) { gg = CharacterType.Player; } else if (Left == Identity.Landlord) { gg = CharacterType.ComputerLeft; } else if (Right == Identity.Landlord) { gg = CharacterType.ComputerRight; } GameOverArgs e = new GameOverArgs() { ComputerLeft = true, ComputerRigh = Right == Left ? true : false, PlayerWin = p == Left ? true : false, type = gg, isLand = p == Identity.Landlord ? true : false }; dispatcher.Dispatch(CommandEvent.GameOver, e); //派发游戏结束命令 } else { dispatcher.Dispatch(CommandEvent.PlayCard, play); //下家出牌 } } else { //不出牌 dispatcher.Dispatch(CommandEvent.PassCard); } break; default: break; } // characterView.m_ComputerLeft.SmartSelectCards(); }