Пример #1
0
    /// <summary>
    /// 请求玩家出牌事件的回调
    /// </summary>
    /// <param name="payload"></param>
    private void onPlayPayCard(IEvent payload)
    {
        List <Card> cardList = characterView.player.FindSelectCard();
        CardType    cardType;

        Rulers.CanPop(cardList, out cardType);
        //还需要根据上次出牌的类型



        if (cardType != CardType.None)
        {
            //可以出牌
            PlayCardArg e = new PlayCardArg(cardList.Count, Toos.GetWeight(cardList, cardType), CharacterType.Player, cardType);


            dispatcher.Dispatch(CommandEvent.PlayCard, e);
        }
        else
        {
            Debug.Log("请选择正确的牌");
        }
    }
Пример #2
0
    IEnumerator DelayOneSecound(ComputerSmartArgs obj)
    {
        yield return(new WaitForSeconds(1f));

        bool can = false;

        switch (obj.characterType)
        {
        case CharacterType.ComputerRight:
            can = characterView.ComputerRight.ComputerSemarPlayCard(obj.cardType, obj.weight, obj.lenght, obj.biggerst == CharacterType.ComputerRight);
            if (can)
            {
                List <Card> cardList = characterView.ComputerRight.SelectCards;
                CardType    cardType = characterView.ComputerRight.currType;
                //--------------------------添加牌到桌面----------------



                characterView.Desk.Clear();    //添加牌之前把桌面清空下。这里可以做一个剩余牌数(记牌器),把出的牌临时放到一个数组里面,把总牌数减去手牌减去临时数组,就是剩余牌数,这是一个扩展
                foreach (Card card in cardList)
                {
                    characterView.AddCard(CharacterType.Desk, card, false);
                }


                //-----------------可以出牌-------------------
                PlayCardArg ee = new PlayCardArg(cardList.Count, Toos.GetWeight(cardList, cardType), CharacterType.ComputerRight, cardType);


                if (!characterView.ComputerRight.HasCard)
                {
                    Identity     r   = characterView.ComputerRight.Identity;
                    Identity     l   = characterView.ComputerLeft.Identity;
                    Identity     p   = characterView.player.Identity;
                    GameOverArgs eee = new GameOverArgs()
                    {
                        ComputerRightWin = true,

                        ComputerLeftWin = l == r ? true : false,
                        PlayWin         = p == r ? true: false,
                    };


                    dispatcher.Dispatch(CommandEvent.GameOver, eee);
                }
                else
                {
                    dispatcher.Dispatch(CommandEvent.PlayCard, ee);
                }
            }
            else
            {
                dispatcher.Dispatch(CommandEvent.PassCard);
            }

            break;

        case CharacterType.ComputerLeft:

            can = characterView.ComputerLeft.ComputerSemarPlayCard(obj.cardType, obj.weight, obj.lenght, obj.biggerst == CharacterType.ComputerLeft);

            if (can)
            {
                List <Card> cardList = characterView.ComputerLeft.SelectCards;
                CardType    cardType = characterView.ComputerLeft.currType;
                //--------------------------添加牌到桌面----------------
                characterView.Desk.Clear();    //添加牌之前把桌面清空下。这里可以做一个剩余牌数(记牌器),把出的牌临时放到一个数组里面,把总牌数减去手牌减去临时数组,就是剩余牌数,这是一个扩展
                foreach (Card card in cardList)
                {
                    characterView.AddCard(CharacterType.Desk, card, false);
                }


                //-----------------可以出牌-------------------
                PlayCardArg ee = new PlayCardArg(cardList.Count, Toos.GetWeight(cardList, cardType), CharacterType.ComputerLeft, cardType);

                if (!characterView.ComputerLeft.HasCard)
                {
                    Identity     r   = characterView.ComputerRight.Identity;
                    Identity     l   = characterView.ComputerLeft.Identity;
                    Identity     p   = characterView.player.Identity;
                    GameOverArgs eee = new GameOverArgs()
                    {
                        ComputerLeftWin  = true,
                        ComputerRightWin = r == l ? true : false,
                        PlayWin          = p == l ? true : false,
                    };


                    dispatcher.Dispatch(CommandEvent.GameOver, eee);
                }
                else
                {
                    dispatcher.Dispatch(CommandEvent.PlayCard, ee);
                }
            }
            else
            {
                dispatcher.Dispatch(CommandEvent.PassCard);
            }

            break;

        default:
            break;
        }
    }